ScalarQuantityWidget.h 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#pragma once

#include <QWidget>
#include <QHBoxLayout>
#include <QCheckBox>
#include <QLabel>
#include <QDoubleSpinBox>
#include <QSpacerItem>
#include <QComboBox>
12
#include <QRadioButton.h>
13 14 15 16 17 18 19 20 21

#include "controls/ScalarWidget.h"

#include "cdm/CommonDataModel.h"
#include "cdm/properties/SEScalar.h"

template <typename Unit>
class QScalarQuantityWidget : public QScalarConvertWidget
{
22
 
23
public:
24
  explicit QScalarQuantityWidget(const QString& name, double min, double max, double step, const Unit& unit, ScalarOptionWidget optWidget=ScalarOptionWidget::Check, QWidget *parent = nullptr, bool seperate_label = false);
25 26 27 28

  void reset();
  bool isChecked();

29
  void setDecimals(int prec);
30 31 32 33 34
  void addUnit(const Unit& unit);
  void setValue(const SEScalarQuantity<Unit>& s);
  void getValue(SEScalarQuantity<Unit>& s);
  void enableInput(bool b);
  void enableConverter(bool b);
35 36 37
  void fullDisable();

  const QRadioButton* getRadioButton() { return m_Radio; }
38 39 40 41 42 43 44 45 46 47

protected slots:
  void checkProperty(bool b);
  void convert();

  void enableInput(bool check, bool value);
  void updateMinMax();

  QHBoxLayout*    m_Layout;
  QCheckBox*      m_Check;
48
  QRadioButton*   m_Radio;
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
  QLabel*         m_Label;
  QDoubleSpinBox* m_Value;
  QSpacerItem*    m_Spacer;
  QComboBox*      m_Unit;
  
  bool            m_Convert;
  double          m_Min;
  double          m_Max;
  double          m_Step;
  double          m_LastValue;
  int             m_LastUnitIndex;
  const Unit&     m_DefaultUnit;
  std::vector<const Unit*> m_Units;

};


#include "controls/ScalarQuantityWidget.inl"