NDEVR
API Documentation
MaterialCommands.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/DesignCommand.h>
4#include <NDEVR/DesignObjectLookup.h>
5#include <NDEVR/TranslatedString.h>
6namespace NDEVR
7{
17 {
18 public:
23 NDEVR_DESIGN_API NewMaterialCommand(const std::function<void(Material& material)>& on_finished);
24
29 NDEVR_DESIGN_API virtual StringView icon() const override;
30
35 NDEVR_DESIGN_API virtual TranslatedString name() const override;
36
41 NDEVR_DESIGN_API virtual void execute(DesignObjectLookup* lookup) override;
42
48 NDEVR_DESIGN_API virtual bool addTarget(UUID target_id) override { target = target_id; return true; }
49
52 public:
53 std::function<void(Material& model)> on_create;
54 std::function<void(Material& model)> finished_callback;
57 private:
58 UUID m_previous_material_id = Constant<UUID>::Invalid;
59 };
60
69 {
70 public:
73
76
81 NDEVR_DESIGN_API virtual StringView icon() const override;
82
87 NDEVR_DESIGN_API virtual TranslatedString name() const override;
88
93 NDEVR_DESIGN_API virtual void execute(DesignObjectLookup* lookup) override;
94
100 virtual bool addTarget(UUID target_id) override { m_targets.add(target_id); return true; }
101 public:
103 private:
104 Buffer<UUID> m_targets;
105 Dictionary<UUID, UUID> m_restore_materials;
106 };
107
116 {
117 public:
120
122 NDEVR_DESIGN_API SetMaterialCommand();
123
128 NDEVR_DESIGN_API virtual StringView icon() const override;
129
134 NDEVR_DESIGN_API virtual TranslatedString name() const override;
135
140 NDEVR_DESIGN_API virtual void execute(DesignObjectLookup* lookup) override;
141
147 virtual bool addTarget(UUID target_id) override { m_targets.add(target_id); return true; }
148 public:
149 UUID material_id = Constant<UUID>::Invalid;
150 private:
151 Dictionary<UUID, UUID> m_restore_materials;
152 Buffer<UUID> m_targets;
153 };
154
163 {
164 public:
169 NDEVR_DESIGN_API SetPaletteCommand(const Buffer<RGBColor>& values);
170
173
178 NDEVR_DESIGN_API virtual StringView icon() const override;
179
184 NDEVR_DESIGN_API virtual TranslatedString name() const override;
185
190 NDEVR_DESIGN_API virtual void execute(DesignObjectLookup* lookup) override;
191
197 virtual bool addTarget(UUID target_id) override { m_targets.add(target_id); return true; }
198 private:
199 Buffer<UUID> m_targets;
200 Dictionary<UUID, Buffer<RGBColor>> m_restore_materials;
201 Buffer<RGBColor> m_colors;
202 };
203}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
virtual ~ClearMaterialDescendentsCommand()
Default virtual destructor.
virtual void execute(DesignObjectLookup *lookup) override
Executes the command, clearing material assignments from descendant objects.
virtual TranslatedString name() const override
Returns the translated display name of this command.
virtual StringView icon() const override
Returns the icon identifier for this command.
UUID parent_id
UUID of the parent object scoping the descendant search.
ClearMaterialDescendentsCommand()
Default constructor.
virtual bool addTarget(UUID target_id) override
Adds a target object whose material descendants should be cleared.
DesignCommand()
Default constructor.
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.
Definition Dictionary.h:64
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
virtual TranslatedString name() const override
Returns the translated display name of this command.
virtual bool addTarget(UUID target_id) override
Sets the target object that the new material will be assigned to.
NewMaterialCommand(const std::function< void(Material &material)> &on_finished)
Constructs a NewMaterialCommand with a callback invoked after the material is created.
std::function< void(Material &model)> on_create
Optional callback invoked during material creation.
UUID parent_id
UUID of the parent object under which the new material is created.
virtual StringView icon() const override
Returns the icon identifier for this command.
UUID target
UUID of the target object to receive the new material.
virtual void execute(DesignObjectLookup *lookup) override
Executes the command, creating a new Material within the given lookup.
virtual ~NewMaterialCommand()
Default virtual destructor.
std::function< void(Material &model)> finished_callback
Callback invoked after the command finishes execution.
virtual void execute(DesignObjectLookup *lookup) override
Executes the command, assigning the material to all target objects.
virtual StringView icon() const override
Returns the icon identifier for this command.
virtual TranslatedString name() const override
Returns the translated display name of this command.
UUID material_id
UUID of the material to assign to each target.
SetMaterialCommand()
Default constructor.
virtual bool addTarget(UUID target_id) override
Adds a target object to receive the material assignment.
virtual ~SetMaterialCommand()
Default virtual destructor.
virtual TranslatedString name() const override
Returns the translated display name of this command.
SetPaletteCommand(const Buffer< RGBColor > &values)
Constructs a SetPaletteCommand with the given color palette.
virtual StringView icon() const override
Returns the icon identifier for this command.
virtual void execute(DesignObjectLookup *lookup) override
Executes the command, applying the color palette to all target materials.
virtual ~SetPaletteCommand()
Default virtual destructor.
virtual bool addTarget(UUID target_id) override
Adds a target material to receive the palette.
The core String View class for the NDEVR API.
Definition StringView.h:58
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...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.