API Documentation
Loading...
Searching...
No Matches
ModelEditController.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: ModelEditController
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/SnapController.h>
34#if NDEVR_VIEWPORT
35#include <NDEVR/CommandLockObject.h>
36#include <NDEVR/SelectionController.h>
37
38namespace NDEVR
39{
40 class ModelEditController;
41 /**--------------------------------------------------------------------------------------------------
42 \brief A Model function allows a user to interact with the program to perform a task on models.
43 *-----------------------------------------------------------------------------------------------**/
44 class NDEVR_DESIGN_API ModelFunction
45 {
46 friend class ModelEditController;
47 public:
48 TranslatedString name;
49 String icon;
50 UUID id;
51 virtual ~ModelFunction(){};
52 virtual TranslatedString group() const;
53 virtual TranslatedString hint() const { return TranslatedString(); };
54 virtual TranslatedString expandedHint() const { return TranslatedString(); };
55 virtual bool selectionModeAllowed(const SubSelectionMode& mode) const = 0;
56 virtual bool processMouseEvent(const MouseEvent&, DesignObjectLookup*, Camera*) { return false; }
57 virtual bool processKeyEvent(const KeyEvent&, DesignObjectLookup*, Camera*) { return false; }
58 virtual void refreshState(ModelEditController& controller) = 0;
59 virtual bool canAutoFinishNow() const { return false; };
60 virtual SubSelectionMode defaultSelectionMode() const = 0;
61 virtual void setupFilters(SelectionController*) {}
62 virtual void onSelect(const Buffer<UUID>&) {}
63 virtual bool isSelecting() const = 0;
64 virtual void onCancel() = 0;
65 virtual void requestCancel();
66 virtual void requestFinish();
67 virtual bool shouldShowInterface() const { return false; }
68 virtual void requestFinishSelection();
69 protected:
70
71 virtual void setController(ModelEditController* controller);
72 ModelEditController* m_controller = nullptr;
73 };
74 /**--------------------------------------------------------------------------------------------------
75 \brief Takes user input in order to modify a model in real-time.
76 *-----------------------------------------------------------------------------------------------**/
77 class NDEVR_DESIGN_API ModelEditController : public SnapController
78 {
79 public:
80 enum ModelEditMode : uint04
81 {
82 e_no_edit
83 , e_center_locked_scale
84 , e_center_scale
85 , e_two_point_locked_scale
86 , e_two_point_scale
87 , e_two_length_scale
88 , e_offset
89 , e_vertex_offset
90 , e_rotate
91 , e_place
92
93 , e_flip_left
94 , e_flip_front
95 , e_flip_vertical
96
97 , e_set_real_thickness
98
99 , e_rubber_stamp
100 , e_erase
101
102 , e_add_selection_mask
103 , e_edit_mode_size
104 , e_model_function
105 };
106
107
108 ModelEditController(DesignObjectLookup* manager);
109 ModelEditController(const ModelEditController&) = delete;
110 virtual ~ModelEditController(){};
111 virtual void begin() override;
112 virtual void finish() override;
113 virtual void cancel() override;
114 bool hasCommandLock() const { return m_command_lock.isLocked(); }
115 const UUID& material() const { return m_paint_material; }
116 const UUID& pasteModel() const { return m_paste_model; }
117 const UUID& activeModel() const { return m_current_model; }
118 UUID activeModelFunction() const;
119 void setPasteModel(UUID model);
120 void setActiveModel(UUID model);
121 void addEditFunction(const DynamicPointer<ModelFunction>& function);
122 void setActiveEditFunction(const UUID& function);
123 const Dictionary<UUID, DynamicPointer<ModelFunction>>& editFunctions() const { return m_edit_functions; };
124 void setActiveVertex(const Matrix<fltp08>& complete_transform, UUID geometry, uint04 vertex_id);
125 void refreshState();
126 void addPoint(const Vertex<3, fltp08>& point) override;
127 virtual void updateLocation(const Vertex<3, fltp08>& location, bool is_select = false, Camera* camera = nullptr) override;
128 bool selectionModeAllowed(const SubSelectionMode& mode) const;
129 bool shouldShowInterface() const;
130 TranslatedString title() const;
131 TranslatedString hint() const;
132 TranslatedString expandedHint() const;
133 SubSelectionMode defaultSelectionMode() const;
134 Resource<BitFlag> grip_mode;
135 Resource<ModelEditMode> edit_mode;
136 Buffer<UUID> editedModels() { return m_edited_models; }
137 bool tryCommandLock();
138 Matrix<fltp08> originalTransform() const { return m_original_matrix; }
139 void setOriginalTransform(const Matrix<fltp08>& transform);
140 SelectionInfo createSelectionInfo(const MouseEvent& event, Camera* camera) override;
141 virtual void addPoint(const SnapPoint& point) override;
142 virtual void addNextFinishedCallback(std::function<void(bool canceled, UUID id)> callback) { m_next_finished_callback = callback; }
143 bool isSelecting() const;
144 void finishSelection();
145 void setAutoFinish(bool auto_finish);
146 bool hasFinishedMouseActions() const;
147 protected:
148 void refreshOffsetState();
149 void refreshPlaceState();
150 void refreshVertexOffsetState();
151 void refreshScaleState();
152 void refreshRotateState();
153 void refreshRealThicknessState();
154 void refreshTwoPointSelectState();
155 void setSelectionFilters();
156 void onSelect(UUID object);
157 void onMouseSelect();
158 virtual bool processMouseEvent(const MouseEvent& mouse_event, DesignObjectLookup* lookup, Camera* camera) override;
159 virtual bool processKeyEvent(const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
160 protected:
161 CommandLockObject m_command_lock;
162 UUID m_paint_material;
163 UUID m_paste_model;
164 UUID m_current_model;
165 UUID m_current_geometry;
166 uint04 m_current_vertex;
167 Buffer<UUID> m_edited_models;
168 Matrix<fltp08> m_original_matrix;
169 Vector<2, sint02> m_mouse_screen_original;
170 Vector<3, fltp08> m_mouse_scene_original;
171 Plane<3, fltp08> m_command_plane;
172 bool m_snap_to_normal;
173 bool m_yaw_to_normal;
174 bool m_lock_scale;
175 bool m_ignore_elevation;
176 bool m_is_selecting;
177 bool m_auto_finish;
178 std::function<void(bool canceled, UUID id)> m_next_finished_callback;
179 Dictionary<UUID, DynamicPointer<ModelFunction>> m_edit_functions;
180 DynamicPointer<ModelFunction> m_active_edit_function;
181 };
182}
183#endif
184
185
186
187
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:94