33#include <NDEVR/SnapController.h>
35#include <NDEVR/CommandLockObject.h>
36#include <NDEVR/SelectionController.h>
51 friend class ModelEditController;
The equivelent of std::vector but with a bit more control.
A core object representing a user view as well as convenience functions for moving this view through ...
Used with DesignObjectLookups to lock the application for a critical process.
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Describes a user key press event used to trigger behavior in the NDEVR API.
Templated logic for doing matrix multiplication.
Takes user input in order to modify a model in real-time.
bool m_auto_finish
Whether to automatically finish when conditions are met.
void refreshPlaceState()
Refreshes the state for place editing mode.
ModelEditMode
Enumerates the available model editing modes.
@ e_two_point_scale
Scale using two reference points with free aspect ratio.
@ e_place_and_rotate
Place the model at a location and allow rotation.
@ e_vertex_offset
Translate a single vertex of the model.
@ e_edit_mode_size
Sentinel value representing the number of built-in edit modes.
@ e_rotate
Rotate the model.
@ e_flip_left
Flip the model along the left/right axis.
@ e_offset
Translate/offset the model.
@ e_set_real_thickness
Set a real-world thickness value on the model.
@ e_no_edit
No active editing operation.
@ e_center_locked_scale
Scale from center with locked aspect ratio.
@ e_flip_vertical
Flip the model along the vertical axis.
@ e_flip_front
Flip the model along the front/back axis.
@ e_two_point_locked_scale
Scale using two reference points with locked aspect ratio.
@ e_add_selection_mask
Add a selection mask to the model.
@ e_center_scale
Scale from center with free aspect ratio.
@ e_model_function
Delegate editing to a custom ModelFunction.
@ e_erase
Erase or remove parts of the model.
@ e_two_length_scale
Scale by specifying two lengths.
@ e_place_no_rotate
Place the model at a location without rotation.
@ e_rubber_stamp
Duplicate and place copies of the model (rubber stamp tool).
Model m_current_model
The model currently being edited.
void setOriginalTransform(const Matrix< fltp08 > &transform)
Sets the original transform matrix for undo/reference purposes.
Dictionary< UUID, DynamicPointer< ModelFunction > > m_edit_functions
Dictionary of registered custom model functions.
TranslatedString title() const
Returns the display title for the current editing operation.
void refreshRotateState()
Refreshes the state for rotate editing mode.
virtual void updateLocation(const Vertex< 3, fltp08 > &location, bool is_select=false, Camera *camera=nullptr) override
Updates the current location during an editing operation.
Buffer< UUID > editedModels()
Returns the list of model UUIDs that have been edited during this operation.
bool selectionModeAllowed(const SubSelectionMode &mode) const
Checks whether a given sub-selection mode is allowed in the current edit state.
bool hasCommandLock() const
Checks whether the controller currently holds a command lock.
void setSelectionFilters()
Configures the selection filters based on the current edit mode.
void updateGravityPoints()
Updates the cached gravity points used for gravity-based placement.
CommandLockObject m_command_lock
Lock object preventing concurrent command execution.
virtual bool processMouseEvent(MouseControllerEvent &event, SelectionInfo &info) override
Processes a mouse event during the editing operation.
Plane< 3, fltp08 > m_command_plane
The plane used for constrained editing operations.
void refreshState()
Refreshes the internal state of the controller based on the current edit mode.
Matrix< fltp08 > originalTransform() const
Returns the original transform matrix of the model before editing began.
void setAutoFinish(bool auto_finish)
Enables or disables automatic finishing of the edit when conditions are met.
const Dictionary< UUID, DynamicPointer< ModelFunction > > & editFunctions() const
Returns the dictionary of all registered model edit functions.
void refreshRealThicknessState()
Refreshes the state for real thickness editing mode.
Resource< ModelEditMode > edit_mode
The resource tracking the current edit mode.
bool hasFinishedMouseActions() const
Checks whether all required mouse actions for the current edit have been completed.
void setupSelectionInfo(const MouseEvent &event, Camera *camera, SelectionInfo &info) override
Sets up selection info from a mouse event and camera for the editing operation.
void setActiveEditFunction(const UUID &function)
Sets the currently active custom model function by UUID.
Model activeModel() const
Returns the currently active model being edited.
void refreshOffsetState()
Refreshes the state for offset (translation) editing mode.
Buffer< Vertex< 3, fltp08 > > m_gravity_points
Cached gravity points for gravity-based placement.
void setActiveVertex(const Matrix< fltp08 > &complete_transform, UUID geometry, uint04 vertex_id)
Sets the active vertex for vertex-level editing operations.
bool m_snap_to_normal
Whether to snap orientation to surface normals.
uint04 m_current_vertex
Index of the vertex being edited at vertex level.
void setActiveModel(UUID model)
Sets the model that is currently being edited.
void refreshScaleState()
Refreshes the state for scale editing mode.
virtual void cancel() override
Cancels the current editing operation, reverting changes.
void refreshTwoPointSelectState()
Refreshes the state for two-point selection editing mode.
void onSelect(UUID object)
Called when an object is selected during an editing operation.
void setPasteModel(UUID model)
Sets the model to be used for paste/rubber stamp operations.
Matrix< fltp08 > m_original_matrix
The original transform of the model before editing.
void onMouseSelect()
Called when a mouse-based selection occurs.
void finishSelection()
Completes the selection phase of the current editing operation.
void addPoint(const Vertex< 3, fltp08 > &point) override
Adds a 3D point as input to the current editing operation.
UUID activeModelFunction() const
Returns the UUID of the currently active model function, if any.
bool m_lock_scale
Whether to lock the scale during editing.
virtual void addNextFinishedCallback(std::function< void(bool canceled, UUID id)> callback)
Registers a callback to be invoked when the next edit operation finishes.
ModelEditController(DesignObjectLookup *manager)
Constructs a ModelEditController.
Vector< 2, sint02 > m_mouse_screen_original
Screen-space mouse position at the start of the edit.
bool m_is_selecting
Whether the controller is currently in selection mode.
Vector< 3, fltp08 > m_mouse_scene_original
Scene-space mouse position at the start of the edit.
bool m_yaw_to_normal
Whether to align yaw to surface normals.
UUID m_paste_model
UUID of the model used for paste/rubber stamp operations.
TranslatedString hint() const
Returns a short hint describing the current editing operation.
std::function< void(bool canceled, UUID id)> m_next_finished_callback
Callback invoked when the next edit operation finishes.
const UUID & pasteModel() const
Returns the UUID of the model being pasted (for rubber stamp / paste operations).
bool usingGravity() const
Checks whether gravity-based placement is currently enabled.
virtual void begin() override
Begins the current editing operation, setting up required state.
bool m_use_gravity
Whether gravity-based placement is enabled.
TranslatedString expandedHint() const
Returns an expanded hint with detailed description of the current editing operation.
bool m_ignore_elevation
Whether to ignore elevation changes during editing.
SubSelectionMode defaultSelectionMode() const
Returns the default sub-selection mode for the current edit mode.
virtual bool processKeyEvent(const KeyEvent &event, DesignObjectLookup *lookup, Camera *camera) override
Processes a keyboard event during the editing operation.
void refreshVertexOffsetState()
Refreshes the state for vertex offset editing mode.
bool tryCommandLock()
Attempts to acquire a command lock for the current editing operation.
void addEditFunction(const DynamicPointer< ModelFunction > &function)
Adds a custom model function to the controller.
UUID m_paint_material
UUID of the material used for paint operations.
const UUID & material() const
Returns the UUID of the current paint material.
DynamicPointer< ModelFunction > m_active_edit_function
The currently active custom model function.
virtual void finish() override
Finishes the current editing operation, applying changes.
Buffer< UUID > m_edited_models
List of model UUIDs modified during the current operation.
void setUseGravity(bool use_gravity)
Enables or disables gravity-based placement adjustment.
UUID m_current_geometry
UUID of the geometry being edited at vertex level.
bool isSelecting() const
Checks whether the controller is currently in a selection state.
Matrix< fltp08 > gravityAdjust(const Matrix< fltp08 > &mat) const
Applies gravity adjustment to a transformation matrix.
virtual void addPoint(const SnapPoint &point) override
Adds a snap point as input to the current editing operation.
bool shouldShowInterface() const
Checks whether the active function or edit mode has a UI interface to display.
A Model function allows a user to interact with the program to perform a task on models.
TranslatedString name
The display name of the function shown in UI.
String icon
The icon identifier used for toolbar/menu display.
virtual TranslatedString hint() const
Returns a short hint or tooltip string describing the function.
virtual void requestCancel()
Requests cancellation of the current function through the controller.
UUID id
Unique identifier for this model function.
virtual bool selectionModeAllowed(const SubSelectionMode &mode) const =0
Checks whether a given sub-selection mode is valid for this function.
virtual void setupFilters(SelectionController *)
Sets up selection filters on the given selection controller for this function.
virtual void setController(ModelEditController *controller)
Sets the owning controller for this function.
virtual SubSelectionMode defaultSelectionMode() const =0
Returns the default sub-selection mode for this function.
virtual bool shouldShowInterface() const
Checks whether this function should display a UI interface panel.
virtual void refreshState(ModelEditController &controller)=0
Refreshes the internal state of this function based on the current controller state.
virtual bool processKeyEvent(const KeyEvent &, DesignObjectLookup *, Camera *)
Processes a keyboard event during this function's operation.
virtual TranslatedString expandedHint() const
Returns an expanded hint with more detailed description of the function.
virtual bool isSelecting() const =0
Checks whether the function is currently in a selection state.
virtual void onCancel()=0
Called when the function's operation is cancelled.
virtual void requestFinish()
Requests that the function finishes its operation through the controller.
ModelEditController * m_controller
Pointer to the owning ModelEditController.
virtual bool canAutoFinishNow() const
Checks whether the function can automatically finish in its current state.
virtual bool processMouseEvent(MouseControllerEvent &)
Processes a mouse controller event during this function's operation.
virtual void onSelect(const Buffer< UUID > &)
Called when objects are selected during this function's operation.
virtual TranslatedString group() const
Returns the group or category this function belongs to for UI organization.
virtual void requestFinishSelection()
Requests that the selection phase of this function be completed.
A core class that represents a node on model hierarchy.
Describes a mouse or touch input event with position, button, and modifier information.
Logic for a given plane or N-dimensions.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Allows user to select data in a DesignObjectLookup.
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
SnapController(DesignObjectLookup *manager)
Constructs a SnapController associated with the given DesignObjectLookup.
Contains information about a particular point of interest created from a user mouse interaction.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
SubSelectionMode
Defines the mode of sub-selection used by the SelectionController.
A wrapper for a mouse event that is used by MouseControllerBase.