From 3ccd62a2eedaf895c689d77ab4bfc698a592870e Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 29 Apr 2014 19:17:29 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines Resume operation for sketch after a line operation finish --- src/ModuleBase/ModuleBase_Operation.cpp | 13 +++++++++++++ src/ModuleBase/ModuleBase_Operation.h | 1 + src/PartSet/PartSet_Module.cpp | 16 ++++++++++++++-- src/PartSet/PartSet_OperationSketch.cpp | 8 +++++++- src/PartSet/PartSet_OperationSketchBase.cpp | 1 + src/PartSet/PartSet_OperationSketchBase.h | 7 +++++++ src/PartSet/PartSet_OperationSketchLine.cpp | 3 +-- src/SketchPlugin/plugin-Sketch.xml | 2 +- src/XGUI/XGUI_OperationMgr.cpp | 10 +++++++++- src/XGUI/XGUI_OperationMgr.h | 11 +++++++++-- 10 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index f31a292e0..d5a0ce993 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -196,6 +196,19 @@ void ModuleBase_Operation::start() emit started(); } +/*! + * \brief Resumes operation + * + * Public slot. Verifies whether operation can be started and starts operation. + * This slot is not virtual and cannot be redefined. Redefine startOperation method + * to change behavior of operation. There is no point in using this method. It would + * be better to inherit own operator from base one and redefine startOperation method + * instead. + */ +void ModuleBase_Operation::resume() +{ +} + /*! * \brief Aborts operation * diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 818476d6f..14978bee3 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -101,6 +101,7 @@ signals: public slots: void start(); + void resume(); void abort(); void commit(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 54472ed0a..0724e6de1 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -154,8 +154,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) if (!anOperation) return; PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (aPreviewOp) - visualizePreview(false); + //if (aPreviewOp) + // visualizePreview(false); } void PartSet_Module::onSelectionChanged() @@ -218,6 +218,18 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) if (aViewer) { aViewer->setViewProjection(theX, theY, theZ); } + + ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); + if (anOperation) { + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + if (aPreviewOp) { + aPreviewOp->setEditMode(true); + // the preview should be shown in another local context + visualizePreview(false); + visualizePreview(true); + } + } + myWorkshop->actionsMgr()->setNestedActionsEnabled(true); } diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index cc5fad46c..9a3a5c716 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -32,7 +32,10 @@ PartSet_OperationSketch::~PartSet_OperationSketch() int PartSet_OperationSketch::getSelectionMode() const { - return TopAbs_FACE; + int aMode = TopAbs_FACE; + if (isEditMode()) + aMode = TopAbs_VERTEX; + return aMode; } void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList) @@ -40,6 +43,9 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List aGShape(new GeomAPI_Shape); diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 864f77dda..a9f861fbb 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -16,6 +16,7 @@ PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent) : ModuleBase_PropPanelOperation(theId, theParent) { + setEditMode(false); } PartSet_OperationSketchBase::~PartSet_OperationSketchBase() diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index bcc3f3aa1..c578796a5 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -50,6 +50,13 @@ public: /// Processes the mouse move in the point /// \param thePoint a 3D point clicked in the viewer virtual void mouseMoved(const gp_Pnt& thePoint) {}; + + /// temporary code to provide edition mode + void setEditMode(const bool isEditMode) { myIsEditMode = isEditMode; }; +protected: + bool isEditMode() const { return myIsEditMode; } +private: + bool myIsEditMode; }; #endif diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 6da4b71f5..45121e285 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -49,7 +49,7 @@ void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint) break; case SM_SecondPoint: { setLinePoint(thePoint, LINE_ATTR_END); - commit(); + myPointSelectionMode = SM_None; } break; case SM_None: { @@ -83,7 +83,6 @@ void PartSet_OperationSketchLine::startOperation() void PartSet_OperationSketchLine::stopOperation() { PartSet_OperationSketchBase::stopOperation(); - myPointSelectionMode = SM_None; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 489bf53e6..2feedd6d7 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1,7 +1,7 @@ - + diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index aeb0ed3c0..5661727c2 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -36,6 +36,14 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) return true; } +void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation) +{ + connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped())); + connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted())); + + theOperation->resume(); +} + bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation) { bool aCanStart = true; @@ -78,5 +86,5 @@ void XGUI_OperationMgr::onOperationStopped() } } if (aResultOp) - startOperation(aResultOp); + resumeOperation(aResultOp); } diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index ef06d7da7..2e74ab0b1 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -34,8 +34,9 @@ public: /// Returns the current operation or NULL /// \return the current operation ModuleBase_Operation* currentOperation() const; - /// Sets the current operation or NULL - /// \return the current operation + /// Start the operation and append it to the stack of operations + /// \param theOperation the started operation + /// \return the state whether the current operation is started bool startOperation(ModuleBase_Operation* theOperation); signals: @@ -46,6 +47,12 @@ signals: void operationStopped(ModuleBase_Operation* theOperation); protected: + /// Sets the current operation or NULL + /// \param theOperation the started operation + /// \param isCheckBeforeStart the flag whether to check whether the operation can be started + /// \return the state whether the operation is resumed + void resumeOperation(ModuleBase_Operation* theOperation); + /// Returns whether the operation can be started. Check if there is already started operation and /// the granted parameter of the launched operation /// \param theOperation an operation to check -- 2.39.2