Ref T259, Ref T243 interpolation setup form

This commit is contained in:
Klaus Basan
2018-03-19 21:06:24 +01:00
parent 101e5bb6c3
commit 0ff3b68d5c
3 changed files with 210 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
/* Copyright (C) 2018
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "interpolationsetupform.h"
#include "ui_interpolationsetupform.h"
#include "blackgui/guiutility.h"
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
namespace BlackGui
{
namespace Editors
{
CInterpolationSetupForm::CInterpolationSetupForm(QWidget *parent) :
CForm(parent),
ui(new Ui::CInterpolationSetupForm)
{
ui->setupUi(this);
m_allCheckBoxes = this->findChildren<QCheckBox *>(QString(), Qt::FindDirectChildrenOnly);
for (QCheckBox *cb : m_allCheckBoxes)
{
connect(cb, &QCheckBox::stateChanged, this, &CInterpolationSetupForm::onCheckboxChanged);
}
}
CInterpolationSetupForm::~CInterpolationSetupForm()
{ }
void CInterpolationSetupForm::setValue(const CInterpolationAndRenderingSetupBase &setup)
{
ui->cb_DebugDriver->setChecked(setup.showSimulatorDebugMessages());
ui->cb_LogInterpolation->setChecked(setup.logInterpolation());
ui->cb_EnableParts->setChecked(setup.isAircraftPartsEnabled());
ui->cb_ForceFullInterpolation->setChecked(setup.isForcingFullInterpolation());
ui->cb_EnableGndFlag->setChecked(setup.isGndFlagEnabled());
ui->cb_SendGndFlagToSim->setChecked(setup.sendGndFlagToSimulator());
}
CInterpolationAndRenderingSetupPerCallsign CInterpolationSetupForm::getValue() const
{
CInterpolationAndRenderingSetupPerCallsign setup;
setup.setEnabledAircraftParts(ui->cb_EnableParts->isChecked());
setup.setEnabledGndFLag(ui->cb_EnableGndFlag->isChecked());
setup.setForceFullInterpolation(ui->cb_ForceFullInterpolation->isChecked());
setup.setLogInterpolation(ui->cb_LogInterpolation->isChecked());
setup.setSendGndFlagToSimulator(ui->cb_SendGndFlagToSim->isChecked());
setup.setSimulatorDebuggingMessages(ui->cb_DebugDriver->isChecked());
return setup;
}
void CInterpolationSetupForm::setReadOnly(bool readonly)
{
CGuiUtility::checkBoxReadOnly(ui->cb_DebugDriver, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_LogInterpolation, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_EnableParts, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ForceFullInterpolation, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_EnableGndFlag, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_SendGndFlagToSim, readonly);
}
CStatusMessageList CInterpolationSetupForm::validate(bool nested) const
{
Q_UNUSED(nested);
return CStatusMessageList();
}
void CInterpolationSetupForm::onCheckboxChanged(int state)
{
Q_UNUSED(state);
emit this->valueChanged();
}
} // ns
} // ns

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 2018
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_EDITORS_INTERPOLATIONSETUPFORM_H
#define BLACKGUI_EDITORS_INTERPOLATIONSETUPFORM_H
#include "form.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/statusmessagelist.h"
#include <QScopedPointer>
#include <QCheckBox>
namespace Ui { class CInterpolationSetupForm; }
namespace BlackGui
{
namespace Editors
{
//! Setup of interpolation and rendering
class CInterpolationSetupForm : public CForm
{
Q_OBJECT
public:
//! Constructor
explicit CInterpolationSetupForm(QWidget *parent = nullptr);
//! Destructor
virtual ~CInterpolationSetupForm();
//! Set value
void setValue(const BlackMisc::Simulation::CInterpolationAndRenderingSetupBase &setup);
//! Get value
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign getValue() const;
//! \name Form class implementations
//! @{
virtual void setReadOnly(bool readonly) override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
signals:
//! Value changed
void valueChanged();
private:
QScopedPointer<Ui::CInterpolationSetupForm> ui;
QList<QCheckBox *> m_allCheckBoxes;
//! Checkbox has been changed
void onCheckboxChanged(int state);
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CInterpolationSetupForm</class>
<widget class="QFrame" name="CInterpolationSetupForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>236</width>
<height>75</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QCheckBox" name="cb_EnableGndFlag">
<property name="text">
<string>use gnd.flag</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cb_EnableParts">
<property name="text">
<string>enable parts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cb_ForceFullInterpolation">
<property name="text">
<string>force full interpolation</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cb_DebugDriver">
<property name="text">
<string>driver dbg. msgs.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cb_LogInterpolation">
<property name="text">
<string>log.interpolation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cb_SendGndFlagToSim">
<property name="text">
<string>send gnd.to simulator</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>