Choreonoid  1.8
PositionDragger.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_POSITION_DRAGGER_H
6 #define CNOID_BASE_POSITION_DRAGGER_H
7 
8 #include "SceneWidgetEditable.h"
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class CNOID_EXPORT PositionDragger : public SgPosTransform, public SceneWidgetEditable
14 {
15 public:
16  enum AxisBit {
17  TX = 1 << 0, TY = 1 << 1, TZ = 1 << 2,
18  TranslationAxes = (TX | TY | TZ),
19  RX = 1 << 3, RY = 1 << 4, RZ = 1 << 5,
20  RotationAxes = (RX | RY | RZ),
21  AllAxes = (TX | TY | TZ | RX | RY | RZ),
22 
23  // deprecated
24  TRANSLATION_AXES = TranslationAxes,
25  ROTATION_AXES = RotationAxes,
26  ALL_AXES = AllAxes
27  };
28 
29  enum HandleType {
30  StandardHandle = 0,
31  PositiveOnlyHandle = 1,
32  WideHandle = 2,
33  };
34 
35  PositionDragger(int axes = AllAxes, int handleType = StandardHandle);
36  PositionDragger(const PositionDragger& org) = delete;
37 
39  void setOffset(const Isometry3& T);
40 
41  void setDraggableAxes(int axisBitSet, SgUpdateRef update);
42  int draggableAxes() const;
43  SignalProxy<void(int axisBitSet)> sigDraggableAxesChanged();
44 
45  double handleSize() const;
46  void setHandleSize(double s);
47  void setHandleWidthRatio(double w); // width ratio
48 
49  double rotationHandleSizeRatio() const;
50  void setRotationHandleSizeRatio(double r);
51 
52  [[deprecated("Use setHandleSize and setRotationHandlerSizeRatio")]]
53  void setRadius(double r, double translationAxisRatio = 2.0f);
54  [[deprecated("Use handleSize")]]
55  double radius() const;
56 
57  bool adjustSize();
58  bool adjustSize(const BoundingBox& bb);
59 
60  void setPixelSize(int length, int width);
61 
67  void setScreenFixedSize(double length, double width);
68 
69  bool isScreenFixedSizeMode() const;
70 
71  [[deprecated("Use setFixedPixelSize")]]
72  void setFixedPixelSizeMode(bool on, double pixelSizeRatio = 1.0);
73  [[deprecated("Use isFixedScreenSizeMode")]]
74  bool isFixedPixelSizeMode() const;
75 
76  void setTransparency(float t);
77  float transparency() const;
78 
79  void setOverlayMode(bool on);
80  bool isOverlayMode() const;
81 
82  bool isContainerMode() const;
83  void setContainerMode(bool on);
84 
85  void setContentsDragEnabled(bool on);
86  bool isContentsDragEnabled() const;
87 
88  enum DisplayMode { DisplayAlways, DisplayInEditMode, DisplayInFocus, DisplayNever };
89  DisplayMode displayMode() const;
90  void setDisplayMode(DisplayMode mode, SgUpdateRef update = nullptr);
91 
92  [[deprecated("This function does nothing.")]]
93  void setUndoEnabled(bool on);
94  [[deprecated("This function always returns false.")]]
95  bool isUndoEnabled() const;
96  [[deprecated("This function does nothing.")]]
97  void storeCurrentPositionToHistory();
98 
99  bool isDragEnabled() const;
100  void setDragEnabled(bool on);
101  bool isDragging() const;
102 
103  [[deprecated("Use globalDraggingPosition to get the global coordinate, or "
104  "draggingPosition to get the local position in the parent node coordinate.")]]
105  Isometry3 draggedPosition() const { return globalDraggingPosition(); }
106 
107  Isometry3 draggingPosition() const;
108  Isometry3 globalDraggingPosition() const;
109 
110  SignalProxy<void()> sigDragStarted();
111  SignalProxy<void()> sigPositionDragged();
112  SignalProxy<void()> sigDragFinished();
113 
114  virtual void onSceneModeChanged(SceneWidgetEvent* event) override;
115  virtual bool onButtonPressEvent(SceneWidgetEvent* event) override;
116  virtual bool onButtonReleaseEvent(SceneWidgetEvent* event) override;
117  virtual bool onPointerMoveEvent(SceneWidgetEvent* event) override;
118  virtual void onPointerLeaveEvent(SceneWidgetEvent* event) override;
119  virtual void onFocusChanged(SceneWidgetEvent* event, bool on) override;
120 
121  // Thw following functions are deprecated. Use displayMode and setDisplayMode instead.
122  [[deprecated("Use setDisplayMode.")]]
123  void setDraggerAlwaysShown(bool on, SgUpdateRef update);
124  [[deprecated("Use displayMode.")]]
125  bool isDraggerAlwaysShown() const;
126  [[deprecated("Use setDisplayMode.")]]
127  void setDraggerAlwaysHidden(bool on, SgUpdateRef update);
128  [[deprecated("Use displayMode.")]]
129  bool isDraggerAlwaysHidden() const;
130 
131  class Impl;
132 
133 private:
134  Impl* impl;
135 };
136 
138 
139 }
140 
141 #endif
cnoid::SgPosTransform
Definition: SceneGraph.h:357
cnoid::PositionDragger::DisplayMode
DisplayMode
Definition: PositionDragger.h:88
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::PositionDraggerPtr
ref_ptr< PositionDragger > PositionDraggerPtr
Definition: PositionDragger.h:137
cnoid::SgUpdateRef
Definition: SceneUpdate.h:73
cnoid::PositionDragger::draggedPosition
Isometry3 draggedPosition() const
Definition: PositionDragger.h:105
cnoid::ref_ptr< PositionDragger >
cnoid::PositionDragger::HandleType
HandleType
Definition: PositionDragger.h:29
cnoid::SceneWidgetEvent
Definition: SceneWidgetEvent.h:15
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::PositionDragger
Definition: PositionDragger.h:13
cnoid::SignalProxy
Definition: Signal.h:470
SceneWidgetEditable.h
cnoid::PositionDragger::AxisBit
AxisBit
Definition: PositionDragger.h:16
cnoid::SceneWidgetEditable
Definition: SceneWidgetEditable.h:16
cnoid::BoundingBox
Definition: BoundingBox.h:17