From: nds Date: Fri, 25 Apr 2014 14:46:19 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~116^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f63615bc0bed9bf4b7badf757129f3938c6caa2a;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Line operation start over the sketch --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp index c8419fe37..84e4234bd 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp @@ -16,6 +16,8 @@ boost::shared_ptr GeomAlgoAPI_EdgeBuilder::line( const gp_Pnt& aStart = theStart->impl(); const gp_Pnt& anEnd = theEnd->impl(); + if (aStart.IsEqual(anEnd, Precision::Confusion())) + 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/ModuleBase/ModuleBase_PropPanelOperation.h b/src/ModuleBase/ModuleBase_PropPanelOperation.h index 29ced2bd3..c6dc06814 100644 --- a/src/ModuleBase/ModuleBase_PropPanelOperation.h +++ b/src/ModuleBase/ModuleBase_PropPanelOperation.h @@ -29,15 +29,6 @@ public: ModuleBase_PropPanelOperation(const QString& theId = "", QObject* parent = 0); virtual ~ModuleBase_PropPanelOperation(); - /*! - * \brief Replied whether the operation should be commited after the start, or the operation itself - * do that. The default realization provides the check by the operation having the xml prepresentation - * @return the boolean value - */ - virtual bool isPerformedImmediately() const - { - return xmlRepresentation().isEmpty(); - } /*! * \brief Returns XML representation of the operation's widget. * \return XML QString diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5893526b4..c91631f06 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include #include @@ -162,8 +164,10 @@ void PartSet_Module::visualizePreview(bool isDisplay) return; if (isDisplay) { - myWorkshop->displayer()->LocalSelection(anOperation->feature(), aPreviewOp->preview(), - aPreviewOp->getSelectionMode()); + boost::shared_ptr aPreview = aPreviewOp->preview(); + if (aPreview) + myWorkshop->displayer()->LocalSelection(anOperation->feature(), + aPreview->impl(), aPreviewOp->getSelectionMode()); } else { myWorkshop->displayer()->GlobalSelection(false); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 7eca33e43..32a2199b8 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -30,11 +30,6 @@ PartSet_OperationSketch::~PartSet_OperationSketch() { } -bool PartSet_OperationSketch::isPerformedImmediately() const -{ - return false; -} - int PartSet_OperationSketch::getSelectionMode() const { return TopAbs_FACE; diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 6a7670b00..4a4fd74bc 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -25,9 +25,6 @@ public: /// Destructor virtual ~PartSet_OperationSketch(); - /// The sketch can not be created immediately, firstly a plane should be set - virtual bool isPerformedImmediately() const; - /// Returns the operation local selection mode /// \return the selection mode virtual int getSelectionMode() const; diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 519c97f76..864f77dda 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -22,9 +22,9 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase() { } -const TopoDS_Shape& PartSet_OperationSketchBase::preview() const +boost::shared_ptr PartSet_OperationSketchBase::preview() const { boost::shared_ptr aFeature = boost::dynamic_pointer_cast(feature()); - return aFeature->preview()->impl(); + return aFeature->preview(); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 7ca7fd2d3..916ebc466 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -13,6 +13,8 @@ #include #include +class GeomAPI_Shape; + /*! \class PartSet_OperationSketchBase * \brief The base operation for the sketch features. @@ -30,7 +32,7 @@ public: virtual ~PartSet_OperationSketchBase(); /// Returns the feature preview shape - const TopoDS_Shape& preview() const; + boost::shared_ptr preview() const; /// Returns the operation local selection mode /// \return the selection mode diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 7a5a78196..6ceda06f1 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -23,9 +23,9 @@ PartSet_OperationSketchLine::~PartSet_OperationSketchLine() { } -bool PartSet_OperationSketchLine::isPerformedImmediately() const +bool PartSet_OperationSketchLine::isGranted() const { - return false; + return true; } int PartSet_OperationSketchLine::getSelectionMode() const diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index 7c228af06..737c73c36 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -27,8 +27,9 @@ public: /// Destructor virtual ~PartSet_OperationSketchLine(); - /// The sketch can not be created immediately, firstly a plane should be set - virtual bool isPerformedImmediately() const; + /// Returns that this operator can be started above already running one. + /// The runned operation should be the sketch feature modified operation + virtual bool isGranted() const; /// Returns the operation local selection mode /// \return the selection mode diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9af73c3df..0729b14c7 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -179,7 +179,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer()); if (myOperationMgr->startOperation(anOperation)) { - if (anOperation->isPerformedImmediately()) { + if (anOperation->xmlRepresentation().isEmpty()) { anOperation->commit(); updateCommandStatus(); }