0023663: Removing 2D viewer library
[occt.git] / src / AIS / AIS_InteractiveContext_3.cxx
1 // Created on: 2001-01-09
2 // Created by: Sergey Altukhov
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 // Modified: 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
22
23 #include <AIS_InteractiveContext.jxx>
24 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
25 #include <AIS_GlobalStatus.hxx>
26 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
27
28 //=======================================================================
29 //function : Erase
30 //purpose  : display an interactive object from the collector.
31 //=======================================================================
32 void AIS_InteractiveContext::DisplayFromCollector(const Handle(AIS_InteractiveObject)& anIObj,
33                                                                                                   const Standard_Boolean updateviewer)
34 {
35         if ( !IsInCollector( anIObj ) ) return;
36
37         if ( !HasOpenedContext() ){
38                 
39                 if ( DisplayStatus( anIObj ) == AIS_DS_Erased )
40                         Display( anIObj,Standard_False);
41
42                 if( updateviewer ){
43                         myMainVwr->Update();
44                         if( !myCollectorVwr.IsNull() )
45                                 myCollectorVwr->Update();
46                 }
47         }
48 }
49
50 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
51
52 //=======================================================================
53 //function : SetPolygonOffsets 
54 //purpose  : 
55 //======================================================================= 
56 void AIS_InteractiveContext::SetPolygonOffsets(
57                              const Handle(AIS_InteractiveObject)& anObj,
58                              const Standard_Integer               aMode,
59                              const Standard_ShortReal             aFactor,
60                              const Standard_ShortReal             aUnits,
61                              const Standard_Boolean               updateviewer) 
62 {
63   if ( anObj.IsNull() )
64     return;
65
66   if( !anObj->HasInteractiveContext() )
67     anObj->SetContext( this );
68
69   anObj->SetPolygonOffsets( aMode, aFactor, aUnits );
70
71   if ( updateviewer ) {
72     if( myObjects.IsBound( anObj ) ) {
73       Handle(AIS_GlobalStatus) STATUS = myObjects(anObj);
74       if ( STATUS->GraphicStatus() == AIS_DS_Displayed )
75         myMainVwr->Update();
76     }
77   }
78 }
79
80
81 //=======================================================================
82 //function : HasPolygonOffsets 
83 //purpose  : 
84 //=======================================================================
85 Standard_Boolean AIS_InteractiveContext::HasPolygonOffsets(const Handle(AIS_InteractiveObject)& anObj) const
86 {
87   return ( !anObj.IsNull() && anObj->HasPolygonOffsets() );
88 }
89
90 //=======================================================================
91 //function : PolygonOffsets 
92 //purpose  : 
93 //=======================================================================
94 void AIS_InteractiveContext::PolygonOffsets(
95                              const Handle(AIS_InteractiveObject)& anObj,
96                              Standard_Integer&                    aMode,
97                              Standard_ShortReal&                  aFactor,
98                              Standard_ShortReal&                  aUnits) const 
99 {
100   if ( HasPolygonOffsets( anObj ) )
101     anObj->PolygonOffsets( aMode, aFactor, aUnits );
102 }
103 // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets