NDEVR
API Documentation
DesignObjectVisibleButton.h
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: NDEVR
28File: DesignObjectVisibleButton
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignObjectWidgetInterface.h>
35#include <NDEVR/QTDesignObject.h>
36#include <NDEVR/Button.h>
37#include <NDEVR/Toggle.h>
38#include <QWidgetAction>
39
40namespace NDEVR
41{
45 class NDEVR_API DesignObjectVisibleButton : public Button, public DesignObjectWidgetInterface
46 {
47 Q_OBJECT
48 public:
54 DesignObjectVisibleButton(const DynamicPointer<QTDesignObject>& object, QWidget* parent = nullptr)
55 : Button(parent)
56 {
57 init();
58 setTarget(object);
59 }
60
64 DesignObjectVisibleButton(QWidget* parent = nullptr)
65 : Button(parent)
66 {
67 init();
68 setEnabled(false);
69 }
70
75 void setShowMeshVisibleToggle(bool show, bool toggled)
76 {
79 if(m_show_mesh)
80 m_show_mesh->setChecked(toggled);
81 }
82
87 void setShowLineworkVisibleToggle(bool show, bool toggled)
88 {
92 m_show_linework->setChecked(toggled);
93 }
94
99 void setShowPointsVisibleToggle(bool show, bool toggled)
100 {
103 if (m_show_points)
104 m_show_points->setChecked(toggled);
105 }
106 protected:
110 void onClicked();
115 void onTargetUpdated(UUID) override;
116 protected:
124 void init();
125 protected:
129
132 Toggle* m_show_mesh = nullptr;
133
134 QWidgetAction* m_show_mesh_group = nullptr;
135 QWidgetAction* m_show_linework_group = nullptr;
136 QWidgetAction* m_show_points_group = nullptr;
137 QMenu* m_menu = nullptr;
138 };
139}
Button(QWidget *parent=nullptr)
Constructs a Button with an optional parent widget.
QWidgetAction * m_show_mesh_group
Widget action wrapping the mesh toggle for the context menu.
bool m_show_linework_visible_toggle
Whether the linework visibility toggle is shown.
DesignObjectVisibleButton(const DynamicPointer< QTDesignObject > &object, QWidget *parent=nullptr)
Constructs a visibility button bound to the given design object.
bool m_show_mesh_visible_toggle
Whether the mesh visibility toggle is shown.
QMenu * m_menu
The context menu containing visibility toggles.
DesignObjectVisibleButton(QWidget *parent=nullptr)
Constructs an unbound visibility button in a disabled state.
void init()
Initializes the button icon, checkable state, and context menu.
QWidgetAction * m_show_points_group
Widget action wrapping the points toggle for the context menu.
void setShowLineworkVisibleToggle(bool show, bool toggled)
Shows or hides the linework visibility toggle and sets its initial state.
Toggle * m_show_points
Toggle widget for points visibility.
void setShowMeshVisibleToggle(bool show, bool toggled)
Shows or hides the mesh visibility toggle and sets its initial state.
void onTargetUpdated(UUID) override
Called when the target design object is updated, refreshing the button icon state.
void setShowPointsVisibleToggle(bool show, bool toggled)
Shows or hides the points visibility toggle and sets its initial state.
bool m_show_points_visible_toggle
Whether the points visibility toggle is shown.
void onClicked()
Handles the button click to toggle visibility of the target design object.
Toggle * m_show_mesh
Toggle widget for mesh visibility.
QWidgetAction * m_show_linework_group
Widget action wrapping the linework toggle for the context menu.
void updateToggles()
Updates the context menu to show or hide the mesh, linework, and points toggles.
Toggle * m_show_linework
Toggle widget for linework visibility.
void setTarget(const DynamicPointer< QTDesignObject > &object)
Sets a single target design object, replacing any existing targets.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
A Button that toggles between on and off.
Definition Toggle.h:50
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.