🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
UiQuantity.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include <QWidget>
25#include <QMetaType>
26#include "UiValueEdit.hpp"
27#include "AstUtil/Quantity.hpp"
28#include "AstUtil/Unit.hpp"
29
30
31AST_NAMESPACE_BEGIN
32
40class AST_GUI_API UiQuantity: public UiValueEdit
41{
42 Q_OBJECT
43
44public:
45 explicit UiQuantity(QWidget* parent = nullptr);
46 UiQuantity(const UiQuantity&) = delete;
47 UiQuantity& operator=(const UiQuantity&) = delete;
48
51 void setQuantity(const Quantity& quantity);
52
55 Quantity getQuantity() const;
56
59 double getMagnitude() const;
60
63 void setMagnitude(double value);
64
67 Unit getUnit() const;
68
73 void setUnit(const Unit& unit);
74
79 void changeUnit(const Unit& unit);
80
83 double getValueSI() const;
84
87 double value() const{return getValueSI();}
88
92 void setValueSI(double value);
93
96 void setValue(double valueInSI){setValueSI(valueInSI);}
97
101 double getValueInUnit(const Unit& unit) const;
102
106 void setValueUnit(double value, const Unit& unit);
107
109 Dimension dimension() const{return currentQuantity_.dimension();}
110
112 void setDimension(Dimension dim);
113
115 void setDimensionLocked(bool locked) { dimensionLocked_ = locked; }
116
118 bool isDimensionLocked() const { return dimensionLocked_; }
119
120signals:
121 void quantityChanged(const Quantity& quantity);
122protected:
123 void changeEvent(QEvent* event) override;
124
125private slots:
126 void showUnitMenu();
127private:
128 void updateQuantity();
129 void updateArrowIcon();
130 Quantity currentQuantity_{};
131 QAction* actionSwitchUnit_{nullptr};
132 bool dimensionLocked_{true};
133};
134
137AST_NAMESPACE_END
量纲
定义 Dimension.hpp:362
数量值
定义 Quantity.hpp:114
数量输入框
定义 UiQuantity.hpp:41
bool isDimensionLocked() const
量纲是否锁定
定义 UiQuantity.hpp:118
Dimension dimension() const
获取当前的量纲
定义 UiQuantity.hpp:109
double value() const
获取国际单位表示的值
定义 UiQuantity.hpp:87
void setDimensionLocked(bool locked)
量纲锁定,默认锁定,任意量纲字段需调用 setDimensionLocked(false)
定义 UiQuantity.hpp:115
void setValue(double valueInSI)
设置国际单位下的值
定义 UiQuantity.hpp:96
数值输入框基类
定义 UiValueEdit.hpp:36
单位
定义 Unit.hpp:155