QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 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 whileBlocking( mAzimuthSpinBox )->setValue( std::fmod( value / 10.0 + 180, 360.0 ) );
38 emit directionChanged();
39 } );
40
41 connect( mAltitudeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
42 whileBlocking( mAltitudeSlider )->setValue( static_cast<int>( value * 10 ) );
43 emit directionChanged();
44 } );
45
46 connect( mAltitudeSlider, &QSlider::valueChanged, this, [this]( int value ) {
47 whileBlocking( mAltitudeSpinBox )->setValue( value / 10.0 );
48 emit directionChanged();
49 } );
50}
51
55
57{
58 mAzimuthSpinBox->setValue( azimuth );
59}
60
62{
63 return mAzimuthSpinBox->value();
64}
65
67{
68 mAltitudeSpinBox->setValue( altitude );
69}
70
72{
73 return mAltitudeSpinBox->value();
74}
75
77{
78 mAzimuthSpinBox->setEnabled( enable );
79 mDialAzimuth->setEnabled( enable );
80}
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:5928