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 
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class CNOID_EXPORT PositionDragger : public SgPosTransform, public SceneWidgetEventHandler
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  PositiveOnlyHandle = 0,
31  SymmetricHandle = 1,
32  WideHandle = 2,
33  StandardHandle = PositiveOnlyHandle,
34  };
35 
36  PositionDragger(int axes = AllAxes, int handleType = StandardHandle);
37  PositionDragger(const PositionDragger& org) = delete;
38 
40  void setOffset(const Isometry3& T);
41 
42  void setDraggableAxes(int axisBitSet, SgUpdateRef update);
43  int draggableAxes() const;
44  SignalProxy<void(int axisBitSet)> sigDraggableAxesChanged();
45 
46  double handleSize() const;
47  void setHandleSize(double s);
48  void setHandleWidthRatio(double w); // width ratio
49 
50  double rotationHandleSizeRatio() const;
51  void setRotationHandleSizeRatio(double r);
52 
53  [[deprecated("Use setHandleSize and setRotationHandlerSizeRatio")]]
54  void setRadius(double r, double translationAxisRatio = 2.0f);
55  [[deprecated("Use handleSize")]]
56  double radius() const;
57 
58  bool adjustSize();
59  bool adjustSize(const BoundingBox& bb);
60 
61  void setPixelSize(int length, int width);
62 
68  //void setScreenFixedSize(double length, double width);
69 
70  bool isScreenFixedSizeMode() const;
71 
73  [[deprecated("Use setPixelSize")]]
74  void setFixedPixelSizeMode(bool on, double pixelSizeRatio = 1.0);
75 
77  [[deprecated("Use isScreenFixedSizeMode")]]
78  bool isFixedPixelSizeMode() const;
79 
80  void setTransparency(float t);
81  float transparency() const;
82 
83  void setOverlayMode(bool on);
84  bool isOverlayMode() const;
85 
86  bool isContainerMode() const;
87  void setContainerMode(bool on);
88 
89  void setContentsDragEnabled(bool on);
90  bool isContentsDragEnabled() const;
91 
92  enum DisplayMode { DisplayAlways, DisplayInEditMode, DisplayInFocus, DisplayNever };
93  DisplayMode displayMode() const;
94  void setDisplayMode(DisplayMode mode, SgUpdateRef update = nullptr);
95 
97  [[deprecated("This function does nothing.")]]
98  void setUndoEnabled(bool on);
100  [[deprecated("This function always returns false.")]]
101  bool isUndoEnabled() const;
103  [[deprecated("This function does nothing.")]]
104  void storeCurrentPositionToHistory();
105 
106  bool isDragEnabled() const;
107  void setDragEnabled(bool on);
108  bool isDragging() const;
109 
111  [[deprecated("Use globalDraggingPosition to get the global coordinate, or "
112  "draggingPosition to get the local position in the parent node coordinate.")]]
113  Isometry3 draggedPosition() const { return globalDraggingPosition(); }
114 
115  Isometry3 draggingPosition() const;
116  Isometry3 globalDraggingPosition() const;
117 
118  SignalProxy<void()> sigDragStarted();
119  SignalProxy<void()> sigPositionDragged();
120  SignalProxy<void()> sigDragFinished();
121 
122  virtual void onSceneModeChanged(SceneWidgetEvent* event) override;
123  virtual bool onButtonPressEvent(SceneWidgetEvent* event) override;
124  virtual bool onButtonReleaseEvent(SceneWidgetEvent* event) override;
125  virtual bool onPointerMoveEvent(SceneWidgetEvent* event) override;
126  virtual void onPointerLeaveEvent(SceneWidgetEvent* event) override;
127  virtual void onFocusChanged(SceneWidgetEvent* event, bool on) override;
128 
130  [[deprecated("Use setDisplayMode.")]]
131  void setDraggerAlwaysShown(bool on, SgUpdateRef update);
133  [[deprecated("Use displayMode.")]]
134  bool isDraggerAlwaysShown() const;
136  [[deprecated("Use setDisplayMode.")]]
137  void setDraggerAlwaysHidden(bool on, SgUpdateRef update);
139  [[deprecated("Use displayMode.")]]
140  bool isDraggerAlwaysHidden() const;
141 
142  class Impl;
143 
144 private:
145  Impl* impl;
146 };
147 
149 
150 }
151 
152 #endif
cnoid::SgPosTransform
Definition: SceneGraph.h:357
cnoid::PositionDragger::DisplayMode
DisplayMode
Definition: PositionDragger.h:92
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::PositionDraggerPtr
ref_ptr< PositionDragger > PositionDraggerPtr
Definition: PositionDragger.h:148
cnoid::SgUpdateRef
Definition: SceneUpdate.h:73
cnoid::PositionDragger::draggedPosition
Isometry3 draggedPosition() const
Definition: PositionDragger.h:113
cnoid::ref_ptr< PositionDragger >
cnoid::SceneWidgetEventHandler
Definition: SceneWidgetEventHandler.h:15
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
SceneWidgetEventHandler.h
cnoid::PositionDragger::AxisBit
AxisBit
Definition: PositionDragger.h:16
cnoid::BoundingBox
Definition: BoundingBox.h:17