mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[FEATURE]: A tool to measure angles
git-svn-id: http://svn.osgeo.org/qgis/trunk@12663 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
0fcf64b40a
commit
8545ed7ea7
@ -156,6 +156,7 @@
|
||||
<file>themes/default/mActionLowerItems.png</file>
|
||||
<file>themes/default/mActionMapTips.png</file>
|
||||
<file>themes/default/mActionMeasure.png</file>
|
||||
<file>themes/default/mActionMeasureAngle.png</file>
|
||||
<file>themes/default/mActionMeasureArea.png</file>
|
||||
<file>themes/default/mActionMergeFeatures.png</file>
|
||||
<file>themes/default/mActionMoveFeature.png</file>
|
||||
|
BIN
images/themes/default/mActionMeasureAngle.png
Normal file
BIN
images/themes/default/mActionMeasureAngle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -21,6 +21,7 @@ SET(QGIS_APP_SRCS
|
||||
qgsspatialitefilterproxymodel.cpp
|
||||
qgsspatialitetablemodel.cpp
|
||||
qgsdelattrdialog.cpp
|
||||
qgsdisplayangle.cpp
|
||||
qgsfieldcalculator.cpp
|
||||
qgsnewvectorlayerdialog.cpp
|
||||
qgsgraduatedsymboldialog.cpp
|
||||
@ -37,6 +38,7 @@ SET(QGIS_APP_SRCS
|
||||
qgsmaptooldeletevertex.cpp
|
||||
qgsmaptooledit.cpp
|
||||
qgsmaptoolidentify.cpp
|
||||
qgsmaptoolmeasureangle.cpp
|
||||
qgsmaptoolmovefeature.cpp
|
||||
qgsmaptoolmovevertex.cpp
|
||||
qgsmaptoolnodetool.cpp
|
||||
@ -128,6 +130,7 @@ SET (QGIS_APP_MOC_HDRS
|
||||
qgscustomprojectiondialog.h
|
||||
qgsdelattrdialog.h
|
||||
qgsfieldcalculator.h
|
||||
qgsmaptoolmeasureangle.h
|
||||
qgsnewvectorlayerdialog.h
|
||||
qgsgraduatedsymboldialog.h
|
||||
qgshelpviewer.h
|
||||
|
@ -169,6 +169,7 @@
|
||||
#include "qgsmaptooldeletepart.h"
|
||||
#include "qgsmaptooldeletevertex.h"
|
||||
#include "qgsmaptoolidentify.h"
|
||||
#include "qgsmaptoolmeasureangle.h"
|
||||
#include "qgsmaptoolmovefeature.h"
|
||||
#include "qgsmaptoolmovevertex.h"
|
||||
#include "qgsmaptoolnodetool.h"
|
||||
@ -811,6 +812,10 @@ void QgisApp::createActions()
|
||||
mActionMeasureArea->setStatusTip( tr( "Measure an Area" ) );
|
||||
connect( mActionMeasureArea, SIGNAL( triggered() ), this, SLOT( measureArea() ) );
|
||||
|
||||
mActionMeasureAngle = new QAction( getThemeIcon( "mActionMeasureAngle.png" ), tr( "Measure Angle" ), this );
|
||||
mActionMeasureAngle->setStatusTip( tr( "Measure Angle" ) );
|
||||
connect( mActionMeasureAngle, SIGNAL( triggered() ), this, SLOT( measureAngle() ) );
|
||||
|
||||
mActionZoomFullExtent = new QAction( getThemeIcon( "mActionZoomFullExtent.png" ), tr( "Zoom Full" ), this );
|
||||
shortcuts->registerAction( mActionZoomFullExtent, tr( "Ctrl+Shift+F", "Zoom to Full Extents" ) );
|
||||
mActionZoomFullExtent->setStatusTip( tr( "Zoom to Full Extents" ) );
|
||||
@ -1110,6 +1115,8 @@ void QgisApp::createActionGroups()
|
||||
mMapToolGroup->addAction( mActionMeasure );
|
||||
mActionMeasureArea->setCheckable( true );
|
||||
mMapToolGroup->addAction( mActionMeasureArea );
|
||||
mActionMeasureAngle->setCheckable( true );
|
||||
mMapToolGroup->addAction( mActionMeasureAngle );
|
||||
mActionCaptureLine->setCheckable( true );
|
||||
mMapToolGroup->addAction( mActionCaptureLine );
|
||||
mActionCapturePoint->setCheckable( true );
|
||||
@ -1272,6 +1279,7 @@ void QgisApp::createMenus()
|
||||
mViewMenu->addAction( mActionIdentify );
|
||||
mViewMenu->addAction( mActionMeasure );
|
||||
mViewMenu->addAction( mActionMeasureArea );
|
||||
mViewMenu->addAction( mActionMeasureAngle );
|
||||
mActionViewSeparator1 = mViewMenu->addSeparator();
|
||||
|
||||
mViewMenu->addAction( mActionZoomFullExtent );
|
||||
@ -1490,6 +1498,7 @@ void QgisApp::createToolBars()
|
||||
mAttributesToolBar->addAction( mActionOpenTable );
|
||||
mAttributesToolBar->addAction( mActionMeasure );
|
||||
mAttributesToolBar->addAction( mActionMeasureArea );
|
||||
mAttributesToolBar->addAction( mActionMeasureAngle );
|
||||
mAttributesToolBar->addAction( mActionMapTips );
|
||||
mAttributesToolBar->addAction( mActionShowBookmarks );
|
||||
mAttributesToolBar->addAction( mActionNewBookmark );
|
||||
@ -1734,6 +1743,7 @@ void QgisApp::setTheme( QString theThemeName )
|
||||
mActionOpenTable->setIcon( getThemeIcon( "/mActionOpenTable.png" ) );
|
||||
mActionMeasure->setIcon( getThemeIcon( "/mActionMeasure.png" ) );
|
||||
mActionMeasureArea->setIcon( getThemeIcon( "/mActionMeasureArea.png" ) );
|
||||
mActionMeasureAngle->setIcon( getThemeIcon( "/mActionMeasureAngle.png" ) );
|
||||
mActionMapTips->setIcon( getThemeIcon( "/mActionMapTips.png" ) );
|
||||
mActionShowBookmarks->setIcon( getThemeIcon( "/mActionShowBookmarks.png" ) );
|
||||
mActionNewBookmark->setIcon( getThemeIcon( "/mActionNewBookmark.png" ) );
|
||||
@ -1835,6 +1845,8 @@ void QgisApp::createCanvas()
|
||||
mMapTools.mMeasureDist->setAction( mActionMeasure );
|
||||
mMapTools.mMeasureArea = new QgsMeasureTool( mMapCanvas, TRUE /* area */ );
|
||||
mMapTools.mMeasureArea->setAction( mActionMeasureArea );
|
||||
mMapTools.mMeasureAngle = new QgsMapToolMeasureAngle( mMapCanvas );
|
||||
mMapTools.mMeasureAngle->setAction( mActionMeasureAngle );
|
||||
mMapTools.mCapturePoint = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePoint );
|
||||
mMapTools.mCapturePoint->setAction( mActionCapturePoint );
|
||||
mActionCapturePoint->setVisible( false );
|
||||
@ -3508,6 +3520,11 @@ void QgisApp::measureArea()
|
||||
mMapCanvas->setMapTool( mMapTools.mMeasureArea );
|
||||
}
|
||||
|
||||
void QgisApp::measureAngle()
|
||||
{
|
||||
mMapCanvas->setMapTool( mMapTools.mMeasureAngle );
|
||||
}
|
||||
|
||||
void QgisApp::attributeTable()
|
||||
{
|
||||
if ( mMapCanvas && mMapCanvas->isDrawing() )
|
||||
|
@ -591,6 +591,8 @@ class QgisApp : public QMainWindow
|
||||
void measure();
|
||||
//! Measure area
|
||||
void measureArea();
|
||||
//! Measure angle
|
||||
void measureAngle();
|
||||
|
||||
//! show the attribute table for the currently selected layer
|
||||
void attributeTable();
|
||||
@ -798,6 +800,7 @@ class QgisApp : public QMainWindow
|
||||
QAction *mActionDeselectAll;
|
||||
QAction *mActionIdentify;
|
||||
QAction *mActionMeasure;
|
||||
QAction *mActionMeasureAngle;
|
||||
QAction *mActionMeasureArea;
|
||||
QAction *mActionViewSeparator1;
|
||||
QAction *mActionZoomFullExtent;
|
||||
@ -900,6 +903,7 @@ class QgisApp : public QMainWindow
|
||||
QgsMapTool* mIdentify;
|
||||
QgsMapTool* mMeasureDist;
|
||||
QgsMapTool* mMeasureArea;
|
||||
QgsMapTool* mMeasureAngle;
|
||||
QgsMapTool* mCapturePoint;
|
||||
QgsMapTool* mCaptureLine;
|
||||
QgsMapTool* mCapturePolygon;
|
||||
|
52
src/app/qgsdisplayangle.cpp
Normal file
52
src/app/qgsdisplayangle.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
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 <QSettings>
|
||||
|
||||
#ifndef Q_OS_MACX
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
QgsDisplayAngle::QgsDisplayAngle( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
|
||||
{
|
||||
setupUi( this );
|
||||
}
|
||||
|
||||
QgsDisplayAngle::~QgsDisplayAngle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QgsDisplayAngle::setValueInRadians( double value )
|
||||
{
|
||||
QSettings settings;
|
||||
QString unitString = settings.value( "/qgis/measure/angleunits", "degrees" ).toString();
|
||||
if ( unitString == "degrees" )
|
||||
{
|
||||
mAngleLineEdit->setText( tr( "%1 degrees" ).arg( value * 180 / M_PI ) );
|
||||
}
|
||||
else if ( unitString == "radians" )
|
||||
{
|
||||
mAngleLineEdit->setText( tr( "%1 radians" ).arg( value ) );
|
||||
}
|
||||
else if ( unitString == "gon" )
|
||||
{
|
||||
mAngleLineEdit->setText( tr( "%1 gon" ).arg( value / M_PI * 200 ) );
|
||||
}
|
||||
}
|
||||
|
32
src/app/qgsdisplayangle.h
Normal file
32
src/app/qgsdisplayangle.h
Normal file
@ -0,0 +1,32 @@
|
||||
/***************************************************************************
|
||||
qgsdisplayangle.h
|
||||
------------------------
|
||||
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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSDISPLAYANGLE_H
|
||||
#define QGSDISPLAYANGLE_H
|
||||
|
||||
#include "ui_qgsdisplayanglebase.h"
|
||||
|
||||
/**A class that displays results of angle measurements with the proper unit*/
|
||||
class QgsDisplayAngle: public QDialog, private Ui::QgsDisplayAngleBase
|
||||
{
|
||||
public:
|
||||
QgsDisplayAngle( QWidget * parent = 0, Qt::WindowFlags f = 0 );
|
||||
~QgsDisplayAngle();
|
||||
/**Sets the measured angle value (in radians). The value is going to
|
||||
be converted to degrees / gon automatically if necessary*/
|
||||
void setValueInRadians( double value );
|
||||
};
|
||||
|
||||
#endif // QGSDISPLAYANGLE_H
|
154
src/app/qgsmaptoolmeasureangle.cpp
Normal file
154
src/app/qgsmaptoolmeasureangle.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
/***************************************************************************
|
||||
qgsmaptoolmeasureangle.cpp
|
||||
--------------------------
|
||||
begin : December 2009
|
||||
copyright : (C) 2009 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 "qgsmaptoolmeasureangle.h"
|
||||
#include "qgsdisplayangle.h"
|
||||
#include "qgsdistancearea.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsmaptopixel.h"
|
||||
#include "qgsrubberband.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QSettings>
|
||||
|
||||
#ifndef Q_OS_MACX
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTool( canvas ), mRubberBand( 0 ), mResultDisplay( 0 )
|
||||
{
|
||||
mSnapper.setMapCanvas( canvas );
|
||||
}
|
||||
|
||||
QgsMapToolMeasureAngle::~QgsMapToolMeasureAngle()
|
||||
{
|
||||
stopMeasuring();
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::canvasMoveEvent( QMouseEvent * e )
|
||||
{
|
||||
if ( !mRubberBand || mAnglePoints.size() < 1 || mAnglePoints.size() > 2 || !mRubberBand )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsPoint point = snapPoint( e->pos() );
|
||||
mRubberBand->movePoint( point );
|
||||
if ( mAnglePoints.size() == 2 )
|
||||
{
|
||||
//do angle calculation
|
||||
QgsDistanceArea* distArea = mCanvas->mapRenderer()->distanceArea();
|
||||
if ( distArea )
|
||||
{
|
||||
double azimutOne = distArea->bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
|
||||
double azimutTwo = distArea->bearing( mAnglePoints.at( 1 ), point );
|
||||
double resultAngle = azimutTwo - azimutOne;
|
||||
QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
|
||||
QgsDebugMsg( QString::number( M_PI ) );
|
||||
if ( fabs( resultAngle ) > M_PI )
|
||||
{
|
||||
if ( resultAngle < 0 )
|
||||
{
|
||||
resultAngle = M_PI + ( resultAngle + M_PI );
|
||||
}
|
||||
else
|
||||
{
|
||||
resultAngle = -M_PI + ( resultAngle - M_PI );
|
||||
}
|
||||
}
|
||||
|
||||
//show angle in dialog
|
||||
if ( !mResultDisplay )
|
||||
{
|
||||
mResultDisplay = new QgsDisplayAngle( mCanvas->topLevelWidget() );
|
||||
QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
|
||||
mResultDisplay->move( e->pos() - QPoint( 100, 100 ) );
|
||||
}
|
||||
mResultDisplay->show();
|
||||
mResultDisplay->setValueInRadians( resultAngle );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::canvasReleaseEvent( QMouseEvent * e )
|
||||
{
|
||||
//add points until we have three
|
||||
if ( mAnglePoints.size() == 3 )
|
||||
{
|
||||
mAnglePoints.clear();
|
||||
}
|
||||
|
||||
if ( mAnglePoints.size() < 1 )
|
||||
{
|
||||
createRubberBand();
|
||||
}
|
||||
|
||||
if ( mAnglePoints.size() < 3 )
|
||||
{
|
||||
QgsPoint newPoint = snapPoint( e->pos() );
|
||||
mAnglePoints.push_back( newPoint );
|
||||
mRubberBand->addPoint( newPoint );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::stopMeasuring()
|
||||
{
|
||||
delete mRubberBand;
|
||||
mRubberBand = 0;
|
||||
delete mResultDisplay;
|
||||
mResultDisplay = 0;
|
||||
mAnglePoints.clear();
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::activate()
|
||||
{
|
||||
QgsMapTool::activate();
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::deactivate()
|
||||
{
|
||||
stopMeasuring();
|
||||
QgsMapTool::deactivate();
|
||||
}
|
||||
|
||||
void QgsMapToolMeasureAngle::createRubberBand()
|
||||
{
|
||||
delete mRubberBand;
|
||||
mRubberBand = new QgsRubberBand( mCanvas, false );
|
||||
|
||||
QSettings settings;
|
||||
int myRed = settings.value( "/qgis/default_measure_color_red", 180 ).toInt();
|
||||
int myGreen = settings.value( "/qgis/default_measure_color_green", 180 ).toInt();
|
||||
int myBlue = settings.value( "/qgis/default_measure_color_blue", 180 ).toInt();
|
||||
mRubberBand->setColor( QColor( myRed, myGreen, myBlue ) );
|
||||
}
|
||||
|
||||
QgsPoint QgsMapToolMeasureAngle::snapPoint( const QPoint& p )
|
||||
{
|
||||
QList<QgsSnappingResult> snappingResults;
|
||||
if ( mSnapper.snapToBackgroundLayers( p, snappingResults ) != 0 || snappingResults.size() < 1 )
|
||||
{
|
||||
return mCanvas->getCoordinateTransform()->toMapCoordinates( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
return snappingResults.constBegin()->snappedVertex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
64
src/app/qgsmaptoolmeasureangle.h
Normal file
64
src/app/qgsmaptoolmeasureangle.h
Normal file
@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
qgsmaptoolmeasureangle.h
|
||||
------------------------
|
||||
begin : December 2009
|
||||
copyright : (C) 2009 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSMAPTOOLMEASUREANGLE_H
|
||||
#define QGSMAPTOOLMEASUREANGLE_H
|
||||
|
||||
#include "qgsmaptool.h"
|
||||
#include "qgsmapcanvassnapper.h"
|
||||
#include "qgspoint.h"
|
||||
|
||||
class QgsDisplayAngle;
|
||||
class QgsRubberBand;
|
||||
|
||||
/**Map tool to measure angle between two segments*/
|
||||
class QgsMapToolMeasureAngle: public QgsMapTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsMapToolMeasureAngle( QgsMapCanvas* canvas );
|
||||
~QgsMapToolMeasureAngle();
|
||||
|
||||
//! Mouse move event for overriding
|
||||
void canvasMoveEvent( QMouseEvent * e );
|
||||
|
||||
//! Mouse release event for overriding
|
||||
void canvasReleaseEvent( QMouseEvent * e );
|
||||
|
||||
//! called when set as currently active map tool
|
||||
void activate();
|
||||
|
||||
//! called when map tool is being deactivated
|
||||
void deactivate();
|
||||
|
||||
private:
|
||||
/**Points defining the angle (three for measuring)*/
|
||||
QList<QgsPoint> mAnglePoints;
|
||||
QgsRubberBand* mRubberBand;
|
||||
QgsDisplayAngle* mResultDisplay;
|
||||
QgsMapCanvasSnapper mSnapper;
|
||||
|
||||
/**Creates a new rubber band and deletes the old one*/
|
||||
void createRubberBand();
|
||||
/**Snaps point to background layers*/
|
||||
QgsPoint snapPoint( const QPoint& p );
|
||||
|
||||
private slots:
|
||||
/**Deletes the rubber band and the dialog*/
|
||||
void stopMeasuring();
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSMAPTOOLMEASUREANGLE_H
|
@ -151,6 +151,25 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
||||
radMeters->setChecked( true );
|
||||
}
|
||||
|
||||
QButtonGroup* angleButtonGroup = new QButtonGroup( this );
|
||||
angleButtonGroup->addButton( mDegreesRadioButton );
|
||||
angleButtonGroup->addButton( mRadiansRadioButton );
|
||||
angleButtonGroup->addButton( mGonRadioButton );
|
||||
|
||||
QString myAngleUnitsTxt = settings.value( "/qgis/measure/angleunits", "degrees" ).toString();
|
||||
if ( myAngleUnitsTxt == "gon" )
|
||||
{
|
||||
mGonRadioButton->setChecked( true );
|
||||
}
|
||||
else if ( myAngleUnitsTxt == "radians" )
|
||||
{
|
||||
mRadiansRadioButton->setChecked( true );
|
||||
}
|
||||
else //degrees
|
||||
{
|
||||
mDegreesRadioButton->setChecked( true );
|
||||
}
|
||||
|
||||
|
||||
// add the themes to the combo box on the option dialog
|
||||
QDir myThemeDir( ":/images/themes/" );
|
||||
@ -500,6 +519,23 @@ void QgsOptions::saveOptions()
|
||||
settings.setValue( "/qgis/measure/displayunits", "meters" );
|
||||
}
|
||||
settings.setValue( "/qgis/measure/ellipsoid", getEllipsoidAcronym( cmbEllipsoid->currentText() ) );
|
||||
|
||||
if ( mDegreesRadioButton->isChecked() )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString angleUnitString = "degrees";
|
||||
if ( mRadiansRadioButton->isChecked() )
|
||||
{
|
||||
angleUnitString = "radians";
|
||||
}
|
||||
else if ( mGonRadioButton->isChecked() )
|
||||
{
|
||||
angleUnitString = "gon";
|
||||
}
|
||||
settings.setValue( "/qgis/measure/angleunits", angleUnitString );
|
||||
|
||||
//set the color for selections
|
||||
QColor myColor = pbnSelectionColor->color();
|
||||
settings.setValue( "/qgis/default_selection_color_red", myColor.red() );
|
||||
|
@ -434,14 +434,21 @@ double QgsDistanceArea::measurePolygon( const QList<QgsPoint>& points )
|
||||
double QgsDistanceArea::bearing( const QgsPoint& p1, const QgsPoint& p2 )
|
||||
{
|
||||
QgsPoint pp1 = p1, pp2 = p2;
|
||||
double bearing;
|
||||
|
||||
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
|
||||
{
|
||||
pp1 = mCoordTransform->transform( p1 );
|
||||
pp2 = mCoordTransform->transform( p2 );
|
||||
computeDistanceBearing( pp1, pp2, &bearing );
|
||||
}
|
||||
else //compute simple planar azimuth
|
||||
{
|
||||
double dx = p2.x() - p1.x();
|
||||
double dy = p2.y() - p1.y();
|
||||
bearing = atan2( dx, dy );
|
||||
}
|
||||
|
||||
double bearing;
|
||||
computeDistanceBearing( pp1, pp2, &bearing );
|
||||
return bearing;
|
||||
}
|
||||
|
||||
|
84
src/ui/qgsdisplayanglebase.ui
Normal file
84
src/ui/qgsdisplayanglebase.ui
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsDisplayAngleBase</class>
|
||||
<widget class="QDialog" name="QgsDisplayAngleBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>276</width>
|
||||
<height>78</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Angle</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="mAngleLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>129</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QgsDisplayAngleBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QgsDisplayAngleBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -374,10 +374,170 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="stackedWidgetPage3">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Identify</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string><b>Note:</b> Specify the search radius as a percentage of the map width</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel1_3">
|
||||
<property name="text">
|
||||
<string>Search radius for identifying features and displaying map tips</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cmbIdentifyMode"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbxAutoFeatureForm">
|
||||
<property name="text">
|
||||
<string>Open feature form, if a single feature is identified</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Measure tool</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1_8">
|
||||
<property name="text">
|
||||
<string>Ellipsoid for distance calculations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cmbEllipsoid"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel1_10">
|
||||
<property name="text">
|
||||
<string>Rubberband color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QgsColorButton" name="pbnMeasureColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel1_11">
|
||||
<property name="text">
|
||||
<string>Preferred measurements units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="radMeters">
|
||||
<property name="text">
|
||||
<string>Meters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="radFeet">
|
||||
<property name="text">
|
||||
<string>Feet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="mAngleUnitsLabel">
|
||||
<property name="text">
|
||||
<string>Preferred angle units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QRadioButton" name="mDegreesRadioButton">
|
||||
<property name="text">
|
||||
<string>Degrees</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QRadioButton" name="mRadiansRadioButton">
|
||||
<property name="text">
|
||||
<string>Radians</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QRadioButton" name="mGonRadioButton">
|
||||
<property name="text">
|
||||
<string>Gon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="title">
|
||||
@ -441,68 +601,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>Identify</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string><b>Note:</b> Specify the search radius as a percentage of the map width</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel1_3">
|
||||
<property name="text">
|
||||
<string>Search radius for identifying features and displaying map tips</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cmbIdentifyMode"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbxAutoFeatureForm">
|
||||
<property name="text">
|
||||
<string>Open feature form, if a single feature is identified</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
@ -516,82 +614,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Measure tool</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item row="1" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QgsColorButton" name="pbnMeasureColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="cmbEllipsoid"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel1_10">
|
||||
<property name="text">
|
||||
<string>Rubberband color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1_8">
|
||||
<property name="text">
|
||||
<string>Ellipsoid for distance calculations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel1_11">
|
||||
<property name="text">
|
||||
<string>Preferred measurements units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="radMeters">
|
||||
<property name="text">
|
||||
<string>Meters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="radFeet">
|
||||
<property name="text">
|
||||
<string>Feet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="stackedWidgetPage4">
|
||||
@ -1470,8 +1492,8 @@
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>186</x>
|
||||
<y>574</y>
|
||||
<x>190</x>
|
||||
<y>532</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>730</x>
|
||||
@ -1486,8 +1508,8 @@
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>186</x>
|
||||
<y>574</y>
|
||||
<x>190</x>
|
||||
<y>532</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>731</x>
|
||||
@ -1502,12 +1524,12 @@
|
||||
<slot>setCurrentIndex(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>136</x>
|
||||
<y>21</y>
|
||||
<x>113</x>
|
||||
<y>25</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>864</x>
|
||||
<y>14</y>
|
||||
<x>808</x>
|
||||
<y>18</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
Loading…
x
Reference in New Issue
Block a user