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 #include "NodeDelegate.h"
20 
21  namespace maquina
22  {
23  class CameraContext;
24  class InteractionContext;
25 
28  {
29  public:
30 
31  enum class Space
32  {
33  world,
34  parent,
35  object,
36  view
37  };
38 
39  enum class Axis
40  {
41  x,
42  y,
43  z,
44  mx,
45  my,
46  mz
47  };
48 
49  ManipulatorPlugin(Node *node) : NodePlugin(node) {}
50 
52 
53  Node controller(const char *ctrl_name) const;
54 
55  static float float_controller(
56  const Imath::V2i& original_pos,
57  const Imath::V2i& pos,
58  int modifiers,
59  float original_value,
60  float slider_min=0.f,
61  float slider_max=1.f,
62  float min=-FLT_MAX,
63  float max=FLT_MAX,
64  float mouse_range = 500.f
65  );
66 
67  static void translate_controller(
68  const std::shared_ptr<maquina::NodeDelegate>& nd,
69  const Imath::V3d& delta_world,
70  const Imath::M44d& initial_matrix,
71  const Imath::M44d& initial_world_matrix,
72  float frame,
74  bool use_current_parent_matrix = false);
75 
76  static Imath::V3d translate_controller(
77  const Imath::V3d& initial_world_position,
78  const Imath::M44d& original_ctrl_matrix,
79  const CameraContext& camera,
80  const Imath::V2i& original_pos,
81  float original_depth,
82  const Imath::V2i& pos,
83  int modifiers,
84  Space space,
85  const char* mode);
86 
87  static Imath::V3d translate_view(
88  const Imath::V3d& initial_world_position,
89  const CameraContext& camera,
90  const Imath::V2i& original_pos,
91  float original_depth,
92  const Imath::V2i& pos,
93  int modifiers);
94 
95  static Imath::V3d translate_plane(
96  const Imath::M44d& original_ctrl_matrix,
97  const CameraContext& camera,
98  const Imath::V2i& original_pos,
99  float original_depth,
100  const Imath::V2i& pos,
101  int modifiers,
102  const Imath::V3d& _plane_normal,
103  Space space);
104 
105  static Imath::V3d translate_axis(
106  const Imath::M44d& original_ctrl_matrix,
107  const CameraContext& camera,
108  const Imath::V2i& original_pos,
109  float original_depth,
110  const Imath::V2i& pos,
111  const Imath::V3d& axis,
112  Space space);
113 
114  static void rotate_controller(const std::shared_ptr<maquina::NodeDelegate>& nd, const Imath::V3d& axis, double angle, Space space,
115  const Imath::M44d& initial_matrix, const Imath::M44d& initial_world_matrix, float frame, maquina::NodeDelegate::TransformUserData* user_data);
116  static void rotate_gimbal_controller(Node& controller, const Imath::V3d& gimbal, const Imath::V3d& original, const ModificationContext& mc);
117 
118  static Imath::Quatd rotate_controller(
119  int& lock_axis,
120  int& major_axis,
121  const char*& cursor,
122  const Imath::V3d& initial_world_position,
123  const Imath::M44d& original_ctrl_matrix,
124  const CameraContext& camera,
125  const Imath::V2i& original_pos,
126  float original_depth,
127  const Imath::V2i& pos,
128  int modifiers,
129  int nd_flags,
130  float angle_speed = 0.01f);
131 
132  static const Imath::M44d to_world(Space space, const Imath::M44d& object, const Imath::M44d& world);
133 
134  static const Imath::V3d& axis(Axis axis);
135  static Imath::V3d axis(const Imath::M44d& matrix, Axis axis);
136 
137  static Array rotate_help(const char* rotate_mode);
138  static Array translate_help(const char* rotate_mode);
139 
140  virtual Node default_controller();
151  void add_controller_cache_dependency( const Plug& plug );
152 
158  void remove_controller_cache_dependency( const Plug& plug );
159  virtual void on_mouse_press(const CameraContext& camera, const InteractionContext& interaction);
160 
161  virtual void on_mouse_move(const CameraContext& camera, const InteractionContext& interaction);
162 
163  virtual void on_mouse_release(const CameraContext& camera, const InteractionContext& interaction);
164 
165  virtual std::string get_cursor();
166 
167  virtual Array get_help(const char *tool);
168 
169  virtual Array get_status(const char *tool);
170 
171  static float manipulation_frame();
172 
173  std::shared_ptr<maquina::NodeDelegate> node_delegate() const override;
174  };
175  }
The y component of a vector value.
Definition: ImathFrame.h:42
Derive this class to create your own Manipulator type.
Definition: ManipulatorPlugin.h:27
The x component of a vector value.
Definition: ImathFrame.h:43
Space
Definition: ManipulatorPlugin.h:31
A blind data provided by the start_transform&#39;s implementation and passed to set_scale, set_rotation and set_translation.
Definition: NodeDelegate.h:440
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
Definition: ModificationContext.h:21
Axis
Definition: ManipulatorPlugin.h:39
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:59
Definition: ImathVec.h:61
The z component of a vector value.
This interface is passed to the events and is implemented by the application. */. ...
Definition: InteractionContext.h:22
ManipulatorPlugin(Node *node)
Definition: ManipulatorPlugin.h:49
Base class of all Rumba nodes.
Definition: Node.h:37