NDEVR
API Documentation
UnitsDialog.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: UnitsDialog
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Unit.h>
35#include <NDEVR/Pointer.h>
36#include <QWidget>
37namespace Ui
38{
39 class UnitsDialogUI;
40}
41namespace NDEVR
42{
43 class UnitManager;
44 class UnitOption;
45 class CustomUnit;
46 class QCustomComboBox;
53 class NDEVR_WIDGETS_API UnitsDialog : public QWidget
54 {
55 Q_OBJECT
56 public:
59 UnitsDialog(QWidget* parent = nullptr);
63 UnitsDialog(UnitManager* manager, QWidget* parent = nullptr);
66 void setManager(UnitManager* manager);
69 void setAutosize(bool auto_size);
72 void setAllowSubUnit(bool allow_sub_unit);
89 signals:
91 void edited();
92 protected:
99 void setupCombo(UnitCategory type, QCustomComboBox* combo, QCustomComboBox* subcombo = nullptr);
124 ConstPointer<Unit> selectedUnit(const Buffer<ConstPointer<UnitOption>>& options, const ConstPointer<Unit>& reference_unit, QCustomComboBox* combo, QCustomComboBox* subcombo = nullptr);
129 void setSelectedUnit(UnitCategory type, QCustomComboBox* combo, QCustomComboBox* subcombo = nullptr);
133 bool event(QEvent* event) override;
137 void setup();
144 protected slots:
155 protected:
159 bool m_update_posted = false;
160 Ui::UnitsDialogUI* ui;
161 };
162}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
A program-defined unit that can be used for some specific task different from a program-wide unit.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
A compact way to present a list of options to the user.
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
Definition QTTools.h:493
Manages a collection of units across multiple data categories with INI persistence.
A definition of how to describe a particular set of data to a custom category of unit.
Definition UnitManager.h:18
ConstPointer< Unit > selectedUnit(const Buffer< ConstPointer< UnitOption > > &options, const ConstPointer< Unit > &reference_unit, QCustomComboBox *combo, QCustomComboBox *subcombo=nullptr)
Returns the unit selected from a list of options.
void hideSurfaceVolumeUnit()
Hides the surface area and volume unit selection sections.
void initialize()
Performs one-time initialization of the dialog layout and connections.
bool m_update_posted
Guard to prevent recursive UI updates.
void removeScrollArea()
Removes the scroll area wrapper from the dialog layout.
QTResourceListener * m_resource_listener
Listener for unit resource changes.
void setAutosize(bool auto_size)
Enables or disables automatic resizing of the dialog.
void updateOrientationUnitFromUISlot()
Slot that applies the orientation unit selection from the UI to the UnitManager.
bool m_allow_sub_unit
Whether sub-unit combo boxes are enabled.
ConstPointer< Unit > selectedUnit(UnitCategory type, QCustomComboBox *combo, QCustomComboBox *subcombo=nullptr)
Returns the unit currently selected in the combo for a given category.
QWidget * extraUnitWidget(DynamicPointer< CustomUnit > custom_unit)
Creates an additional widget for editing a custom unit.
Ui::UnitsDialogUI * ui
The auto-generated UI form pointer.
bool event(QEvent *event) override
Handles events, including language-change retranslation.
void updateSurfaceAreaUnitFromUISlot()
Slot that applies the surface area unit selection from the UI to the UnitManager.
void hideAngleUnit()
Hides the angle unit selection section.
UnitManager * m_manager
The UnitManager this dialog configures.
void setupCombo(const Buffer< ConstPointer< UnitOption > > &options, const ConstPointer< Unit > &unit, QCustomComboBox *combo, QCustomComboBox *subcombo)
Sets up a combo box with specific unit options and a reference unit.
void setAllowSubUnit(bool allow_sub_unit)
Enables or disables the sub-unit selection combo boxes.
void resetToDefaultUnits()
Resets all unit selections to their default values.
ConstPointer< UnitOption > setupCombo(const Buffer< ConstPointer< UnitOption > > &options, const ConstPointer< Unit > &unit, QCustomComboBox *combo)
Sets up a combo box and returns the selected unit option.
void setup()
Configures the dialog layout and combo box connections.
UnitsDialog(QWidget *parent=nullptr)
Constructs a UnitsDialog with an optional parent.
void setManager(UnitManager *manager)
Sets the UnitManager that this dialog configures.
void hideDefaultButtons()
Hides the default/reset buttons from the dialog.
void refreshUnitsDialog()
Refreshes all combo box contents to reflect current unit options.
void edited()
Signal emitted when any unit selection has been edited.
void retranslate()
Retranslates all user-facing text in the dialog.
void updateComboContents()
Updates all combo box contents based on the current UnitManager state.
UnitsDialog(UnitManager *manager, QWidget *parent=nullptr)
Constructs a UnitsDialog bound to a specific UnitManager.
void updateWeightUnitFromUISlot()
Slot that applies the weight unit selection from the UI to the UnitManager.
void hideSpacialLabels()
Hides the spatial dimension labels in the dialog.
void setupCombo(UnitCategory type, QCustomComboBox *combo, QCustomComboBox *subcombo=nullptr)
Sets up a combo box for the given unit category.
void setSelectedUnit(UnitCategory type, QCustomComboBox *combo, QCustomComboBox *subcombo=nullptr)
Applies the selected unit for a given category to the UnitManager.
void updateFromUnit()
Updates the UI to reflect the current UnitManager state.
void updateSpacialUnitFromUISlot()
Slot that applies the spatial unit selection from the UI to the UnitManager.
void hideCoordinateMode()
Hides the coordinate mode selection section.
void updateVolumeUnitFromUISlot()
Slot that applies the volume unit selection from the UI to the UnitManager.
The primary namespace for the NDEVR SDK.
UnitCategory
A category of unit describing what it relates to.
Definition Unit.h:15