OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ModuleFeedbackManager.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef MODULE_FEEDBACK_MANAGER_H_
9 #define MODULE_FEEDBACK_MANAGER_H_
10 
11 #include <util/coTypes.h>
12 
13 #include <string>
14 
15 #include <cover/ui/Owner.h>
16 namespace opencover {
17 namespace ui {
18 class Menu;
19 class Action;
20 class Button;
21 }
22 }
23 
24 class cp3dplane;
25 
26 namespace opencover
27 {
28 class RenderObject;
29 class ColorBar;
30 class coInteractor;
31 }
32 
33 #include <osg/Node>
34 #include <osg/Geode>
35 #include <osg/MatrixTransform>
36 
37 // this class manages the interaction (menu and execution)
38 // of a module (but not the icon)
39 
40 namespace opencover
41 {
42 
43 class PLUGIN_UTILEXPORT ModuleFeedbackManager
44  : public ui::Owner
45 {
46 public:
47  ModuleFeedbackManager(const opencover::RenderObject *, opencover::coInteractor *, const char *pluginName);
48  ModuleFeedbackManager(const RenderObject *, const RenderObject *, const char *pluginName);
49  virtual ~ModuleFeedbackManager();
50 
51  // returns true if inter comes from the same module: used in
52  // ModuleFeedbackPlugin::add for adding or updating an entry in
53  // ModuleFeedbackPlugin::_ComplexModuleList
54  bool compare(coInteractor *inter);
55  // returns true if name is an object name from the same module:
56  // used in ModuleFeedbackPlugin::remove for deleting an entry
57  // in ModuleFeedbackPlugin::_ComplexModuleList
58  bool compare(const char *name);
59  // returns true if this moduelFeedbackManager is for the same plugin
60  bool comparePlugin(const char *pluginName);
61 
62  // called for menu update when a new object is received
63  virtual void update(const RenderObject *container, coInteractor *);
64  virtual void update(const RenderObject *container, const RenderObject *);
65 
66  // empty implementation
67  virtual void preFrame();
68 
69  // empty implementation of 3DTex functionality
70  virtual void update3DTex(std::string, cp3dplane *, const char *cmName);
71 
72  std::string ModuleName(const char *) const;
73  std::string ModuleName()
74  {
75  return moduleName_;
76  };
77 
78  // set checkbox and and hide geometry
79  void setHideFromGui(bool);
80 
81  // set the case name and put item into this menu
82  void setCaseFromGui(const char *casename);
83 
84  // set the a new name
85  void setNameFromGui(const char *casename);
86 
87  // show/hide geometry
88  virtual void hideGeometry(bool);
89 
90  //Transform geometry
91  void setMatrix(float *row0, float *row1, float *row2, float *row3);
92 
93  //Transform geometry
94  void addNodeToCase(osg::Node *node);
95 
96  //enable feed back to Colors module
97  void addColorbarInteractor(coInteractor *i);
98 
99  // do hide button functionality
100  virtual void triggerHide(bool state);
101 
103  {
104  return inter_;
105  }
106  bool getSyncState();
107 
108 protected:
109  // helper for constructor
110  void createMenu();
111  void registerObjAtUi(std::string name);
112 
113  // helper for update
114  void updateMenuNames();
115  void updateColorBar(const RenderObject *container);
116 
117  // gets either from attribute OBJECTNAME or from the module name
118  // a suggestion for the menu name, the result is kept in _menuName
119  //std::string suggestMenuName();
120  std::string getMenuName() const;
121 
122  ui::Menu *menu_ = nullptr; // the menu for the interaction of the module managed by the instance of this class
123  ui::Button *hideCheckbox_ = nullptr; // hide geometry
124  ui::Button *syncCheckbox_ = nullptr; // sync interaction
125  ui::Action *newButton_ = nullptr; // copy this module
126  ui::Action *deleteButton_ = nullptr; // delete this module
127  ui::Button *executeCheckbox_ = nullptr; // execute module button
128  //ui::coSubMenuItem *colorsButton_; // open colorbar
129  opencover::coInteractor *inter_ = nullptr; // the last interaction got from the module at issue
130  bool inExecute_; // switch checkbox off when new object arrived
131  std::string menuName_; // name associated to _menuItem: its updated when a new object is received
132 
133  // Overload this function if you want to do anything before an EXEC
134  // call is sent to a module. Always call it before doing an EXEC call!
136 
137  // search the corresponding node in sg
138  osg::Node *findMyNode();
139  std::vector<osg::Geode *> findMyGeode();
140 
141  std::string geomObjectName_;
142  std::string containerObjectName_;
143  std::string attrObjectName_;
144  std::string attrPartName_;
145 
146  std::string initialObjectName_; //we have to save it for the grmsg, because _inter is not always valid
147  osg::ref_ptr<osg::MatrixTransform> geometryCaseDCS_;
148 
149 private:
150  // it is used in ModuleFeedbackManager::compare(const char *name)
151  std::string moduleName_;
152 
153  std::string pName_;
154 
155  ui::Menu *coviseMenu_ = nullptr;
156  ui::Menu *parentMenu_ = nullptr;
157  ui::Menu *caseMenu_ = nullptr;
158  std::string caseName_;
159 
160  std::string visItemName_; //"Tracer_1..."
161  std::string visMenuName_; // "Tracer_1"
162  void sendHideMsg(bool);
163  std::vector<osg::Geode *> findRecMyGeode(osg::Node *node);
164  osg::ref_ptr<osg::Node> myNode_;
165  osg::ref_ptr<osg::Group> myNodesParent_;
166 };
167 }
168 #endif
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:146
abstract feedback class for interacting with parameters of visualization modules (e.g. COVISE or Vistle)
Definition: coInteractor.h:36
std::string attrPartName_
Definition: ModuleFeedbackManager.h:144
osg::ref_ptr< osg::MatrixTransform > geometryCaseDCS_
Definition: ModuleFeedbackManager.h:147
std::string initialObjectName_
Definition: ModuleFeedbackManager.h:146
std::string attrObjectName_
Definition: ModuleFeedbackManager.h:143
bool inExecute_
Definition: ModuleFeedbackManager.h:130
std::string containerObjectName_
Definition: ModuleFeedbackManager.h:142
opencover::coInteractor * getInteractor()
Definition: ModuleFeedbackManager.h:102
std::string ModuleName()
Definition: ModuleFeedbackManager.h:73
Definition: ModuleFeedbackManager.h:43
virtual void preExecCB(opencover::coInteractor *)
Definition: ModuleFeedbackManager.h:135
std::string menuName_
Definition: ModuleFeedbackManager.h:131
std::string geomObjectName_
Definition: ModuleFeedbackManager.h:141