1 // Copyright (C) 2014-2024 CEA, EDF
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 XGUI_FacesPanel_H_
21 #define XGUI_FacesPanel_H_
25 #include <ModuleBase_ActionType.h>
26 #include <ModuleBase_Definitions.h>
27 #include <ModuleBase_ViewerPrs.h>
28 #include <ModuleBase_ResultPrs.h>
30 #include <ModelAPI_Object.h>
31 #include <ModelAPI_Feature.h>
33 #include <GeomAPI_AISObject.h>
35 #include <SelectMgr_ListOfFilter.hxx>
36 #include <TopoDS_Shape.hxx>
38 #include <QDockWidget>
44 class AIS_InteractiveObject;
46 class GeomAPI_AISObject;
49 class ModuleBase_ListView;
57 * A Hide Faces panel for making it possible to hide faces in the 3D view.
58 * The panel has multi-selector filled by faces elements. When the control is active
59 * it is possible to select faces in the viewer. The selected faces are hidden/transparent
60 * after selection and the corresponding item is appeared in the multi selector.
62 * In order to redisplay a face, it is enough to click delete on the name of this face
63 * in the multiselector.
64 * When the panel is opened, the multiselector is empty.
65 * When the panel is closed, the multiselector is emptied and the faces are displayed again.
66 * The default position by of this dockable window is to the right of the view (in SALOME mode).
67 * If no feature is processed (in neutral point), this panel can be activated too.
68 * On feature edition start or finish, movement of the history line, undo/redo and other
69 * modification of the model, the multiselector is emptied.
71 class XGUI_EXPORT XGUI_FacesPanel : public QDockWidget
76 /// \param theParent is a parent of the property panel
77 XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop);
80 /// Clear content of list widget
81 /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
82 virtual void reset(const bool isToFlushRedisplay);
84 /// Returns whether faces panel contains elements
85 /// \return boolean value
88 /// Fills container with the panel selection mode: FACE
89 // \param theModes [out] a container of modes
90 void selectionModes(QIntList& theModes);
92 /// Appends into container of workshop selection filters
93 /// \param [out] selection filters
94 void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
96 /// Returns whether the panel is active or not
97 bool isActivePanel() const { return myIsActive; }
99 /// Stores the state if panel is active and highlight the panel in an active color
100 /// \param theIsActive state whether the panel should be activated or deactivated
101 void setActivePanel(const bool theIsActive);
103 /// Returns true if the object is in internal container of hidden objects by this panel
104 /// \param theObject a checked object
105 /// \return boolean value
106 bool isObjectHiddenByPanel(const ObjectPtr& theObject) const
107 { return myHiddenObjects.find(theObject) != myHiddenObjects.end(); }
109 /// Removed faces of the objects from the panel
110 /// \param container of objects
111 void restoreObjects(const std::set<ObjectPtr >& theHiddenObjects);
113 /// Returns true if the event is processed. The default implementation is empty, returns false.
114 virtual bool processAction(ModuleBase_ActionType theActionType);
116 /// Append selected item in the list and customize presentations to hide faces
117 void processSelection();
119 /// Deletes item in a list of elements
120 /// \return whether the delete action is processed
121 bool processDelete();
123 /// Delete last(s) item(s) added since the recent activation of the faces panel
126 /// Processing focus in/out for the faces control
127 /// \param theObject source object of event
128 /// \param theEvent an event
129 virtual bool eventFilter(QObject* theObject, QEvent *theEvent);
131 XGUI_Workshop* workshop() const { return myWorkshop; }
134 /// Slot called on an object erase
135 void onObjectDisplay(ObjectPtr theObject, AISObjectPtr theAIS);
138 /// Reimplementation to emit a signal about the panel close
139 virtual void closeEvent(QCloseEvent* theEvent);
142 /// Signal about activating pane
144 /// Signal about deactivating pane
146 /// Signal is emitted by the top widget cross button click
150 /// Redisplay objects.
151 /// \param theObjects container of objects
152 /// \return true if some of objects was redisplayed
153 static bool redisplayObjects(const std::set<ObjectPtr>& theObjects);
155 /// Container of objects participating in the panel, it is filled by internal container
156 /// \param theItems container of selected values
157 /// \param theObjects [out] container of objects
158 static void updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr> theItems,
159 std::set<ObjectPtr>& theObjects);
161 /// Returns true if transparency choice is checked
162 /// \return boolean value
163 bool useTransparency() const;
165 double transparency() const;
167 void removeItems(std::set<int> theIds);
170 /// Deletes element in list of items
173 /// Upates hidden faces to be hidden or transparent
174 void onTransparencyChanged();
176 /// Closes faces panel restore all hidden faces by calling reset()
179 /// Flushes redisplay event and perform update of object browser icons
180 /// (objects might be hidden/shown)
181 void flushRedisplay() const;
185 QCheckBox* myHiddenOrTransparent; ///< if checked - transparent, else hidden
186 ModuleBase_ListView* myListView; ///< list control of processed faces
187 XGUI_Workshop* myWorkshop; ///< workshop
189 bool myIsActive; ///< current state about the panel is active
190 int myLastItemIndex; ///< last index to be used in the map of items for the next added item
191 std::vector<int> myUndoList; ///< indexes of items for undo
193 QMap<int, ModuleBase_ViewerPrsPtr> myItems; ///< selected face items
194 std::set<ObjectPtr > myItemObjects; ///< cached objects of myItems
195 std::set<ObjectPtr > myHiddenObjects; ///< hidden objects