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