]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Edit sketch objects
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 15:12:10 +0000 (19:12 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 15:12:10 +0000 (19:12 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index 6ddaeabe155a71db3cc1c02997f9671e7fa8fee8..4cea1a7bf62bd349bb79d047ca87f9a28540947b 100644 (file)
@@ -172,8 +172,8 @@ void PartSet_Module::onOperationStarted()
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp) {
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
-    connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-      this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
+    connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+      this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
   }
 }
 
@@ -184,8 +184,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
   if (aPreviewOp) {
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
-    //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-    //           this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
+    //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+    //           this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
   }
 }
 
@@ -273,15 +273,22 @@ void PartSet_Module::onFitAllView()
   myWorkshop->viewer()->fitAll();
 }
 
-void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theFeature)
+void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
 {
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
   if (!aFeature) {
-    qDebug("Warning! Restart operation without feature!");
-    return;
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+      DocumentPtr aDoc = aMgr->rootDocument();
+      aFeature = aDoc->feature(aResult);
+    } else {
+      qDebug("Warning! Restart operation without feature!");
+      return;
+    }
   }
   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
-                                                      theFeature ? aFeature->getKind() : "");
+                                                      aFeature ? aFeature->getKind() : "");
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp)
   {
@@ -361,15 +368,6 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
         }
       }
     }
-/*      FeaturePtr aFeature = aPrevOp->feature();
-      if (aFeature) {
-        std::list<ResultPtr> aResList = aFeature->results();
-        std::list<ResultPtr>::iterator aIt;
-        for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) {
-          aDisplayer->deactivate((*aIt), false);
-        }
-      }
-    }*/
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, 
         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 //  }
@@ -575,17 +573,19 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
 //  }
 }
 
-void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
+void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
 {
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
   if (!aPreviewOp)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(theAttribute));
 
-  PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
+  PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute,
                                 aPoint->x(), aPoint->y());
 }
 
index ac90ea98a02730215a7fc137396dd72d61729d9a..c32b3af077ecd2e5fbbabdcc27256bee8fcfce94 100644 (file)
@@ -140,7 +140,7 @@ public slots:
   /// Slot which reacts to the point 2d set to the feature. Creates a constraint
   /// \param the feature
   /// \param the attribute of the feature
-  void onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
 protected:
   /// Creates a new operation
index adf7b27481b978ee2bf0799d1970bcb80d068e33..99f8b066da82feb19b8ebb00cb198f87658d4ca4 100644 (file)
@@ -94,8 +94,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
 
       ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
       if (aPointWidget)
-        connect(aPointWidget, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
-                this, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)));
+        connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
+                this, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
     }
     ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
     if (aLastWidget) {
index 74c3c5fba03fbd2186504843b60f7249686b2ee1..22853105352ca4edcc3ba6be5495d52105091c04 100644 (file)
@@ -52,7 +52,7 @@ signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
-  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
 private:
   QWidget* myCustomWidget;
index 9505d9cf2e2b29ce834ca696c1df132f434eb5b0..03a3bae5e5fc833d343a6b181665f4d7ed1c8c4a 100644 (file)
@@ -467,7 +467,8 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
     aCommand = aMenu->feature(theOperation->getDescription()->operationId());
   }
   //Abort operation on uncheck the command
-  connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
+  if (aCommand)
+    connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
 }
 
 /*
@@ -767,7 +768,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
   aObjDock->setWindowTitle(tr("Object browser"));
   aObjDock->setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
-  connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
+  connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(changeCurrentDocument(ObjectPtr)));
   aObjDock->setWidget(myObjectBrowser);
 
   myContextMenuMgr->connectObjectBrowser();