Choreonoid  1.8
ScenePointSelectionMode.h
Go to the documentation of this file.
1 #ifndef CNOID_BASE_SCENE_POINT_SELECTION_MODE_H
2 #define CNOID_BASE_SCENE_POINT_SELECTION_MODE_H
3 
5 #include <cnoid/EigenTypes>
6 #include <cnoid/Signal>
7 #include <vector>
8 #include <memory>
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
14 {
15  class Impl;
16 
17 public:
20  virtual ~ScenePointSelectionMode();
21 
22  void setCustomModeId(int id);
23 
24  class PointInfo : public Referenced
25  {
26  public:
27  PointInfo();
28 
29  bool operator==(const PointInfo& rhs) const = delete;
30  bool hasSameVertexWith(const PointInfo& point) const;
31 
32  const SgNodePath& path() const { return *path_; }
33 
38  int vertexIndex() const { return vertexIndex_; }
39 
40  int triangleVertexIndex() const { return triangleVertexIndex_; }
41 
42  const Vector3f& position() const { return position_; }
43  const Vector3f& normal() const { return normal_; }
44  bool hasNormal() const { return hasNormal_; }
45 
46  private:
47  std::shared_ptr<SgNodePath> path_;
48  int vertexIndex_;
49  int triangleVertexIndex_;
50  Vector3f position_;
51  Vector3f normal_;
52  bool hasNormal_;
53 
54  friend class ScenePointSelectionMode::Impl;
55  };
56 
58 
59  PointInfo* highlightedPoint();
60 
61  const std::vector<PointInfoPtr>& selectedPoints() const;
62  void clearSelection();
63 
64  SignalProxy<void(const std::vector<PointInfoPtr>& points)> sigPointSelectionAdded();
65 
66 protected:
67  virtual std::vector<SgNode*> getTargetSceneNodes(SceneWidgetEvent* event);
68 
69  //virtual void onSelectionModeActivated(SceneWidgetEvent* event);
70  //virtual void onSelectionModeDeactivated(SceneWidgetEvent* event);
71 
72  // SceneWidgetEventHandler functions
73  virtual void onSceneModeChanged(SceneWidgetEvent* event) override;
74  virtual bool onButtonPressEvent(SceneWidgetEvent* event) override;
75  virtual bool onButtonReleaseEvent(SceneWidgetEvent* event) override;
76  virtual bool onDoubleClickEvent(SceneWidgetEvent* event) override;
77  virtual bool onPointerMoveEvent(SceneWidgetEvent* event) override;
78  virtual void onPointerLeaveEvent(SceneWidgetEvent* event) override;
79  virtual bool onKeyPressEvent(SceneWidgetEvent* event) override;
80  virtual bool onKeyReleaseEvent(SceneWidgetEvent* event) override;
81  virtual bool onContextMenuRequest(SceneWidgetEvent* event, MenuManager* menu) override;
82 
83 private:
84  Impl* impl;
85 };
86 
87 }
88 
89 #endif
cnoid::ScenePointSelectionMode::PointInfo
Definition: ScenePointSelectionMode.h:24
cnoid::ScenePointSelectionMode
Definition: ScenePointSelectionMode.h:13
cnoid::ScenePointSelectionMode::PointInfo::triangleVertexIndex
int triangleVertexIndex() const
Definition: ScenePointSelectionMode.h:40
cnoid::ScenePointSelectionMode::PointInfo::position
const Vector3f & position() const
Definition: ScenePointSelectionMode.h:42
cnoid::MenuManager
Definition: MenuManager.h:14
cnoid::ScenePointSelectionMode::PointInfo::hasNormal
bool hasNormal() const
Definition: ScenePointSelectionMode.h:44
cnoid::ScenePointSelectionMode::PointInfo::path
const SgNodePath & path() const
Definition: ScenePointSelectionMode.h:32
cnoid::ref_ptr< PointInfo >
cnoid::SceneWidgetEventHandler
Definition: SceneWidgetEventHandler.h:15
cnoid::SceneWidgetEvent
Definition: SceneWidgetEvent.h:15
cnoid::ScenePointSelectionMode::PointInfoPtr
ref_ptr< PointInfo > PointInfoPtr
Definition: ScenePointSelectionMode.h:57
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ScenePointSelectionMode::PointInfo::normal
const Vector3f & normal() const
Definition: ScenePointSelectionMode.h:43
cnoid::operator==
bool operator==(ref_ptr< T > const &a, ref_ptr< U > const &b)
Definition: Referenced.h:211
cnoid::ScenePointSelectionMode::PointInfo::vertexIndex
int vertexIndex() const
Definition: ScenePointSelectionMode.h:38
cnoid::Referenced
Definition: Referenced.h:54
cnoid::SgNodePath
std::vector< SgNode * > SgNodePath
Definition: SceneGraph.h:24
cnoid::SignalProxy
Definition: Signal.h:470
SceneWidgetEventHandler.h