ImpairedAlveolarExchangeWidget.cxx 2.58 KB
Newer Older
Aaron Bray's avatar
Aaron Bray committed
1
2
3
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#include "ImpairedAlveolarExchangeWidget.h"
4
5
#include "controls/ScalarWidget.h"
#include "controls/ScalarQuantityWidget.h"
Aaron Bray's avatar
Aaron Bray committed
6
7

#include "cdm/CommonDataModel.h"
8
#include "cdm/patient/conditions/SEImpairedAlveolarExchange.h"
Aaron Bray's avatar
Aaron Bray committed
9
#include "cdm/properties/SEScalar0To1.h"
10
11
#include "cdm/properties/SEScalarArea.h"
#include "bind/cdm/PatientConditions.pb.h"
Aaron Bray's avatar
Aaron Bray committed
12

13
class QImpairedAlveolarExchangeWidget::Controls
Aaron Bray's avatar
Aaron Bray committed
14
15
16
{
public:
  Controls() {}
17
18
19
  SEImpairedAlveolarExchange Condition;
  QScalarWidget* ImpairedFraction;
  QScalarQuantityWidget<AreaUnit>* ImpairedSurfaceArea;
Aaron Bray's avatar
Aaron Bray committed
20
21
};

22
QImpairedAlveolarExchangeWidget::QImpairedAlveolarExchangeWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
Aaron Bray's avatar
Aaron Bray committed
23
24
{
  m_Controls = new Controls();
25
26
27
28
29
30
  m_Controls->ImpairedFraction = new QScalarWidget("Impaired Fraction", 0, 1, 0.1, false, this);
  layout()->addWidget(m_Controls->ImpairedFraction);
  m_Controls->ImpairedSurfaceArea = new QScalarQuantityWidget<AreaUnit>("Impaired Surface Area", 0, 100, 1, AreaUnit::m2, false, this);
  m_Controls->ImpairedSurfaceArea->addUnit(AreaUnit::cm2);
  layout()->addWidget(m_Controls->ImpairedSurfaceArea);
  reset();
Aaron Bray's avatar
Aaron Bray committed
31
32
33
34
35
36
37
}

QImpairedAlveolarExchangeWidget::~QImpairedAlveolarExchangeWidget()
{
  delete m_Controls;
}

38
void QImpairedAlveolarExchangeWidget::reset()
Aaron Bray's avatar
Aaron Bray committed
39
{
40
  QConditionWidget::reset();
41
42
43
44
45
  m_Controls->Condition.Clear();
  m_Controls->ImpairedFraction->reset();
  m_Controls->ImpairedSurfaceArea->reset();
  enableProperties(false);
}
Aaron Bray's avatar
Aaron Bray committed
46

47
48
49
50
51
52
53
54
void QImpairedAlveolarExchangeWidget::enableProperties(bool b)
{
  m_Controls->ImpairedFraction->enableInput(b);
  m_Controls->ImpairedSurfaceArea->enableInput(b);
  m_Controls->ImpairedSurfaceArea->enableConverter(!b);
}
void QImpairedAlveolarExchangeWidget::enableConverter(bool b)
{
Aaron Bray's avatar
Aaron Bray committed
55
56
}

57
const SECondition& QImpairedAlveolarExchangeWidget::getCondition()
Aaron Bray's avatar
Aaron Bray committed
58
{
59
60
61
62
  m_Controls->Condition.Clear();
  m_Controls->ImpairedFraction->getValue(m_Controls->Condition.GetImpairedFraction());
  m_Controls->ImpairedSurfaceArea->getValue(m_Controls->Condition.GetImpairedSurfaceArea());
  return m_Controls->Condition;
Aaron Bray's avatar
Aaron Bray committed
63
64
}

65
66
67
68
69
70
71
void QImpairedAlveolarExchangeWidget::setCondition(const SECondition& c)
{
  CDM_COPY(SEImpairedAlveolarExchange, (SEImpairedAlveolarExchange*)(&c), &m_Controls->Condition);
  m_Controls->ImpairedFraction->setValue(m_Controls->Condition.GetImpairedFraction());
  m_Controls->ImpairedSurfaceArea->setValue(m_Controls->Condition.GetImpairedSurfaceArea());
  QConditionWidget::enableCondition(c.IsActive());
}