]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The contour closing.
authornds <natalia.donis@opencascade.com>
Fri, 23 May 2014 06:04:40 +0000 (10:04 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 23 May 2014 06:04:40 +0000 (10:04 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h

index 06e21761f06a556a84592b0a81c69452a4c3901c..63f7a1a373a1aa1ada079af3a030afb43eb502fc 100644 (file)
@@ -122,6 +122,14 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
   }
 }
 
+void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
+{
+  QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures();
+  if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
+    editFeature(aFeatures.first());
+  }
+}
+
 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
@@ -397,3 +405,13 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
   aDisplayer->UpdateViewer();
 }
 
+void PartSet_Module::editFeature(FeaturePtr theFeature)
+{
+  /*if (!theFeature)
+    return;
+
+  if (theFeature->getKind() == "Sketch") {
+    onLaunchOperation(theFeature->getKind(), theFeature);
+    visualizePreview(theFeature, true);
+  }*/
+}
index 17dc2034820d6cdef49ddde5c1ae81ce6a548c00..1766a6e02b8a31c4174001c9da14555f6437bd5f 100644 (file)
@@ -62,7 +62,8 @@ public slots:
   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
   /// by the operation start
   void onOperationStopped(ModuleBase_Operation* theOperation);
-
+  /// SLOT, that is called afetr the popup menu action clicked.
+  void onContextMenuCommand(const QString& theId, bool isChecked);
   /// SLOT, that is called by mouse press in the viewer.
   /// The mouse released point is sent to the current operation to be processed.
   /// \param theEvent the mouse event
@@ -118,6 +119,10 @@ protected:
   /// \param theOperation the operation
   void sendOperation(ModuleBase_Operation* theOperation);
 
+protected:
+  //! Edits the feature
+  void editFeature(FeaturePtr theFeature);
+
 private:
   XGUI_Workshop* myWorkshop;
   PartSet_Listener* myListener;
index d630bb2c3c914dcd9847677b2cc1a13d82fac739..df852732c792b915f7c5f663c053d5fb873153f1 100644 (file)
@@ -206,6 +206,8 @@ void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature
     return;
 
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  if (!aData->isValid())
+    return;
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
 
index e83e133193014b32e297e2174f667abfb8dc75cc..5aff76e1c24159b33c4cc7d052c6a7f6373345da 100644 (file)
@@ -51,6 +51,12 @@ std::list<int> PartSet_OperationSketch::getSelectionModes(boost::shared_ptr<Mode
   return aModes;
 }
 
+void PartSet_OperationSketch::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                   const std::list<XGUI_ViewerPrs>& thePresentations)
+{
+  setFeature(theFeature);
+}
+
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketch::sketch() const
 {
   return feature();
@@ -61,10 +67,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
                                            const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
   if (!hasSketchPlane()) {
-    XGUI_ViewerPrs aPrs = theHighlighted.front();
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull())
-      setSketchPlane(aShape);
+    if (!theHighlighted.empty()) {
+      XGUI_ViewerPrs aPrs = theHighlighted.front();
+      const TopoDS_Shape& aShape = aPrs.shape();
+      if (!aShape.IsNull())
+        setSketchPlane(aShape);
+    }
   }
   else {
     if (theHighlighted.size() == 1) {
@@ -98,6 +106,8 @@ std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
   boost::shared_ptr<SketchPlugin_Feature> aFeature;
 
   boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  if (!aData->isValid())
+    return aPreviewMap;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
 
@@ -106,8 +116,6 @@ std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
                                                                   aLast = aFeatures.end();
   for (; anIt != aLast; anIt++) {
     aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
-    if (!aFeature)
-      continue;
     boost::shared_ptr<GeomAPI_Shape> aPreview = aFeature->preview();
     if (aPreview)
       aPreviewMap[aFeature] = aPreview;
index 6b32d1955969eccbd52b2427f5d602f76cdd151c..8f3a8fd4e856a4b898641137c8497159a50129de 100644 (file)
@@ -34,6 +34,12 @@ public:
   /// \return the selection mode
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
 
+  /// Initializes some fields accorging to the feature
+  /// \param theFeature the feature
+  /// \param thePresentations the list of additional presentations
+  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                    const std::list<XGUI_ViewerPrs>& thePresentations);
+
   /// Returns the operation sketch feature
   /// \returns the sketch instance
   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;