-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsdisplayangle.cpp
55 lines (47 loc) · 2.21 KB
/
qgsdisplayangle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/***************************************************************************
qgsdisplayangle.cpp
------------------------
begin : January 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsdisplayangle.h"
#include "qgsmapcanvas.h"
#include "qgsunittypes.h"
#include "qgssettings.h"
#include "qgsprojectdisplaysettings.h"
#include "qgsproject.h"
#include "qgsbearingnumericformat.h"
#include "qgsmaptool.h"
#include "qgsgui.h"
#include <cmath>
QgsDisplayAngle::QgsDisplayAngle( QgsMapTool *tool, Qt::WindowFlags f )
: QDialog( tool->canvas()->topLevelWidget(), f )
, mTool( tool )
{
setupUi( this );
QgsGui::enableAutoGeometryRestore( this );
}
void QgsDisplayAngle::setAngleInRadians( double value )
{
mValue = value;
const QgsSettings settings;
const Qgis::AngleUnit unit = QgsUnitTypes::decodeAngleUnit( settings.value( QStringLiteral( "qgis/measure/angleunits" ), QgsUnitTypes::encodeUnit( Qgis::AngleUnit::Degrees ) ).toString() );
const int decimals = settings.value( QStringLiteral( "qgis/measure/decimalplaces" ), 3 ).toInt();
mAngleLineEdit->setText( QgsUnitTypes::formatAngle( mValue * QgsUnitTypes::fromUnitToUnitFactor( Qgis::AngleUnit::Radians, unit ), decimals, unit ) );
}
void QgsDisplayAngle::setBearingInRadians( double value )
{
mValue = value;
const double degrees = value * 180.0 / M_PI;
const QgsNumericFormatContext context;
const QString valueAsText = QgsProject::instance()->displaySettings()->bearingFormat()->formatDouble( degrees, context );
mAngleLineEdit->setText( valueAsText );
}