HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP3D_SelectorSupport.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: OP3D_SelectorSupport.h
7  *
8  * COMMENTS:
9  * OP3D_SelectorSupport is designed to provide a selector framework
10  * for python state hosts. Classes deriving from OP3D_SelectorSupport
11  * provides specific selector implementation e.g. OP3D_GeometrySelectorSupport
12  */
13 
14 #ifndef OP3D_SelectorSupport_h
15 #define OP3D_SelectorSupport_h
16 
17 #include "OP3D_API.h"
18 
19 #include <DM/DM_Defines.h>
20 #include <UI/UI_Object.h>
21 #include <UI/UI_Value.h>
22 #include <PI/PI_PythonState.h>
23 
24 class BM_View;
25 class BM_Viewport;
26 class DM_Workbench;
27 class OP_Node;
28 class op3dValueDelegate;
30 class OP3D_ScriptSelectStateInfoPtr;
31 class UI_Event;
32 class UI_Feel;
33 
35 {
36  public:
38 
39  // Interface typically implemented by python state hosts to interact
40  // with a selector
41  struct Handler
42  {
43  Handler() = default;
44  virtual ~Handler() = default;
45 
46  // returns the node tied to the host handler
47  virtual OP_Node* opNode() = 0;
48 
49  // accessor to the host viewer
50  virtual BM_View& hostView() = 0;
51 
52  // accessor to the host workbench
53  virtual DM_Workbench& hostWorkbench() = 0;
54 
55  // start selector event
56  virtual void onStartSelector() = 0;
57  // stop selector event
58  virtual void onStopSelector() = 0;
59  // host selection processing, returns true to accept the selection and
60  // stop the running selector
61  virtual bool onSelection(UI_Event* ui_event) = 0;
62 
63  // allow the host to display the selector prompt
64  virtual void updateSelectorPrompt() = 0;
65  };
66 
67  OP3D_SelectorSupport(Handler* handler);
68  OP3D_SelectorSupport() = delete;
69  ~OP3D_SelectorSupport() override;
70 
71  void init(PI_PythonState::Info& template_info);
72  void trigger(char const * name, PI_PythonState::SelectorAction action);
73  void onHandlerStart();
74  void updatePrompt();
75 
76  // the selector has been started and ready to use
77  bool started() const;
78  UI_Value& finishedValue();
79 
80  // the selector cannot be used
81  bool useSelector() const;
82 
83  int handleMouseEvent(UI_Event *event);
84  int handleMouseWheelEvent(UI_Event *event);
85  int handleDoubleClickEvent(UI_Event *event);
86  int handleKeyEvent(UI_Event *event, BM_Viewport &viewport);
87  bool handleTransitoryKey(const UI_Event &event);
88  bool handleHotkey(int key);
89  void handleNodeDeleted(OP_Node &node);
90  void doHandleSelection(UI_Event *);
91  OP3D_ScriptSelectStateInfoPtr& selectorInfo();
92  char const * selectorName() const;
93  PI_PythonState::SecureSelectionOption secureSelectionOption() const;
94  bool selectionHandlingStatus() const;
95 
96  // mandatory overridables
97  virtual Selector* selector() = 0;
98  virtual void createSelector() = 0;
99  virtual void termSelector() = 0;
100  virtual void clearSelectorPtr() = 0;
101  virtual int getToolboxCount() const = 0;
102  virtual UI_Feel* getToolbox(int index) const = 0;
103 
104  // optional overridables
105  virtual void handleVolatileSelection()
106  {}
107  virtual void handleExistingSelection()
108  {}
109  virtual bool canHandleExistingSelection() const
110  {
111  return false;
112  }
113 
114  protected:
115  Handler* handler();
116  Handler const* handler() const;
117  void updateToolbox();
118 
119  private:
120  void selectionDelegate(UI_Event* ui_event);
121  void enterKeyDelegate(UI_Event* ui_event);
122  void trigger(
123  PI_PythonState::Info::Selector::Ptr const& selector_info, PI_PythonState::SelectorAction action);
124  void start();
125  void stop();
126 
127  virtual bool handleSelection(UI_Event *) = 0;
128  void handleExistingSelection_internal();
129 
130  bool mySelectionHandlingStatus;
131  bool myStartedStatus;
132  bool myOldSecureSelection;
133  bool myRestoreSecureSelectionFlag;
134  PI_PythonState::SecureSelectionOption mySecureSelection;
135  Handler* myHandler;
136  PI_PythonState::Info::Selector::Ptr mySelectorInfo;
137  PI_PythonState::Info* myTemplateInfo;
138  UT_SharedPtr<op3dValueDelegate> myEnterKeyDelegate;
139  UT_SharedPtr<op3dValueDelegate> myStopSelectorDelegate;
140 };
141 
142 #endif // OP3D_SelectorSupport_h
GLuint const GLchar * name
Definition: glew.h:1814
GLuint index
Definition: glew.h:1814
virtual void handleExistingSelection()
virtual bool canHandleExistingSelection() const
virtual void handleVolatileSelection()
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
GLuint start
Definition: glew.h:1253
cl_event event
Definition: glew.h:3695
#define OP3D_API
Definition: OP3D_API.h:10