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
103 /// Activates all not loaded parts
104 void onActivateAllParts();
107 /// Redefinition of virtual method
108 /// \param theObj an object
109 /// \param theEvent an event
110 virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
113 /// Returns true if the current operation is sketch entity create operation
114 /// \param theValue the current auxiliary value
115 /// \return the boolean result
116 bool canSetAuxiliary(bool& theValue) const;
118 /// Changes the sketcher entity construction argument value
119 /// \param isChecked if true, the feature is a construction
120 void setAuxiliary(const bool isChecked);
122 /// Create all actions for context menus. It is called on creation of module
123 /// Put the created actions into an internal map
124 void createActions();
126 /// Add action to the internal map
127 /// \param theId - string ID of the item
128 /// \param theAction - action to add
129 void addAction(const QString& theId, QAction* theAction);
131 /// Set color on presentation of result listed in myCoinsideLines
132 /// \param theId object Id in myCoinsideLines list
133 /// \param theColor a color which has to be set
134 /// \param theUpdate update viewer flag
135 /// \return previously defined color on the object
136 QColor setLineColor(int theId, const QColor theColor, bool theUpdate);
138 /// Reference to a parent module
139 PartSet_Module* myModule;
141 /// the popup menu actions
142 QMap<QString, QAction*> myActions;
144 /// List of lines coincided in a one point
145 mutable QList<FeaturePtr> myCoinsideLines;
147 /// A Coincedence feature selected by user for detaching
148 mutable FeaturePtr mySelectedFeature;
150 /// Id of menu item in Detach menu previously selected
153 /// Original color of highlighted line