From d855bcb1e5035b3ca512b221e704f886d2bdba4a Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 23 May 2014 10:04:40 +0400 Subject: [PATCH] The contour closing. --- src/PartSet/PartSet_Module.cpp | 18 ++++++++++++++++++ src/PartSet/PartSet_Module.h | 7 ++++++- src/PartSet/PartSet_OperationEditLine.cpp | 2 ++ src/PartSet/PartSet_OperationSketch.cpp | 20 ++++++++++++++------ src/PartSet/PartSet_OperationSketch.h | 6 ++++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 06e21761f..63f7a1a37 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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( @@ -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); + }*/ +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 17dc20348..1766a6e02 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -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; diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index d630bb2c3..df852732c 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -206,6 +206,8 @@ void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr aData = theFeature->data(); + if (!aData->isValid()) + return; boost::shared_ptr aPoint = boost::dynamic_pointer_cast(aData->attribute(theAttribute)); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index e83e13319..5aff76e1c 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -51,6 +51,12 @@ std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr theFeature, + const std::list& thePresentations) +{ + setFeature(theFeature); +} + boost::shared_ptr PartSet_OperationSketch::sketch() const { return feature(); @@ -61,10 +67,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie const std::list& 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 > boost::shared_ptr aFeature; boost::shared_ptr aData = feature()->data(); + if (!aData->isValid()) + return aPreviewMap; boost::shared_ptr aRefList = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_FEATURES)); @@ -106,8 +116,6 @@ std::map, boost::shared_ptr > aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { aFeature = boost::dynamic_pointer_cast(*anIt); - if (!aFeature) - continue; boost::shared_ptr aPreview = aFeature->preview(); if (aPreview) aPreviewMap[aFeature] = aPreview; diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 6b32d1955..8f3a8fd4e 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -34,6 +34,12 @@ public: /// \return the selection mode 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 + virtual void init(boost::shared_ptr theFeature, + const std::list& thePresentations); + /// Returns the operation sketch feature /// \returns the sketch instance virtual boost::shared_ptr sketch() const; -- 2.39.2