Commit 93abbb3a authored by Aaron Bray's avatar Aaron Bray

Merge 3 branchs ['unc/enviornment', 'unc/DataRequests',...

Merge 3 branchs ['unc/enviornment', 'unc/DataRequests', 'unc/idata_request_selection'] into unc/comp_523
parents fcfa3023 720a2f2a
......@@ -87,6 +87,8 @@ set(moc_sources
controls/ScenarioEditorWidget.h
controls/PlotSetWidget.h
controls/EnviornmentWidget.h
conditions/ConditionWidget.h
conditions/ChronicAnemiaWidget.h
conditions/ChronicObstructivePulmonaryDiseaseWidget.h
......@@ -111,6 +113,7 @@ set(UI_FILES
ui/DataRequestView.ui
ui/DynamicControls.ui
ui/Enviornment.ui
ui/ConditionsEditor.ui
ui/Condition.ui
......@@ -162,6 +165,9 @@ set(CONTROLS_FILES
controls/DataRequestViewWidget.h
controls/VitalsMonitorWidget.cxx
controls/VitalsMonitorWidget.h
controls/EnviornmentWidget.cxx
controls/EnviornmentWidget.h
)
source_group("Controls" FILES ${CONTROLS_FILES})
list(APPEND SOURCE ${CONTROLS_FILES})
......@@ -371,11 +377,35 @@ set(CPACK_PACKAGE_VERSION "${EXPLORER_VERSION}")
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/pulse_logo.png")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/AirDensity.jpeg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/AirPressure.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Blanket.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Clothing.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Emissivity.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Fan.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Heater.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Humidity.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/RadiantTemp.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Submerged.jpeg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Temp.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Wind.jpg")
#set(CPACK_DMG_DS_STORE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/DS_Store")
if(APPLE)
set(CPACK_BUNDLE_STARTUP_COMMAND PulseExplorer)
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/pulse_logo.png")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/AirDensity.jpeg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/AirPressure.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Blanket.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Clothing.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Emissivity.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Fan.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Heater.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Humidity.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/RadiantTemp.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Submerged.jpeg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Temp.jpg")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resource/Wind.jpg")
set(CPACK_BUNDLE_ICON pulse.icns)
set(MACOSX_BUNDLE_ICON_FILE pulse.icns)
set(MACOSX_BUNDLE_BUNDLE_VERSION "${EXPLORER_VERSION}")
......
......@@ -18,7 +18,7 @@ public:
QChronicAnemiaWidget::QChronicAnemiaWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent, flags)
{
m_Controls = new Controls();
m_Controls->ReductionFactor = new QScalarWidget("Reduction Factor", 0, 1, 0.1, false, this);
m_Controls->ReductionFactor = new QScalarWidget("Reduction Factor", 0, 1, 0.1, ScalarOptionWidget::None, this);
layout()->addWidget(m_Controls->ReductionFactor);
reset();
}
......
......@@ -19,8 +19,8 @@ public:
QChronicObstructivePulmonaryDiseaseWidget::QChronicObstructivePulmonaryDiseaseWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
{
m_Controls = new Controls();
m_Controls->BronchitisSeverity = new QScalarWidget("Bronchitis Severity", 0, 1, 0.1, false, this);
m_Controls->EmphysemaSeverity = new QScalarWidget("Emphysema Severity", 0, 1, 0.1, false, this);
m_Controls->BronchitisSeverity = new QScalarWidget("Bronchitis Severity", 0, 1, 0.1, ScalarOptionWidget::None, this);
m_Controls->EmphysemaSeverity = new QScalarWidget("Emphysema Severity", 0, 1, 0.1, ScalarOptionWidget::None, this);
layout()->addWidget(m_Controls->BronchitisSeverity);
layout()->addWidget(m_Controls->EmphysemaSeverity);
reset();
......
......@@ -22,7 +22,7 @@ public:
QChronicPericardialEffusionWidget::QChronicPericardialEffusionWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
{
m_Controls = new Controls();
m_Controls->AccumulatedVolume = new QScalarQuantityWidget<VolumeUnit>("Accumulated Volume", 0, 1000, 1, VolumeUnit::mL, false, this);
m_Controls->AccumulatedVolume = new QScalarQuantityWidget<VolumeUnit>("Accumulated Volume", 0, 1000, 1, VolumeUnit::mL, ScalarOptionWidget::None, this);
m_Controls->AccumulatedVolume->addUnit(VolumeUnit::L);
layout()->addWidget(m_Controls->AccumulatedVolume);
reset();
......
......@@ -19,8 +19,8 @@ public:
QChronicRenalStenosisWidget::QChronicRenalStenosisWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
{
m_Controls = new Controls();
m_Controls->LeftKidneySeverity = new QScalarWidget("Left Kidney Severity", 0, 1, 0.1, false, this);
m_Controls->RightKidneySeverity = new QScalarWidget("Right Kidney Severity", 0, 1, 0.1, false, this);
m_Controls->LeftKidneySeverity = new QScalarWidget("Left Kidney Severity", 0, 1, 0.1, ScalarOptionWidget::None, this);
m_Controls->RightKidneySeverity = new QScalarWidget("Right Kidney Severity", 0, 1, 0.1, ScalarOptionWidget::None, this);
layout()->addWidget(m_Controls->LeftKidneySeverity);
layout()->addWidget(m_Controls->RightKidneySeverity);
reset();
......
......@@ -21,9 +21,9 @@ public:
QImpairedAlveolarExchangeWidget::QImpairedAlveolarExchangeWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
{
m_Controls = new Controls();
m_Controls->ImpairedFraction = new QScalarWidget("Impaired Fraction", 0, 1, 0.1, false, this);
m_Controls->ImpairedFraction = new QScalarWidget("Impaired Fraction", 0, 1, 0.1, ScalarOptionWidget::None, 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 = new QScalarQuantityWidget<AreaUnit>("Impaired Surface Area", 0, 100, 1, AreaUnit::m2, ScalarOptionWidget::None, this);
m_Controls->ImpairedSurfaceArea->addUnit(AreaUnit::cm2);
layout()->addWidget(m_Controls->ImpairedSurfaceArea);
reset();
......
......@@ -20,9 +20,9 @@ public:
QLobarPneumoniaWidget::QLobarPneumoniaWidget(QWidget *parent, Qt::WindowFlags flags) : QConditionWidget(parent,flags)
{
m_Controls = new Controls();
m_Controls->Severity = new QScalarWidget("Severity", 0, 1, 0.1, false, this);
m_Controls->LeftLungAffected = new QScalarWidget("Left Lung Affected", 0, 1, 0.1, false, this);
m_Controls->RightLungAffected = new QScalarWidget("Right Lung Affected", 0, 1, 0.1, false, this);
m_Controls->Severity = new QScalarWidget("Severity", 0, 1, 0.1, ScalarOptionWidget::None, this);
m_Controls->LeftLungAffected = new QScalarWidget("Left Lung Affected", 0, 1, 0.1, ScalarOptionWidget::None, this);
m_Controls->RightLungAffected = new QScalarWidget("Right Lung Affected", 0, 1, 0.1, ScalarOptionWidget::None, this);
layout()->addWidget(m_Controls->Severity);
layout()->addWidget(m_Controls->LeftLungAffected);
layout()->addWidget(m_Controls->RightLungAffected);
......
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#include <QApplication>
#include <QDockWidget>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLayout>
#include <QMainWindow>
#include <QWidget>
#include <QPlainTextEdit>
#include <QFile>
#include <QDoubleSpinBox>
#include <QGroupBox>
#include <QScrollBar>
#include <QTimer>
#include <QThread>
#include <QPointer>
#include <QtCharts/QChart>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QtCharts/QValueAxis>
#include <QCloseEvent>
#include <QMessageBox>
#include "cdm/CommonDataModel.h"
#include "cdm/utils/FileUtils.h"
#ifdef PARAVIEW
#include <pqActiveObjects.h>
#include <pqAlwaysConnectedBehavior.h>
#include <pqApplicationCore.h>
#include <pqObjectBuilder.h>
#include <pqPersistentMainWindowStateBehavior.h>
#include <pqContextView.h>
#include <pqXYChartView.h>
#include <pqRenderView.h>
#include <vtkSMProxy.h>
#include <vtkSMPropertyHelper.h>
#include <vtkSMReaderFactory.h>
#include "GeometryView.h"
#endif
#include "AddPopup.h"
#include "ui_AddPopup.h"
#include "ExplorerIntroWidget.h"
#include "ui_AddPopup.h"
#include "DataRequestsWidget.h"
#include "VitalsMonitorWidget.h"
#include "DynamicControlsWidget.h"
#include "EnviornmentWidget.h"
#include "cdm/CommonDataModel.h"
#include "PulsePhysiologyEngine.h"
#include "cdm/engine/SEDataRequestManager.h"
#include "cdm/engine/SEEngineTracker.h"
#include "cdm/properties/SEScalarTime.h"
class AddPopup::Controls : public Ui::AddPopup
{
public:
virtual ~Controls()
{
}
#ifdef PARAVIEW
QPointer<GeometryView> GeometryView;
pqRenderView* ParaViewRenderView;
#endif
QPulse* Pulse = nullptr;
QPointer<QThread> Thread;
std::stringstream Status;
double CurrentSimTime_s;
InputMode Mode = InputMode::None;
QEnviornmentWidget* envir;
};
AddPopup::AddPopup(std::string name,QWidget *parent):QDialog(parent),Ui(new Ui::AddPopup)
{
QEnviornmentWidget* envir = dynamic_cast<QEnviornmentWidget*> (parent);
m_Controls = new Controls();
m_Controls->setupUi(this);
setWindowIcon(QIcon("resource/pulse.ico"));
QFont f("Arial", 18);
m_Controls->label->setFont(f);
m_Controls->label->setText(QString::fromUtf8(name.c_str()));
if (name == "Add Gases") {
m_Controls->Substance->addItem(QString("Oxygen"));
m_Controls->Substance->addItem(QString("Nitrogen"));
m_Controls->Substance->addItem(QString("Hydrogen"));
m_Controls->Substance->addItem(QString("Argon"));
m_Controls->Substance->addItem(QString("Carbon Dioxide"));
}
else {
m_Controls->Substance->addItem(QString("Dust"));
m_Controls->Substance->addItem(QString("Forest Exudates"));
m_Controls->Substance->addItem(QString("Geyesr Steam"));
m_Controls->Substance->addItem(QString("Smoke"));
m_Controls->Substance->addItem(QString("Particulates"));
}
connect(m_Controls->Add, SIGNAL(clicked()), this, SLOT(add()));
}
AddPopup::~AddPopup()
{
delete m_Controls;
}
void AddPopup::add() {
if (m_Controls->label->text() == "Add Gases") {
emit insertG(m_Controls->Substance->currentText(), m_Controls->Amount->value());
hide();
}
else {
emit insertA(m_Controls->Substance->currentText(), m_Controls->Amount->value());
hide();
}
}
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#ifndef AddPopup_H
#define AddPopup_H
#include <qdialog.h>
#include <QMainWindow>
#include <QObject>
#include "QPulse.h"
namespace Ui {
class AddPopup;
}
class AddPopup : public QDialog
{
Q_OBJECT
public:
explicit AddPopup(std::string name,QWidget * parent = nullptr);
virtual ~AddPopup();
Ui::AddPopup *Ui;
//protected:
signals:
void insertG(QString substance, double amount);
signals:
void insertA(QString substance, double amount);
protected slots:
void add();
private:
class Controls;
Controls* m_Controls;
};
#endif // AddPopup_H
......@@ -42,12 +42,15 @@ QDataRequestViewWidget::~QDataRequestViewWidget()
void QDataRequestViewWidget::Reset()
{
QMdiSubWindow* item;
if (m_Controls->mdiArea->subWindowList().size() > 0)
{
while ((item = m_Controls->mdiArea->subWindowList().takeAt(0)) != nullptr)
{
QPlotSetWidget* plotSet = (QPlotSetWidget*)item->widget();
plotSet->Reset();
m_Controls->mdiArea->subWindowList().removeAt(0);
}
}
m_Controls->TileButton->setEnabled(false);
m_Controls->NewPlotSetButton->setEnabled(false);
}
......
This diff is collapsed.
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#pragma once
#include <QObject>
#include <QDockWidget>
#include "QPulse.h"
class SEEnvironmentalConditions;
namespace Ui {
class EnviornmentWidget;
}
class QEnviornmentWidget : public QDockWidget, public PulseListener
{
Q_OBJECT
public:
QEnviornmentWidget(QPulse& qp, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
virtual ~QEnviornmentWidget();
void Reset();
//SECondition& GetInitialEnvironmentConditions();
void EnableControls(bool conditions, bool actions);
void AtSteadyState(PhysiologyEngine& pulse);
void AtSteadyStateUpdateUI();// Main Window will call this to update UI Components
void ProcessPhysiology(PhysiologyEngine& pulse);
void PhysiologyUpdateUI();// Main Window will call this to update UI Components
//signals:
protected slots:
void EnableCooling();
void EnableCoolingSurfaceArea();
void EnableCoolingSurfaceAreaFraction();
void EnableHeating();
void EnableHeatingSurfaceArea();
void EnableHeatingSurfaceAreaFraction();
void EnableAppliedTemp();
void EnableAppliedTempSurfaceArea();
void EnableAppliedSurfaceAreaFraction();
void LoadEnvironmentFile();
void LoadEnvironmentFile(const std::string& fileName);
void SaveEnvironmentFile();
void SaveEnviornmentFile(const std::string& fileName);
void ControlsToEnvironment();
void EnvironmentToControls();
private:
class Controls;
Controls* m_Controls;
};
\ No newline at end of file
......@@ -48,7 +48,7 @@ See accompanying NOTICE file for details.*/
#include "DataRequestViewWidget.h"
#include "VitalsMonitorWidget.h"
#include "DynamicControlsWidget.h"
#include "EnviornmentWidget.h"
#include "cdm/CommonDataModel.h"
#include "PulsePhysiologyEngine.h"
#include "cdm/engine/SEDataRequestManager.h"
......@@ -69,6 +69,7 @@ public:
delete ExplorerIntroWidget;
delete VitalsMonitorWidget;
delete DataRequestViewWidget;
delete EnviornmentWidget;
delete DynamicControls;
}
......@@ -81,6 +82,7 @@ public:
QExplorerIntroWidget* ExplorerIntroWidget=nullptr;
QVitalsMonitorWidget* VitalsMonitorWidget=nullptr;
QDataRequestViewWidget* DataRequestViewWidget=nullptr;
QEnviornmentWidget* EnviornmentWidget = nullptr;
QDynamicControlsWidget* DynamicControls=nullptr;
std::stringstream Status;
double CurrentSimTime_s;
......@@ -146,6 +148,9 @@ MainExplorerWindow::MainExplorerWindow()
m_Controls->DataRequestViewWidget = new QDataRequestViewWidget(*m_Controls->Pulse, this);
m_Controls->DataRequestViewWidget->setTitleBarWidget(new QWidget());
m_Controls->TabWidget->widget(tabIdx++)->layout()->addWidget(m_Controls->DataRequestViewWidget);
m_Controls->EnviornmentWidget = new QEnviornmentWidget(*m_Controls->Pulse, this);
m_Controls->EnviornmentWidget->setTitleBarWidget(new QWidget());
m_Controls->TabWidget->widget(tabIdx++)->layout()->addWidget(m_Controls->EnviornmentWidget);
m_Controls->StartEngine->setVisible(false);
m_Controls->RunInRealtime->setVisible(false);
......@@ -206,6 +211,7 @@ void MainExplorerWindow::ResetExplorer()
m_Controls->Pulse->Reset();
m_Controls->Mode = InputMode::None;
m_Controls->DataRequestViewWidget->Reset();
m_Controls->EnviornmentWidget->Reset();
m_Controls->VitalsMonitorWidget->Reset();
m_Controls->RunInRealtime->setChecked(true);
m_Controls->PlayPause->setText("Pause");
......@@ -231,6 +237,7 @@ void MainExplorerWindow::ResetEngine()
#endif
m_Controls->DynamicControls->Reset();
m_Controls->DataRequestViewWidget->Reset();
m_Controls->EnviornmentWidget->Reset();
m_Controls->VitalsMonitorWidget->Reset();
m_Controls->RunInRealtime->setChecked(true);
m_Controls->PlayPause->setText("Pause");
......@@ -263,6 +270,7 @@ void MainExplorerWindow::StartShowcase()
m_Controls->RunInRealtime->setVisible(true);
m_Controls->ResetExplorer->setVisible(true);
m_Controls->ResetEngine->setVisible(true);
m_Controls->EnviornmentWidget->EnableControls(false, false);
if (!m_Controls->DynamicControls->SetupShowcase(m_Controls->ExplorerIntroWidget->GetSelectedShowcase()))
{
......@@ -290,6 +298,7 @@ void MainExplorerWindow::SetupScenarioEditor()
m_Controls->RunInRealtime->setVisible(false);
m_Controls->ResetExplorer->setVisible(true);
m_Controls->ResetEngine->setVisible(false);
m_Controls->EnviornmentWidget->EnableControls(true, false);
m_Controls->Mode = InputMode::Scenario;
}
......@@ -310,6 +319,7 @@ void MainExplorerWindow::SetupEngineState()
m_Controls->RunInRealtime->setVisible(false);
m_Controls->ResetExplorer->setVisible(true);
m_Controls->ResetEngine->setVisible(false);
m_Controls->EnviornmentWidget->EnableControls(false, false);
m_Controls->Mode = InputMode::State;
}
......@@ -329,6 +339,7 @@ void MainExplorerWindow::SetupPatientEditor()
m_Controls->RunInRealtime->setVisible(false);
m_Controls->ResetExplorer->setVisible(true);
m_Controls->ResetEngine->setVisible(false);
m_Controls->EnviornmentWidget->EnableControls(true, false);
m_Controls->DynamicControls->SetupPatientEditor();
m_Controls->Mode = InputMode::Patient;
......@@ -369,12 +380,14 @@ void MainExplorerWindow::AtSteadyState(PhysiologyEngine& pulse)
m_Controls->DynamicControls->AtSteadyState(pulse);
m_Controls->VitalsMonitorWidget->AtSteadyState(pulse);
m_Controls->DataRequestViewWidget->AtSteadyState(pulse);
m_Controls->EnviornmentWidget->AtSteadyState(pulse);
}
void MainExplorerWindow::AtSteadyStateUpdateUI()
{// This is called from a slot, you can update UI here
m_Controls->DynamicControls->AtSteadyStateUpdateUI();
m_Controls->VitalsMonitorWidget->AtSteadyStateUpdateUI();
m_Controls->DataRequestViewWidget->AtSteadyStateUpdateUI();
m_Controls->EnviornmentWidget->AtSteadyStateUpdateUI();
m_Controls->PlayPause->setEnabled(true);
m_Controls->ResetEngine->setEnabled(true);
......@@ -387,7 +400,7 @@ void MainExplorerWindow::ProcessPhysiology(PhysiologyEngine& pulse)
m_Controls->DynamicControls->ProcessPhysiology(pulse);
m_Controls->VitalsMonitorWidget->ProcessPhysiology(pulse);
m_Controls->DataRequestViewWidget->ProcessPhysiology(pulse);
m_Controls->EnviornmentWidget->ProcessPhysiology(pulse);
m_Controls->CurrentSimTime_s = pulse.GetSimulationTime(TimeUnit::s);
}
void MainExplorerWindow::PhysiologyUpdateUI()
......@@ -395,6 +408,7 @@ void MainExplorerWindow::PhysiologyUpdateUI()
m_Controls->DynamicControls->PhysiologyUpdateUI();
m_Controls->VitalsMonitorWidget->PhysiologyUpdateUI();
m_Controls->DataRequestViewWidget->PhysiologyUpdateUI();
m_Controls->EnviornmentWidget->PhysiologyUpdateUI();
m_Controls->Status.str("");
m_Controls->Status << "Current Simulation Time : " << m_Controls->CurrentSimTime_s << "s";
......
This diff is collapsed.
......@@ -9,6 +9,7 @@ See accompanying NOTICE file for details.*/
#include <QDoubleSpinBox>
#include <QSpacerItem>
#include <QComboBox>
#include <QRadioButton.h>
#include "controls/ScalarWidget.h"
......@@ -18,17 +19,22 @@ See accompanying NOTICE file for details.*/
template <typename Unit>
class QScalarQuantityWidget : public QScalarConvertWidget
{
public:
explicit QScalarQuantityWidget(const QString& name, double min, double max, double step, const Unit& unit, bool check = true, QWidget *parent = nullptr);
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);
void reset();
bool isChecked();
void setDecimals(int prec);
void addUnit(const Unit& unit);
void setValue(const SEScalarQuantity<Unit>& s);
void getValue(SEScalarQuantity<Unit>& s);
void enableInput(bool b);
void enableConverter(bool b);
void fullDisable();
const QRadioButton* getRadioButton() { return m_Radio; }
protected slots:
void checkProperty(bool b);
......@@ -39,6 +45,7 @@ protected slots:
QHBoxLayout* m_Layout;
QCheckBox* m_Check;
QRadioButton* m_Radio;
QLabel* m_Label;
QDoubleSpinBox* m_Value;
QSpacerItem* m_Spacer;
......
......@@ -3,7 +3,7 @@ See accompanying NOTICE file for details.*/
#include "ScalarQuantityWidget.h"
template<typename Unit>
QScalarQuantityWidget<Unit>::QScalarQuantityWidget(const QString& name, double min, double max, double step, const Unit& unit, bool check, QWidget *parent) : QScalarConvertWidget(parent), m_DefaultUnit(unit)
QScalarQuantityWidget<Unit>::QScalarQuantityWidget(const QString& name, double min, double max, double step, const Unit& unit, ScalarOptionWidget optWidget, QWidget *parent, bool seperate_label) : QScalarConvertWidget(parent), m_DefaultUnit(unit)
{
setAutoFillBackground(true);
m_Layout = new QHBoxLayout(this);
......@@ -13,7 +13,11 @@ QScalarQuantityWidget<Unit>::QScalarQuantityWidget(const QString& name, double m
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
if (check)
m_Check = nullptr;
m_Radio = nullptr;
switch (optWidget)
{
case ScalarOptionWidget::Check:
{
m_Check = new QCheckBox(name, this);
sizePolicy.setHeightForWidth(m_Check->sizePolicy().hasHeightForWidth());
......@@ -21,22 +25,46 @@ QScalarQuantityWidget<Unit>::QScalarQuantityWidget(const QString& name, double m
m_Label = nullptr;
m_Layout->addWidget(m_Check);
connect(m_Check, SIGNAL(toggled(bool)), this, SLOT(checkProperty(bool)));
if (seperate_label)
{
m_Label = new QLabel(name, this);
m_Label->setSizePolicy(sizePolicy);
m_Layout->addWidget(m_Label);
}
else
break;
}
case ScalarOptionWidget::Radio:
{
m_Radio = new QRadioButton(name, this);
sizePolicy.setHeightForWidth(m_Radio->sizePolicy().hasHeightForWidth());
m_Radio->setSizePolicy(sizePolicy);
m_Label = nullptr;
m_Layout->addWidget(m_Radio);
//connect(m_Radio, SIGNAL(toggled(bool)), this, SLOT(checkProperty(bool)));
if (seperate_label)
{
m_Label = new QLabel(name, this);
m_Label->setSizePolicy(sizePolicy);
m_Layout->addWidget(m_Label);
}
break;
}
case ScalarOptionWidget::None:
{
m_Check = nullptr;
m_Label = new QLabel(name, this);
sizePolicy.setHeightForWidth(m_Label->sizePolicy().hasHeightForWidth());
m_Label->setSizePolicy(sizePolicy);
m_Layout->addWidget(m_Label);
break;
}
}
m_Spacer = new QSpacerItem(40, 30, QSizePolicy::Expanding, QSizePolicy::Minimum);
m_Layout->addItem(m_Spacer);
m_Value = new QDoubleSpinBox(this);
m_Value->setSingleStep(step);
if (check)
if (optWidget == ScalarOptionWidget::Check)
m_Value->setSpecialValueText("nan");
m_Value->setMinimum(check ? min - step : min);
m_Value->setMinimum(optWidget == ScalarOptionWidget::Check ? min - step : min);
m_Value->setMaximum(max);
m_Value->setMinimumSize(QSize(70, 22));
m_Value->setMaximumSize(QSize(70, 22));
......@@ -57,11 +85,18 @@ QScalarQuantityWidget<Unit>::QScalarQuantityWidget(const QString& name, double m
connect(m_Unit, SIGNAL(currentIndexChanged(int)), this, SLOT(convert()));
m_Layout->addWidget(m_Unit);
setLayout(m_Layout);
m_Min = min;
m_Max = max;
m_Step = step;
reset();
if (seperate_label)
{
if (m_Check != nullptr)
{
m_Check->setChecked(true);
m_Check->hide();
}
}
}
template<typename Unit>
......@@ -70,6 +105,8 @@ void QScalarQuantityWidget<Unit>::reset()
m_Convert = false;
if (m_Check != nullptr)
m_Check->setChecked(false);
if (m_Radio != nullptr)
m_Radio->setChecked(false);
enableInput(true, false);
m_LastUnitIndex = 0;
m_LastValue = m_Value->minimum();
......@@ -82,9 +119,17 @@ bool QScalarQuantityWidget<Unit>::isChecked()
{
if (m_Check != nullptr)
return m_Check->isChecked();
if (m_Radio != nullptr)
return m_Radio->isChecked();
return true;
}
template<typename Unit>
void QScalarQuantityWidget<Unit>::setDecimals(int prec)
{
m_Value->setDecimals(prec);
}
template<typename Unit>
void QScalarQuantityWidget<Unit>::addUnit(const Unit& unit)
{
......@@ -115,6 +160,7 @@ void QScalarQuantityWidget<Unit>::setValue(const SEScalarQuantity<Unit>& s)
m_Value->setValue(m_Value->minimum());
if (m_Check != nullptr)
m_Check->setChecked(false);
m_Value->setEnabled(false);
}
}
......@@ -139,9 +185,21 @@ void QScalarQuantityWidget<Unit>::enableInput(bool check, bool value)
{
if (m_Check != nullptr)
m_Check->setEnabled(check);
if (m_Radio != nullptr)
m_Radio->setChecked(check);
m_Value->setEnabled(value);
}
template<typename Unit>
void QScalarQuantityWidget<Unit>::fullDisable()
{
enableInput(false);
if (m_Check != nullptr)
m_Check->setDisabled(true);
if (m_Radio != nullptr)
m_Radio->setDisabled(true);
}
template<typename Unit>
void QScalarQuantityWidget<Unit>::checkProperty(bool b)
{
......
......@@ -5,7 +5,7 @@ See accompanying NOTICE file for details.*/
#include "cdm/CommonDataModel.h"
#include "cdm/properties/SEScalar.h"
QScalarWidget::QScalarWidget(const QString& name, double min, double max, double step, bool check, QWidget *parent) : QWidget(parent)
QScalarWidget::QScalarWidget(const QString& name, double min, double max, double step, ScalarOptionWidget optWidget, QWidget *parent, bool seperate_label) : QWidget(parent)
{
setAutoFillBackground(true);
m_Layout = new QHBoxLayout(this);
......@@ -15,30 +15,58 @@ QScalarWidget::QScalarWidget(const QString& name, double min, double max, double
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
if (check)
m_Check = nullptr;
m_Radio = nullptr;
switch (optWidget)
{
case ScalarOptionWidget::Check:
{
m_Check = new QCheckBox(name,this);
m_Check = new QCheckBox(name, this);
sizePolicy.setHeightForWidth(m_Check->sizePolicy().hasHeightForWidth());
m_Check->setSizePolicy(sizePolicy);
m_Label = nullptr;
m_Layout->addWidget(m_Check);
connect(m_Check, SIGNAL(toggled(bool)), this, SLOT(checkProperty(bool)));
if (seperate_label)
{
m_Label = new QLabel(name, this);
m_Label->setSizePolicy(sizePolicy);
m_Layout->addWidget(m_Label);
}
else
break;
}
case ScalarOptionWidget::Radio:
{
m_Check = nullptr;
m_Label = new QLabel(name,this);
m_Radio = new QRadioButton(name, this);
sizePolicy.setHeightForWidth(m_Radio->sizePolicy().hasHeightForWidth());
m_Radio->setSizePolicy(sizePolicy);
m_Label = nullptr;
m_Layout->addWidget(m_Radio);
//connect(m_Radio, SIGNAL(toggled(bool)), this, SLOT(checkProperty(bool)));
if (seperate_label)
{
m_Label = new QLabel(name, this);