select_tools_core.diff

Jeremy Palmer, 2010-08-11 10:14 PM

Download (75.1 KB)

View differences:

images/images.qrc (working copy)
193 193
    <file>themes/default/mActionSaveMapAsImage.png</file>
194 194
    <file>themes/default/mActionScaleBar.png</file>
195 195
    <file>themes/default/mActionSelect.png</file>
196
    <file>themes/default/mActionSelectRectangle.png</file>
197
    <file>themes/default/mActionSelectFreehand.png</file>
198
    <file>themes/default/mActionSelectPolygon.png</file>
199
    <file>themes/default/mActionSelectRadius.png</file>
196 200
    <file>themes/default/mActionSelectedToTop.png</file>
197 201
    <file>themes/default/mActionSelectPan.png</file>
198 202
    <file>themes/default/mActionShowAllLayers.png</file>
images/themes/default/selectTools.svg (revision 0)
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<!-- Created with Inkscape (http://www.inkscape.org/) -->
3

  
4
<svg
5
   xmlns:dc="http://purl.org/dc/elements/1.1/"
6
   xmlns:cc="http://creativecommons.org/ns#"
7
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
   xmlns:svg="http://www.w3.org/2000/svg"
9
   xmlns="http://www.w3.org/2000/svg"
10
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
   width="128"
13
   height="128"
14
   id="svg2"
15
   sodipodi:version="0.32"
16
   inkscape:version="0.47 r22583"
17
   sodipodi:docname="selectTools.svg"
18
   inkscape:export-filename="C:\Dev\SPI\QGIS\qgis_linz\images\themes\default\mActionDeselectAll.png"
19
   inkscape:export-xdpi="22.5"
20
   inkscape:export-ydpi="22.5"
21
   inkscape:output_extension="org.inkscape.output.svg.inkscape"
22
   version="1.0"
23
   style="display:inline">
24
  <defs
25
     id="defs4">
26
    <inkscape:perspective
27
       sodipodi:type="inkscape:persp3d"
28
       inkscape:vp_x="0 : 64 : 1"
29
       inkscape:vp_y="0 : 1000 : 0"
30
       inkscape:vp_z="128 : 64 : 1"
31
       inkscape:persp3d-origin="64 : 42.666667 : 1"
32
       id="perspective3673" />
33
    <inkscape:perspective
34
       id="perspective3683"
35
       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
36
       inkscape:vp_z="1 : 0.5 : 1"
37
       inkscape:vp_y="0 : 1000 : 0"
38
       inkscape:vp_x="0 : 0.5 : 1"
39
       sodipodi:type="inkscape:persp3d" />
40
    <inkscape:perspective
41
       id="perspective3632"
42
       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
43
       inkscape:vp_z="1 : 0.5 : 1"
44
       inkscape:vp_y="0 : 1000 : 0"
45
       inkscape:vp_x="0 : 0.5 : 1"
46
       sodipodi:type="inkscape:persp3d" />
47
    <inkscape:perspective
48
       id="perspective2849"
49
       inkscape:persp3d-origin="200 : 133.33333 : 1"
50
       inkscape:vp_z="400 : 200 : 1"
51
       inkscape:vp_y="0 : 1000 : 0"
52
       inkscape:vp_x="0 : 200 : 1"
53
       sodipodi:type="inkscape:persp3d" />
54
    <inkscape:perspective
55
       id="perspective2862"
56
       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
57
       inkscape:vp_z="1 : 0.5 : 1"
58
       inkscape:vp_y="0 : 1000 : 0"
59
       inkscape:vp_x="0 : 0.5 : 1"
60
       sodipodi:type="inkscape:persp3d" />
61
  </defs>
62
  <sodipodi:namedview
63
     id="base"
64
     pagecolor="#ffffff"
65
     bordercolor="#666666"
66
     borderopacity="1.0"
67
     inkscape:pageopacity="0.0"
68
     inkscape:pageshadow="2"
69
     inkscape:zoom="1.0689466"
70
     inkscape:cx="87.337091"
71
     inkscape:cy="28.491338"
72
     inkscape:document-units="px"
73
     inkscape:current-layer="layer3"
74
     inkscape:window-width="1920"
75
     inkscape:window-height="1181"
76
     inkscape:window-x="1916"
77
     inkscape:window-y="-4"
78
     showgrid="false"
79
     showguides="false"
80
     inkscape:guide-bbox="true"
81
     inkscape:window-maximized="1"
82
     inkscape:snap-bbox="false">
83
    <sodipodi:guide
84
       orientation="0,1"
85
       position="72.98243,80.487715"
86
       id="guide3475" />
87
    <sodipodi:guide
88
       orientation="1,0"
89
       position="8.7993001,105.5916"
90
       id="guide3477" />
91
    <sodipodi:guide
92
       orientation="1,0"
93
       position="119.04935,94.721877"
94
       id="guide3479" />
95
    <sodipodi:guide
96
       orientation="0,1"
97
       position="62.889115,99.121527"
98
       id="guide3481" />
99
    <sodipodi:guide
100
       orientation="0,1"
101
       position="16.045782,34.161988"
102
       id="guide3483" />
103
  </sodipodi:namedview>
104
  <metadata
105
     id="metadata7">
106
    <rdf:RDF>
107
      <cc:Work
108
         rdf:about="">
109
        <dc:format>image/svg+xml</dc:format>
110
        <dc:type
111
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
112
        <dc:title></dc:title>
113
      </cc:Work>
114
    </rdf:RDF>
115
  </metadata>
116
  <g
117
     inkscape:groupmode="layer"
118
     id="layer18"
119
     inkscape:label="geometry"
120
     style="display:inline">
121
    <path
122
       sodipodi:nodetypes="cccccccccccccc"
123
       id="path3651"
124
       d="m 19.779996,17.509313 c -3.532055,4.322031 -7.342958,7.665491 -10.5961677,12.966093 -2.2307708,7.828585 3.0673117,23.241111 2.5096197,27.889335 1.022437,9.867278 -7.9935995,28.786358 -4.461544,35.473271 5.298083,6.442268 19.519255,13.373828 32.625039,14.189308 14.592967,-0.0815 26.676315,-0.89702 37.086584,-3.91428 12.362197,-6.279184 26.397473,-10.356568 37.086593,-18.837539 5.76282,-8.480967 0.92948,-16.961934 1.39422,-25.442901 1.20834,-9.622635 8.27245,-19.245272 3.62501,-28.867907 C 112.26408,22.483725 104.92113,16.204548 96.183935,12.127161 87.632642,9.7622757 80.75443,5.9295309 70.530057,5.0325056 59.469147,5.6848874 53.148627,6.5819127 49.61657,11.148587 c -5.018489,4.879529 -13.661982,2.909048 -20.632396,4.608214 -3.068059,0.584171 -1.953421,-0.788805 -9.204178,1.752512 z"
125
       style="fill:#f9f5aa;fill-opacity:1;fill-rule:evenodd;stroke:#f7ff0e;stroke-width:9.08285809;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0" />
126
  </g>
127
  <g
128
     inkscape:groupmode="layer"
129
     id="layer2"
130
     inkscape:label="polygon"
131
     style="display:none">
132
    <path
133
       style="fill:none;stroke:#000000;stroke-width:4.5527215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:9.10544312, 4.55272156;stroke-dashoffset:0.91054431;marker-start:none"
134
       d="m 17.47589,31.218672 0,56.625225 82.65304,0 0,-34.88518 L 58.279291,7.9618805 17.47589,31.218672 z"
135
       id="path3739"
136
       sodipodi:nodetypes="cccccc" />
137
  </g>
138
  <g
139
     style="display:none"
140
     inkscape:label="rectangle"
141
     id="g3353"
142
     inkscape:groupmode="layer">
143
    <rect
144
       ry="4.2915325"
145
       rx="3.7192686"
146
       y="18.580549"
147
       x="20.102806"
148
       height="66.669243"
149
       width="70.849724"
150
       id="rect3357"
151
       style="fill:none;stroke:#000000;stroke-width:4.85300016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:14.559, 4.853;stroke-dashoffset:0" />
152
  </g>
153
  <g
154
     inkscape:groupmode="layer"
155
     id="layer4"
156
     inkscape:label="freehand"
157
     style="display:none">
158
    <path
159
       style="fill:none;stroke:#000000;stroke-width:4.85300016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:14.55900049, 4.85300016;stroke-dashoffset:0"
160
       d="m 65.631777,19.622757 c 3.372249,2.334854 6.798968,4.534261 9.6239,7.493861 3.548394,1.422469 6.188971,4.211435 9.151571,6.404982 2.26531,2.776805 4.907746,5.034247 6.784489,7.925865 3.159939,2.920266 2.011006,6.867562 -0.715179,9.631059 -2.126962,2.305245 -4.955287,3.74761 -8.125686,4.296975 -3.456502,0.706393 -6.916555,1.400855 -10.371803,2.108626 -2.053947,3.955867 -6.051049,7.653779 -5.629434,12.251329 0.467619,3.008031 1.223448,6.242605 0.136154,9.094395 0.407152,1.920461 -1.049349,5.429071 -3.496388,7.483144 -1.754341,0.327918 -7.289292,1.888569 -4.324372,1.828724 -3.127392,1.409414 -6.690985,1.603867 -10.026642,2.438953 -2.480112,0.479602 -4.947038,1.045241 -7.425489,1.509628 -3.607438,-0.677375 -7.892266,-0.579686 -9.408378,-4.843976 -2.134562,-2.261195 -3.150972,-5.044904 -4.003804,-7.910423 -1.013951,-3.096434 -0.04344,-6.390682 1.873569,-8.917917 2.811686,-2.178519 4.140031,-4.626929 5.476315,-8.14662 0.913521,-3.585631 -0.937579,-7.955511 -5.086237,-8.416383 -3.61114,-1.462893 -7.894018,-2.302632 -11.360052,-4.460891 -3.650399,-0.479435 -4.921101,-5.047635 -6.712353,-8.065664 -0.433468,-3.055139 -1.705333,-6.09 -1.535071,-9.142397 -0.4963948,-4.45055 2.458202,-6.675362 4.551653,-9.909291 3.013664,-3.080159 6.001773,-6.96011 10.451694,-7.848464 2.041769,-3.03077 5.891971,-3.511097 9.383844,-4.07197 2.365637,-0.298342 4.728099,-1.3569002 7.079018,-1.11044 3.713249,0.1535691 7.338273,2.214335 11.000028,3.581469 3.286492,2.625264 7.499402,2.579901 10.852758,5.636778 0.619669,0.384552 1.238165,0.770994 1.855895,1.158648 z"
161
       id="path2835" />
162
  </g>
163
  <g
164
     inkscape:groupmode="layer"
165
     id="layer1"
166
     inkscape:label="circle"
167
     style="display:none">
168
    <path
169
       sodipodi:type="arc"
170
       style="fill:none;stroke:#000000;stroke-width:4.3162117;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:12.9486357, 4.3162119;stroke-dashoffset:0;display:inline"
171
       id="path3711"
172
       sodipodi:cx="12.41272"
173
       sodipodi:cy="10.343482"
174
       sodipodi:rx="37.168804"
175
       sodipodi:ry="37.168804"
176
       d="m 49.581524,10.343482 a 37.168804,37.168804 0 1 1 -74.337608,0 37.168804,37.168804 0 1 1 74.337608,0 z"
177
       transform="matrix(0.98001475,0,0,0.98001475,41.225852,38.703496)" />
178
  </g>
179
  <g
180
     inkscape:groupmode="layer"
181
     id="layer3"
182
     inkscape:label="deselect"
183
     style="display:inline">
184
    <path
185
       style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:1.49048018;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
186
       d="M 29.698339,52.423481 C 16.051712,52.698413 3.7408429,65.048573 4.6081639,78.953941 4.8817259,94.332694 20.485443,106.38102 35.480351,103.75189 49.274567,102.24135 60.320488,88.247365 57.669083,74.382603 55.631983,61.225586 42.881728,51.610763 29.698339,52.423481 z m 1.440284,7.723266 c 4.459556,-0.06984 8.968478,1.410814 12.419846,4.237359 -9.818417,7.003216 -19.85089,14.970704 -29.536271,21.374658 -4.7651221,-9.524832 1.348854,-21.773355 11.292666,-24.651827 1.880027,-0.607635 3.849567,-0.917354 5.823759,-0.96019 z m 17.408658,10.645582 c 5.037209,10.044615 -2.047165,22.890788 -12.83732,24.985806 -5.71851,1.360445 -11.98502,0.0904 -16.552835,-3.611148 9.772879,-7.044573 19.727298,-14.730417 29.390155,-21.374658 z"
187
       id="path2834" />
188
  </g>
189
  <g
190
     inkscape:groupmode="layer"
191
     id="layer5"
192
     inkscape:label="single"
193
     style="display:none">
194
    <path
195
       id="path1875"
196
       style="fill:none;stroke:#414141;stroke-width:5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
197
       d="m 54.856583,17.189923 4.11214,11.11022 10.36977,-5.8817 -3.99191,11.15397 11.72465,2.15947 -10.2281,5.97866 7.59343,9.1902 -11.67845,-1.99414 -0.0908,11.920741 -7.66432,-9.033851 -7.7326,9.073431 -0.064,-11.846531 -11.7562,1.98056 7.5663,-9.11608 -10.27893,-6.03903 11.65623,-2.12013 -3.99205,-11.23289 10.29207,5.86787 4.16277,-11.17077 z" />
198
  </g>
199
  <g
200
     style="display:inline"
201
     inkscape:label="cursor"
202
     id="g3343"
203
     inkscape:groupmode="layer">
204
    <path
205
       inkscape:export-filename="/Users/tim/dev/cpp/qgis/images/themes/default/mActionSelect.png"
206
       inkscape:export-ydpi="21.652922"
207
       inkscape:export-xdpi="21.652922"
208
       sodipodi:nodetypes="cccccccc"
209
       id="path3349"
210
       d="M 65.601843,106.16511 53.904423,35.587576 118.53385,75.098555 94.614817,82.168858 120.52875,117.31634 108.41356,126.20813 83.079984,89.636153 65.601843,106.16511 z"
211
       style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.87363958;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" />
212
    <path
213
       inkscape:export-ydpi="21.652922"
214
       inkscape:export-xdpi="21.652922"
215
       sodipodi:nodetypes="cccccccc"
216
       id="path3351"
217
       d="M 65.469806,103.68103 54.660978,36.602094 114.38086,74.154478 92.278819,80.874298 116.22422,114.27949 105.02935,122.73052 81.620226,87.971433 65.469806,103.68103 z"
218
       style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#414141;stroke-width:3.63013959;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
219
  </g>
220
</svg>
python/gui/qgisinterface.sip (working copy)
193 193
    virtual QAction *actionZoomIn() = 0;
194 194
    virtual QAction *actionZoomOut() = 0;
195 195
    virtual QAction *actionSelect() = 0;
196
    virtual QAction *actionSelectRectangle() = 0;
197
    virtual QAction *actionSelectPolygon() = 0;
198
    virtual QAction *actionSelectFreehand() = 0;
199
    virtual QAction *actionSelectRadius() = 0;
196 200
    virtual QAction *actionIdentify() = 0;
197 201
    virtual QAction *actionMeasure() = 0;
198 202
    virtual QAction *actionMeasureArea() = 0;
python/gui/qgsrubberband.sip (working copy)
57 57

  
58 58
    /**Return vertex*/
59 59
    const QgsPoint *getPoint(int i, int j=0) const;
60
    
61
    /**Returns the rubberband as a Geometry.
62
    * added in 1.5 */
63
    QgsGeometry* asGeometry();
60 64

  
61 65
  protected:
62 66
    virtual void paint(QPainter* p);
src/app/CMakeLists.txt (working copy)
46 46
  qgsmaptoolreshape.cpp
47 47
  qgsmaptoolrotatepointsymbols.cpp
48 48
  qgsmaptoolselect.cpp
49
  qgsmaptoolselectrectangle.cpp
50
  qgsmaptoolselectfreehand.cpp
51
  qgsmaptoolselectpolygon.cpp
52
  qgsmaptoolselectradius.cpp
53
  qgsmaptoolselectutils.cpp
49 54
  qgsmaptoolsimplify.cpp
50 55
  qgsmaptoolsplitfeatures.cpp
51 56
  qgsmaptooltextannotation.cpp
......
158 163
  qgsmaptoolreshape.h
159 164
  qgsmaptoolrotatepointsymbols.h
160 165
  qgsmaptoolselect.h
166
  qgsmaptoolselectrectangle.h
167
  qgsmaptoolselectfreehand.h
168
  qgsmaptoolselectpolygon.h
169
  qgsmaptoolselectradius.h
170
  qgsmaptoolselectutils.h
161 171
  qgsmaptooladdvertex.h
162 172
  qgsmaptooldeletering.h
163 173
  qgsmaptooldeletepart.h
src/app/qgisapp.cpp (working copy)
199 199
#include "qgsmaptoolnodetool.h"
200 200
#include "qgsmaptoolpan.h"
201 201
#include "qgsmaptoolselect.h"
202
#include "qgsmaptoolselectrectangle.h"
203
#include "qgsmaptoolselectfreehand.h"
204
#include "qgsmaptoolselectpolygon.h"
205
#include "qgsmaptoolselectradius.h"
202 206
#include "qgsmaptoolreshape.h"
203 207
#include "qgsmaptoolrotatepointsymbols.h"
204 208
#include "qgsmaptoolsplitfeatures.h"
......
551 555
  delete mMapTools.mReshapeFeatures;
552 556
  delete mMapTools.mSplitFeatures;
553 557
  delete mMapTools.mSelect;
558
  delete mMapTools.mSelectRectangle;
559
  delete mMapTools.mSelectPolygon;
560
  delete mMapTools.mSelectFreehand;
561
  delete mMapTools.mSelectRadius;
554 562

  
555 563
#if 0 //these three tools to be deprecated - use node tool rather
556 564
  delete mMapTools.mVertexAdd;
......
869 877
  connect( mActionSelect, SIGNAL( triggered() ), this, SLOT( select() ) );
870 878
  mActionSelect->setEnabled( false );
871 879

  
880
  mActionSelectRectangle = new QAction( getThemeIcon( "mActionSelectRectangle.png" ), tr( "Select features by rectangle" ), this );
881
  shortcuts->registerAction( mActionSelectRectangle );
882
  mActionSelectRectangle->setStatusTip( tr( "Select features by rectangle" ) );
883
  connect( mActionSelectRectangle, SIGNAL( triggered() ), this, SLOT( selectByRectangle() ) );
884
  mActionSelectRectangle->setEnabled( false );
885

  
886
  mActionSelectPolygon = new QAction( getThemeIcon( "mActionSelectPolygon.png" ), tr( "Select features by polygon" ), this );
887
  shortcuts->registerAction( mActionSelectPolygon );
888
  mActionSelectPolygon->setStatusTip( tr( "Select features by polygon" ) );
889
  connect( mActionSelectPolygon, SIGNAL( triggered() ), this, SLOT( selectByPolygon() ) );
890
  mActionSelectPolygon->setEnabled( false );
891

  
892
  mActionSelectFreehand = new QAction( getThemeIcon( "mActionSelectFreehand.png" ), tr( "Select features by freehand" ), this );
893
  shortcuts->registerAction( mActionSelectFreehand );
894
  mActionSelectFreehand->setStatusTip( tr( "Select features by freehand" ) );
895
  connect( mActionSelectFreehand, SIGNAL( triggered() ), this, SLOT( selectByFreehand() ) );
896
  mActionSelectFreehand->setEnabled( false );
897

  
898
  mActionSelectRadius = new QAction( getThemeIcon( "mActionSelectRadius.png" ), tr( "Select features by radius" ), this );
899
  shortcuts->registerAction( mActionSelectRadius );
900
  mActionSelectRadius->setStatusTip( tr( "Select features by radius" ) );
901
  connect( mActionSelectRadius, SIGNAL( triggered() ), this, SLOT( selectByRadius() ) );
902
  mActionSelectRadius->setEnabled( false );
903

  
872 904
  mActionDeselectAll = new QAction( getThemeIcon( "mActionDeselectAll.png" ), tr( "Deselect features from all layers" ), this );
873 905
  shortcuts->registerAction( mActionDeselectAll );
874 906
  mActionDeselectAll->setStatusTip( tr( "Deselect features from all layers" ) );
......
1243 1275
  mMapToolGroup->addAction( mActionIdentify );
1244 1276
  mActionSelect->setCheckable( true );
1245 1277
  mMapToolGroup->addAction( mActionSelect );
1278
  mActionSelectRectangle->setCheckable( true );
1279
  mMapToolGroup->addAction( mActionSelectRectangle );
1280
  mActionSelectPolygon->setCheckable( true );
1281
  mMapToolGroup->addAction( mActionSelectPolygon );
1282
  mActionSelectFreehand->setCheckable( true );
1283
  mMapToolGroup->addAction( mActionSelectFreehand );
1284
  mActionSelectRadius->setCheckable( true );
1285
  mMapToolGroup->addAction( mActionSelectRadius );
1246 1286
  mActionDeselectAll->setCheckable( false );
1247 1287
  mMapToolGroup->addAction( mActionDeselectAll );
1248 1288
  mActionMeasure->setCheckable( true );
......
1408 1448
  mViewMenu->addAction( mActionPan );
1409 1449
  mViewMenu->addAction( mActionZoomIn );
1410 1450
  mViewMenu->addAction( mActionZoomOut );
1451
  mActionViewSeparator1 = mViewMenu->addSeparator();
1411 1452
  mViewMenu->addAction( mActionSelect );
1453
  mViewMenu->addAction( mActionSelectRectangle );
1454
  mViewMenu->addAction( mActionSelectPolygon );
1455
  mViewMenu->addAction( mActionSelectFreehand );
1456
  mViewMenu->addAction( mActionSelectRadius );
1412 1457
  mViewMenu->addAction( mActionDeselectAll );
1458
  mActionViewSeparator2 = mViewMenu->addSeparator();
1413 1459
  mViewMenu->addAction( mActionIdentify );
1414 1460
  mViewMenu->addAction( mActionMeasure );
1415 1461
  mViewMenu->addAction( mActionMeasureArea );
1416 1462
  mViewMenu->addAction( mActionMeasureAngle );
1417
  mActionViewSeparator1 = mViewMenu->addSeparator();
1463
  mActionViewSeparator3 = mViewMenu->addSeparator();
1418 1464

  
1419 1465
  mViewMenu->addAction( mActionZoomFullExtent );
1420 1466
  mViewMenu->addAction( mActionZoomToLayer );
......
1422 1468
  mViewMenu->addAction( mActionZoomLast );
1423 1469
  mViewMenu->addAction( mActionZoomNext );
1424 1470
  mViewMenu->addAction( mActionZoomActualSize );
1425
  mActionViewSeparator2 = mViewMenu->addSeparator();
1471
  mActionViewSeparator4 = mViewMenu->addSeparator();
1426 1472

  
1427 1473
  mViewMenu->addAction( mActionMapTips );
1428 1474
  mViewMenu->addAction( mActionNewBookmark );
......
1431 1477

  
1432 1478
  if ( layout != QDialogButtonBox::KdeLayout )
1433 1479
  {
1434
    mActionViewSeparator3 = mViewMenu->addSeparator();
1480
    mActionViewSeparator5 = mViewMenu->addSeparator();
1435 1481
    mViewMenu->addMenu( mPanelMenu );
1436 1482
    mViewMenu->addMenu( mToolbarMenu );
1437 1483
    mViewMenu->addAction( mActionToggleFullScreen );
......
1638 1684
  mMapNavToolBar->addAction( mActionZoomNext );
1639 1685
  mMapNavToolBar->addAction( mActionDraw );
1640 1686
  mToolbarMenu->addAction( mMapNavToolBar->toggleViewAction() );
1687

  
1641 1688
  //
1689
  // Feature Select Toolbar
1690
  mFeatureSelectToolBar = addToolBar( tr( "Select Tools" ) );
1691
  mFeatureSelectToolBar->setIconSize( myIconSize );
1692
  mFeatureSelectToolBar->setObjectName( "Select Tools" );
1693
  mFeatureSelectToolBar->addAction( mActionIdentify );
1694
  mFeatureSelectToolBar->addAction( mActionSelect );
1695
  mFeatureSelectToolBar->addAction( mActionSelectRectangle );
1696
  mFeatureSelectToolBar->addAction( mActionSelectPolygon );
1697
  mFeatureSelectToolBar->addAction( mActionSelectFreehand );
1698
  mFeatureSelectToolBar->addAction( mActionSelectRadius );
1699
  mFeatureSelectToolBar->addAction( mActionDeselectAll );
1700

  
1701
  //
1642 1702
  // Attributes Toolbar
1643 1703
  mAttributesToolBar = addToolBar( tr( "Attributes" ) );
1644 1704
  mAttributesToolBar->setIconSize( myIconSize );
1645 1705
  mAttributesToolBar->setObjectName( "Attributes" );
1646
  mAttributesToolBar->addAction( mActionIdentify );
1647
  mAttributesToolBar->addAction( mActionSelect );
1648
  mAttributesToolBar->addAction( mActionDeselectAll );
1649 1706
  mAttributesToolBar->addAction( mActionOpenTable );
1650 1707
  mAttributesToolBar->addAction( mActionMeasure );
1651 1708
  mAttributesToolBar->addAction( mActionMeasureArea );
......
1905 1962
  mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
1906 1963
  mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
1907 1964
  mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
1965
  mActionSelectRectangle->setIcon( getThemeIcon( "/mActionSelectRectangle.png" ) );
1966
  mActionSelectPolygon->setIcon( getThemeIcon( "/mActionSelectPolygon.png" ) );
1967
  mActionSelectFreehand->setIcon( getThemeIcon( "/mActionSelectFreehand.png" ) );
1968
  mActionSelectRadius->setIcon( getThemeIcon( "/mActionSelectRadius.png" ) );
1908 1969
  mActionDeselectAll->setIcon( getThemeIcon( "/mActionDeselectAll.png" ) );
1909 1970
  mActionOpenTable->setIcon( getThemeIcon( "/mActionOpenTable.png" ) );
1910 1971
  mActionMeasure->setIcon( getThemeIcon( "/mActionMeasure.png" ) );
......
2039 2100
  mMapTools.mSplitFeatures->setAction( mActionSplitFeatures );
2040 2101
  mMapTools.mSelect = new QgsMapToolSelect( mMapCanvas );
2041 2102
  mMapTools.mSelect->setAction( mActionSelect );
2103
  mMapTools.mSelectRectangle = new QgsMapToolSelectRectangle( mMapCanvas );
2104
  mMapTools.mSelectRectangle->setAction( mActionSelectRectangle );
2105
  mMapTools.mSelectPolygon = new QgsMapToolSelectPolygon( mMapCanvas );
2106
  mMapTools.mSelectPolygon->setAction( mActionSelectPolygon );
2107
  mMapTools.mSelectFreehand = new QgsMapToolSelectFreehand( mMapCanvas );
2108
  mMapTools.mSelectFreehand->setAction( mActionSelectFreehand );
2109
  mMapTools.mSelectRadius = new QgsMapToolSelectRadius( mMapCanvas );
2110
  mMapTools.mSelectRadius->setAction( mActionSelectRadius );
2111

  
2042 2112
#if 0 //these three tools to be deprecated - use node tool rather
2043 2113
  mMapTools.mVertexAdd = new QgsMapToolAddVertex( mMapCanvas );
2044 2114
  mMapTools.mVertexAdd->setAction( mActionAddVertex );
......
4399 4491
  mMapCanvas->setMapTool( mMapTools.mSelect );
4400 4492
}
4401 4493

  
4494
void QgisApp::selectByRectangle()
4495
{
4496
  mMapCanvas->setMapTool( mMapTools.mSelectRectangle );
4497
}
4498

  
4499
void QgisApp::selectByPolygon()
4500
{
4501
  mMapCanvas->setMapTool( mMapTools.mSelectPolygon );
4502
}
4503

  
4504
void QgisApp::selectByFreehand()
4505
{
4506
  mMapCanvas->setMapTool( mMapTools.mSelectFreehand );
4507
}
4508

  
4509
void QgisApp::selectByRadius()
4510
{
4511
  mMapCanvas->setMapTool( mMapTools.mSelectRadius );
4512
}
4513

  
4402 4514
void QgisApp::deselectAll()
4403 4515
{
4404 4516
  if ( !mMapCanvas || mMapCanvas->isDrawing() )
......
5764 5876
  if ( !layer )
5765 5877
  {
5766 5878
    mActionSelect->setEnabled( false );
5879
    mActionSelectRectangle->setEnabled( false );
5880
    mActionSelectPolygon->setEnabled( false );
5881
    mActionSelectFreehand->setEnabled( false );
5882
    mActionSelectRadius->setEnabled( false );
5767 5883
    mActionIdentify->setEnabled( QSettings().value( "/Map/identifyMode", 0 ).toInt() != 0 );
5768 5884
    mActionZoomActualSize->setEnabled( false );
5769 5885
    mActionOpenTable->setEnabled( false );
......
5817 5933
    bool layerHasSelection = vlayer->selectedFeatureCount() != 0;
5818 5934

  
5819 5935
    mActionSelect->setEnabled( true );
5936
    mActionSelectRectangle->setEnabled( true );
5937
    mActionSelectPolygon->setEnabled( true );
5938
    mActionSelectFreehand->setEnabled( true );
5939
    mActionSelectRadius->setEnabled( true );
5820 5940
    mActionIdentify->setEnabled( true );
5821 5941
    mActionZoomActualSize->setEnabled( false );
5822 5942
    mActionOpenTable->setEnabled( true );
......
6036 6156
  {
6037 6157
    mActionLayerSubsetString->setEnabled( false );
6038 6158
    mActionSelect->setEnabled( false );
6159
    mActionSelectRectangle->setEnabled( false );
6160
    mActionSelectPolygon->setEnabled( false );
6161
    mActionSelectFreehand->setEnabled( false );
6162
    mActionSelectRadius->setEnabled( false );
6039 6163
    mActionZoomActualSize->setEnabled( true );
6040 6164
    mActionOpenTable->setEnabled( false );
6041 6165
    mActionToggleEditing->setEnabled( false );
src/app/qgisapp.h (working copy)
244 244
    QAction *actionZoomIn() { return mActionZoomIn; }
245 245
    QAction *actionZoomOut() { return mActionZoomOut; }
246 246
    QAction *actionSelect() { return mActionSelect; }
247
    QAction *actionSelectRectangle() { return mActionSelectRectangle; }
248
    QAction *actionSelectPolygon() { return mActionSelectPolygon; }
249
    QAction *actionSelectFreehand() { return mActionSelectFreehand; }
250
    QAction *actionSelectRadius() { return mActionSelectRadius; }
247 251
    QAction *actionIdentify() { return mActionIdentify; }
248 252
    QAction *actionMeasure() { return mActionMeasure; }
249 253
    QAction *actionMeasureArea() { return mActionMeasureArea; }
......
592 596
    //! activates the selection tool
593 597
    void select();
594 598

  
599
    //! activates the rectangle selection tool
600
    void selectByRectangle();
601

  
602
    //! activates the polygon selection tool
603
    void selectByPolygon();
604

  
605
    //! activates the freehand selection tool
606
    void selectByFreehand();
607

  
608
    //! activates the radius selection tool
609
    void selectByRadius();
610

  
595 611
    //! deselect features from all layers
596 612
    void deselectAll();
597 613

  
......
804 820
    QToolBar *mDigitizeToolBar;
805 821
    QToolBar *mAdvancedDigitizeToolBar;
806 822
    QToolBar *mAttributesToolBar;
823
    QToolBar *mFeatureSelectToolBar;
807 824
    QToolBar *mPluginToolBar;
808 825
    QToolBar *mHelpToolBar;
809 826

  
......
856 873
    QAction *mActionPan;
857 874
    QAction *mActionZoomIn;
858 875
    QAction *mActionZoomOut;
876
    QAction *mActionViewSeparator1;
859 877
    QAction *mActionSelect;
878
    QAction *mActionSelectRectangle;
879
    QAction *mActionSelectPolygon;
880
    QAction *mActionSelectFreehand;
881
    QAction *mActionSelectRadius;
860 882
    QAction *mActionDeselectAll;
883
    QAction *mActionViewSeparator2;
861 884
    QAction *mActionIdentify;
862 885
    QAction *mActionMeasure;
863 886
    QAction *mActionMeasureAngle;
864 887
    QAction *mActionMeasureArea;
865
    QAction *mActionViewSeparator1;
888
    QAction *mActionViewSeparator3;
866 889
    QAction *mActionZoomFullExtent;
867 890
    QAction *mActionZoomToLayer;
868 891
    QAction *mActionZoomToSelected;
869 892
    QAction *mActionZoomLast;
870 893
    QAction *mActionZoomNext;
871 894
    QAction *mActionZoomActualSize;
872
    QAction *mActionViewSeparator2;
895
    QAction *mActionViewSeparator4;
873 896
    QAction *mActionMapTips;
874 897
    QAction *mActionNewBookmark;
875 898
    QAction *mActionShowBookmarks;
876 899
    QAction *mActionDraw;
877
    QAction *mActionViewSeparator3;
900
    QAction *mActionViewSeparator5;
878 901
    QAction *mActionTextAnnotation;
879 902
    QAction *mActionFormAnnotation;
880 903
    QAction *mActionAnnotation;
......
985 1008
        QgsMapTool* mReshapeFeatures;
986 1009
        QgsMapTool* mSplitFeatures;
987 1010
        QgsMapTool* mSelect;
1011
        QgsMapTool* mSelectRectangle;
1012
        QgsMapTool* mSelectPolygon;
1013
        QgsMapTool* mSelectFreehand;
1014
        QgsMapTool* mSelectRadius;
988 1015
        QgsMapTool* mVertexAdd;
989 1016
        QgsMapTool* mVertexMove;
990 1017
        QgsMapTool* mVertexDelete;
src/app/qgisappinterface.cpp (working copy)
285 285
QAction *QgisAppInterface::actionZoomIn() { return qgis->actionZoomIn(); }
286 286
QAction *QgisAppInterface::actionZoomOut() { return qgis->actionZoomOut(); }
287 287
QAction *QgisAppInterface::actionSelect() { return qgis->actionSelect(); }
288
QAction *QgisAppInterface::actionSelectRectangle() { return qgis->actionSelectRectangle(); }
289
QAction *QgisAppInterface::actionSelectPolygon() { return qgis->actionSelectPolygon(); }
290
QAction *QgisAppInterface::actionSelectFreehand() { return qgis->actionSelectFreehand(); }
291
QAction *QgisAppInterface::actionSelectRadius() { return qgis->actionSelectRadius(); }
288 292
QAction *QgisAppInterface::actionIdentify() { return qgis->actionIdentify(); }
289 293
QAction *QgisAppInterface::actionMeasure() { return qgis->actionMeasure(); }
290 294
QAction *QgisAppInterface::actionMeasureArea() { return qgis->actionMeasureArea(); }
src/app/qgisappinterface.h (working copy)
198 198
    virtual QAction *actionZoomIn();
199 199
    virtual QAction *actionZoomOut();
200 200
    virtual QAction *actionSelect();
201
    virtual QAction *actionSelectRectangle();
202
    virtual QAction *actionSelectPolygon();
203
    virtual QAction *actionSelectFreehand();
204
    virtual QAction *actionSelectRadius();
201 205
    virtual QAction *actionIdentify();
202 206
    virtual QAction *actionMeasure();
203 207
    virtual QAction *actionMeasureArea();
src/app/qgsmaptoolselect.cpp (working copy)
1 1
/***************************************************************************
2
    qgsmaptoolselect.cpp  -  map tool for selecting features
2
    qgsmaptoolselect.cpp  -  map tool for selecting features by single click
3 3
    ----------------------
4 4
    begin                : January 2006
5 5
    copyright            : (C) 2006 by Martin Dobias
......
12 12
 *   (at your option) any later version.                                   *
13 13
 *                                                                         *
14 14
 ***************************************************************************/
15
/* $Id: qgsmaptoolselect.cpp 13380 2010-04-25 12:51:49Z jef $ */
15
/* $Id$ */
16 16

  
17

  
17 18
#include "qgsmaptoolselect.h"
19
#include "qgsmaptoolselectutils.h"
20
#include "qgsrubberband.h"
18 21
#include "qgsmapcanvas.h"
19
#include "qgsmaptopixel.h"
20 22
#include "qgsvectorlayer.h"
21
#include "qgscsexception.h"
22
#include "qgscursors.h"
23
#include "qgslogger.h"
23
#include "qgsgeometry.h"
24
#include "qgspoint.h"
24 25
#include "qgis.h"
25 26

  
26
#include <QApplication>
27
#include <QMessageBox>
28 27
#include <QMouseEvent>
29
#include <QRubberBand>
30 28
#include <QRect>
31 29

  
32 30

  
33 31
QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
34
    : QgsMapTool( canvas ), mDragging( false )
32
: QgsMapTool( canvas )
35 33
{
36
  QPixmap mySelectQPixmap = QPixmap(( const char ** ) select_cursor );
37
  mCursor = QCursor( mySelectQPixmap, 1, 1 );
38
  mRubberBand = 0;
34
  mCursor = Qt::ArrowCursor;
39 35
}
40 36

  
41

  
42
void QgsMapToolSelect::canvasPressEvent( QMouseEvent * e )
43
{
44
  mSelectRect.setRect( 0, 0, 0, 0 );
45
}
46

  
47

  
48
void QgsMapToolSelect::canvasMoveEvent( QMouseEvent * e )
49
{
50
  if ( e->buttons() != Qt::LeftButton )
51
    return;
52

  
53
  if ( !mDragging )
54
  {
55
    mDragging = true;
56
    mRubberBand = new QRubberBand( QRubberBand::Rectangle, mCanvas );
57
    mSelectRect.setTopLeft( e->pos() );
58
  }
59

  
60
  mSelectRect.setBottomRight( e->pos() );
61
  mRubberBand->setGeometry( mSelectRect.normalized() );
62
  mRubberBand->show();
63
}
64

  
65

  
66 37
void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
67 38
{
68
  if ( !mCanvas->currentLayer() ||
69
       qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ) == NULL )
39
  QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
40
  if ( vlayer == NULL )
70 41
  {
71
    QMessageBox::warning( mCanvas, tr( "No active layer" ),
72
                          tr( "To select features, you must choose a "
73
                              "vector layer by clicking on its name in the legend"
74
                            ) );
75 42
    return;
76 43
  }
77
  QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
78
  //if the user simply clicked without dragging a rect
79
  //we will fabricate a small 1x1 pix rect and then continue
80
  //as if they had dragged a rect
81
  if ( !mDragging )
82
  {
83
    int boxSize = 0;
84
    if ( vlayer->geometryType() != QGis::Polygon )
85
    {
86
      //if point or line use an artificial bounding box of 10x10 pixels
87
      //to aid the user to click on a feature accurately
88
      boxSize = 5;
89
    }
90
    else
91
    {
92
      //otherwise just use the click point for polys
93
      boxSize = 1;
94
    }
95
    mSelectRect.setLeft( e->pos().x() - boxSize );
96
    mSelectRect.setRight( e->pos().x() + boxSize );
97
    mSelectRect.setTop( e->pos().y() - boxSize );
98
    mSelectRect.setBottom( e->pos().y() + boxSize );
99
  }
100
  else
101
  {
102
    delete mRubberBand;
103
    mRubberBand = 0;
104

  
105
    // Set valid values for rectangle's width and height
106
    if ( mSelectRect.width() == 1 )
107
    {
108
      mSelectRect.setLeft( mSelectRect.left() + 1 );
109
    }
110
    if ( mSelectRect.height() == 1 )
111
    {
112
      mSelectRect.setBottom( mSelectRect.bottom() + 1 );
113
    }
114
  }
115

  
116
  mDragging = false;
117

  
118
  const QgsMapToPixel* transform = mCanvas->getCoordinateTransform();
119
  QgsPoint ll = transform->toMapCoordinates( mSelectRect.left(), mSelectRect.bottom() );
120
  QgsPoint ur = transform->toMapCoordinates( mSelectRect.right(), mSelectRect.top() );
121

  
122
  QgsRectangle search( ll.x(), ll.y(), ur.x(), ur.y() );
123

  
124
  // if Ctrl key is pressed, selected features will be flipped in selection
125
  // instead of removing old selection
126
  bool flip = ( e->modifiers() & Qt::ControlModifier );
127

  
128
  // toLayerCoordinates will throw an exception for an 'invalid' rectangle.
129
  // For example, if you project a world map onto a globe using EPSG 2163
130
  // and then click somewhere off the globe, an exception will be thrown.
131
  try
132
  {
133
    search = toLayerCoordinates( vlayer, search );
134
  }
135
  catch ( QgsCsException &cse )
136
  {
137
    Q_UNUSED( cse );
138
    // catch exception for 'invalid' rectangle and leave existing selection unchanged
139
    QgsLogger::warning( "Caught CRS exception " + QString( __FILE__ ) + ": " + QString::number( __LINE__ ) );
140
    QMessageBox::warning( mCanvas, tr( "CRS Exception" ),
141
                          tr( "Selection extends beyond layer's coordinate system." ) );
142
    return;
143
  }
144

  
145
  QApplication::setOverrideCursor( Qt::WaitCursor );
146
  if ( flip )
147
  {
148
    vlayer->invertSelectionInRectangle( search );
149
  }
150
  else
151
  {
152
    vlayer->select( search, false );
153
  }
154
  QApplication::restoreOverrideCursor();
44
  QgsRubberBand rubberBand( mCanvas, true );
45
  QRect selectRect(0, 0, 0, 0);
46
  QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() );
47
  QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, &rubberBand );
48
  QgsGeometry* selectGeom = rubberBand.asGeometry();
49
  bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
50
  bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
51
  QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, addSelection, substractSelection, true );
52
  delete selectGeom;
53
  rubberBand.reset( true );
155 54
}
src/app/qgsmaptoolselect.h (working copy)
1 1
/***************************************************************************
2
    qgsmaptoolselect.h  -  map tool for selecting features
2
    qgsmaptoolselect.h  -  map tool for selecting features by single click
3 3
    ---------------------
4
    begin                : January 2006
5
    copyright            : (C) 2006 by Martin Dobias
6
    email                : wonder.sk at gmail dot com
4
    begin                : May 2010
5
    copyright            : (C) 2010 by Jeremy Palmer
6
    email                : jpalmer at linz dot govt dot nz
7 7
 ***************************************************************************
8 8
 *                                                                         *
9 9
 *   This program is free software; you can redistribute it and/or modify  *
......
12 12
 *   (at your option) any later version.                                   *
13 13
 *                                                                         *
14 14
 ***************************************************************************/
