Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 26 Jun 2014 13:23:56 +0000 (17:23 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 26 Jun 2014 13:23:56 +0000 (17:23 +0400)
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/XGUI/XGUI_ViewerPrs.cpp
src/XGUI/XGUI_ViewerPrs.h

index 28ddf17a29f3459b2f7789ac5b263c56e4b32638..baa7285b054873ef2bf7f8c59defbac16ebd0f05 100644 (file)
@@ -80,8 +80,11 @@ bool ModuleBase_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue)
     ModuleBase_WidgetValueFeature* aFeatureValue = 
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
-      setPoint(aFeatureValue->point());
-      isDone = true;
+      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = aFeatureValue->point();
+      if (aPoint) {
+        setPoint(aPoint);
+        isDone = true;
+      }
     }
   }
   return isDone;
index 2e410b5004e723c3f8939230c68020536cd0e098..206bbaa5baf315cbcc56ceeb352745f6bb5f6a7a 100644 (file)
@@ -138,14 +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);
-  //
+  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);
 }
 
index 41a30c5d3533732bde8b9acb395ffd43c349fb14..6007204aceb6430ef319c986ccb056299073bc39 100644 (file)
@@ -86,12 +86,11 @@ std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theF
 void PartSet_OperationFeatureCreate::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
                                                    const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
+  myPreSelection = theSelected;
 }
 
 void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature)
 {
-  //if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
-  //  return;
   myInitFeature = theFeature;
 }
 
@@ -190,7 +189,15 @@ void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent*
 void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
 {
   myActiveWidget = theWidget;
-
+  if (myPreSelection.size() > 0) {
+    const XGUI_ViewerPrs& aPrs = myPreSelection.front();
+    ModuleBase_WidgetValueFeature aValue;
+    aValue.setFeature(aPrs.feature());
+    if (myActiveWidget->setValue(&aValue)) {
+      myPreSelection.remove(aPrs);
+      emit activateNextWidget(myActiveWidget);
+    }
+  } 
   if (myInitFeature && myActiveWidget) {
     ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
     if (aWgt && aWgt->initFromPrevious(myInitFeature)) { 
index d6ca0c77b696a3b520ec9db2794ee9d4e51e1048..ee711b1bc02fb3818f7cc4d3242413a0fa3add0f 100644 (file)
@@ -127,6 +127,8 @@ private:
   FeaturePtr mySketch; ///< the sketch of the feature
 
   ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
+
+  std::list<XGUI_ViewerPrs> myPreSelection;
 };
 
 #endif
index e0958f76fc6417fd2cbf50bbb543b8b4000882c2..f280905a7bcc43887875fcac30154e019c74238b 100644 (file)
@@ -50,3 +50,11 @@ const TopoDS_Shape& XGUI_ViewerPrs::shape() const
 {
   return myShape;
 }
+
+bool XGUI_ViewerPrs::operator==(const XGUI_ViewerPrs& thePrs)
+{
+  bool aFeature = (myFeature.get() == thePrs.feature().get());
+  bool aOwner = (myOwner.Access() == thePrs.owner().Access());
+  bool aShape = myShape.IsEqual(thePrs.shape());
+  return aFeature && aOwner && aShape;
+}
index 585b65cc37a8dffd705a1e6f21271c488cc1dac9..808640ce47cf9c2ca3965a5cf23877e9824d5f0a 100644 (file)
@@ -56,6 +56,8 @@ public:
   /// \return a shape instance
   const TopoDS_Shape& shape() const;
 
+  bool operator==(const XGUI_ViewerPrs&);
+
 private:
   FeaturePtr myFeature; /// the feature
   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner