NDEVR
API Documentation
OrientationEditor.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: Widgets
28File: OrientationEditor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Resource.h>
35#include <NDEVR/Matrix.h>
36#include <NDEVR/Pointer.h>
37#include <NDEVR/Unit.h>
38#include <QWidget>
39namespace Ui
40{
41 class OrientationEditorUI;
42}
43class QBoxLayout;
44namespace NDEVR
45{
47 class String;
48 class QCustomDial;
49 class QCustomLineEdit;
54 class NDEVR_WIDGETS_API OrientationEditor : public QWidget
55 {
56 Q_OBJECT
57 public:
69
73 explicit OrientationEditor(QWidget* parent = nullptr);
99 void setOffsetTitle(const TranslatedString& title);
111 void setScaleTitle(const TranslatedString& title);
118 void setRotationTitle(const TranslatedString& roll, const TranslatedString& pitch, const TranslatedString& yaw);
135 QBoxLayout* offsetLayout();
145 void setMatrix(const Matrix<fltp08>& matrix);
150 void resizeEvent(QResizeEvent *event) override;
159 virtual QSize minimumSizeHint() const override;
164 virtual QSize sizeHint() const override;
173 void setAutoHideDials(bool auto_hide_dials);
174 signals:
178 void updated();
180 void scaleEdited();
182 void edited();
183 public slots:
205 private slots:
209 void updatePositionFromUI();
213 void updateOrientationFromDials();
217 void updateOrientationFromUI();
221 void updateScaleFromUI();
225 void updateScaleFieldsX();
229 void updateScaleFieldsY();
233 void updateScaleFieldsZ();
234 public:
238
242
246
253 protected:
259 Ui::OrientationEditorUI* ui;
260 };
261}
262
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
Resource< Vector< 3, Angle< fltp08 > > > orientation
The current 3D rotation angles (roll, pitch, yaw).
void updateScale()
Refreshes the scale UI fields from the scale resource.
void setOffsetLabels(const TranslatedString &x, const TranslatedString &y, const TranslatedString &z)
Sets the axis labels for the position/offset fields.
void updated()
Emitted when any resource is updated programmatically.
Ui::OrientationEditorUI * ui
The auto-generated UI form.
void updateLabels()
Updates the axis labels to reflect the current unit settings.
Matrix< fltp08 > getMatrix()
Computes a 4x4 transformation matrix from the current position, rotation, and scale.
void setAutoHideDials(bool auto_hide_dials)
Sets whether dials are automatically hidden when the widget is too small.
Resource< Vector< 3, bool > > show_orientation
Controls visibility of each orientation axis field.
Resource< Vector< 3, bool > > show_position
Controls visibility of each position axis field.
void positionEdited()
Emitted when the user edits position values in the UI.
Resource< Vector< 3, bool > > show_scale
Controls visibility of each scale axis field.
void setOffsetTitle(const TranslatedString &title)
Sets the title label for the position/offset section.
void orientationUpdated()
Emitted when the orientation resource is updated programmatically.
Resource< Vector< 3, fltp08 > > min_position
The minimum allowed position values.
void updateLayoutSize()
Recalculates the layout based on the current size mode.
Resource< Vector< 3, fltp08 > > position
The current 3D position values.
void scaleEdited()
Emitted when the user edits scale values in the UI.
Resource< Vector< 3, fltp08 > > scale
The current 3D scale values.
Resource< Vector< 3, fltp08 > > max_position
The maximum allowed position values.
virtual QSize sizeHint() const override
Returns the preferred size hint for the widget.
Vector< 3, fltp08 > getUILocation() const
Returns the current position values from the UI fields.
Vector< 3, fltp08 > getUIScale() const
Returns the current scale values from the UI fields.
QBoxLayout * offsetLayout()
Returns the layout containing the position/offset fields.
Resource< ConstPointer< Unit > > position_unit
The unit used for displaying position values.
Resource< ConstPointer< Unit > > angle_unit
The unit used for displaying angle values.
QCustomLineEdit * getUILineEdit(uint01 orientation)
Returns the line edit widget for a given rotation axis.
void setScaleTitle(const TranslatedString &title)
Sets the title label for the scale section.
void setMatrix(const Matrix< fltp08 > &matrix)
Decomposes a transformation matrix and populates the UI fields accordingly.
QCustomDial * getUIDial(uint01 orientation)
Returns the dial widget for a given rotation axis.
Vector< 3, Angle< fltp08 > > getUIDialRotation() const
Returns the current rotation values from the UI dial widgets.
virtual QSize minimumSizeHint() const override
Returns the minimum size hint for the widget.
OrientationEditor(QWidget *parent=nullptr)
Constructs an OrientationEditor widget.
Resource< ConstPointer< Unit > > size_unit
The unit used for displaying scale/size values.
SizeMode m_size_mode
The current layout size mode.
void positionUpdated()
Emitted when the position resource is updated programmatically.
bool m_auto_hide_dials
Whether to automatically hide dials when space is limited.
void orientationEdited()
Emitted when the user edits orientation values in the UI.
bool m_auto_set_layout
Whether to automatically adjust layout on resize.
void updatePosition()
Refreshes the position UI fields from the position resource.
SizeMode
Enumerates layout size modes for the orientation editor.
@ e_normal
Full-size layout with all elements visible.
@ e_tiny_vertical
Minimal vertical layout.
@ e_tiny_horizontal
Minimal horizontal layout.
@ e_small_vertical
Compact vertical layout.
@ e_small_horizontal
Compact horizontal layout.
void scaleUpdated()
Emitted when the scale resource is updated programmatically.
void setSizeMode(SizeMode mode)
Sets the layout size mode of the orientation editor.
void lockAspectRatio()
Locks the aspect ratio so that scale changes on one axis propagate proportionally.
Resource< Vector< 3, Angle< fltp08 > > > min_orientation
The minimum allowed rotation angles.
Resource< Vector< 3, fltp08 > > min_scale
The minimum allowed scale values.
Resource< Vector< 3, Angle< fltp08 > > > max_orientation
The maximum allowed rotation angles.
void resizeEvent(QResizeEvent *event) override
Handles resize events by adjusting the layout mode if auto-layout is enabled.
Resource< Vector< 3, fltp08 > > max_scale
The maximum allowed scale values.
Vector< 3, Angle< fltp08 > > getUIRotation() const
Returns the current rotation values from the UI text fields.
Vector< 3, fltp08 > m_aspect_ratio
The locked aspect ratio between scale axes.
QTResourceListener * m_units_listener
Listener that triggers label updates when units change.
void setRotationTitle(const TranslatedString &roll, const TranslatedString &pitch, const TranslatedString &yaw)
Sets the title labels for the rotation section axes.
void updateOrientation()
Refreshes the orientation UI fields and dials from the orientation resource.
void edited()
Emitted when the user edits any value in the UI.
Provides a rounded range control (like a speedometer or potentiometer).
Definition QCustomDial.h:76
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
Definition QTTools.h:493
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...