API Documentation
Loading...
Searching...
No Matches
VisibleCommand.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/DesignCommand.h>
4#include <NDEVR/DesignObjectLookup.h>
5#include <NDEVR/TranslatedString.h>
6#include <NDEVR/Translator.h>
7namespace NDEVR
8{
9 /**--------------------------------------------------------------------------------------------------
10 \brief A specified type of DesignCommand that can make objects visible or invisible in a 3D space
11 such as a viewport
12 *-----------------------------------------------------------------------------------------------**/
14 {
15 public:
16 VisibleCommand(bool make_visible)
18 , m_make_visible(make_visible)
19 {}
20 virtual void execute(DesignObjectLookup* lookup) override
21 {
22 WLock lock(lookup->lockPtr());
23 if (is_undo)
24 {
25 for (const UUID& toggle_id : m_models_to_toggle)
26 {
27 Model model = lookup->modelOrLayer(toggle_id);
28 if(model.isValid())
30 }
31 }
32 else
33 {
34 m_models_to_toggle.clear();
35 for (UUID target_id : targets)
36 {
37 Model model = lookup->model(target_id);
38 while (model.isValid())
39 {
40 if (model.isVisible() == m_make_visible)
41 break;
43 {
45 m_models_to_toggle.add(model.uuid());
46 }
47 if (!m_make_visible)
48 break;
49 if (model.hasDirectLayer())
50 {
51 Model layer = model.getLayer();
53 {
55 m_models_to_toggle.add(layer.uuid());
56 }
57 }
58 model = model.getParent();
59 }
60 }
61 }
62 }
63 String icon() const override
64 {
66 return "visible";
67 else
68 return "invisible";
69 }
70 TranslatedString name() const override
71 {
73 return _t("Visible");
74 else
75 return _t("Invisible");
76 }
77 protected:
80 };
81}
#define _t(english_string)
Definition Translator.h:90
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
A command for safely modifying something in a DesignObjectLookup. Modifications will be done in a sep...
Definition DesignCommand.h:52
bool is_undo
Definition DesignCommand.h:71
Buffer< UUID > targets
Definition DesignCommand.h:68
bool isValid() const
Definition DesignObject.h:356
UUID uuid() const
t_type getProperty(DesignProperty property) const
Definition DesignObject.h:257
@ e_3D_visible
Definition DesignObject.h:110
A core class where all Design Objects including models, materials, and geometries are stored.
Definition DesignObjectLookup.h:65
Model modelOrLayer(const UUID &id, bool allow_deleted=false) const
const void * lockPtr() const
Model model(const UUID &id, bool allow_deleted=false) const
A core class that represents a node on model heirarchy. This node may contain a Geometry or.
Definition Model.h:58
bool hasDirectLayer() const
Model getParent() const
bool isVisible() const
Model getLayer() const
void updateVisible(bool is_visible)
The core String class for the software.
Definition String.h:47
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:62
A specified type of DesignCommand that can make objects visible or invisible in a 3D space.
Definition VisibleCommand.h:14
virtual void execute(DesignObjectLookup *lookup) override
Definition VisibleCommand.h:20
TranslatedString name() const override
Definition VisibleCommand.h:70
VisibleCommand(bool make_visible)
Definition VisibleCommand.h:16
Buffer< UUID > m_models_to_toggle
Definition VisibleCommand.h:78
bool m_make_visible
Definition VisibleCommand.h:79
String icon() const override
Definition VisibleCommand.h:63
Used to lock a particular variable for writing. Only one write lock can be created when no read locks...
Definition RWLock.h:115
Definition ACIColor.h:37