15
/* $Id: qgsmaptoolselect.h 13187 2010-03-28 22:14:44Z jef $ */
15
/* $Id$ */
16 16

  
17 17
#ifndef QGSMAPTOOLSELECT_H
18 18
#define QGSMAPTOOLSELECT_H
19 19

  
20 20
#include "qgsmaptool.h"
21
#include <QRect>
22 21

  
23

  
24
class QRubberBand;
25 22
class QgsMapCanvas;
23
class QMouseEvent;
26 24

  
27

  
28 25
class QgsMapToolSelect : public QgsMapTool
29 26
{
30
    Q_OBJECT
31
  public:
32
    QgsMapToolSelect( QgsMapCanvas* canvas );
27
  Q_OBJECT
28
public:
29
  QgsMapToolSelect( QgsMapCanvas* canvas );
33 30

  
34
    //! Overridden mouse move event
35
    virtual void canvasMoveEvent( QMouseEvent * e );
31
  //! Overridden mouse release event
32
  virtual void canvasReleaseEvent( QMouseEvent * e );
36 33

  
37
    //! Overridden mouse press event
38
    virtual void canvasPressEvent( QMouseEvent * e );
39

  
40
    //! Overridden mouse release event
41
    virtual void canvasReleaseEvent( QMouseEvent * e );
42

  
43

  
44
  protected:
45

  
46
    //! stores actual select rect
47
    QRect mSelectRect;
48

  
49
    //! Flag to indicate a map canvas drag operation is taking place
50
    bool mDragging;
51

  
52
    //! rubber band for select rect
53
    QRubberBand* mRubberBand;
34
private:
54 35
};
55 36

  
56 37
#endif
src/app/qgsmaptoolselectfreehand.cpp (revision 0)
1
/***************************************************************************
2
qgsmaptoolselectfreehand.cpp  -  map tool for selecting features by freehand
3
---------------------
4
begin                : May 2010
5
copyright            : (C) 2010 by Jeremy Palmer
6
email                : jpalmer at linz dot govt dot nz
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
#include "qgsmaptoolselectfreehand.h"
18
#include "qgsmaptoolselectutils.h"
19
#include "qgsgeometry.h"
20
#include "qgsrubberband.h"
21
#include "qgsmapcanvas.h"
22
#include "qgis.h"
23

  
24
#include <QMouseEvent>
25

  
26

  
27
QgsMapToolSelectFreehand::QgsMapToolSelectFreehand( QgsMapCanvas* canvas )
28
    : QgsMapTool( canvas )
29
{
30
  mRubberBand = 0;
31
  mCursor = Qt::ArrowCursor;
32
}
33

  
34
QgsMapToolSelectFreehand::~QgsMapToolSelectFreehand()
35
{
36
  delete mRubberBand;
37
}
38

  
39
void QgsMapToolSelectFreehand::canvasPressEvent( QMouseEvent * e )
40
{
41
  if ( e->button() != Qt::LeftButton )
42
  {
43
    return;
44
  }
45
  if ( mRubberBand == NULL )
46
  {
47
    mRubberBand = new QgsRubberBand( mCanvas, true );
48
  }
49
  mRubberBand->addPoint( toMapCoordinates( e->pos() ) );
50
  mDragging = true;
51
}
52

  
53

  
54
void QgsMapToolSelectFreehand::canvasMoveEvent( QMouseEvent * e )
55
{
56
  if ( !mDragging || mRubberBand == NULL )
57
  {
58
    return;
59
  }
60
  mRubberBand->addPoint( toMapCoordinates( e->pos() ) );
61
}
62

  
63

  
64
void QgsMapToolSelectFreehand::canvasReleaseEvent( QMouseEvent * e )
65
{
66
  if ( mRubberBand == NULL )
67
  {
68
    return;
69
  }
70
  if ( mRubberBand->numberOfVertices() > 2 )
71
  {
72
	QgsGeometry* shapeGeom = mRubberBand->asGeometry();
73
    QgsMapToolSelectUtils::setSelectFeatures( mCanvas, shapeGeom, e );
74
	delete shapeGeom;
75
  }
76
  mRubberBand->reset( true );
77
  delete mRubberBand;
78
  mRubberBand = 0;
79
  mDragging = false;
80
}
src/app/qgsmaptoolselectfreehand.h (revision 0)
1
/***************************************************************************
2
    qgsmaptoolselectfreehand.h  -  map tool for selecting features by freehand
3
    ---------------------
4
    begin                : May 2010
5
    copyright            : (C) 2010 by Jeremy Palmer
6
    email                : jpalmer at linz dot govt dot nz
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 QGSMAPTOOLSELECTFREEHAND_H
18
#define QGSMAPTOOLSELECTFREEHAND_H
19

  
20
#include "qgsmaptool.h"
21

  
22
class QgsMapCanvas;
23
class QgsRubberBand;
24

  
25

  
26
class QgsMapToolSelectFreehand : public QgsMapTool
27
{
28
    Q_OBJECT
29
  public:
30
    QgsMapToolSelectFreehand( QgsMapCanvas* canvas );
31

  
32
    virtual ~QgsMapToolSelectFreehand();
33

  
34
    //! Overridden mouse move event
35
    virtual void canvasMoveEvent( QMouseEvent * e );
36

  
37
    //! Overridden mouse press event
38
    virtual void canvasPressEvent( QMouseEvent * e );
39

  
40
    //! Overridden mouse release event
41
    virtual void canvasReleaseEvent( QMouseEvent * e );
42

  
43
  private:
44

  
45
    //! used for storing all of the maps point for the freehand sketch
46
    QgsRubberBand* mRubberBand;
47

  
48
    bool mDragging;
49
};
50

  
51
#endif
src/app/qgsmaptoolselectpolygon.cpp (revision 0)
1
/***************************************************************************
2
qgsmaptoolselectpolygon.cpp  -  map tool for selecting features by polygon
3
---------------------
4
begin                : May 2010
5
copyright            : (C) 2010 by Jeremy Palmer
6
email                : jpalmer at linz dot govt dot nz
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
#include "qgsmaptoolselectpolygon.h"
18
#include "qgsmaptoolselectutils.h"
19
#include "qgsgeometry.h"
20
#include "qgsrubberband.h"
21
#include "qgsmapcanvas.h"
22
#include "qgis.h"
23

  
24
#include <QMouseEvent>
25

  
26

  
27
QgsMapToolSelectPolygon::QgsMapToolSelectPolygon( QgsMapCanvas* canvas )
28
: QgsMapTool( canvas )
29
{
30
  mRubberBand = 0;
31
  mCursor = Qt::ArrowCursor;
32
}
33

  
34
QgsMapToolSelectPolygon::~QgsMapToolSelectPolygon()
35
{
36
  delete mRubberBand;
37
}
38

  
39
void QgsMapToolSelectPolygon::canvasPressEvent( QMouseEvent * e )
40
{
41
  if ( mRubberBand == NULL )
42
  {
43
    mRubberBand = new QgsRubberBand( mCanvas, true );
44
  }
45
  if ( e->button() == Qt::LeftButton )
46
  {
47
    mRubberBand->addPoint( toMapCoordinates( e->pos() ) );
48
  }
49
  else
50
  {
51
    if ( mRubberBand->numberOfVertices() > 2 )
52
    {
53
      QgsGeometry* polygonGeom = mRubberBand->asGeometry();
54
      QgsMapToolSelectUtils::setSelectFeatures( mCanvas, polygonGeom, e );
55
	  delete polygonGeom;
56
    }
57
	mRubberBand->reset( true );
58
	delete mRubberBand;
59
	mRubberBand = 0;
60
  }
61
}
62

  
63
void QgsMapToolSelectPolygon::canvasMoveEvent( QMouseEvent * e )
64
{
65
  if ( mRubberBand == NULL )
66
  {
67
    return;
68
  }
69
  if ( mRubberBand->numberOfVertices() > 0 )
70
  {
71
    mRubberBand->removeLastPoint( 0 );
72
    mRubberBand->addPoint( toMapCoordinates( e->pos() ) );
73
  }
74
}
75

  
src/app/qgsmaptoolselectpolygon.h (revision 0)
1
/***************************************************************************
2
qgsmaptoolselectpolygon.h  -  map tool for selecting features by polygon
3
---------------------
4
begin                : May 2010
5
copyright            : (C) 2010 by Jeremy Palmer
6
email                : jpalmer at linz dot govt dot nz
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 QGSMAPTOOLSELECTPOLYGON_H
18
#define QGSMAPTOOLSELECTPOLYGON_H
19

  
20
#include "qgsmaptool.h"
21

  
22
class QgsMapCanvas;
23
class QgsRubberBand;
24

  
25

  
26
class QgsMapToolSelectPolygon : public QgsMapTool
27
{
28
  Q_OBJECT
29
public:
30
  QgsMapToolSelectPolygon( QgsMapCanvas* canvas );
31

  
32
  virtual ~QgsMapToolSelectPolygon();
33

  
34
  //! Overridden mouse move event
35
  virtual void canvasMoveEvent( QMouseEvent * e );
36

  
37
  //! Overridden mouse press event
38
  virtual void canvasPressEvent( QMouseEvent * e );
39

  
40
private:
41

  
42
  //! used for storing all of the maps point for the polygon
43
  QgsRubberBand* mRubberBand;
44
};
45

  
46
#endif
src/app/qgsmaptoolselectradius.cpp (revision 0)
1
/***************************************************************************
2
qgsmaptoolselectradius.cpp  -  map tool for selecting features by radius
3
---------------------
4
begin                : May 2010
5
copyright            : (C) 2010 by Jeremy Palmer
6
email                : jpalmer at linz dot govt dot nz
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
#include "qgsmaptoolselectradius.h"
18
#include "qgsmaptoolselectutils.h"
19
#include "qgsgeometry.h"
20
#include "qgsrubberband.h"
21
#include "qgsmapcanvas.h"
22
#include "qgis.h"
23
#include "qgslogger.h"
24

  
25
#include <cmath>
26
#include <QMouseEvent>
27

  
28
#ifndef M_PI
29
#define M_PI 3.1415926535897931159979634685
30
#endif
31

  
32
const int RADIUS_SEGMENTS = 40;
33

  
34
QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas* canvas )
35
: QgsMapTool( canvas ), mDragging( false )
36
{
37
  mRubberBand = 0;
38
  mCursor = Qt::ArrowCursor;
39
}
40

  
41
QgsMapToolSelectRadius::~QgsMapToolSelectRadius()
42
{
43
  delete mRubberBand;
44
}
45

  
46
void QgsMapToolSelectRadius::canvasPressEvent( QMouseEvent * e )
47
{
48
  if ( e->button() != Qt::LeftButton )
49
  {
50
    return;
51
  }
52
  mRadiusCenter = toMapCoordinates( e->pos() );
53
}
54

  
55

  
56
void QgsMapToolSelectRadius::canvasMoveEvent( QMouseEvent * e )
57
{
58
  if ( e->buttons() != Qt::LeftButton )
59
  {
60
    return;
61
  }
62
  if ( !mDragging )
63
  {
64
    if ( mRubberBand == NULL )
65
    {
66
      mRubberBand = new QgsRubberBand( mCanvas, true );
67
    }
68
    mDragging = true;
69
  }
70
  QgsPoint radiusEdge = toMapCoordinates( e->pos() );
71
  setRadiusRubberBand( radiusEdge );
72
}
73

  
74

  
75
void QgsMapToolSelectRadius::canvasReleaseEvent( QMouseEvent * e )
76
{
77
  if ( e->button() != Qt::LeftButton )
78
  {
79
    return;
80
  }
81
  if ( !mDragging )
82
  {
83
    if ( mRubberBand == NULL )
84
    {
85
      mRubberBand = new QgsRubberBand( mCanvas, true );
86
    }
87
    mRadiusCenter = toMapCoordinates( e->pos() );
88
    QgsPoint radiusEdge = toMapCoordinates( QPoint( e->pos().x() + 1, e->pos().y() + 1 ) );
89
    setRadiusRubberBand( radiusEdge );
90
  }
91
  QgsGeometry* radiusGeometry = mRubberBand->asGeometry();
92
  QgsMapToolSelectUtils::setSelectFeatures( mCanvas, radiusGeometry, e );
93
  delete radiusGeometry;
94
  mRubberBand->reset( true );
95
  delete mRubberBand;
96
  mRubberBand = 0;
97
  mDragging = false;
98
}
99

  
100

  
101
void QgsMapToolSelectRadius::setRadiusRubberBand( QgsPoint & radiusEdge )
102
{
103
  double r = sqrt( mRadiusCenter.sqrDist( radiusEdge ) );
104
  mRubberBand->reset( true );
105
  for ( int i = 0; i <= RADIUS_SEGMENTS; ++i )
106
  {
107
    double theta = i * ( 2.0 * M_PI / RADIUS_SEGMENTS );
108
    QgsPoint radiusPoint( mRadiusCenter.x() + r * cos( theta ), 
109
                          mRadiusCenter.y() + r * sin( theta ) );
110
    mRubberBand->addPoint( radiusPoint );
111
  }
112
}
src/app/qgsmaptoolselectradius.h (revision 0)
1
/***************************************************************************
2
qgsmaptoolselectradius.h  -  map tool for selecting features by radius
3
---------------------
4
begin                : May 2010
5
copyright            : (C) 2010 by Jeremy Palmer
6
email                : jpalmer at linz dot govt dot nz
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 QGSMAPTOOLSELECTRADIUS_H
18
#define QGSMAPTOOLSELECTRADIUS_H
19

  
20

  
21
#include "qgsmaptool.h"
22
#include "qgspoint.h"
23

  
24
class QgsMapCanvas;
25
class QgsRubberBand;
26

  
27

  
28
class QgsMapToolSelectRadius : public QgsMapTool
29
{
30
  Q_OBJECT
31
public:
32
  QgsMapToolSelectRadius( QgsMapCanvas* canvas );
33

  
34
  virtual ~QgsMapToolSelectRadius();
35

  
36
  //! Overridden mouse move event
37
  virtual void canvasMoveEvent( QMouseEvent * e );
38

  
39
  //! Overridden mouse press event
40
  virtual void canvasPressEvent( QMouseEvent * e );
41

  
42
  //! Overridden mouse release event
43
  virtual void canvasReleaseEvent( QMouseEvent * e );
44

  
45
private:
46

  
47
  //! sets the rubber band to a circle approximated using 40 segments. 
48
  // The radius center point is defined in the canvasPressEvent event.
49
  void setRadiusRubberBand( QgsPoint & radiusEdge );
50

  
51
  //! used for storing all of the maps point for the polygon
52
  QgsRubberBand* mRubberBand;
53

  
54
  //! Center point for the radius
55
  QgsPoint mRadiusCenter;
56

  
57
  bool mDragging;
58
};
59

  
60
#endif
src/app/qgsmaptoolselectrectangle.cpp (revision 0)
1
/***************************************************************************
2
    qgsmaptoolselectrectangle.cpp  -  map tool for selecting features by 
3
                                   rectangle
4
    ----------------------
5
    begin                : January 2006
6
    copyright            : (C) 2006 by Martin Dobias
7
    email                : wonder.sk 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
 ***************************************************************************/
