From: vsv Date: Fri, 26 Sep 2014 12:24:19 +0000 (+0400) Subject: Provide hasPreview method for operations with preview X-Git-Tag: V_0.4.4~7^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9d08fda0173567e0b8f1232a9dabb330fdeffe0f;p=modules%2Fshaper.git Provide hasPreview method for operations with preview --- diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 8e36a7704..17be4cba4 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -79,6 +79,10 @@ Q_OBJECT virtual void activateNextToCurrentWidget() {}; + /// If operation needs to redisplay its result during operation + /// then this method has to return True + virtual bool hasPreview() const { return false; } + public slots: /// Slots which listen the mode widget activation /// \param theWidget the model widget diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index fe04a7f98..b2387c238 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -376,28 +376,6 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) if (isDisplay) ModelAPI_EventCreator::get()->sendUpdated( theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); - /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; - // TODO visualizePreview(theFeature, isDisplay, false); - if (!isDisplay) { - ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); - FeaturePtr aSketch; - PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); - if (aPrevOp) { - std::list aList = aPrevOp->subFeatures(); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - - std::list::const_iterator anIt = aList.begin(), - aLast = aList.end(); - //TODO for (; anIt != aLast; anIt++) - // visualizePreview((*anIt), false, false); - //aDisplayer->updateViewer(); - } - } - - if (theMode == PartSet_OperationSketchBase::FM_Activation || - theMode == PartSet_OperationSketchBase::FM_Deactivation) - activateFeature(theFeature, true);*/ } ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId, @@ -485,35 +463,6 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) Events_Loop::loop()->send(aMessage); } -/*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, - const bool isUpdateViewer) - { - ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); - if (!anOperation) - return; - - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (!aPreviewOp) - return; - - ResultPtr aResult = theFeature->firstResult(); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - if (isDisplay) { - boost::shared_ptr aSPFeature = - boost::dynamic_pointer_cast(theFeature); - if (aSPFeature) { - PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); - if (aSketchOp && !aSketchOp->hasSketchPlane()) - showPlanes(); - } - } - else - aDisplayer->erase(aResult, false); - - if (isUpdateViewer) - aDisplayer->updateViewer(); - }*/ - void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); @@ -611,26 +560,6 @@ void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& the aPoint->y()); } -/*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const - { - XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr(); - XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr(); - - ModuleBase_Operation* aOperation = aOpMgr->currentOperation(); - if (!aOperation) - return !aActMgr->isNested(theCmdId); - - PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast(aOperation); - if (aSketchEdtOp) { - QStringList aConstraintList; - aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength" - <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular"; - return aConstraintList.contains(theCmdId); - } - QStringList aList = aActMgr->nestedCommands(aOperation->id()); - return aList.contains(theCmdId); - }*/ - QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, Config_WidgetAPI* theWidgetApi, QList& theModelWidgets) diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 1a90c5b88..72338efff 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -166,12 +166,11 @@ void PartSet_OperationSketch::stopOperation() FeaturePtr aFeature = feature(); std::list aResults = aFeature->results(); std::list::const_iterator aIt; + Events_ID anEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW); for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { - ModelAPI_EventCreator::get()->sendUpdated( - *aIt, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + ModelAPI_EventCreator::get()->sendUpdated(*aIt, anEvent); } - //ModelAPI_EventCreator::get()->sendUpdated(aFeature, - // Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + Events_Loop::loop()->flush(anEvent); } bool PartSet_OperationSketch::isNestedOperationsEnabled() const diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 0cdf593ac..862c6a4bf 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -97,6 +97,10 @@ Q_OBJECT /// \param theShape the shape void setSketchPlane(const TopoDS_Shape& theShape); + /// If operation needs to redisplay its result during operation + /// then this method has to return True + virtual bool hasPreview() const { return false; } + signals: /// signal about the sketch plane is selected /// \param theX the value in the X direction of the plane diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 878c56dd4..9b43039ea 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -120,6 +120,10 @@ Q_OBJECT /// theFeature the operation argument void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr()); + /// If operation needs to redisplay its result during operation + /// then this method has to return True + virtual bool hasPreview() const { return true; } + signals: /// signal about the request to launch operation /// theName the operation name diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 1b48c4e08..def3e45ac 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -419,9 +419,9 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptrhasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation->hasObject(aObj)) { // Display only current operation results + // Display only current operation results if operation has preview + if (aOperation->hasObject(aObj) && aOperation->hasPreview()) myDisplayer->display(aObj, false); - } } } }