measure_angle.diff

path for measure angle tool. - Sergey Yakushev, 2011-06-09 11:40 PM

Download (4.28 KB)

View differences:

src/app/qgsmaptoolmeasureangle.cpp
45 45
  mRubberBand->movePoint( point );
46 46
  if ( mAnglePoints.size() == 2 )
47 47
  {
48
    if ( !mResultDisplay )
48
    if ( !mResultDisplay->isVisible() )
49 49
    {
50
      mResultDisplay = new QgsDisplayAngle( mCanvas->topLevelWidget() );
51
      QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
52
      QObject::connect( mResultDisplay, SIGNAL( changeProjectionEnabledState() ),
53
                        this, SLOT( changeProjectionEnabledState() ) );
54 50
      mResultDisplay->move( e->pos() - QPoint( 100, 100 ) );
51
      mResultDisplay->show();
55 52
    }
56
    mResultDisplay->show();
57

  
58
    QgsDistanceArea myDa;
59
    configureDistanceArea( myDa );
60 53

  
61 54
    //angle calculation
62
    double azimuthOne = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
63
    double azimuthTwo = myDa.bearing( mAnglePoints.at( 1 ), point );
55
    double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
56
    double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), point );
64 57
    double resultAngle = azimuthTwo - azimuthOne;
65 58
    QgsDebugMsg( QString::number( qAbs( resultAngle ) ) );
66 59
    QgsDebugMsg( QString::number( M_PI ) );
......
90 83

  
91 84
  if ( mAnglePoints.size() < 1 )
92 85
  {
86
    if ( mResultDisplay == NULL )
87
    {
88
      mResultDisplay = new QgsDisplayAngle( mCanvas->topLevelWidget() );
89
      QObject::connect( mResultDisplay, SIGNAL( rejected() ), this, SLOT( stopMeasuring() ) );
90
      QObject::connect( mResultDisplay, SIGNAL( changeProjectionEnabledState() ),
91
                        this, SLOT( changeProjectionEnabledState() ) );
92
    }
93
    configureDistanceArea();
93 94
    createRubberBand();
94 95
  }
95 96

  
......
153 154
  if ( !mResultDisplay )
154 155
    return;
155 156

  
156
  QgsDistanceArea myDa;
157
  configureDistanceArea( myDa );
157
  configureDistanceArea();
158 158

  
159 159
  //angle calculation
160
  double azimuthOne = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
161
  double azimuthTwo = myDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) );
160
  double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
161
  double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) );
162 162
  double resultAngle = azimuthTwo - azimuthOne;
163 163
  QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
164 164
  QgsDebugMsg( QString::number( M_PI ) );
......
177 177

  
178 178
}
179 179

  
180
void QgsMapToolMeasureAngle::configureDistanceArea( QgsDistanceArea& da )
180
void QgsMapToolMeasureAngle::configureDistanceArea()
181 181
{
182 182
  QSettings settings;
183 183
  QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
184
  da.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
185
  da.setEllipsoid( ellipsoidId );
186
  da.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
184
  mDa.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
185
  mDa.setEllipsoid( ellipsoidId );
186
  mDa.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
187 187
}
188 188

  
189 189

  
src/app/qgsmaptoolmeasureangle.h
19 19
#include "qgsmaptool.h"
20 20
#include "qgsmapcanvassnapper.h"
21 21
#include "qgspoint.h"
22
#include "qgsdistancearea.h"
22 23

  
23 24
class QgsDisplayAngle;
24 25
class QgsRubberBand;
......
54 55
    void createRubberBand();
55 56
    /**Snaps point to background layers*/
56 57
    QgsPoint snapPoint( const QPoint& p );
58
    
59
    /** tool for measuring */
60
    QgsDistanceArea mDa;
57 61

  
58 62
  private slots:
59 63
    /**Deletes the rubber band and the dialog*/
......
63 67
    void changeProjectionEnabledState();
64 68

  
65 69
    //! Configures distance area objects with ellipsoid / output crs
66
    void configureDistanceArea( QgsDistanceArea& da );
70
    void configureDistanceArea();
67 71

  
68 72
};
69 73