Rumba C++ SDK
ManipulatorPlugin.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Array.h"
18 #include "NodePlugin.h"
19 
20  namespace maquina
21  {
22  class CameraContext;
23  class InteractionContext;
24 
27  {
28  public:
29 
30  enum class Space
31  {
32  world,
33  parent,
34  object,
35  view
36  };
37 
38  enum class Axis
39  {
40  x,
41  y,
42  z,
43  mx,
44  my,
45  mz
46  };
47 
48  ManipulatorPlugin(Node *node) : NodePlugin(node) {}
49 
50  Node controller(const char *ctrl_name) const;
51 
52  static float float_controller(
53  const Imath::V2i& original_pos,
54  const Imath::V2i& pos,
55  int modifiers,
56  float original_value,
57  float slider_min=0.f,
58  float slider_max=1.f,
59  float min=-FLT_MAX,
60  float max=FLT_MAX,
61  float mouse_range = 500.f
62  );
63 
64  static void translate_controller(
65  const std::shared_ptr<maquina::NodeDelegate>& nd,
66  const Imath::V3d& delta_world,
67  const Imath::M44d& initial_matrix,
68  const Imath::M44d& initial_world_matrix,
69  float frame,
70  bool use_current_parent_matrix = false);
71 
72  static Imath::V3d translate_controller(
73  const Imath::V3d& initial_world_position,
74  const Imath::M44d& original_ctrl_matrix,
75  const CameraContext& camera,
76  const Imath::V2i& original_pos,
77  float original_depth,
78  const Imath::V2i& pos,
79  int modifiers,
80  Space space,
81  const char* mode);
82 
83  static Imath::V3d translate_view(
84  const Imath::V3d& initial_world_position,
85  const CameraContext& camera,
86  const Imath::V2i& original_pos,
87  float original_depth,
88  const Imath::V2i& pos,
89  int modifiers);
90 
91  static Imath::V3d translate_plane(
92  const Imath::M44d& original_ctrl_matrix,
93  const CameraContext& camera,
94  const Imath::V2i& original_pos,
95  float original_depth,
96  const Imath::V2i& pos,
97  int modifiers,
98  const Imath::V3d& _plane_normal,
99  Space space);
100 
101  static Imath::V3d translate_axis(
102  const Imath::M44d& original_ctrl_matrix,
103  const CameraContext& camera,
104  const Imath::V2i& original_pos,
105  float original_depth,
106  const Imath::V2i& pos,
107  const Imath::V3d& axis,
108  Space space);
109 
110  static void rotate_controller(const std::shared_ptr<maquina::NodeDelegate>& nd, const Imath::V3d& axis, double angle, Space space,
111  const Imath::M44d& initial_matrix, const Imath::M44d& initial_world_matrix, float frame);
112  static void rotate_gimbal_controller(Node& controller, const Imath::V3d& gimbal, const Imath::V3d& original);
113 
114  static Imath::Quatd rotate_controller(
115  int& lock_axis,
116  int& major_axis,
117  const char*& cursor,
118  const Imath::V3d& initial_world_position,
119  const Imath::M44d& original_ctrl_matrix,
120  const CameraContext& camera,
121  const Imath::V2i& original_pos,
122  float original_depth,
123  const Imath::V2i& pos,
124  int modifiers,
125  int nd_flags,
126  float angle_speed = 0.01f);
127 
128  static const Imath::M44d to_world(Space space, const Imath::M44d& object, const Imath::M44d& world);
129 
130  static const Imath::V3d& axis(Axis axis);
131  static Imath::V3d axis(const Imath::M44d& matrix, Axis axis);
132 
133  static Array rotate_help(const char* rotate_mode);
134  static Array translate_help(const char* rotate_mode);
135 
136  virtual Node default_controller();
147  void add_controller_cache_dependency( const Plug& plug );
148 
154  void remove_controller_cache_dependency( const Plug& plug );
155  virtual void on_mouse_press(const CameraContext& camera, const InteractionContext& interaction);
156 
157  virtual void on_mouse_move(const CameraContext& camera, const InteractionContext& interaction);
158 
159  virtual void on_mouse_release(const CameraContext& camera, const InteractionContext& interaction);
160 
161  virtual std::string get_cursor();
162 
163  virtual Array get_help(const char *tool);
164 
165  virtual Array get_status(const char *tool);
166 
167  std::shared_ptr<maquina::NodeDelegate> node_delegate() const override;
168  };
169  }
Definition: ImathFrame.h:42
Derive this class to create your own Manipulator type.
Definition: ManipulatorPlugin.h:26
Definition: ImathFrame.h:43
Space
Definition: ManipulatorPlugin.h:30
Derive this class to create your own Node type.
Definition: NodePlugin.h:28
This class provides viewport space conversion services.
Definition: CameraContext.h:23
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
Axis
Definition: ManipulatorPlugin.h:38
MAQUINA_EXPORT Node controller(const Plug &plug)
Return the controller associated to a plug.
An array of values.
Definition: Array.h:26
Definition: ImathQuat.h:71
#define MAQUINA_EXPORT
Definition: Export.h:31
A node plug.
Definition: Plug.h:52
Definition: ImathVec.h:61
This interface is passed to the events and is implemented by the application. */. ...
Definition: InteractionContext.h:22
ManipulatorPlugin(Node *node)
Definition: ManipulatorPlugin.h:48
Base class of all Rumba nodes.
Definition: Node.h:36