ImpairedAlveolarExchangeWidget.cxx 2.54 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
#include "cdm/properties/SEScalarArea.h"
Aaron Bray's avatar
Aaron Bray committed
11

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

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

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

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

46
47
48
49
50
51
52
53
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
54
55
}

56
const SECondition& QImpairedAlveolarExchangeWidget::getCondition()
Aaron Bray's avatar
Aaron Bray committed
57
{
58
59
60
61
  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
62
63
}

64
65
void QImpairedAlveolarExchangeWidget::setCondition(const SECondition& c)
{
Aaron Bray's avatar
Aaron Bray committed
66
  m_Controls->Condition.Copy((SEImpairedAlveolarExchange&)(c));
67
68
69
70
  m_Controls->ImpairedFraction->setValue(m_Controls->Condition.GetImpairedFraction());
  m_Controls->ImpairedSurfaceArea->setValue(m_Controls->Condition.GetImpairedSurfaceArea());
  QConditionWidget::enableCondition(c.IsActive());
}