16
/* $Id: qgsmaptoolselectrangle.cpp 13380 2010-04-25 12:51:49Z jef $ */
17

  
18
#include "qgsmaptoolselectrectangle.h"
19
#include "qgsmaptoolselectutils.h"
20
#include "qgsrubberband.h"
21
#include "qgsmapcanvas.h"
22
#include "qgsmaptopixel.h"
23
#include "qgsvectorlayer.h"
24
#include "qgscursors.h"
25
#include "qgsgeometry.h"
26
#include "qgspoint.h"
27
#include "qgis.h"
28

  
29
#include <QMouseEvent>
30
#include <QRect>
31

  
32

  
33
QgsMapToolSelectRectangle::QgsMapToolSelectRectangle( QgsMapCanvas* canvas )
34
    : QgsMapTool( canvas ), mDragging( false )
35
{
36
  QPixmap mySelectQPixmap = QPixmap(( const char ** ) select_cursor );
37
  mCursor = QCursor( mySelectQPixmap, 1, 1 );
38
  mRubberBand = 0;
39
}
40

  
41

  
42
void QgsMapToolSelectRectangle::canvasPressEvent( QMouseEvent * e )
43
{
44
  mSelectRect.setRect( 0, 0, 0, 0 );
45
  mRubberBand = new QgsRubberBand( mCanvas, true );
... This diff was truncated because it exceeds the maximum size that can be displayed.