Salome HOME
Style changes.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PolylineOp.cxx
index dc0d2d6b12f85d497a8e9b55ff765a7cb358faf8..47b25a1233b9769803854985c2caa4e4ab4dbcff 100755 (executable)
@@ -52,8 +52,7 @@
 HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
 : HYDROGUI_Operation( theModule ), 
   myIsEdit( theIsEdit ),
-  myCurve( NULL ), 
-  myViewManager( NULL )
+  myCurve( NULL )
 {
   setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
 }
@@ -81,6 +80,32 @@ bool HYDROGUI_PolylineOp::deleteEnabled()
   return aPanel->deleteEnabled();
 }
 
+/**
+ * Set Z layer for the operation preview.
+ \param theLayer a layer position
+ */
+void HYDROGUI_PolylineOp::updatePreviewZLayer( int theLayer )
+{
+  HYDROGUI_Operation::updatePreviewZLayer( theLayer );
+
+  int aZLayer = getPreviewZLayer();
+  if ( aZLayer >= 0 )
+  {
+    if( getPreviewManager() )
+    {
+      if ( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
+      {
+        Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+        if( !aCtx.IsNull() )
+        {
+          Handle(AIS_InteractiveObject) anObject = myCurve->getAISObject( true );
+          aCtx->SetZLayer( anObject, aZLayer );
+        }
+      }
+    }
+  }
+}
+
 void HYDROGUI_PolylineOp::startOperation()
 {
   if( myIsEdit )
@@ -109,9 +134,10 @@ void HYDROGUI_PolylineOp::startOperation()
   aPanel->reset();
 
   LightApp_Application* anApp = module()->getApp();
-  myViewManager =
+  OCCViewer_ViewManager* aViewManager =
     dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
-  aPanel->setOCCViewer( myViewManager ? myViewManager->getOCCViewer() : 0 );
+  aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
+  setPreviewManager( aViewManager );
 
   QString aPolylineName;
   if( !myEditedObject.IsNull() )
@@ -320,14 +346,14 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged()
 
 void HYDROGUI_PolylineOp::displayPreview()
 {
-  if( myViewManager )
+  if( getPreviewManager() )
   {
-    if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+    if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
     {
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
       if( !aCtx.IsNull() )
       {
-        CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
+        CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx, getPreviewZLayer() );
         myCurve->setDisplayer( aDisplayer );
         aDisplayer->display( myCurve->getAISObject( true ), true );
       }
@@ -338,9 +364,9 @@ void HYDROGUI_PolylineOp::displayPreview()
 void HYDROGUI_PolylineOp::erasePreview()
 {
   CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0;
-  if( myViewManager && aDisplayer )
+  if( getPreviewManager() && aDisplayer )
   {
-    if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+    if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
     {
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
       if( !aCtx.IsNull() )
@@ -350,7 +376,7 @@ void HYDROGUI_PolylineOp::erasePreview()
     }
   }
 
-  myViewManager = NULL;
+  setPreviewManager( NULL );
   if ( myCurve )
   {
     delete myCurve;