2#include <NDEVR/DesignCommand.h>
3#include <NDEVR/Model.h>
4#include <NDEVR/Geometry.h>
5#include <NDEVR/Material.h>
6#include <NDEVR/Pointer.h>
7#include <NDEVR/StringEnum.h>
21#define NDEVR_MANAGED_COMMAND_TYPES(X) \
24 X(e_set_geometry_property) \
25 X(e_set_material_property) \
26 X(e_set_model_property) \
27 X(e_set_model_material_mode) \
28 X(e_set_design_property) \
29 X(e_create_property) \
30 X(e_normal_expansion) \
31 X(e_set_winding_mode) \
33 X(e_smooth_laplacian) \
34 X(e_smooth_cotangent) \
35 X(e_remove_smoothing) \
36 X(e_fill_holes_by_neighbor) \
37 X(e_make_closed_solid) \
39 X(e_calculate_tangents) \
40 X(e_set_normal_mode) \
42 X(e_remove_duplicates) \
46 X(e_set_real_thickness) \
48 X(e_set_UV_intensity) \
49 X(e_set_UV_property_channel) \
52 X(e_delete_enclosed_area) \
56 X(e_color_by_channel) \
58 X(e_read_from_database) \
59 X(e_create_material) \
60 X(e_create_geometry) \
64 X(e_set_active_filters) \
65 X(e_add_active_filters) \
66 X(e_slice_into_polylines) \
72 NDEVR_DEFINE_STRING_STREAM(ManagedCommandType, NDEVR_MANAGED_COMMAND_TYPES);
108 template<
class t_arg_type>
120 template<
class t_arg_type_a,
class t_arg_type_b>
133 template<
class t_arg_type_a,
class t_arg_type_b,
class t_arg_type_c>
134 ManagedDesignCommand(ManagedCommandType command,
const t_arg_type_a& param_a,
const t_arg_type_b& param_b,
const t_arg_type_c& param_c)
147 template<
class t_arg_type_a,
class t_arg_type_b,
class t_arg_type_c,
class t_arg_type_d>
148 ManagedDesignCommand(ManagedCommandType command,
const t_arg_type_a& param_a,
const t_arg_type_b& param_b,
const t_arg_type_c& param_c,
const t_arg_type_d& param_d)
219 template<
class t_arg_type>
230 template<
class t_arg_type_a,
class t_arg_type_b>
242 template<
class t_arg_type_a,
class t_arg_type_b,
class t_arg_type_c>
243 void setUndoParams(
const UUID& uuid,
const t_arg_type_a& param_a,
const t_arg_type_b& param_b,
const t_arg_type_c& param_c)
302 template<
class t_type>
305 return new ManagedDesignCommand(ManagedCommandType::e_set_geometry_property, geo_property, value);
313 template<
class t_type>
316 return new ManagedDesignCommand(ManagedCommandType::e_set_material_property, mat_property, value);
324 template<
class t_type>
344 template<
class t_type>
347 return new ManagedDesignCommand(ManagedCommandType::e_set_design_property, design_property, value);
466 return new ManagedDesignCommand(ManagedCommandType::e_smooth_laplacian, number_of_iterations, shrink_rate, grow_rate);
477 return new ManagedDesignCommand(ManagedCommandType::e_smooth_cotangent, number_of_iterations, shrink_rate, grow_rate);
486 template<
class t_type>
489 return new ManagedDesignCommand(ManagedCommandType::e_update_vertex, property, vertex_id, new_location);
597 return new ManagedDesignCommand(ManagedCommandType::e_set_UV_property_channel, uv_type, uv_channel);
702 return new ManagedDesignCommand(ManagedCommandType::e_calibrate_scan, angle, calibrate_yaw, value);
712 return new ManagedDesignCommand(ManagedCommandType::e_calculate_tangents, calc_tangent, calc_bitangent);
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
The equivelent of std::vector but with a bit more control.
bool update_project_modified
Whether executing this command should mark the project as modified.
DesignCommand()
Default constructor.
bool can_undo
Whether this command supports being undone.
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.
String toString() const
Produces a human-readable string representation of this command including its targets and parameters.
static DynamicPointer< ManagedDesignCommand > SmoothLaplacianCommand(uint04 number_of_iterations, fltp08 shrink_rate, fltp08 grow_rate)
Creates a Laplacian smoothing command with shrink and grow rates for Taubin-style smoothing.
static DynamicPointer< ManagedDesignCommand > SetWindingMode(WindingMode mode)
Creates a command to set the polygon winding mode on target geometry.
static DynamicPointer< ManagedDesignCommand > SetSize(const Vector< 3, fltp08 > &size)
Creates a command to set the size of a design object.
virtual TranslatedString name() const override
Gets the human-readable translated name of this command based on its command_type.
ManagedDesignCommand(ManagedCommandType command, const t_arg_type ¶m_a)
Constructs a managed command with a single typed parameter.
virtual StringView icon() const override
Gets the icon identifier for this command based on its command_type.
bool canCombineWith(const DynamicPointer< DesignCommand > &command) override
Checks whether this command can be combined with another into a single operation.
Dictionary< UUID, Buffer< String > > m_undo_params
Per-target undo parameters keyed by UUID, used to restore previous state.
bool isAsyncExecution() const override
Whether this command should be executed asynchronously.
void setParams(const String ¶ms)
Sets the command parameters by splitting a pipe-delimited string.
static DynamicPointer< ManagedDesignCommand > RemoveSmoothingCommand()
Creates a command to remove any applied smoothing from the target geometry.
void setUndoParams(const UUID &uuid, const t_arg_type_a ¶m_a, const t_arg_type_b ¶m_b)
Stores two undo parameters for a specific target object.
ManagedDesignCommand(ManagedCommandType command, const String ¶ms)
Constructs a managed command of the given type with pipe-delimited parameter string.
static DynamicPointer< ManagedDesignCommand > SetUVPropertyChannel(UVType uv_type, String uv_channel)
Creates a command to set the UV property channel for a specific UV type.
static DynamicPointer< ManagedDesignCommand > ScaleObject(const Vector< 3, fltp08 > &scale, const Vector< 3, fltp08 > &scale_center)
Creates a command to scale an object by per-axis factors about a specified center point.
static DynamicPointer< ManagedDesignCommand > CreateMaterial(const StringView &name=StringView())
Creates a command to create a new material object.
static DynamicPointer< ManagedDesignCommand > AddActiveFilters(const String &filters)
Creates a command to append additional filters to the active filter set.
static DynamicPointer< ManagedDesignCommand > SetProperty(NDPO design_property, const t_type &value)
Creates a command to set a design-level property to the given value.
bool hasUndo(const UUID &uuid) const
Checks whether undo parameters exist for a given target object.
static DynamicPointer< ManagedDesignCommand > SetModelMaterialMode(Model::MaterialMode mode)
Creates a command to set the material mode on a model.
static DynamicPointer< ManagedDesignCommand > SelectObjects(bool add_to_selection)
Creates a non-undoable command to select target objects in the design.
static DynamicPointer< ManagedDesignCommand > MakeClosedSolid(bool is_closed_solid)
Creates a command to mark geometry as a closed solid or open surface.
virtual bool addTarget(UUID target_id) override
Adds a target object UUID to this command.
static DynamicPointer< ManagedDesignCommand > FillHolesByNeighbor()
Creates a command to fill mesh holes by extrapolating from neighboring geometry.
Buffer< String > m_command_params
The serialized string parameters for this command.
static DynamicPointer< ManagedDesignCommand > SmoothCotangentCommand(uint04 number_of_iterations, fltp08 shrink_rate, fltp08 grow_rate)
Creates a cotangent-weighted smoothing command with shrink and grow rates for Taubin-style smoothing.
static DynamicPointer< ManagedDesignCommand > SendInfo(const String &info)
Creates a command to append data or informational content to the target.
static DynamicPointer< ManagedDesignCommand > Delete()
Creates a command to delete target design objects.
Dictionary< UUID, Buffer< String > > undoParams()
Gets a copy of the entire undo parameter dictionary.
static DynamicPointer< ManagedDesignCommand > SetUVMode(UVType uv_type, Material::UVMode uv_mode)
Creates a command to set the UV mapping mode for a given UV type.
void execute(DesignObjectLookup *lookup) override
Executes this managed command against the given DesignObjectLookup.
static DynamicPointer< ManagedDesignCommand > SetMetadata(const String &label, const String &value)
Creates a command to set a metadata key-value pair on target objects.
ManagedDesignCommand(ManagedCommandType command, const t_arg_type_a ¶m_a, const t_arg_type_b ¶m_b, const t_arg_type_c ¶m_c, const t_arg_type_d ¶m_d)
Constructs a managed command with four typed parameters, pipe-delimited.
static DynamicPointer< ManagedDesignCommand > UpdateVertex(VertexProperty property, uint04 vertex_id, const t_type &new_location)
Creates a command to update a single vertex property value.
ManagedDesignCommand()
Default constructor.
const Buffer< String > & params() const
Gets the command parameters.
void deleteEnclosedSelection(DesignObjectLookup *lookup)
Deletes geometry within an enclosed selection region from the given lookup.
void setParams(const Buffer< String > ¶ms)
Sets the command parameters from a buffer of strings.
static DynamicPointer< ManagedDesignCommand > DeleteEnclosedArea()
Creates a command to delete geometry enclosed within a selection area.
static DynamicPointer< ManagedDesignCommand > SetUVImage(UVType uv_type, const String &uv_image)
Creates a command to set the UV texture image for a specific UV type.
static DynamicPointer< ManagedDesignCommand > ScaleObject(const fltp08 &scale)
Creates a command to uniformly scale an object by a single factor.
static DynamicPointer< ManagedDesignCommand > Explode()
Creates a command to explode grouped objects into individual children.
ManagedCommandType command_type
The type of managed operation this command represents.
static DynamicPointer< ManagedDesignCommand > CalculateTangents(bool calc_tangent, bool calc_bitangent)
Creates a command to compute tangent and/or bitangent vectors for target geometry.
void setUndoParams(const UUID &uuid, const t_arg_type ¶ms)
Stores a single undo parameter for a specific target object.
static DynamicPointer< ManagedDesignCommand > SetActiveFilters(const String &filters)
Creates a command to replace the active filter set on target objects.
static DynamicPointer< ManagedDesignCommand > FlipNormals()
Creates a command to flip (reverse) the normals on target geometry.
static DynamicPointer< ManagedDesignCommand > PlaceObject(const Matrix< fltp08 > &transform)
Creates a command to place an object using the given transformation matrix.
static DynamicPointer< ManagedDesignCommand > ClearAll()
Creates a command to clear all design objects from the lookup.
static DynamicPointer< ManagedDesignCommand > SetNormalMode(NormalMode mode, Angle< fltp08 > smooth_angle)
Creates a command to set the normal mode with a smooth angle threshold.
static DynamicPointer< ManagedDesignCommand > SetNormalMode(NormalMode mode)
Creates a command to set the normal computation mode on target geometry.
static DynamicPointer< ManagedDesignCommand > ValidateCommand()
Creates a command that validates the target design objects.
static DynamicPointer< ManagedDesignCommand > CalibrateScan(Angle< fltp08 > angle, bool calibrate_yaw, InterpolationValues value=InterpolationValues::e_linear)
Creates a command to calibrate scan data with an explicit angle and yaw correction.
static DynamicPointer< ManagedDesignCommand > ScaleObject(const fltp08 &scale, const Vector< 3, fltp08 > &scale_center)
Creates a command to uniformly scale an object about a specified center point.
void setUndoParams(const UUID &uuid, const t_arg_type_a ¶m_a, const t_arg_type_b ¶m_b, const t_arg_type_c ¶m_c)
Stores three undo parameters for a specific target object.
static DynamicPointer< ManagedDesignCommand > SetUVIntensity(UVType uv_type, fltp08 uv_intensity)
Creates a command to set the UV intensity for a specific UV type.
static DynamicPointer< ManagedDesignCommand > CenterAlign()
Creates a command to center-align the target objects at the origin.
static DynamicPointer< ManagedDesignCommand > RemoveDuplicateVertices()
Creates a command to remove duplicate vertices from the target geometry.
const Buffer< String > & undoParams(const UUID &uuid) const
Gets the undo parameters stored for a specific target object.
static DynamicPointer< ManagedDesignCommand > CreateGeometry(const StringView &name=StringView())
Creates a command to create a new geometry object.
static DynamicPointer< ManagedDesignCommand > AutoRegister(const String &filters, const UUID &reference)
Creates a command to automatically register objects using a filter and reference.
static DynamicPointer< ManagedDesignCommand > ScaleObject(const Vector< 3, fltp08 > &scale)
Creates a command to scale an object by per-axis scale factors.
static DynamicPointer< ManagedDesignCommand > ColorByChannel(String vertex_channel)
Creates a command to colorize geometry vertices based on a named data channel.
static DynamicPointer< ManagedDesignCommand > SmoothCotangentCommand(uint04 number_of_iterations)
Creates a cotangent-weighted smoothing command with the given iteration count.
bool canGroupWith(const DynamicPointer< DesignCommand > &command) override
Checks whether this command can be grouped with another for batch execution.
static DynamicPointer< ManagedDesignCommand > SetUVColor(const RGBColor &uv_color)
Creates a command to set the UV color using the default UV type.
static DynamicPointer< ManagedDesignCommand > SetMaterialProperty(NDPM mat_property, const t_type &value)
Creates a command to set a material property to the given value.
void removeUndo(const UUID &uuid)
Removes the stored undo parameters for a specific target object.
static DynamicPointer< ManagedDesignCommand > SmoothLaplacianCommand(uint04 number_of_iterations)
Creates a Laplacian smoothing command with the given iteration count.
static DynamicPointer< ManagedDesignCommand > set(NDPG geo_property, const t_type &value)
Creates a command to set a geometry property to the given value.
ManagedDesignCommand(ManagedCommandType command)
Constructs a managed command of the given type with no parameters.
static DynamicPointer< ManagedDesignCommand > set(NDPN mod_property, const t_type &value)
Creates a command to set a model property to the given value.
ManagedDesignCommand(ManagedCommandType command, const t_arg_type_a ¶m_a, const t_arg_type_b ¶m_b)
Constructs a managed command with two typed parameters, pipe-delimited.
const Dictionary< UUID, Buffer< String > > & undoParams() const
Gets the entire undo parameter dictionary (const).
static DynamicPointer< ManagedDesignCommand > SetUVColor(UVType uv_type, const RGBColor &uv_color)
Creates a command to set the UV color for a specific UV type.
static DynamicPointer< ManagedDesignCommand > CalibrateScan(bool calibrate_yaw, InterpolationValues value=InterpolationValues::e_linear)
Creates a command to calibrate scan data with optional yaw correction.
Buffer< UUID > targets
The UUIDs of design objects this command will operate on.
static DynamicPointer< ManagedDesignCommand > SetRealThickness(fltp08 real_thickness)
Creates a command to set the real-world thickness of a geometry.
void combineWith(const DynamicPointer< DesignCommand > &command) override
Combines this command with another compatible command, merging their operations.
static DynamicPointer< ManagedDesignCommand > RemoveActiveFilter(const uint04 &index)
Creates a command to remove an active filter by its index.
static DynamicPointer< ManagedDesignCommand > SliceIntoPolylines(const Matrix< fltp08 > &transform, const Vector< 3, fltp08 > &spacing)
Creates a command to slice geometry into polylines along planes defined by a transform and spacing.
ManagedDesignCommand(ManagedCommandType command, const t_arg_type_a ¶m_a, const t_arg_type_b ¶m_b, const t_arg_type_c ¶m_c)
Constructs a managed command with three typed parameters, pipe-delimited.
static DynamicPointer< ManagedDesignCommand > Group(const String &model_name=String())
Creates a command to group the target objects under a new parent model.
UVMode
Defines UV mapping modes that control how texture colors are determined for surfaces.
Templated logic for doing matrix multiplication.
MaterialMode
Determines how a model resolves its material for rendering.
Represents a color in the RGB space with optional alpha transparency.
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
static StringViewBuffer Convert(const StringBuffer &strings)
Converts a StringBuffer into a StringViewBuffer.
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...
String englishTranslation() const
Returns the English translation of this string.
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.
The primary namespace for the NDEVR SDK.
NormalMode
Describes how surface normals are computed or stored for a Geometry object.
NDPM
NDPM - NDEVR Design Property Material: Values stored in the material database.
NDPN
NDPN - NDEVR Design Property Node: Values stored in the model database.
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
InterpolationValues
Values that represent interpolation functions.
NDPO
NDPO - NDEVR Design Property Object: Values stored in the property database.
@ transform
A 4x4 transform matrix that maps local coordinates into global space.
WindingMode
Describes the vertex winding order used to determine front-facing direction of polygons.
UVType
Channels that describe how an object should interact with light.
NDPG
Forward declaration for Geometry design object.
@ is_closed_solid
Whether the geometry forms a closed solid (watertight mesh).