Salome HOME
Updated copyright comment
[modules/geom.git] / src / CurveCreator / CurveCreator_Displayer.cxx
1 // Copyright (C) 2013-2024  CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "CurveCreator_Displayer.hxx"
21
22 CurveCreator_Displayer::CurveCreator_Displayer( Handle(AIS_InteractiveContext) theContext,
23                                                 const int theZLayer ) :
24   myContext( theContext ), myZLayer( theZLayer )
25 {
26   myObjects.clear();
27 }
28
29 CurveCreator_Displayer::~CurveCreator_Displayer(void)
30 {
31   eraseAll( true );
32   for( int i = 0 ; i < (int)myObjects.size() ; i++ ){
33     myObjects[i].Nullify();
34   }
35   myObjects.clear();
36 }
37
38 void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
39 {
40   if ( theObject.IsNull() )
41     return;
42
43   myObjects.push_back( theObject );
44   myContext->Display( theObject, Standard_False );
45
46   if ( myZLayer >= 0 )
47     myContext->SetZLayer( theObject, myZLayer );
48
49   if( isUpdate )
50     myContext->UpdateCurrentViewer();
51 }
52
53 void CurveCreator_Displayer::eraseAll( bool isUpdate )
54 {
55   if(myObjects.empty())
56     return;
57   for( int i = 0 ; i < (int)myObjects.size() ; i++ )
58     myContext->Erase(myObjects[i], Standard_False);
59   myObjects.clear();
60   if( isUpdate )
61     myContext->UpdateCurrentViewer();
62 }
63
64 void CurveCreator_Displayer::erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
65 {
66   if(theObject.IsNull())
67     return;
68   myContext->Erase(theObject, Standard_False);
69   if( isUpdate )
70     myContext->UpdateCurrentViewer();
71 }
72
73 Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
74 {
75   if( isHL ){
76     return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
77   }
78   return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
79 }
80
81 void CurveCreator_Displayer::Update()
82 {
83   for( int i = 0 ; i < (int)myObjects.size() ; i++ )
84     myContext->Update(myObjects[i], Standard_True);
85   myContext->UpdateCurrentViewer();
86 }
87
88 /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
89 {
90   return;
91   //TODO:
92   Quantity_Color aColor = getActiveColor( isHL );
93   for( int i = 0 ; i < theObjects.size() ; i++ ){
94     theObjects[i]->SetColor(aColor);
95     myContext->Display(theObjects[i], Standard_False);
96   }
97   myContext->UpdateCurrentViewer();
98 }*/