From: vsv Date: Thu, 26 Jun 2014 06:44:31 +0000 (+0400) Subject: Divide init method of sketch operation on initFeature and initSelection. X-Git-Tag: V_0.4.4~226^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a00f219feb510c253eeded6b54c36f0b4e21218;p=modules%2Fshaper.git Divide init method of sketch operation on initFeature and initSelection. --- diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 58130a384..e53cc16ea 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -136,10 +136,10 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent) return ModuleBase_ModelWidget::eventFilter(theObject, theEvent); } -void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature) +bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature) { if (myOptionParam.length() == 0) - return; + return false; boost::shared_ptr aData = theFeature->data(); boost::shared_ptr aPoint = boost::dynamic_pointer_cast(aData->attribute(myOptionParam)); @@ -151,5 +151,7 @@ void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature) emit valuesChanged(); emit storedPoint2D(theFeature, myOptionParam); + return true; } + return false; } diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index 519e96ccc..784f02daa 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -55,7 +55,7 @@ public: /// \param theEvent the processed event virtual bool eventFilter(QObject *theObject, QEvent *theEvent); - void initFromPrevious(FeaturePtr theFeature); + bool initFromPrevious(FeaturePtr theFeature); signals: /// Signal about the point 2d set to the feature diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 1266a0cb1..8c3b099ed 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -138,6 +138,14 @@ void PartSet_Module::onFeatureTriggered() void PartSet_Module::launchOperation(const QString& theCmdId) { ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString()); + //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + //if (aPreviewOp) { + // XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + // // Initialise operation with preliminary selection + // std::list aSelected = aDisplayer->getSelected(); + // std::list aHighlighted = aDisplayer->getHighlighted(); + // aPreviewOp->initSelection(aSelected, aHighlighted); + //} sendOperation(anOperation); } @@ -260,7 +268,8 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur // refill the features list with avoiding of the features, obtained only by vertex shape (TODO) std::list aSelected = aDisplayer->getSelected(); std::list aHighlighted = aDisplayer->getHighlighted(); - aPreviewOp->init(theFeature, aSelected, aHighlighted); + aPreviewOp->initFeature(theFeature); + aPreviewOp->initSelection(aSelected, aHighlighted); } else { anOperation->setEditingFeature(theFeature); } diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 5b22f3fac..89d168353 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -86,15 +86,19 @@ std::list PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theF return aModes; } -void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::initSelection(const std::list& theSelected, + const std::list& /*theHighlighted*/) { - if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND) - return; +} + +void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature) +{ +// if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND) +// return; myInitFeature = theFeature; } + FeaturePtr PartSet_OperationFeatureCreate::sketch() const { return mySketch; @@ -214,10 +218,10 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t if (myInitFeature && myActiveWidget) { ModuleBase_WidgetPoint2D* aWgt = dynamic_cast(myActiveWidget); - if (aWgt) - aWgt->initFromPrevious(myInitFeature); - myInitFeature = FeaturePtr(); - emit activateNextWidget(myActiveWidget); + if (aWgt && aWgt->initFromPrevious(myInitFeature)) { + myInitFeature = FeaturePtr(); + emit activateNextWidget(myActiveWidget); + } } } diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index 606bdc3bf..3c181063d 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -55,12 +55,14 @@ public: /// \return the selection mode virtual std::list getSelectionModes(FeaturePtr theFeature) const; - /// Initializes some fields accorging to the feature + /// Initializes the operation with previously created feature. It is used in sequental operations + virtual void initFeature(FeaturePtr theFeature); + + /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void init(FeaturePtr theFeature, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void initSelection(const std::list& theSelected, + const std::list& theHighlighted); /// Returns the operation sketch feature /// \returns the sketch instance diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index cb51f46b9..cd334f1cd 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -57,12 +57,14 @@ public: /// \return the selection mode virtual std::list getSelectionModes(FeaturePtr theFeature) const; - /// Initializes some fields accorging to the feature + /// Initializes the operation with previously created feature. It is used in sequental operations + virtual void initFeature(FeaturePtr theFeature) {} + + /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void init(FeaturePtr theFeature, - const std::list& theSelected, - const std::list& theHighlighted) {} + virtual void initSelection(const std::list& theSelected, + const std::list& theHighlighted) {} /// Returns the operation sketch feature /// \returns the sketch instance diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 542eca0cf..a491a89ee 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -30,4 +30,5 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const QFeatureList XGUI_ModuleConnector::selectedFeatures() const { return myWorkshop->selector()->selectedFeatures(); -} \ No newline at end of file +} + diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 04d7b3ef1..fbab125db 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -13,6 +13,7 @@ class Handle_AIS_InteractiveContext; class XGUI_Workshop; +class XGUI_Displayer; /** * Implementation of IWorkshop interface which provides access to Workshop sevices at module level @@ -29,7 +30,7 @@ public: virtual Handle(AIS_InteractiveContext) AISContext() const; //! Returns list of currently selected data objects - QFeatureList selectedFeatures() const; + virtual QFeatureList selectedFeatures() const; private: XGUI_Workshop* myWorkshop;