From 3de7ac3f686ffc390092084c9ef1351cf1349ce8 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 5 May 2014 16:56:23 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines Edge/vertex selection modes for the line. --- src/PartSet/PartSet_Module.cpp | 2 +- src/PartSet/PartSet_OperationSketch.cpp | 10 +++++----- src/PartSet/PartSet_OperationSketch.h | 2 +- src/PartSet/PartSet_OperationSketchBase.h | 2 +- src/PartSet/PartSet_OperationSketchLine.cpp | 10 ++++++---- src/PartSet/PartSet_OperationSketchLine.h | 2 +- src/XGUI/XGUI_Displayer.cpp | 13 ++++++------- src/XGUI/XGUI_Displayer.h | 3 ++- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 59cec6d98..4a0c54e5b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -255,7 +255,7 @@ void PartSet_Module::visualizePreview(boost::shared_ptr theFea boost::shared_ptr aPreview = aPreviewOp->preview(theFeature); if (aPreview) { aDisplayer->RedisplayInLocalContext(theFeature, aPreview->impl(), - aPreviewOp->getSelectionMode(theFeature)); + aPreviewOp->getSelectionModes(theFeature)); } } else { diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index b583c1e80..ee9334b32 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -30,12 +30,12 @@ PartSet_OperationSketch::~PartSet_OperationSketch() { } -int PartSet_OperationSketch::getSelectionMode(boost::shared_ptr theFeature) const +std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr theFeature) const { - int aMode = TopAbs_FACE; - if (isEditMode()) - aMode = TopAbs_VERTEX; - return aMode; + std::list aModes; + if (!isEditMode()) + aModes.push_back(TopAbs_FACE); + return aModes; } void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList) diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 7818a67cd..e577962bb 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -28,7 +28,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual int getSelectionMode(boost::shared_ptr theFeature) const; + virtual std::list getSelectionModes(boost::shared_ptr theFeature) const; /// Gives the current selected objects to be processed by the operation /// \param theList a list of interactive selected shapes diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 0cb2900d7..173851cbc 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -43,7 +43,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual int getSelectionMode(boost::shared_ptr theFeature) const = 0; + virtual std::list getSelectionModes(boost::shared_ptr theFeature) const = 0; /// Gives the current selected objects to be processed by the operation /// \param theList a list of interactive selected shapes diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 69590f33a..14e0502b5 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -37,12 +37,12 @@ bool PartSet_OperationSketchLine::isGranted() const return true; } -int PartSet_OperationSketchLine::getSelectionMode(boost::shared_ptr theFeature) const +std::list PartSet_OperationSketchLine::getSelectionModes(boost::shared_ptr theFeature) const { - int aMode = 0; + std::list aModes; if (theFeature != feature()) - aMode = TopAbs_VERTEX; - return aMode; + aModes.push_back(TopAbs_VERTEX); + return aModes; } void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint) @@ -111,6 +111,8 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey) myPointSelectionMode = SM_FirstPoint; document()->abortOperation(); } + else + myPointSelectionMode = SM_FirstPoint; } break; default: diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index 939cdef7f..7883143fa 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -34,7 +34,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual int getSelectionMode(boost::shared_ptr theFeature) const; + virtual std::list getSelectionModes(boost::shared_ptr theFeature) const; /// Gives the current selected objects to be processed by the operation /// \param thePoint a point clicked in the viewer diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 8d7b6ef9d..c0a57d545 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -78,7 +78,7 @@ void XGUI_Displayer::Erase(boost::shared_ptr theFeature, void XGUI_Displayer::RedisplayInLocalContext(boost::shared_ptr theFeature, const TopoDS_Shape& theShape, - const int theMode, const bool isUpdateViewer) + const std::list& theModes, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -105,12 +105,11 @@ void XGUI_Displayer::RedisplayInLocalContext(boost::shared_ptr // Activate selection of objects from prs if (!anAIS.IsNull()) { if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) { - ic->Display(anAIS, 0/*display mode*/, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode), - false/*update viewer*/, true/*allow decomposition*/); - /*if (theMode == TopAbs_VERTEX) { - ic->ActivateStandardMode(TopAbs_EDGE); - ic->ActivateStandardMode(TopAbs_VERTEX); - }*/ + ic->Display(anAIS, false); + ic->Load(anAIS, -1, true/*allow decomposition*/); + std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); + for (; anIt != aLast; anIt++) + ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt)); } } if (isUpdateViewer) diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 3ca9b964c..ec9d69649 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -16,6 +16,7 @@ #include #include +#include class XGUI_Viewer; class ModelAPI_Feature; @@ -61,7 +62,7 @@ public: /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void RedisplayInLocalContext(boost::shared_ptr theFeature, const TopoDS_Shape& theShape, - const int theMode, const bool isUpdateViewer = true); + const std::list& theMode, const bool isUpdateViewer = true); /// Erase the feature and a shape. /// \param theFeature a feature instance -- 2.39.2