From: nds Date: Fri, 15 Jan 2016 18:33:33 +0000 (+0300) Subject: Imrove multi-selector control to provide items multi-selection. Activate/deactivate... X-Git-Tag: V_2.2.0~203 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=54b08d00ae547e27c084d6df5d58d7588ec81090;p=modules%2Fshaper.git Imrove multi-selector control to provide items multi-selection. Activate/deactivate highlight customization of the active widget. When the widget is deactivated, selected items should not be visualized in the viewer in half-highlighted color. --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 94b2ff98c..d80620a48 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -160,15 +160,28 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theModes a list of modes virtual void activeSelectionModes(QIntList& theModes) {} - /** Update the object presentable properties such as color, lines width and other - * If the object is result with the color attribute value set, it is used, - * otherwise the customize is applyed to the object's feature if it is a custom prs - * \param theObject an object instance - * \param theFlag a flag of level of customization, which means that only part of sub-elements - * should be updated(e.g. only highlighted elements) - * \param theUpdateViewer the parameter whether the viewer should be update immediately - * \returns true if the object is modified - */ + /// Activate custom presentation for the object. Default realization is empty. + /// \param theObject an object instance + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// \param theUpdateViewer the parameter whether the viewer should be update immediately + virtual void activateCustomPrs(const FeaturePtr& theFeature, + const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) {} + + /// Deactivate custom presentation for the object. Default realization is empty. + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// \param theUpdateViewer the parameter whether the viewer should be update immediately + virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) {} + + /// Update the object presentable properties such as color, lines width and other + /// If the object is result with the color attribute value set, it is used, + /// otherwise the customize is applyed to the object's feature if it is a custom prs + /// \param theObject an object instance + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// should be updated(e.g. only highlighted elements) + /// \param theUpdateViewer the parameter whether the viewer should be update immediately + /// \returns true if the object is modified virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 38bc5c9c8..03d584fc7 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -160,6 +160,23 @@ ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector() { } +//******************************************************************** +void ModuleBase_WidgetMultiSelector::activateCustom() +{ + ModuleBase_WidgetSelector::activateCustom(); + + myWorkshop->module()->activateCustomPrs(myFeature, + ModuleBase_IModule::CustomizeHighlightedObjects, true); +} + +//******************************************************************** +void ModuleBase_WidgetMultiSelector::deactivate() +{ + ModuleBase_WidgetSelector::deactivate(); + + myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true); +} + //******************************************************************** bool ModuleBase_WidgetMultiSelector::storeValueCustom() const { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 591d842ad..7156e0517 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -65,6 +65,9 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// \return a control list virtual QList getControls() const; + /// The methiod called when widget is deactivated + virtual void deactivate(); + /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values @@ -99,6 +102,9 @@ protected slots: void onListSelection(); protected: + /// The methiod called when widget is activated + virtual void activateCustom(); + /// Saves the internal parameters to the given feature /// \return True in success virtual bool storeValueCustom() const; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index cb7d76e42..63404f66f 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -87,7 +87,7 @@ Q_OBJECT /// \return true if it is succeed virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) = 0; - /// The methiod called when widget is activated + /// The methiod called when widget is activated virtual void activateCustom(); /// Returns true if selected shape corresponds to requested shape types. diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index 54298f76d..373ee6332 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -25,25 +25,31 @@ //#define DO_NOT_VISUALIZE_CUSTOM_PRESENTATION PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop) - : myWorkshop(theWorkshop), myIsActive(false), myFeature(FeaturePtr()) + : myWorkshop(theWorkshop), myFeature(FeaturePtr()) { initPresentation(ModuleBase_IModule::CustomizeArguments); initPresentation(ModuleBase_IModule::CustomizeResults); initPresentation(ModuleBase_IModule::CustomizeHighlightedObjects); + + myIsActive[ModuleBase_IModule::CustomizeArguments] = false; + myIsActive[ModuleBase_IModule::CustomizeResults] = false; + myIsActive[ModuleBase_IModule::CustomizeHighlightedObjects] = false; } -bool PartSet_CustomPrs::isActive() +bool PartSet_CustomPrs::isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag) { - return myIsActive; + return myIsActive[theFlag]; } -bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer) +bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, + const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) { #ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION return false; #endif - myIsActive = true; + myIsActive[theFlag] = true; myFeature = theFeature; bool isModified = false; @@ -56,9 +62,10 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd return isModified; } -bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer) +bool PartSet_CustomPrs::deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) { - myIsActive = false; + myIsActive[theFlag] = false; bool isModified = false; erasePresentation(ModuleBase_IModule::CustomizeArguments, theUpdateViewer); diff --git a/src/PartSet/PartSet_CustomPrs.h b/src/PartSet/PartSet_CustomPrs.h index 8a27f041c..da5c24773 100755 --- a/src/PartSet/PartSet_CustomPrs.h +++ b/src/PartSet/PartSet_CustomPrs.h @@ -45,18 +45,24 @@ public: PARTSET_EXPORT virtual ~PartSet_CustomPrs() {}; /// Returns true if the presentation is active - bool isActive(); + /// \param theFlag an object AIS presentation type + bool isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag); /// Initializes the operation presentation by the parameter object and display the presentation /// \param theObject an operation feature source to fill the presentation + /// \param theFlag an object AIS presentation type /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly /// \returns true if the presentation is displayed - bool activate(const FeaturePtr& theObject, const bool theUpdateViewer); + bool activate(const FeaturePtr& theObject, + const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer); /// Initializes the operation presentation by empty object and erase the presentation /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + /// \param theFlag an object AIS presentation type /// \returns true if the presentation has been displayed and now it is erased - bool deactivate(const bool theUpdateViewer); + bool deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer); /// If the presentation is active[displayed], the shapes of the presentation is recomputed /// and the presentation is redisplayed. @@ -112,11 +118,12 @@ private: Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag); private: - bool myIsActive; /// State whether the presentation is activated/deactivated FeaturePtr myFeature; /// Reference to a feature object ModuleBase_IWorkshop* myWorkshop; /// current workshop /// map of presentation type to AIS object QMap myPresentations; + /// State whether the presentation is activated/deactivated + QMap myIsActive; }; #endif diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ea2740d62..356132804 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -269,8 +269,10 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation) } ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); - if (aFOperation) - myCustomPrs->activate(aFOperation->feature(), true); + if (aFOperation) { + myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, true); + myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, true); + } } void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation) @@ -278,13 +280,16 @@ void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation) ModuleBase_IModule::operationResumed(theOperation); ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); - if (aFOperation) - myCustomPrs->activate(aFOperation->feature(), true); + if (aFOperation) { + myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, true); + myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, true); + } } void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) { - bool isModified = myCustomPrs->deactivate(false); + bool isModified = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeArguments, false) || + myCustomPrs->deactivate(ModuleBase_IModule::CustomizeResults, false); if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { mySketchMgr->stopNestedSketch(theOperation); @@ -750,11 +755,23 @@ void PartSet_Module::onViewTransformed(int theTrsfType) aDisplayer->updateViewer(); } +void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature, const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) +{ + myCustomPrs->activate(theFeature, theFlag, theUpdateViewer); +} + +void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer) +{ + myCustomPrs->deactivate(theFlag, theUpdateViewer); +} + bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer) { bool isRedisplayed = false; - if (myCustomPrs->isActive()) + if (myCustomPrs->isActive(theFlag)) isRedisplayed = myCustomPrs->redisplay(theObject, theFlag, theUpdateViewer); return isRedisplayed; diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 7135b7c9b..36424180e 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -181,15 +181,28 @@ public: /// \param theFeature a feature void setCustomized(const FeaturePtr& theFeature); - /** Update the object presentable properties such as color, lines width and other - * If the object is result with the color attribute value set, it is used, - * otherwise the customize is applyed to the object's feature if it is a custom prs - * \param theObject an object instance - * \param theFlag a flag of level of customization, which means that only part of sub-elements - * should be updated(e.g. only highlighted elements) - * \param theUpdateViewer the parameter whether the viewer should be update immediatelly - * \returns true if the object is modified - */ + /// Activate custom presentation for the object + /// \param theFeature a feature instance + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// \param theUpdateViewer the parameter whether the viewer should be update immediately + virtual void activateCustomPrs(const FeaturePtr& theFeature, + const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer); + + /// Deactivate custom presentation for the object + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// \param theUpdateViewer the parameter whether the viewer should be update immediately + virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag, + const bool theUpdateViewer); + + /// Update the object presentable properties such as color, lines width and other + /// If the object is result with the color attribute value set, it is used, + /// otherwise the customize is applyed to the object's feature if it is a custom prs + /// \param theObject an object instance + /// \param theFlag a flag of level of customization, which means that only part of sub-elements + /// should be updated(e.g. only highlighted elements) + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + /// \returns true if the object is modified virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer);