QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 "moc_qgsdirectionallightwidget.cpp"
18#include "ui_qgsdirectionallightwidget.h"
19
20#include "qgis.h"
21#include <QDebug>
22
24 QWidget( parent )
25{
26 setupUi( this );
27
28 mAzimuthSpinBox->setClearValue( 315.0 );
29 mAltitudeSpinBox->setClearValue( 45.0 );
30
31 connect( mAzimuthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value )
32 {
33 whileBlocking( mDialAzimuth )->setValue( static_cast<int>( value * 10 + 1800 ) % 3600 );
34 emit directionChanged();
35 } );
36
37 connect( mDialAzimuth, &QDial::valueChanged, this, [this]( int value )
38 {
39 whileBlocking( mAzimuthSpinBox )->setValue( std::fmod( value / 10.0 + 180, 360.0 ) );
40 emit directionChanged();
41 } );
42
43 connect( mAltitudeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value )
44 {
45 whileBlocking( mAltitudeSlider )->setValue( static_cast<int>( value * 10 ) );
46 emit directionChanged();
47 } );
48
49 connect( mAltitudeSlider, &QSlider::valueChanged, this, [this]( int value )
50 {
51 whileBlocking( mAltitudeSpinBox )->setValue( value / 10.0 );
52 emit directionChanged();
53 } );
54}
55
59
61{
62 mAzimuthSpinBox->setValue( azimuth );
63}
64
66{
67 return mAzimuthSpinBox->value();
68}
69
71{
72 mAltitudeSpinBox->setValue( altitude );
73}
74
76{
77 return mAltitudeSpinBox->value();
78}
79
81{
82 mAzimuthSpinBox->setEnabled( enable );
83 mDialAzimuth->setEnabled( enable );
84}
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:5862