~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/gui/qgsmaptoolvertexedit.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
    qgsmaptoolvertexedit.h  - tool for adding, moving, deleting vertices
3
 
    ---------------------
4
 
    begin                : January 2006
5
 
    copyright            : (C) 2006 by Martin Dobias
6
 
    email                : wonder.sk at gmail dot com
7
 
 ***************************************************************************
8
 
 *                                                                         *
9
 
 *   This program is free software; you can redistribute it and/or modify  *
10
 
 *   it under the terms of the GNU General Public License as published by  *
11
 
 *   the Free Software Foundation; either version 2 of the License, or     *
12
 
 *   (at your option) any later version.                                   *
13
 
 *                                                                         *
14
 
 ***************************************************************************/
15
 
/* $Id$ */
16
 
 
17
 
#ifndef QGSMAPTOOLVERTEXEDIT_H
18
 
#define QGSMAPTOOLVERTEXEDIT_H
19
 
 
20
 
#include "qgsmaptool.h"
21
 
#include "qgsgeometry.h"
22
 
 
23
 
class QgsRubberBand;
24
 
class QgsVertexMarker;
25
 
 
26
 
class QgsMapToolVertexEdit : public QgsMapTool
27
 
{
28
 
  public:
29
 
  
30
 
    enum Tool
31
 
    {
32
 
      AddVertex,
33
 
      MoveVertex,
34
 
      DeleteVertex
35
 
    };
36
 
  
37
 
    //! constructor
38
 
    QgsMapToolVertexEdit(QgsMapCanvas* canvas, enum Tool tool);
39
 
 
40
 
    virtual ~QgsMapToolVertexEdit();
41
 
    
42
 
    //! Overridden mouse move event
43
 
    virtual void canvasMoveEvent(QMouseEvent * e);
44
 
  
45
 
    //! Overridden mouse press event
46
 
    virtual void canvasPressEvent(QMouseEvent * e);
47
 
  
48
 
    //! Overridden mouse release event
49
 
    virtual void canvasReleaseEvent(QMouseEvent * e);
50
 
 
51
 
    //! called when map tool is being deactivated
52
 
    virtual void deactivate();
53
 
 
54
 
  private:
55
 
    
56
 
    //! create instance of rubber band - done when the mouse is pressed down
57
 
    void createRubberBand();
58
 
 
59
 
    //! delete instance of rubber band - done when the mouse is released
60
 
    void deleteRubberBand();
61
 
 
62
 
    //! returns tolerance in map coordinates
63
 
    double tolerance();
64
 
 
65
 
    /** Helper function to inverse project a point if projections
66
 
        are enabled. Failsafe, returns the sent point if anything fails.
67
 
        @whenmsg is a part fo the error message. */
68
 
    QgsPoint maybeInversePoint(QgsPoint point, const char whenmsg[]);
69
 
    
70
 
    //! current vertex edit tool
71
 
    enum Tool mTool;
72
 
    
73
 
    /**Searches the closest point within the project tolerance and setx  mSnappedAtFeatureId and mSnappedAtVertex*/
74
 
    bool snapVertexWithContext(QgsPoint& point);
75
 
 
76
 
    /** Searches the closest vertex of "geometry" to the given "point" 
77
 
 
78
 
        This is useful when selecting a vertex to move, as the selection process is a two step process:
79
 
 
80
 
        1. Select the closest line segment to the mouse pointer
81
 
             (snapSegmentWithContext()).
82
 
        2. Select the closest vertex on (1)
83
 
             (snpVertexOfSnappedSegment()).
84
 
 
85
 
        Step 1 is needed to disambiguate between two geometries sharing the same vertex.
86
 
     */
87
 
    bool snapVertexOfSnappedSegment(QgsPoint& point);
88
 
 
89
 
    /**Snaps a point (without setting mSnappedAtFeatureId and mSnappedAtVertex). Does not snap to the specified vertex,
90
 
     because during dragging, a vertex should not be snapped to itself*/
91
 
    bool snapVertex(QgsPoint& point, int exclFeatureId, int exclVertexNr);
92
 
 
93
 
 
94
 
    bool snapSegmentWithContext(QgsPoint& point);
95
 
 
96
 
 
97
 
    //! The snapped-to segment before this vertex number (identifying the vertex that is being moved)
98
 
    QgsGeometryVertexIndex mSnappedAtVertex;
99
 
 
100
 
    /**The index of the first rubber band point (to connect to mSnappedatVertex). -1 if no such point exists*/
101
 
    int mRubberBandIndex1;
102
 
 
103
 
    /**The index of the second rubber band point (to connect to mSnappedatVertex). -1 if no such point exists*/
104
 
    int mRubberBandIndex2;
105
 
 
106
 
    //! The snapped-to segment before this vertex number (identifying the segment that a new vertex is being added to)
107
 
    QgsGeometryVertexIndex mSnappedBeforeVertex;
108
 
 
109
 
    //! The snapped-to feature ID
110
 
    int mSnappedAtFeatureId;
111
 
 
112
 
    //! The snapped-to geometry
113
 
    QgsGeometry mSnappedAtGeometry;
114
 
    
115
 
    QgsRubberBand* mRubberBand;
116
 
    
117
 
    bool mStartPointValid;
118
 
    bool mStopPointValid;
119
 
    
120
 
    QgsVertexMarker* mCross;
121
 
 
122
 
};
123
 
 
124
 
#endif