]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Divide init method of sketch operation on initFeature and initSelection.
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 26 Jun 2014 06:44:31 +0000 (10:44 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 26 Jun 2014 06:44:31 +0000 (10:44 +0400)
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationSketchBase.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h

index 58130a384f6230cb091987d237bfebc85f9a9f19..e53cc16eaaea6c19603350a488bf68ed14fa6436 100644 (file)
@@ -136,10 +136,10 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
   return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
 }
 
-void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
 {
   if (myOptionParam.length() == 0)
-    return;
+    return false;
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
@@ -151,5 +151,7 @@ void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
 
     emit valuesChanged();
     emit storedPoint2D(theFeature, myOptionParam);
+    return true;
   }
+  return false;
 }
index 519e96ccc64235d3abfbf3972179422a56307de9..784f02daabc4908a1915de6433efc95cc52c7db9 100644 (file)
@@ -55,7 +55,7 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
-  void initFromPrevious(FeaturePtr theFeature);
+  bool initFromPrevious(FeaturePtr theFeature);
 
 signals:
   /// Signal about the point 2d set to the feature
index 1266a0cb1e503eba2ada7e35c8823c4d6c2ddd74..8c3b099ed1b1bd54345d2a108b1b6ee8a3a26e5a 100644 (file)
@@ -138,6 +138,14 @@ void PartSet_Module::onFeatureTriggered()
 void PartSet_Module::launchOperation(const QString& theCmdId)
 {
   ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
+  //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  //if (aPreviewOp) {
+  //  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  //  // Initialise operation with preliminary selection
+  //  std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+  //  std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+  //  aPreviewOp->initSelection(aSelected, aHighlighted);
+  //} 
   sendOperation(anOperation);
 }
 
@@ -260,7 +268,8 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur
     // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
-    aPreviewOp->init(theFeature, aSelected, aHighlighted);
+    aPreviewOp->initFeature(theFeature);
+    aPreviewOp->initSelection(aSelected, aHighlighted);
   } else {
     anOperation->setEditingFeature(theFeature);
   }
index 5b22f3face29eb2bd73c5150340e21611d237e30..89d1683531e3df94acb69124ba8d27943316e313 100644 (file)
@@ -86,15 +86,19 @@ std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theF
   return aModes;
 }
 
-void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature,
-                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
+                                                   const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
-  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
-    return;
+}
+
+void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature)
+{
+//  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+//    return;
   myInitFeature = theFeature;
 }
 
+
 FeaturePtr PartSet_OperationFeatureCreate::sketch() const
 {
   return mySketch;
@@ -214,10 +218,10 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
 
   if (myInitFeature && myActiveWidget) {
     ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
-    if (aWgt)
-      aWgt->initFromPrevious(myInitFeature);
-    myInitFeature = FeaturePtr();
-    emit activateNextWidget(myActiveWidget);
+    if (aWgt && aWgt->initFromPrevious(myInitFeature)) { 
+      myInitFeature = FeaturePtr();
+      emit activateNextWidget(myActiveWidget);
+    }
   }
 }
 
index 606bdc3bfefa98b7e5a45fa9d751076a1f104f84..3c181063d2d3351b7d6b1a0c9fa8122c2209d672 100644 (file)
@@ -55,12 +55,14 @@ public:
   /// \return the selection mode
   virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
 
-  /// Initializes some fields accorging to the feature
+  /// Initializes the operation with previously created feature. It is used in sequental operations
+  virtual void initFeature(FeaturePtr theFeature);
+
+  /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void init(FeaturePtr theFeature,
-                    const std::list<XGUI_ViewerPrs>& theSelected,
-                    const std::list<XGUI_ViewerPrs>& theHighlighted);
+  virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
+    const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
index cb51f46b9ce2827a5308fb17ce0420ab7dc76a61..cd334f1cd652c6f5ed227e4b276d3153158589be 100644 (file)
@@ -57,12 +57,14 @@ public:
   /// \return the selection mode
   virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
 
-  /// Initializes some fields accorging to the feature
+  /// Initializes the operation with previously created feature. It is used in sequental operations
+  virtual void initFeature(FeaturePtr theFeature) {}
+
+  /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void init(FeaturePtr theFeature,
-                    const std::list<XGUI_ViewerPrs>& theSelected,
-                    const std::list<XGUI_ViewerPrs>& theHighlighted) {}
+  virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
+    const std::list<XGUI_ViewerPrs>& theHighlighted) {}
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
index 542eca0cfeeca1a7c3d6ae35fb69bb3e2e5ee6df..a491a89ee3367e7f0010b81b426287d1839b5148 100644 (file)
@@ -30,4 +30,5 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
 QFeatureList XGUI_ModuleConnector::selectedFeatures() const
 {
   return myWorkshop->selector()->selectedFeatures();
-}
\ No newline at end of file
+}
+
index 04d7b3ef18df05491d361e9609a9ea009bb66ab4..fbab125db1a03b85e44c9fd4950c40e28f21ad57 100644 (file)
@@ -13,6 +13,7 @@
 
 class Handle_AIS_InteractiveContext;
 class XGUI_Workshop;
+class XGUI_Displayer;
 
 /**
 * Implementation of IWorkshop interface which provides access to Workshop sevices at module level
@@ -29,7 +30,7 @@ public:
   virtual Handle(AIS_InteractiveContext) AISContext() const;
 
   //! Returns list of currently selected data objects
-  QFeatureList selectedFeatures() const; 
+  virtual QFeatureList selectedFeatures() const; 
 
 private:
   XGUI_Workshop* myWorkshop;