diff --git a/src/blackgui/editors/interpolationsetupform.cpp b/src/blackgui/editors/interpolationsetupform.cpp new file mode 100644 index 000000000..fb33c85e8 --- /dev/null +++ b/src/blackgui/editors/interpolationsetupform.cpp @@ -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(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 diff --git a/src/blackgui/editors/interpolationsetupform.h b/src/blackgui/editors/interpolationsetupform.h new file mode 100644 index 000000000..0be237a1b --- /dev/null +++ b/src/blackgui/editors/interpolationsetupform.h @@ -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 +#include + +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; + QList m_allCheckBoxes; + + //! Checkbox has been changed + void onCheckboxChanged(int state); + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/editors/interpolationsetupform.ui b/src/blackgui/editors/interpolationsetupform.ui new file mode 100644 index 000000000..e42da8111 --- /dev/null +++ b/src/blackgui/editors/interpolationsetupform.ui @@ -0,0 +1,66 @@ + + + CInterpolationSetupForm + + + + 0 + 0 + 236 + 75 + + + + Frame + + + + + + use gnd.flag + + + + + + + enable parts + + + true + + + + + + + force full interpolation + + + + + + + driver dbg. msgs. + + + + + + + log.interpolation + + + + + + + send gnd.to simulator + + + + + + + +