/* ** ** @RDE_HEADER@ ** plan_editor.h ** $Id$ ** $HeadURL$ ** $Author$ ** ** ----------------------------------------------------------------------------------------------- ** ** Hardware-Environment: Intel-PC ** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5 ** ** Language ........: C++ 11 ** ** ----------------------------------------------------------------------------------------------- ** ** Author ...........: Jörg Turla, SPD G, Tel. 3132 ** ** ----------------------------------------------------------------------------------------------- ** ** Notes .........: ** ** 26.06.2018, JT : First edition ** ** ----------------------------------------------------------------------------------------------- */ #pragma once #include #include #include #include #include #include #include class ViewshedDialog : public LtsWidgets::LtsDialog { Q_OBJECT public: explicit ViewshedDialog( QWidget *parent ) : LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly, true) { setUnchangeable(); QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *layoutH = new QHBoxLayout(this); QVBoxLayout *layoutCtrl = new QVBoxLayout(this); QFormLayout *layoutParam = new QFormLayout(); m_slAlpha = new QSlider(Qt::Orientation::Horizontal, this); m_leInnerRadius = new QLineEdit(this); m_leObserverHeight = new QLineEdit(this); m_leTargetHeight = new QLineEdit(this); m_leBeamAngle = new QLineEdit(this); m_slAlpha->setRange(0, 255); m_leInnerRadius->setValidator(new QDoubleValidator(0.0, 10000.0, 3, m_leInnerRadius)); m_leObserverHeight->setValidator(new QDoubleValidator(0.0, 100.0, 3, m_leObserverHeight)); m_leTargetHeight->setValidator(new QDoubleValidator(0.0, 100.0, 3, m_leTargetHeight)); m_leBeamAngle->setValidator(new QDoubleValidator(0.5, 10.0, 3, m_leBeamAngle)); layout->addSpacing(10); layout->addLayout(layoutH); layout->addStretch(2); layout->addSpacing(10); layoutH->addSpacing(10); layoutH->addLayout(layoutParam); layoutH->addSpacing(10); layoutH->addLayout(layoutCtrl); layoutH->addSpacing(10); layoutH->addStretch(2); layoutParam->addRow(tr("Transparency"), m_slAlpha); layoutParam->addRow(tr("Inner Radius [m]"), m_leInnerRadius); layoutParam->addRow(tr("Observer Height [m]"), m_leObserverHeight); layoutParam->addRow(tr("Target Height [m]"), m_leTargetHeight); layoutParam->addRow(tr("Angle of Beam [Degree]"), m_leBeamAngle); QPushButton *pbCreateViewshed = new QPushButton(QIcon(QStringLiteral("icon:configure_line_of_sight.svg")) , tr("Create Viewshed"), this); QPushButton *pbRemoveViewshed = new QPushButton(QIcon(QStringLiteral("icon:configure_line_of_sight_remove.svg")), tr("Remove Viewshed"), this); layoutCtrl->addStretch(2); layoutCtrl->addSpacing(10); layoutCtrl->addWidget(pbCreateViewshed); layoutCtrl->addSpacing(10); layoutCtrl->addWidget(pbRemoveViewshed); layoutCtrl->addSpacing(10); layoutCtrl->addStretch(2); connect( pbCreateViewshed , &QPushButton::clicked, this, &ViewshedDialog::createViewshed ); connect( pbRemoveViewshed , &QPushButton::clicked, this, &ViewshedDialog::removeViewshed ); connect( m_slAlpha , &QSlider::valueChanged, this, &ViewshedDialog::parameterChanged ); connect( m_leInnerRadius , &QLineEdit::textEdited, this, &ViewshedDialog::parameterChanged ); connect( m_leObserverHeight, &QLineEdit::textEdited, this, &ViewshedDialog::parameterChanged ); connect( m_leTargetHeight , &QLineEdit::textEdited, this, &ViewshedDialog::parameterChanged ); connect( m_leBeamAngle , &QLineEdit::textEdited, this, &ViewshedDialog::parameterChanged ); setOnlineHelpFilename(QStringLiteral("Situation-Start_Viewshed")); } // ViewshedDialog virtual ~ViewshedDialog() = default; void retranslate() override { // lupdate doesn't like translate(tr("foo")) ... const QString txt(tr("Viewshed Dialog")); translate(txt); } void initValues( double alpha , double viewshedInnerRadius , double viewshedObserverHeight , double viewshedTargetHeight , double viewshedBeamAngle) { if (alpha < 0.0) alpha = 0.0; if (alpha > 1.0) alpha = 1.0; m_slAlpha->setValue(int(alpha * 255)); m_leInnerRadius->setText(QLocale().toString(viewshedInnerRadius)); m_leObserverHeight->setText(QLocale().toString(viewshedObserverHeight)); m_leTargetHeight->setText(QLocale().toString(viewshedTargetHeight)); m_leBeamAngle->setText(QLocale().toString(viewshedBeamAngle)); // especially needed for virtual keyboard's windowtitle in o/c m_leInnerRadius->setToolTip(tr("Inner Radius [m]")); m_leObserverHeight->setToolTip(tr("Observer Height [m]")); m_leTargetHeight->setToolTip(tr("Target Height [m]")); m_leBeamAngle->setToolTip(tr("Angle of Beam [Degree]")); } double alpha() const { return double(m_slAlpha->value()) / 255.0; } double innerRadius() const { return QLocale().toDouble( m_leInnerRadius->text() ); } double observerHeight() const { return QLocale().toDouble( m_leObserverHeight->text() ); } double targetHeight() const { return QLocale().toDouble( m_leTargetHeight->text() ); } double beamAngle() const { return QLocale().toDouble( m_leBeamAngle->text() ); } signals: void createViewshed(); void removeViewshed(); void parameterChanged(); private: QSlider * m_slAlpha; QLineEdit * m_leInnerRadius; QLineEdit * m_leObserverHeight; QLineEdit * m_leTargetHeight; QLineEdit * m_leBeamAngle; }; // ViewshedDialog