From: nds Date: Fri, 23 May 2014 12:49:53 +0000 (+0400) Subject: Edit sketch by popup menu. X-Git-Tag: V_0.2~12^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d3705f6ea0a5aa258916bffee318f2c52669e0d;p=modules%2Fshaper.git Edit sketch by popup menu. #61 - disable view position icons when Create sketch --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp index 84e4234bd..2cc821e39 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp @@ -18,6 +18,8 @@ boost::shared_ptr GeomAlgoAPI_EdgeBuilder::line( if (aStart.IsEqual(anEnd, Precision::Confusion())) return boost::shared_ptr(); + if (Abs(aStart.SquareDistance(anEnd)) > 1.e+100) + return boost::shared_ptr(); BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd); boost::shared_ptr aRes(new GeomAPI_Shape); TopoDS_Edge anEdge = anEdgeBuilder.Edge(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 63f7a1a37..57fbe728f 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -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 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()); + } } diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index eb65c3659..f50dcb41d 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -52,7 +52,8 @@ std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr theFeature, - const std::list& thePresentations) + const std::list& /*theSelected*/, + const std::list& /*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 aData = feature()->data(); - boost::shared_ptr anAttr; - // temporary solution for main planes only boost::shared_ptr aNormal = boost::dynamic_pointer_cast(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; diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 8f3a8fd4e..d40a55331 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -35,10 +35,11 @@ public: virtual std::list getSelectionModes(boost::shared_ptr 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 theFeature, - const std::list& thePresentations); + const std::list& theSelected, + const std::list& 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; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 13b61db1f..1d97cb2b0 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -35,14 +35,18 @@ void SketchPlugin_Sketch::execute() const boost::shared_ptr& SketchPlugin_Sketch::preview() { - std::list > 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 aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); - setPreview(aCompound); + if (isPlaneSet()) { + setPreview(boost::shared_ptr()); + } + else { + std::list > 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 aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); + setPreview(aCompound); + } return getPreview(); } @@ -76,3 +80,11 @@ boost::shared_ptr SketchPlugin_Sketch::to3D(const double theX, cons return boost::shared_ptr(new GeomAPI_Pnt(aSum)); } + +bool SketchPlugin_Sketch::isPlaneSet() +{ + boost::shared_ptr aNormal = + boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_NORM)); + + return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); +} diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 371943ec5..9f82b85ab 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -67,6 +67,10 @@ protected: /// \param theShapes the list of result shapes void addPlane(double theX, double theY, double theZ, std::list >& theShapes) const; + + /// Checks whether the plane is set in the sketch. + /// \returns the boolean state + bool isPlaneSet(); }; #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 389f81420..f21ab22f9 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -307,6 +307,7 @@ void XGUI_Workshop::onOperationStarted() myPropertyPanel->setModelWidgets(aFactory.getModelWidgets()); myPropertyPanel->setWindowTitle(aOperation->getDescription()->description()); } + updateCommandStatus(); } //******************************************************