🛰️航天仿真算法库 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
49 void setQuantity(const Quantity& quantity);
50
53 Quantity getQuantity() const;
54
57 double getMagnitude() const;
58
61 void setMagnitude(double value);
62
65 Unit getUnit() const;
66
71 void setUnit(const Unit& unit);
72
77 void changeUnit(const Unit& unit);
78
81 double getValueSI() const;
82
85 double value() const{return getValueSI();}
86
90 void setValueSI(double value);
91
94 void setValue(double valueInSI){setValueSI(valueInSI);}
95
99 double getValueInUnit(const Unit& unit) const;
100
104 void setValueUnit(double value, const Unit& unit);
105
107 Dimension dimension() const{return currentQuantity_.dimension();}
108
110 void setDimension(Dimension dim);
111
113 void setDimensionLocked(bool locked) { dimensionLocked_ = locked; }
114
116 bool isDimensionLocked() const { return dimensionLocked_; }
117
118signals:
119 void quantityChanged(const Quantity& quantity);
120protected:
121 void changeEvent(QEvent* event) override;
122
123private slots:
124 void showUnitMenu();
125private:
126 void updateQuantity();
127 void updateArrowIcon();
128 Quantity currentQuantity_;
129 QAction* actionSwitchUnit_{nullptr};
130 bool dimensionLocked_{true};
131};
132
135AST_NAMESPACE_END
量纲
定义 Dimension.hpp:355
数量值
定义 Quantity.hpp:114
数量输入框
定义 UiQuantity.hpp:41
bool isDimensionLocked() const
量纲是否锁定
定义 UiQuantity.hpp:116
Dimension dimension() const
获取当前的量纲
定义 UiQuantity.hpp:107
double value() const
获取国际单位表示的值
定义 UiQuantity.hpp:85
void setDimensionLocked(bool locked)
量纲锁定,默认锁定,任意量纲字段需调用 setDimensionLocked(false)
定义 UiQuantity.hpp:113
void setValue(double valueInSI)
设置国际单位下的值
定义 UiQuantity.hpp:94
数值输入框基类
定义 UiValueEdit.hpp:36
单位
定义 Unit.hpp:139