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 PartSet_MenuMgr_H
21 #define PartSet_MenuMgr_H
23 #include <ModelAPI_Feature.h>
24 #include <ModelAPI_ResultPart.h>
32 class ModuleBase_Operation;
39 * A class for management of module specific menu
41 class PartSet_MenuMgr: public QObject
46 /// \param theModule a parent module
47 PartSet_MenuMgr(PartSet_Module* theModule);
50 /// Returns action according to the given ID
51 /// \param theId an action identifier, it should be uniqued in the bounds of the module
52 QAction* action(const QString& theId) const;
54 /// Add menu items for viewer into the actions map
55 /// \param theStdActions a map of standard actions
56 /// \param theParent a parent widget for the
57 /// \param theMenuActions map of action/menu for the desirable index in the viewer menu
58 /// \return true if items are added and there is no necessity to provide standard menu
59 bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
61 QMap<int, QAction*>& theMenuActions) const;
63 /// Update state of pop-up menu items in viewer
64 /// \param theStdActions - a map of standard actions
65 void updateViewerMenu(const QMap<QString, QAction*>& theStdActions);
67 /// Activates a PartSet document
68 void activatePartSet() const;
70 /// Returns list of granted operation indices
71 virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
73 /// Activates a Part document
74 void activatePart(ResultPartPtr thePart) const;
77 /// Processes the context menu action click
78 /// \param isChecked a state of toggle if the action is checkable
79 void onAction(bool isChecked);
83 /// A slot which is called on selection of menu item coresponding to line with coincedence
84 /// \param theAction an action of the selected item
85 void onLineHighlighted(QAction* theAction);
87 /// A slot which is called on hiding Detach menu
88 void onDetachMenuHide();
90 /// A slot which is called on selection an Item in Detach menu
91 /// \param theAction an action of the selected item
92 void onLineDetach(QAction* theAction);
94 /// A slot called on Part activation command
95 void onActivatePart(bool);
97 /// A slot called on PartSet activation command
98 void onActivatePartSet(bool);
100 /// A slot called on edit of feature
104 /// Redefinition of virtual method
105 /// \param theObj an object
106 /// \param theEvent an event
107 virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
110 /// Returns true if the current operation is sketch entity create operation
111 /// \param theValue the current auxiliary value
112 /// \return the boolean result
113 bool canSetAuxiliary(bool& theValue) const;
115 /// Changes the sketcher entity construction argument value
116 /// \param isChecked if true, the feature is a construction
117 void setAuxiliary(const bool isChecked);
119 /// Create all actions for context menus. It is called on creation of module
120 /// Put the created actions into an internal map
121 void createActions();
123 /// Add action to the internal map
124 /// \param theId - string ID of the item
125 /// \param theAction - action to add
126 void addAction(const QString& theId, QAction* theAction);
128 /// Set color on presentation of result listed in myCoinsideLines
129 /// \param theId object Id in myCoinsideLines list
130 /// \param theColor a color which has to be set
131 /// \param theUpdate update viewer flag
132 /// \return previously defined color on the object
133 QColor setLineColor(int theId, const QColor theColor, bool theUpdate);
135 /// Reference to a parent module
136 PartSet_Module* myModule;
138 /// the popup menu actions
139 QMap<QString, QAction*> myActions;
141 /// List of lines coincided in a one point
142 mutable QList<FeaturePtr> myCoinsideLines;
144 /// A Coincedence feature selected by user for detaching
145 mutable FeaturePtr mySelectedFeature;
147 /// Id of menu item in Detach menu previously selected
150 /// Original color of highlighted line