SHAPER 9.16.0
ModuleBase_WidgetSelectionFilter.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModuleBase_WidgetSelectionFilter_H
21#define ModuleBase_WidgetSelectionFilter_H
22
23#include "ModuleBase.h"
24#include "ModuleBase_ModelWidget.h"
25#include "ModuleBase_ViewerPrs.h"
26
27#include <ModelAPI_FiltersFeature.h>
28
29#include <SelectMgr_IndexedMapOfOwner.hxx>
30#include <AIS_Shape.hxx>
31#include <AIS_ListOfInteractive.hxx>
32
33#include <QWidget>
34#include <QList>
35
36class QLabel;
37class QComboBox;
38class QGroupBox;
39class QToolButton;
40class QVBoxLayout;
41class QPushButton;
42class QCheckBox;
43
44class ModelAPI_Filter;
45
47
53class MODULEBASE_EXPORT ModuleBase_FilterStarter: public QWidget
54{
55 Q_OBJECT
56public:
61 ModuleBase_FilterStarter(const std::string& theFeature, QWidget* theParent,
62 ModuleBase_IWorkshop* theWorkshop);
63
66
67private slots:
69 void onFiltersLaunch();
70
71private:
73 std::string myFeatureName;
74
76 ModuleBase_IWorkshop* myWorkshop;
77};
78
79
87{
88 Q_OBJECT
89public:
90
94 ModuleBase_FilterItem(const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent);
95
97 std::string filter() const { return myFilterID; }
98
100 QList<ModuleBase_ModelWidget*> widgets() const {
101 return myWidgets;
102 }
103
104signals:
107
110
111private slots:
114 void onReverse(bool theCheck);
115
117 void onDelete();
118
119private:
121 void addItemRow(QWidget* theParent);
122
124 std::string myFilterID;
125
127 FiltersFeaturePtr mySelection;
128
130 QToolButton* myRevBtn;
131
133 QList<ModuleBase_ModelWidget*> myWidgets;
134};
135
141{
142 Q_OBJECT
143public:
144 static FeaturePtr SelectorFeature;
145 static std::string AttributeId;
146
147
153 const Config_WidgetAPI* theData, bool theReadOnly = false);
154
157
160 virtual QList<QWidget*> getControls() const;
161
164 virtual void onFeatureAccepted();
165
167 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
168
170 QWidget* filtersWidget() const { return myFiltersWgt; }
171
173 virtual QString getError(const bool theValueStateChecked = true) const;
174
175protected:
178 virtual bool storeValueCustom();
179
181 virtual bool restoreValueCustom();
182
183private slots:
185 void onAddFilter(int);
186
188 void onDeleteItem(ModuleBase_FilterItem* theItem);
189
191 void onReverseItem(ModuleBase_FilterItem* theItem);
192
194 void onSelect();
195
197 void onShowOnly(bool theErase);
198
200 void onObjectUpdated();
201
202private:
204 void updateSelectBtn();
205
207 void updateNumberSelected();
208
210 void clearCurrentSelection(bool toUpdate = false);
211
214 void updatePreview(const TopoDS_Shape& theShape);
215
217 void redisplayFeature();
218
220 ModuleBase_FilterItem* onAddFilter(const std::string& theFilter);
221
223 QList<ModuleBase_FilterItem*> itemsList() const;
224
226 QString translate(const std::string& theString) const;
227
229 void storeFilters(const std::list<std::shared_ptr<ModelAPI_Filter> >& theFilters);
230
231private:
232 ModuleBase_IWorkshop* myWorkshop;
233
234 QWidget* myFiltersWgt;
235 QVBoxLayout* myFiltersLayout;
236
237 QComboBox* myFiltersCombo;
238 QPushButton* mySelectBtn;
239 QLabel* myNbLbl;
240 QCheckBox* myShowBtn;
241
243 int mySelectionType;
244
246 QList<ModuleBase_ViewerPrsPtr> myValues;
247
249 Handle(AIS_Shape) myPreview;
250
252 AIS_ListOfInteractive myListIO;
253
255 FeaturePtr mySelectorFeature;
256
258 std::string mySelectorAttribute;
259
261 std::map<std::string, std::shared_ptr<ModelAPI_Filter> > myFilters;
262};
263
264
265#endif
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Definition: ModelAPI_Filter.h:34
A widget which represents a one filter item in filters list Also it includes filter GUI if it exists.
Definition: ModuleBase_WidgetSelectionFilter.h:87
void deleteItem(ModuleBase_FilterItem *theItem)
The seignal is sent on deletion of the item.
ModuleBase_FilterItem(const std::string &theFilter, ModuleBase_WidgetSelectionFilter *theParent)
Constructor.
Definition: ModuleBase_WidgetSelectionFilter.cpp:148
void reversedItem(ModuleBase_FilterItem *theItem)
The seignal is sent on reversing of the item.
std::string filter() const
Returns filter Id.
Definition: ModuleBase_WidgetSelectionFilter.h:97
QList< ModuleBase_ModelWidget * > widgets() const
Returns list of widgets which represent the current filter GUI.
Definition: ModuleBase_WidgetSelectionFilter.h:100
An object which lets to start a Filters operation as a sub-operation of the current one.
Definition: ModuleBase_WidgetSelectionFilter.h:54
~ModuleBase_FilterStarter()
Destructor.
Definition: ModuleBase_WidgetSelectionFilter.h:65
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
A widget for selection by filters.
Definition: ModuleBase_WidgetSelectionFilter.h:141
virtual bool restoreValueCustom()
Restore value from attribute data to the widget's control (not ussed for this widget)
Definition: ModuleBase_WidgetSelectionFilter.cpp:669
ModuleBase_IWorkshop * workshop() const
Returns current workshop.
Definition: ModuleBase_WidgetSelectionFilter.h:167
virtual QList< QWidget * > getControls() const
Returns list of widget controls.
Definition: ModuleBase_WidgetSelectionFilter.cpp:578
~ModuleBase_WidgetSelectionFilter()
Destructor.
Definition: ModuleBase_WidgetSelectionFilter.cpp:329
virtual void onFeatureAccepted()
It is called when user press Ok or OkPlus buttons in the parent property panel By default this slot d...
Definition: ModuleBase_WidgetSelectionFilter.cpp:641
ModuleBase_WidgetSelectionFilter(QWidget *theParent, ModuleBase_IWorkshop *theWorkshop, const Config_WidgetAPI *theData, bool theReadOnly=false)
Constructor.
Definition: ModuleBase_WidgetSelectionFilter.cpp:243
virtual bool storeValueCustom()
Saves the internal parameters to the given feature (not ussed for this widget)
Definition: ModuleBase_WidgetSelectionFilter.cpp:654
QWidget * filtersWidget() const
Returns a container widget for filter items.
Definition: ModuleBase_WidgetSelectionFilter.h:170
virtual QString getError(const bool theValueStateChecked=true) const
Returns error string.
Definition: ModuleBase_WidgetSelectionFilter.cpp:710