]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Create Z layer for constraints
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Jul 2015 12:21:17 +0000 (15:21 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Jul 2015 12:21:30 +0000 (15:21 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h

index 018ae1706ad55270e23d222796e6103b1d838f39..ccc0565cc18ff7564c432592deb9d938629b8015 100644 (file)
@@ -133,6 +133,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
           this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
   connect(aViewer, SIGNAL(viewTransformed(int)),
           SLOT(onViewTransformed(int)));
+  connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)),
+          SLOT(onViewCreated(ModuleBase_IViewWindow*)));
 
   myMenuMgr = new PartSet_MenuMgr(this);
   myCustomPrs = new PartSet_CustomPrs(theWshop);
@@ -276,11 +278,6 @@ void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
 {
-  // z layer is created for all started operations in order to visualize operation AIS presentation
-  // over the object
-  Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
-  aViewer->AddZLayer(myVisualLayerId);
-
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->startSketch(theOperation);
   }
@@ -293,11 +290,6 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
 {
-  // the custom presentation should be deactivated before stop sketch,
-  // because it uses the active sketch of the sketch manager without checking if it is not null
-  Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
-  aViewer->RemoveZLayer(myVisualLayerId);
-  myVisualLayerId = 0;
   myCustomPrs->deactivate();
 
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
@@ -911,3 +903,28 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
     }
   }
 }
+
+
+void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
+{
+  // z layer is created for all started operations in order to visualize operation AIS presentation
+  // over the object
+  Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
+  if (myVisualLayerId == 0) {
+    if (myVisualLayerId == 0)
+      aViewer->AddZLayer(myVisualLayerId);
+  } else {
+    TColStd_SequenceOfInteger aZList;
+    aViewer->GetAllZLayers(aZList);
+    bool aFound = false;
+    //TColStd_SequenceIteratorOfSequenceOfInteger aIt;
+    for (int i = 1; i <= aZList.Length(); i++) {
+      if (aZList(i) == myVisualLayerId) {
+        aFound = true;
+        break;
+      }
+    }
+    if (!aFound)
+      aViewer->AddZLayer(myVisualLayerId);
+  }
+}
index 5520d0d2ced44c795f273fef0e2bb6c57ad068c5..ecb1dffdcba1b2ad6df7ee806a4d37f69f03f1ba 100644 (file)
@@ -200,6 +200,9 @@ protected slots:
   /// It commits the operation of it is can be committed
   void onOperationActivatedByPreselection();
 
+  /// A slot called on view window creation
+  void onViewCreated(ModuleBase_IViewWindow*);
+
  protected:
   /// Register validators for this module
   virtual void registerValidators();