X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetFeatureSelector.h;h=d2782bc0f563487747ce648d906bf8cf66e1ce85;hb=20d35238897e717b51eaba89f9ba3695ebf57e49;hp=7e1538b19f09fc9b7d08677f477b834810d2ce68;hpb=fa2d6e0932a9ef3d391ba4fb99b2608de8fdab33;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureSelector.h b/src/ModuleBase/ModuleBase_WidgetFeatureSelector.h index 7e1538b19..d2782bc0f 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetFeatureSelector.h @@ -1,106 +1,121 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetFeatureSelector.h -// Created: 5 Sep 2016 -// Author: Natalia Ermolaeva - -#ifndef ModuleBase_WidgetFeatureSelector_H -#define ModuleBase_WidgetFeatureSelector_H - -#include "ModuleBase.h" -#include "ModuleBase_WidgetSelector.h" - -class Config_WidgetAPI; -class QWidget; -class QLabel; -class QLineEdit; - -/** -* \ingroup GUI -* Implementation of widget for feature selection. -* This type of widget can be defined in XML file with 'feature_selector' keyword. -* For example: -* \code -* -* \endcode -* It can use following parameters: -* - id - name of object attribute -* - label - content of widget's label -* - tooltip - the witget's tooltip text -*/ -class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated -{ -Q_OBJECT - public: - - /// Constructor - /// \param theParent the parent object - /// \param theWorkshop instance of workshop interface - /// \param theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetFeatureSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, - const Config_WidgetAPI* theData); - - virtual ~ModuleBase_WidgetFeatureSelector(); - - /// Set the given wrapped value to the current widget - /// This value should be processed in the widget according to the needs - /// The method is called by the current operation to process the operation preselection. - /// It is redefined to check the value validity and if it is, fill the attribute with by value - /// \param theValues the wrapped selection values - /// \param theToValidate a flag on validation of the values - virtual bool setSelection(QList>& theValues, - const bool theToValidate); - - /// Returns list of widget controls - /// \return a control list - virtual QList getControls() const; - - /// Fills the attribute with the value of the selected owner - /// \param thePrs a selected owner - virtual bool setSelectionCustom(const std::shared_ptr& thePrs); - - /// The method called when widget is deactivated - virtual void deactivate(); - -protected: - /// The method called when widget is activated - virtual void activateCustom(); - - /// Saves the internal parameters to the given feature - /// \return True in success - virtual bool storeValueCustom(); - - virtual bool restoreValueCustom(); - - /// Computes and updates name of selected object in the widget - virtual void updateSelectionName(); - - // Update focus after the attribute value change - virtual void updateFocus(); - - /// Checks whether all active viewer filters validate the presentation - /// \param thePrs a selected presentation in the view - /// \return a boolean value - virtual bool isValidInFilters(const std::shared_ptr& thePrs); - - /// Emits model changed info, updates the current control by selection change - /// \param theDone a state whether the selection is set - virtual void updateOnSelectionChanged(const bool theDone); - -protected slots: - /// Called on selection changed event - virtual void onSelectionChanged(); - - //----------- Class members ------------- -protected: - /// Label of the widget - QLabel* myLabel; - - /// Input control of the widget - QLineEdit* myTextLine; -}; - -#endif +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef ModuleBase_WidgetFeatureSelector_H +#define ModuleBase_WidgetFeatureSelector_H + +#include "ModuleBase.h" +#include "ModuleBase_WidgetSelector.h" + +class Config_WidgetAPI; +class QWidget; +class QLabel; +class QLineEdit; + +/** +* \ingroup GUI +* Implementation of widget for feature selection. +* This type of widget can be defined in XML file with 'feature_selector' keyword. +* For example: +* \code +* +* \endcode +* It can use following parameters: +* - id - name of object attribute +* - label - content of widget's label +* - tooltip - the witget's tooltip text +*/ +class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated +{ +Q_OBJECT + public: + + /// Constructor + /// \param theParent the parent object + /// \param theWorkshop instance of workshop interface + /// \param theData the widget configuation. The attribute of the model widget is obtained from + ModuleBase_WidgetFeatureSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData); + + virtual ~ModuleBase_WidgetFeatureSelector(); + + /// Set the given wrapped value to the current widget + /// This value should be processed in the widget according to the needs + /// The method is called by the current operation to process the operation preselection. + /// It is redefined to check the value validity and if it is, fill the attribute with by value + /// \param theValues the wrapped selection values + /// \param theToValidate a flag on validation of the values + virtual bool setSelection(QList>& theValues, + const bool theToValidate); + + /// Fills given container with selection modes if the widget has it + /// \param [out] theModuleSelectionModes module additional modes, -1 means all default modes + /// \param theModes [out] a container of modes + virtual void selectionModes(int& theModuleSelectionModes, QIntList& theModes); + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + + /// Fills the attribute with the value of the selected owner + /// \param thePrs a selected owner + virtual bool setSelectionCustom(const std::shared_ptr& thePrs); + +protected: + /// The method called when widget is activated + virtual void activateCustom(); + + /// Saves the internal parameters to the given feature + /// \return True in success + virtual bool storeValueCustom(); + + virtual bool restoreValueCustom(); + + /// Computes and updates name of selected object in the widget + virtual void updateSelectionName(); + + // Update focus after the attribute value change + virtual void updateFocus(); + + /// Checks whether all active viewer filters validate the presentation + /// \param thePrs a selected presentation in the view + /// \return a boolean value + virtual bool isValidInFilters(const std::shared_ptr& thePrs); + + /// Emits model changed info, updates the current control by selection change + /// \param theDone a state whether the selection is set + virtual void updateOnSelectionChanged(const bool theDone); + +protected: + /// Returns true if envent is processed. + virtual bool processSelection(); + + //----------- Class members ------------- +protected: + /// Label of the widget + QLabel* myLabel; + + /// Input control of the widget + QLineEdit* myTextLine; +}; + +#endif