]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Edit sketch by popup menu.
authornds <natalia.donis@opencascade.com>
Fri, 23 May 2014 12:49:53 +0000 (16:49 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 23 May 2014 12:49:53 +0000 (16:49 +0400)
#61 - disable view position icons when Create sketch

src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Workshop.cpp

index 84e4234bde052e0e76ef1c92aa6eba8c79306ee2..2cc821e39fc26a8d52a3103a0fa3adf923b379ed 100644 (file)
@@ -18,6 +18,8 @@ boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_EdgeBuilder::line(
 
   if (aStart.IsEqual(anEnd, Precision::Confusion()))
     return boost::shared_ptr<GeomAPI_Shape>();
+  if (Abs(aStart.SquareDistance(anEnd)) > 1.e+100)
+    return boost::shared_ptr<GeomAPI_Shape>();
   BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
   boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
index 63f7a1a373a1aa1ada079af3a030afb43eb502fc..57fbe728fbcd98bb670e2d181d28cd22ff4794e1 100644 (file)
@@ -17,6 +17,7 @@
 #include <XGUI_ViewPort.h>
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_ViewerProxy.h>
+#include <XGUI_ContextMenuMgr.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -54,6 +55,10 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
 
+  XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
+  connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), 
+          this, SLOT(onContextMenuCommand(const QString&, bool)));
+
   connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
           this, SLOT(onMousePressed(QMouseEvent*)));
   connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
@@ -193,8 +198,8 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<Mo
     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted(TopAbs_VERTEX);
     aPreviewOp->init(theFeature, aSelected, aHighlighted);
   }
-  myWorkshop->actionsMgr()->updateCheckState();
   sendOperation(anOperation);
+  myWorkshop->actionsMgr()->updateCheckState();
 }
 
 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
@@ -407,11 +412,11 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
 
 void PartSet_Module::editFeature(FeaturePtr theFeature)
 {
-  /*if (!theFeature)
+  if (!theFeature)
     return;
 
   if (theFeature->getKind() == "Sketch") {
     onLaunchOperation(theFeature->getKind(), theFeature);
-    visualizePreview(theFeature, true);
-  }*/
+    updateCurrentPreview(theFeature->getKind());
+  }
 }
index eb65c3659515f3b4d05274a1e9121905a8916345..f50dcb41df200e73602dd1eac89418db885328f6 100644 (file)
@@ -52,7 +52,8 @@ std::list<int> PartSet_OperationSketch::getSelectionModes(boost::shared_ptr<Mode
 }
 
 void PartSet_OperationSketch::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                   const std::list<XGUI_ViewerPrs>& thePresentations)
+                                   const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                   const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
   setFeature(theFeature);
 }
@@ -141,20 +142,21 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const
   return hasSketchPlane();
 }
 
+void PartSet_OperationSketch::startOperation()
+{
+  if (!feature())
+    setFeature(createFeature());
+}
+
 bool PartSet_OperationSketch::hasSketchPlane() const
 {
   bool aHasPlane = false;
 
   if (feature()) {
-    // set plane parameters to feature
     boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-
     boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
-    // temporary solution for main planes only
     boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
       boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
-    double aX = aNormal->x(), anY = aNormal->y(), aZ = aNormal->z();
-
     aHasPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
   }
   return aHasPlane;
index 8f3a8fd4e856a4b898641137c8497159a50129de..d40a55331a198a5fdccbb4fdb9cbc8a22872ffda 100644 (file)
@@ -35,10 +35,11 @@ public:
   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
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                    const std::list<XGUI_ViewerPrs>& thePresentations);
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
@@ -80,6 +81,10 @@ signals:
   void planeSelected(double theX, double theY, double theZ);
 
 protected:
+  /// Virtual method called when operation started (see start() method for more description)
+  /// Default impl calls corresponding slot and commits immediately.
+  virtual void startOperation();
+
   /// Returns whether the sketch plane is set
   /// \return the boolean value whether the sketch is set
   bool hasSketchPlane() const;
index 13b61db1fbfaf04c26121633d179d7b75d351804..1d97cb2b051be4fd0e51d787f4f9591d8989b2b9 100644 (file)
@@ -35,14 +35,18 @@ void SketchPlugin_Sketch::execute()
 
 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
 {
-  std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
-
-  addPlane(1, 0, 0, aFaces); // YZ plane
-  addPlane(0, 1, 0, aFaces); // XZ plane
-  addPlane(0, 0, 1, aFaces); // XY plane
-  boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-  setPreview(aCompound);
+  if (isPlaneSet()) {
+    setPreview(boost::shared_ptr<GeomAPI_Shape>());
+  }
+  else {
+    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
 
+    addPlane(1, 0, 0, aFaces); // YZ plane
+    addPlane(0, 1, 0, aFaces); // XZ plane
+    addPlane(0, 0, 1, aFaces); // XY plane
+    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+    setPreview(aCompound);
+  }
   return getPreview();
 }
 
@@ -76,3 +80,11 @@ boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, cons
 
   return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
 }
+
+bool SketchPlugin_Sketch::isPlaneSet()
+{
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+
+  return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+}
index 371943ec599254f9b1d520c90cf87404ffa41704..9f82b85ab8a9f310ee8b2cfc012d3971ca4f7ebc 100644 (file)
@@ -67,6 +67,10 @@ protected:
   /// \param theShapes the list of result shapes
   void addPlane(double theX, double theY, double theZ,
                 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
+
+  /// Checks whether the plane is set in the sketch.
+  /// \returns the boolean state
+  bool isPlaneSet();
 };
 
 #endif
index 389f81420925586f6724787be794a2a9e1a964bb..f21ab22f91b2c7dccc00c35e51962a387a44c2f6 100644 (file)
@@ -307,6 +307,7 @@ void XGUI_Workshop::onOperationStarted()
     myPropertyPanel->setModelWidgets(aFactory.getModelWidgets());
     myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
   }
+  updateCommandStatus();
 }
 
 //******************************************************