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