NDEVR
API Documentation
GridButton.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: GridButton
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/QTDesignObject.h>
34#include <NDEVR/GridlinesDialog.h>
35#if NDEVR_CROSS_SECTION
36#include <NDEVR/QTTools.h>
37#include <NDEVR/Button.h>
38#include <NDEVR/Translator.h>
39#include <QWidgetAction>
40#include <QPointer>
41namespace NDEVR
42{
46 class GridButton : public QObject
47 {
48 Q_OBJECT
49 public:
54 GridButton(Button* combo)
55 : m_combo(combo)
56 , m_dialog(nullptr)
57 {
58 setup();
59 }
65 GridButton(const DynamicPointer<QTDesignObject>& target, Button* combo)
66 : m_combo(combo)
67 , m_dialog(nullptr)
68 {
69 setup();
70 setTarget(target);
71 }
76 void setTargets(const Buffer<DynamicPointer<QTDesignObject>>& targets)
77 {
78 m_targets = targets;
79 if (!m_dialog.isNull())
80 m_dialog->setTargets(targets);
81 }
86 void setTarget(const DynamicPointer<QTDesignObject>& target)
87 {
88 m_targets.clear();
89 m_targets.add(target);
90 if (!m_dialog.isNull())
91 m_dialog->setTarget(target);
92 }
93 protected:
97 void setup()
98 {
99 m_combo->setup(_t("Gridlines"), "grid", [this](Button*)
100 {
101 if (m_dialog.isNull())
102 {
103 m_dialog = new GridlinesDialog();
104 m_dialog->setTargets(m_targets);
105 }
106 PopupInfo info(m_combo);
107 info.make_call_widget_dialog = true;
108 info.closable = true;
109 if(!m_dialog->isVisible())
110 QTTools::ShowDialog(m_dialog, info);
111 else
112 QTTools::HideDialog(m_dialog);
113 //m_target->postCommand(DesignCommand::SetMaterialProperty(NDPM::gridline_spacing_mode
114 //, Material::GridLineMode::e_global_linework));
115 /*, button->isChecked() ? Material::GridLineMode::e_global_linework : Material::GridLineMode::e_no_linework));*/
116 });
117 //m_combo->setCheckable(true);
118
119 }
120 signals:
124 void requestSettingsSignal();
125 protected:
126 Buffer<DynamicPointer<QTDesignObject>> m_targets;
127 Button* m_combo = nullptr;
128 QPointer<GridlinesDialog> m_dialog;
129
130 //QWidgetAction* m_spacing_group = nullptr;
131 //QMenu* m_menu = nullptr;
132
133 };
134}
135#endif
The primary namespace for the NDEVR SDK.