1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef ModuleBase_WidgetSelectionFilter_H
21 #define ModuleBase_WidgetSelectionFilter_H
23 #include "ModuleBase.h"
24 #include "ModuleBase_ModelWidget.h"
25 #include "ModuleBase_ViewerPrs.h"
27 #include <ModelAPI_Filter.h>
29 #include <SelectMgr_IndexedMapOfOwner.hxx>
30 #include <AIS_Shape.hxx>
31 #include <AIS_ListOfInteractive.hxx>
44 class ModuleBase_IWorkshop;
46 class MODULEBASE_EXPORT ModuleBase_FilterStarter: public QWidget
50 ModuleBase_FilterStarter(const std::string& theFeature, QWidget* theParent,
51 ModuleBase_IWorkshop* theWorkshop);
53 ~ModuleBase_FilterStarter() {}
56 void onFiltersLaunch();
59 std::string myFeatureName;
60 ModuleBase_IWorkshop* myWorkshop;
67 class ModuleBase_WidgetSelectionFilter;
69 class ModuleBase_FilterItem : public QWidget
73 ModuleBase_FilterItem(const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent);
75 std::string filter() const { return myFilterID; }
78 void deleteItem(ModuleBase_FilterItem* theItem);
79 void reversedItem(ModuleBase_FilterItem* theItem);
82 void onReverse(bool theCheck);
86 void addItemRow(QWidget* theParent);
88 std::string myFilterID;
89 FiltersFeaturePtr mySelection;
90 QToolButton* myRevBtn;
93 class ModuleBase_WidgetSelectionFilter : public ModuleBase_ModelWidget
97 ModuleBase_WidgetSelectionFilter(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
98 const Config_WidgetAPI* theData);
100 ~ModuleBase_WidgetSelectionFilter();
102 /// Returns list of widget controls
103 /// \return a control list
104 virtual QList<QWidget*> getControls() const;
106 /// It is called when user press Ok or OkPlus buttons in the parent property panel
107 /// By default this slot does nothing
108 virtual void onFeatureAccepted();
110 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
112 QWidget* filtersWidget() const { return myFiltersWgt; }
115 /// Saves the internal parameters to the given feature (not ussed for this widget)
116 /// \return True in success
117 virtual bool storeValueCustom() { return true; }
119 /// Restore value from attribute data to the widget's control (not ussed for this widget)
120 virtual bool restoreValueCustom() { return true; }
123 void onAddFilter(int);
124 void onDeleteItem(ModuleBase_FilterItem* theItem);
125 void onReverseItem(ModuleBase_FilterItem* theItem);
127 void onShowOnly(bool theErase);
130 void updateSelectBtn();
131 void updateNumberSelected();
132 void clearCurrentSelection(bool toUpdate = false);
133 void updatePreview(const TopoDS_Shape& theShape);
136 ModuleBase_IWorkshop* myWorkshop;
138 QWidget* myFiltersWgt;
139 QVBoxLayout* myFiltersLayout;
141 QComboBox* myFiltersCombo;
142 QPushButton* mySelectBtn;
144 QCheckBox* myShowBtn;
147 std::list<std::string> myFilters;
148 std::list<std::string> myUseFilters;
150 QList<ModuleBase_ViewerPrsPtr> myValues;
151 Handle(AIS_Shape) myPreview;
153 AIS_ListOfInteractive myListIO;
155 FeaturePtr mySelectorFeature;
156 std::string mySelectorAttribute;