API Documentation
Loading...
Searching...
No Matches
SizeOperationsWidget.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: StationSetupEditor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Editor.h>
34#include <NDEVR/QTModelManager.h>
35#include <NDEVR/PointWidget.h>
36#include <NDEVR/QTTools.h>
37#include <NDEVR/Toggle.h>
38#include <NDEVR/Model.h>
39#include <QVBoxLayout>
40namespace NDEVR
41{
42 class PointWidget;
44 {
45 Q_OBJECT
46 public:
47 SizeOperationsWidget(const DynamicPointer<QTDesignObject>& object, QWidget* parent = nullptr)
48 : Editor(object, parent)
49 {
50 setWindowTitle(_tqs("Size"));
51 m_size_widget = new PointWidget(this);
52 m_size_widget->setUnitToApplicationDistanceUnit();
53 m_size_widget->setLabel(X, _t("Width"));
54 m_size_widget->setLabel(Y, _t("Length"));
55 m_size_widget->setLabel(Z, _t("Height"));
56 connect(m_size_widget, &PointWidget::editingFinished, this, &SizeOperationsWidget::setSizeFromDialogSlot);
57 m_size_widget->setMinPoint(Vector<3, fltp08>(0.001, 0.001, 0.001));
58 QVBoxLayout* layout = new QVBoxLayout();
59
60 m_lock_aspect_ratio_toggle = new Toggle();
61 m_lock_aspect_ratio_toggle->setup(_t("Lock Aspect Ratio"), "", [](Button*)
62 {
63
64 });
65 m_lock_aspect_ratio_toggle->setChecked(true);
66 layout->addWidget(m_size_widget);
67 layout->addWidget(m_lock_aspect_ratio_toggle);
68 setLayout(layout);
69 updateValues();
70 }
71 void updateValues() override
72 {
73 Model model = m_design_object->getAs<Model>();
74 Ray<3, fltp08> size = model.size();
75 size = model.getParentTransform() * size;
76 if (size[Z] == 0.0)
77 m_size_widget->setDimensionCount(2);
78 else
79 m_size_widget->setDimensionCount(3);
80 m_size_widget->setPoint(abs(size));
81 }
82 public slots:
84 {
85 Ray<3, fltp08> size = m_size_widget->getPoint();
86 WLock lock = m_design_object->manager()->writeLock();
87 Model model = m_design_object->getAs<Model>();
88 size = model.getParentTransform().invert() * size;
89 if (m_lock_aspect_ratio_toggle->isChecked())
90 {
91 Vector<3, fltp08> original_size = m_design_object->getAs<Model>().size();
92 for (uint01 i = 0; i < 3; i++)
93 {
94 if (abs(size[i] - original_size[i]) > 0.001)
95 {
96 if(original_size[i] != 0.0)
97 size = (size[i] / original_size[i]) * original_size;
98 break;
99 }
100 }
101 }
102 m_design_object->getAs<Model>().setSize(abs(size));
103 m_design_object->update();
104 }
105 protected:
108 };
109}
#define NDEVR_API
Definition DLLInfo.h:67
#define _tqs(var)
Definition QTTools.h:193
#define _t(english_string)
Definition Translator.h:87
Definition Button.h:60
Definition Pointer.hpp:303
Definition Editor.h:45
Matrix< t_type, t_cols, t_rows > invert() const
Definition Matrix.hpp:649
Definition Model.h:54
Vector< 3, fltp08 > size() const
Definition Model.cpp:223
Matrix< fltp08 > getParentTransform() const
Definition Model.cpp:128
Definition PointWidget.h:60
Definition Vertex.hpp:341
Definition SizeOperationsWidget.h:44
void updateValues() override
Definition SizeOperationsWidget.h:71
PointWidget * m_size_widget
Definition SizeOperationsWidget.h:106
SizeOperationsWidget(const DynamicPointer< QTDesignObject > &object, QWidget *parent=nullptr)
Definition SizeOperationsWidget.h:47
void setSizeFromDialogSlot()
Definition SizeOperationsWidget.h:83
Toggle * m_lock_aspect_ratio_toggle
Definition SizeOperationsWidget.h:107
Definition Toggle.h:45
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition RWLock.h:99
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Definition AngleFunctions.h:750
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204