1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModuleBase_WidgetShapeSelector_H
22 #define ModuleBase_WidgetShapeSelector_H
24 #include "ModuleBase.h"
25 #include "ModuleBase_WidgetSelector.h"
26 #include "ModuleBase_ViewerFilters.h"
28 #include <ModelAPI_Object.h>
29 #include <ModelAPI_Attribute.h>
30 #include <GeomAPI_Shape.h>
32 #include <TopAbs_ShapeEnum.hxx>
34 #include <QStringList>
36 class Config_WidgetAPI;
41 class ModuleBase_IWorkshop;
42 class ModuleBase_ViewerPrs;
43 class ModelAPI_Validator;
47 * Implementation of widget for shapes selection.
48 * This type of widget can be defined in XML file with 'shape_selector' keyword.
51 * <shape_selector id="main_object"
53 * icon=":icons/cut_shape.png"
54 * tooltip="Select an object solid"
55 * shape_types="solid shell"
59 * It can use following parameters:
60 * - id - name of object attribute
61 * - label - content of widget's label
62 * - icon - icon which can be used instead label
63 * - tooltip - the witget's tooltip text
64 * - shape_types - list of shape types for selection.
65 * Possible values: face, vertex, wire, edge, shell, solid
66 * - object_types - types of selectable objects.
67 * For today it supports only one type "construction"
68 * which corresponds to ModelAPI_ResultConstruction object type
69 * - concealment - hide or not hide selected object after operation
71 class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_WidgetSelector
77 /// \param theParent the parent object
78 /// \param theWorkshop instance of workshop interface
79 /// \param theData the widget configuation. The attribute of the model widget is obtained from
80 ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
81 const Config_WidgetAPI* theData);
83 virtual ~ModuleBase_WidgetShapeSelector();
85 /// Set the given wrapped value to the current widget
86 /// This value should be processed in the widget according to the needs
87 /// The method is called by the current operation to process the operation preselection.
88 /// It is redefined to check the value validity and if it is, fill the attribute with by value
89 /// \param theValues the wrapped selection values
90 /// \param theToValidate a flag on validation of the values
91 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
92 const bool theToValidate);
94 /// Returns list of widget controls
95 /// \return a control list
96 virtual QList<QWidget*> getControls() const;
99 /// Saves the internal parameters to the given feature
100 /// \return True in success
101 virtual bool storeValueCustom();
103 virtual bool restoreValueCustom();
105 /// Computes and updates name of selected object in the widget
106 virtual void updateSelectionName();
108 // Update focus after the attribute value change
109 virtual void updateFocus();
111 /// Retunrs a list of possible shape types
112 /// \return a list of shapes
113 virtual QIntList shapeTypes() const;
115 /// Get the shape from the attribute if the attribute contains a shape, e.g. selection attribute
117 virtual GeomShapePtr getShape() const;
119 /// Return the attribute values wrapped in a list of viewer presentations
120 /// \return a list of viewer presentations, which contains an attribute result and
121 /// a shape. If the attribute do not uses the shape, it is empty
122 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
124 //----------- Class members -------------
126 /// Label of the widget
129 /// Input control of the widget
130 QLineEdit* myTextLine;
132 /// List of accepting shapes types
133 QStringList myShapeTypes;