Salome HOME
Merge remote-tracking branch 'origin/master' into gni/documentation
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFeatureSelector.h
index 7e1538b19f09fc9b7d08677f477b834810d2ce68..d2782bc0f563487747ce648d906bf8cf66e1ce85 100644 (file)
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
-\r
-// File:        ModuleBase_WidgetFeatureSelector.h\r
-// Created:     5 Sep 2016\r
-// Author:      Natalia Ermolaeva\r
-\r
-#ifndef ModuleBase_WidgetFeatureSelector_H\r
-#define ModuleBase_WidgetFeatureSelector_H\r
-\r
-#include "ModuleBase.h"\r
-#include "ModuleBase_WidgetSelector.h"\r
-\r
-class Config_WidgetAPI;\r
-class QWidget;\r
-class QLabel;\r
-class QLineEdit;\r
-\r
-/**\r
-* \ingroup GUI\r
-* Implementation of widget for feature selection.\r
-* This type of widget can be defined in XML file with 'feature_selector' keyword.\r
-* For example:\r
-* \code\r
-*   <feature_selector id="main_object" \r
-*    label="Main object" \r
-*    tooltip="Select an object solid"\r
-*  />\r
-* \endcode\r
-* It can use following parameters:\r
-* - id - name of object attribute\r
-* - label - content of widget's label\r
-* - tooltip - the witget's tooltip text\r
-*/\r
-class MODULEBASE_EXPORT ModuleBase_WidgetFeatureSelector : public ModuleBase_WidgetValidated\r
-{\r
-Q_OBJECT\r
- public:\r
-\r
-  /// Constructor\r
-  /// \param theParent the parent object\r
-  /// \param theWorkshop instance of workshop interface\r
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from\r
-  ModuleBase_WidgetFeatureSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,\r
-                                   const Config_WidgetAPI* theData);\r
-\r
-  virtual ~ModuleBase_WidgetFeatureSelector();\r
-\r
-  /// Set the given wrapped value to the current widget\r
-  /// This value should be processed in the widget according to the needs\r
-  /// The method is called by the current operation to process the operation preselection.\r
-  /// It is redefined to check the value validity and if it is, fill the attribute with by value\r
-  /// \param theValues the wrapped selection values\r
-  /// \param theToValidate a flag on validation of the values\r
-  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,\r
-                            const bool theToValidate);\r
-\r
-  /// Returns list of widget controls\r
-  /// \return a control list\r
-  virtual QList<QWidget*> getControls() const;\r
-\r
-  /// Fills the attribute with the value of the selected owner\r
-  /// \param thePrs a selected owner\r
-  virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
-\r
-  /// The method called when widget is deactivated\r
-  virtual void deactivate();\r
-\r
-protected:\r
-  /// The method called when widget is activated\r
-  virtual void activateCustom();\r
-\r
-  /// Saves the internal parameters to the given feature\r
-  /// \return True in success\r
-  virtual bool storeValueCustom();\r
-\r
-  virtual bool restoreValueCustom();\r
-\r
-  /// Computes and updates name of selected object in the widget\r
-  virtual void updateSelectionName();\r
-\r
-  // Update focus after the attribute value change\r
-  virtual void updateFocus();\r
-\r
-  /// Checks whether all active viewer filters validate the presentation\r
-  /// \param thePrs a selected presentation in the view\r
-  /// \return a boolean value\r
-  virtual bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
-\r
-  /// Emits model changed info, updates the current control by selection change\r
-  /// \param theDone a state whether the selection is set\r
-  virtual void updateOnSelectionChanged(const bool theDone);\r
-\r
-protected slots:\r
-  /// Called on selection changed event\r
-  virtual void onSelectionChanged();\r
-\r
-  //----------- Class members -------------\r
-protected:\r
-  /// Label of the widget\r
-  QLabel* myLabel;\r
-\r
-  /// Input control of the widget\r
-  QLineEdit* myTextLine;\r
-};\r
-\r
-#endif\r
+// 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
+*   <feature_selector id="main_object" 
+*    label="Main object" 
+*    tooltip="Select an object solid"
+*  />
+* \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<std::shared_ptr<ModuleBase_ViewerPrs>>& 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<QWidget*> getControls() const;
+
+  /// Fills the attribute with the value of the selected owner
+  /// \param thePrs a selected owner
+  virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& 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<ModuleBase_ViewerPrs>& 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