Salome HOME
refs #327 - Polyline is not shown during creation
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Displayer.cxx
1 #include "CurveCreator_Displayer.h"
2
3 CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext theContext,
4                                                 const int theZLayer ) :
5   myContext( theContext ), myZLayer( theZLayer )
6 {
7   myObjects.clear();
8 }
9
10 CurveCreator_Displayer::~CurveCreator_Displayer(void)
11 {
12   eraseAll( true );
13   for( int i = 0 ; i < myObjects.size() ; i++ ){
14     myObjects[i].Nullify();
15   }
16   myObjects.clear();
17 }
18
19 void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
20 {
21   if ( theObject.IsNull() )
22     return;
23
24   myObjects.push_back( theObject );
25   myContext->Display( theObject, Standard_False );
26
27   if ( myZLayer >= 0 )
28     myContext->SetZLayer( theObject, myZLayer );
29
30   if( isUpdate )
31     myContext->UpdateCurrentViewer();
32 }
33
34 void CurveCreator_Displayer::eraseAll( bool isUpdate )
35 {
36   if(myObjects.empty())
37     return;
38   for( int i = 0 ; i < myObjects.size() ; i++ ){
39     myContext->Erase(myObjects[i], Standard_False);
40   }
41   myObjects.clear();
42   if( isUpdate )
43     myContext->UpdateCurrentViewer();
44 }
45
46 Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
47 {
48   if( isHL ){
49     return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
50   }
51   return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
52 }
53
54 /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
55 {
56   return;
57   //TODO:
58   Quantity_Color aColor = getActiveColor( isHL );
59   for( int i = 0 ; i < theObjects.size() ; i++ ){
60     theObjects[i]->SetColor(aColor);
61     myContext->Display(theObjects[i], Standard_False);
62   }
63   myContext->UpdateCurrentViewer();
64 }*/