33#include <NDEVR/SnapPoint.h>
34#include <NDEVR/MouseController.h>
36#include <NDEVR/KeyController.h>
37#include <NDEVR/SelectionArea.h>
38#include <NDEVR/Plane.h>
43 class DesignObjectLookup;
44 class NDEVR_DESIGN_API SnapController :
public MouseControllerBase,
public KeyControllerBase
58 , e_lock_to_nearest_snap
64 explicit SnapController(DesignObjectLookup* manager);
65 virtual ~SnapController(){}
66 virtual void cancel();
68 virtual bool processMouseEvent(
const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera)
override;
69 virtual bool processKeyEvent(
const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera)
override;
71 void clearSnapSelection();
72 uint04 pointCount()
const {
return m_points.size(); }
73 virtual void setUpdateCallback(
const std::function<
void()>& callback) { m_update_callback = callback; }
74 virtual void setFinishedCallback(
const std::function<
void(
bool is_accepted)>& callback) { m_finished_callback = callback; }
75 void lockAxis(uint01 axis, fltp08 lock) { m_lock_axis[axis] = lock; }
76 SelectionMode selectionMode()
const {
return m_selection_mode; }
77 void setSelectionMode(SelectionMode mode) { m_selection_mode = mode; }
78 Vertex<3, fltp08> currentLocation()
const {
return m_location; }
79 void setLockMode(LockMode mode);
80 void setLockLine(
const LineSegment<3, fltp08>& line);
81 void setLockPlane(
const Plane<3, fltp08>& plane);
82 void setCustomSnapManager(
const ConstPointer<SnapsManager>& snap_manager) { m_custom_snap_manager = snap_manager; };
83 void setLocation(
const Vertex<3, fltp08>& location,
bool is_click =
false, Camera* camera =
nullptr);
84 void setShowLengthLabels(
bool show);
85 void setShowPointLabels(
bool show);
87 void setPointsDrawMode(PointsDrawMode mode) { m_point_draw_mode = mode; }
88 const Buffer<Vertex<3, fltp08>>& points()
const {
return m_points; }
89 Vertex<3, fltp08> lastPoint()
const {
return m_location; }
90 const Buffer<SnapPoint>& lastSnapPoints()
const {
return m_last_snap_points; }
92 Resource<SnapPoint> current_snap_point;
94 virtual void addPoint(
const Vertex<3, fltp08>& point);
95 virtual void addPoint(
const SnapPoint& point);
97 virtual void finish();
98 virtual void updateLocation(
const Vertex<3, fltp08>& location,
bool is_click, Camera* camera);
99 SelectionInfo getSelectionInfo(
const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera);
100 void addGuideLineModel();
101 void addGuidePointModel();
102 bool processMouseSnap(
const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera);
103 bool processMouseSelection(
const MouseEvent& event, DesignObjectLookup* lookup, Camera* camera);
104 void setGuidePoint(uint04 index,
const Vertex<3, fltp08>& p1,
const UUID& material);
105 void setGuideLine(uint04 index,
const Vertex<3, fltp08>& p1,
const Vector<3, fltp08>& p2,
const UUID& material);
106 void calcLockLineLocation(SnapPoint& point,
const SelectionInfo& info);
107 void calcLockPlaneLocation(SnapPoint& point,
const SelectionInfo& info);
108 void setGuideLineVisible(
bool visible);
109 void setGuideLineVisible(uint04 index,
bool visible);
110 void setGuidePointVisible(
bool visible);
111 void setGuidePointVisible(uint04 index,
bool visible);
112 void drawDefaultGuideLines(
const SnapPoint& point);
113 Model setupGuideModel();
114 void updateRecentGeometry(
const SnapPoint& point);
115 virtual SelectionInfo createSelectionInfo(
const MouseEvent& event, Camera* camera);
116 SnapPoint calcSnapPoint(
const SelectionInfo& info, DesignObjectLookup* lookup);
117 UUID pointMaterial(
const SnapPoint& point);
118 UUID lineMaterial(
const SnapPoint& point);
120 Buffer<Vertex<3, fltp08>> m_points;
121 Vertex<3, fltp08> m_location;
122 Vertex<3, fltp08> m_lock_axis;
123 LineSegment<3, fltp08> m_lock_line;
124 Plane<3, fltp08> m_lock_plane;
126 SnapPoint m_original_snap;
127 UUID m_current_line_material = Constant<UUID>::NaN;
129 UUID m_free_point_material = Constant<UUID>::NaN;
130 UUID m_point_material = Constant<UUID>::NaN;
131 UUID m_edge_point_material = Constant<UUID>::NaN;
132 UUID m_end_point_material = Constant<UUID>::NaN;
133 UUID m_mid_point_material = Constant<UUID>::NaN;
134 UUID m_center_point_material = Constant<UUID>::NaN;
135 UUID m_on_face_point_material = Constant<UUID>::NaN;
137 UUID m_free_line_material = Constant<UUID>::NaN;
138 UUID m_locked_line_material = Constant<UUID>::NaN;
139 UUID m_extend_line_material = Constant<UUID>::NaN;
140 UUID m_perpendicular_line_material = Constant<UUID>::NaN;
141 UUID m_tangent_line_material = Constant<UUID>::NaN;
142 UUID m_red_line_material = Constant<UUID>::NaN;
143 UUID m_green_line_material = Constant<UUID>::NaN;
144 UUID m_blue_line_material = Constant<UUID>::NaN;
146 UUID m_last_selection_camera= Constant<UUID>::NaN;
148 UUID m_guide_model = Constant<UUID>::NaN;
149 UUID m_line_mesh = Constant<UUID>::NaN;
150 UUID m_point_mesh = Constant<UUID>::NaN;
151 Buffer<UUID> m_guide_line_model;
152 Buffer<UUID> m_guide_point_model;
154 Buffer<UUID> m_line_guide_text;
155 Buffer<UUID> m_point_guide_text;
157 Buffer<UUID> m_guide_line_material;
158 Buffer<UUID> m_guide_point_material;
160 Buffer<std::pair<UUID, uint04>> m_last_lines;
161 Buffer<std::pair<UUID, uint04>> m_last_meshes;
162 Buffer<std::pair<UUID, uint04>> m_last_points;
163 ConstPointer<SnapsManager> m_custom_snap_manager;
164 PointsDrawMode m_point_draw_mode;
165 std::function<void()> m_update_callback;
166 std::function<void(
bool is_accepted)> m_finished_callback;
167 DesignObjectLookup* m_manager;
169 Buffer<SnapPoint> m_last_snap_points;
170 LockMode m_lock_mode;
172 bool m_show_length_label;
173 bool m_show_location_label;
SelectionMode
Definition SelectionArea.hpp:43
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120