API Documentation
Loading...
Searching...
No Matches
GridButton.h
Go to the documentation of this file.
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: SmoothButton
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{
43 /**--------------------------------------------------------------------------------------------------
44 \brief Allows the user to easily cross section a particlar selection.
45 **/
46 class GridButton : public QObject
47 {
48 Q_OBJECT
49 public:
50 GridButton(Button* combo)
51 : m_combo(combo)
52 , m_dialog(nullptr)
53 {
54 setup();
55 }
56 GridButton(const DynamicPointer<QTDesignObject>& target, Button* combo)
57 : m_combo(combo)
58 , m_dialog(nullptr)
59 {
60 setup();
61 setTarget(target);
62 }
63 void setTargets(const Buffer<DynamicPointer<QTDesignObject>>& targets)
64 {
65 m_targets = targets;
66 if (!m_dialog.isNull())
67 m_dialog->setTargets(targets);
68 }
69 void setTarget(const DynamicPointer<QTDesignObject>& target)
70 {
71 m_targets.clear();
72 m_targets.add(target);
73 if (!m_dialog.isNull())
74 m_dialog->setTarget(target);
75 }
76 protected:
77 void setup()
78 {
79 m_combo->setup(_t("Gridlines"), "grid", [this](Button*)
80 {
81 if (m_dialog.isNull())
82 {
83 m_dialog = new GridlinesDialog();
84 m_dialog->setTargets(m_targets);
85 }
86 PopupInfo info(m_combo);
87 info.make_call_widget_dialog = true;
88 info.closable = true;
89 if(!m_dialog->isVisible())
90 QTTools::ShowDialog(m_dialog, info);
91 else
92 QTTools::HideDialog(m_dialog);
93 //m_target->postCommand(DesignCommand::SetMaterialProperty(Material::e_gridline_spacing_mode
94 //, Material::GridLineMode::e_global_linework));
95 /*, button->isChecked() ? Material::GridLineMode::e_global_linework : Material::GridLineMode::e_no_linework));*/
96 });
97 //m_combo->setCheckable(true);
98
99 }
100 signals:
101 void requestSettingsSignal();
102 protected:
103 Buffer<DynamicPointer<QTDesignObject>> m_targets;
104 Button* m_combo = nullptr;
105 QPointer<GridlinesDialog> m_dialog;
106
107 //QWidgetAction* m_spacing_group = nullptr;
108 //QMenu* m_menu = nullptr;
109
110 };
111}
112#endif
#define _t(english_string)
Definition Translator.h:90
Definition ACIColor.h:37