QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsdirectionallightwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdirectionallightwidget.cpp - QgsDirectionalLightWidget
3
4 ---------------------
5 begin : 11.12.2022
6 copyright : (C) 2022 by Vincent Cloarec
7 email : vcloarec at gmail dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
17#include "ui_qgsdirectionallightwidget.h"
18
19#include "qgis.h"
20#include <QDebug>
21
23 QWidget( parent )
24{
25 setupUi( this );
26
27 mAzimuthSpinBox->setClearValue( 315.0 );
28 mAltitudeSpinBox->setClearValue( 45.0 );
29
30 connect( mAzimuthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value )
31 {
32 whileBlocking( mDialAzimuth )->setValue( static_cast<int>( value * 10 + 1800 ) % 3600 );
33 emit directionChanged();
34 } );
35
36 connect( mDialAzimuth, &QDial::valueChanged, this, [this]( int value )
37 {
38 whileBlocking( mAzimuthSpinBox )->setValue( std::fmod( value / 10.0 + 180, 360.0 ) );
39 emit directionChanged();
40 } );
41
42 connect( mAltitudeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value )
43 {
44 whileBlocking( mAltitudeSlider )->setValue( static_cast<int>( value * 10 ) );
45 emit directionChanged();
46 } );
47
48 connect( mAltitudeSlider, &QSlider::valueChanged, this, [this]( int value )
49 {
50 whileBlocking( mAltitudeSpinBox )->setValue( value / 10.0 );
51 emit directionChanged();
52 } );
53}
54
58
60{
61 mAzimuthSpinBox->setValue( azimuth );
62}
63
65{
66 return mAzimuthSpinBox->value();
67}
68
70{
71 mAltitudeSpinBox->setValue( altitude );
72}
73
75{
76 return mAltitudeSpinBox->value();
77}
78
80{
81 mAzimuthSpinBox->setEnabled( enable );
82 mDialAzimuth->setEnabled( enable );
83}
void setEnableAzimuth(bool enable)
Sets whether the azimut can be changed, for example, when using multidirectional light.
double altitude() const
Returns the altitude value (degree)
void directionChanged()
Emitted when the direction is changed.
void setAzimuth(double azimuth)
Sets the azimuth value (degree)
void setAltitude(double altitude)
Sets the altitude value (degree)
double azimuth() const
Returns the azimuth value (degree)
QgsDirectionalLightWidget(QWidget *parent=nullptr)
Constructor.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5821