multipart.diff
images/images.qrc | ||
---|---|---|
21 | 21 |
<file>themes/default/mActionAddArrow.png</file> |
22 | 22 |
<file>themes/default/mActionAddBasicShape.png</file> |
23 | 23 |
<file>themes/default/mActionAddImage.png</file> |
24 |
<file>themes/default/mActionAddIsland.png</file>
|
|
24 |
<file>themes/default/mActionAddPart.png</file>
|
|
25 | 25 |
<file>themes/default/mActionAddLayer.png</file> |
26 | 26 |
<file>themes/default/mActionAddLegend.png</file> |
27 | 27 |
<file>themes/default/mActionAddMap.png</file> |
... | ... | |
219 | 219 |
<file>themes/gis/mActionAddBasicShape.png</file> |
220 | 220 |
<file>themes/gis/mActionAddGPSLayer.png</file> |
221 | 221 |
<file>themes/gis/mActionAddImage.png</file> |
222 |
<file>themes/gis/mActionAddIsland.png</file>
|
|
222 |
<file>themes/gis/mActionAddPart.png</file>
|
|
223 | 223 |
<file>themes/gis/mActionAddLayer.png</file> |
224 | 224 |
<file>themes/gis/mActionAddLegend.png</file> |
225 | 225 |
<file>themes/gis/mActionAddMap.png</file> |
python/gui/qgisinterface.sip | ||
---|---|---|
201 | 201 |
virtual QAction *actionCopyFeatures() = 0; |
202 | 202 |
virtual QAction *actionPasteFeatures() = 0; |
203 | 203 |
virtual QAction *actionEditSeparator1() = 0 /Deprecated/; |
204 |
virtual QAction *actionCapturePoint() = 0; |
|
205 |
virtual QAction *actionCaptureLine() = 0; |
|
206 |
virtual QAction *actionCapturePolygon() = 0; |
|
204 |
virtual QAction *actionAddFeature() = 0; |
|
205 |
virtual QAction *actionCapturePoint() = 0 /Deprecated/; |
|
206 |
virtual QAction *actionCaptureLine() = 0 /Deprecated/; |
|
207 |
virtual QAction *actionCapturePolygon() = 0 /Deprecated/; |
|
207 | 208 |
virtual QAction *actionDeleteSelected() = 0; |
208 | 209 |
virtual QAction *actionMoveFeature() = 0; |
209 | 210 |
virtual QAction *actionSplitFeatures() = 0; |
... | ... | |
211 | 212 |
virtual QAction *actionDeleteVertex() = 0 /Deprecated/; |
212 | 213 |
virtual QAction *actionMoveVertex() = 0 /Deprecated/; |
213 | 214 |
virtual QAction *actionAddRing() = 0; |
214 |
virtual QAction *actionAddIsland() = 0; |
|
215 |
virtual QAction *actionAddPart() = 0; |
|
216 |
virtual QAction *actionAddIsland() = 0 /Deprecated/; |
|
215 | 217 |
virtual QAction *actionSimplifyFeature() = 0; |
216 | 218 |
virtual QAction *actionDeleteRing() = 0; |
217 | 219 |
virtual QAction *actionDeletePart() = 0; |
src/app/CMakeLists.txt | ||
---|---|---|
34 | 34 |
qgslabelpreview.cpp |
35 | 35 |
qgsmaptooladdfeature.cpp |
36 | 36 |
qgsmaptooladdvertex.cpp |
37 |
qgsmaptooladdisland.cpp
|
|
37 |
qgsmaptooladdpart.cpp
|
|
38 | 38 |
qgsmaptooladdring.cpp |
39 | 39 |
qgsmaptoolannotation.cpp |
40 | 40 |
qgsmaptoolcapture.cpp |
... | ... | |
172 | 172 |
qgslabelpropertydialog.h |
173 | 173 |
qgsmanageconnectionsdialog.h |
174 | 174 |
qgsmaptooladdfeature.h |
175 |
qgsmaptooladdisland.h |
|
175 |
qgsmaptoolcapture.h |
|
176 |
qgsmaptooladdpart.h |
|
176 | 177 |
qgsmaptooladdring.h |
177 | 178 |
qgsmaptooladdvertex.h |
178 | 179 |
qgsmaptoolchangelabelproperties.h |
src/app/qgisapp.cpp | ||
---|---|---|
187 | 187 |
// Map tools |
188 | 188 |
// |
189 | 189 |
#include "qgsmaptooladdfeature.h" |
190 |
#include "qgsmaptooladdisland.h"
|
|
190 |
#include "qgsmaptooladdpart.h"
|
|
191 | 191 |
#include "qgsmaptooladdring.h" |
192 | 192 |
#include "qgsmaptooladdvertex.h" |
193 | 193 |
#include "qgsmaptoolannotation.h" |
... | ... | |
598 | 598 |
delete mMapTools.mTextAnnotation; |
599 | 599 |
delete mMapTools.mFormAnnotation; |
600 | 600 |
delete mMapTools.mAnnotation; |
601 |
delete mMapTools.mCapturePoint; |
|
602 |
delete mMapTools.mCaptureLine; |
|
603 |
delete mMapTools.mCapturePolygon; |
|
601 |
delete mMapTools.mAddFeature; |
|
604 | 602 |
delete mMapTools.mMoveFeature; |
605 | 603 |
delete mMapTools.mReshapeFeatures; |
606 | 604 |
delete mMapTools.mSplitFeatures; |
... | ... | |
609 | 607 |
delete mMapTools.mSelectPolygon; |
610 | 608 |
delete mMapTools.mSelectFreehand; |
611 | 609 |
delete mMapTools.mSelectRadius; |
612 | ||
613 |
#if 0 //these three tools to be deprecated - use node tool rather |
|
614 |
delete mMapTools.mVertexAdd; |
|
615 |
delete mMapTools.mVertexMove; |
|
616 |
delete mMapTools.mVertexDelete; |
|
617 |
#endif |
|
618 | ||
619 | 610 |
delete mMapTools.mAddRing; |
620 | 611 |
delete mMapTools.mSimplifyFeature; |
621 | 612 |
delete mMapTools.mDeleteRing; |
622 | 613 |
delete mMapTools.mDeletePart; |
623 |
delete mMapTools.mAddIsland;
|
|
614 |
delete mMapTools.mAddPart;
|
|
624 | 615 |
delete mMapTools.mNodeTool; |
625 | 616 |
delete mMapTools.mMoveLabel; |
626 | 617 |
delete mMapTools.mRotateLabel; |
... | ... | |
733 | 724 |
connect( mActionCutFeatures, SIGNAL( triggered() ), this, SLOT( editCut() ) ); |
734 | 725 |
connect( mActionCopyFeatures, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); |
735 | 726 |
connect( mActionPasteFeatures, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); |
736 |
connect( mActionCapturePoint, SIGNAL( triggered() ), this, SLOT( capturePoint() ) ); |
|
737 |
connect( mActionCaptureLine, SIGNAL( triggered() ), this, SLOT( captureLine() ) ); |
|
738 |
connect( mActionCapturePolygon, SIGNAL( triggered() ), this, SLOT( capturePolygon() ) ); |
|
727 |
connect( mActionAddFeature, SIGNAL( triggered() ), this, SLOT( addFeature() ) ); |
|
739 | 728 |
connect( mActionMoveFeature, SIGNAL( triggered() ), this, SLOT( moveFeature() ) ); |
740 | 729 |
connect( mActionReshapeFeatures, SIGNAL( triggered() ), this, SLOT( reshapeFeatures() ) ); |
741 | 730 |
connect( mActionSplitFeatures, SIGNAL( triggered() ), this, SLOT( splitFeatures() ) ); |
742 | 731 |
connect( mActionDeleteSelected, SIGNAL( triggered() ), this, SLOT( deleteSelected() ) ); |
743 | 732 |
connect( mActionAddRing, SIGNAL( triggered() ), this, SLOT( addRing() ) ); |
744 |
connect( mActionAddIsland, SIGNAL( triggered() ), this, SLOT( addIsland() ) );
|
|
733 |
connect( mActionAddPart, SIGNAL( triggered() ), this, SLOT( addPart() ) );
|
|
745 | 734 |
connect( mActionSimplifyFeature, SIGNAL( triggered() ), this, SLOT( simplifyFeature() ) ); |
746 | 735 |
connect( mActionDeleteRing, SIGNAL( triggered() ), this, SLOT( deleteRing() ) ); |
747 | 736 |
connect( mActionDeletePart, SIGNAL( triggered() ), this, SLOT( deletePart() ) ); |
... | ... | |
945 | 934 |
mMapToolGroup->addAction( mActionMeasure ); |
946 | 935 |
mMapToolGroup->addAction( mActionMeasureArea ); |
947 | 936 |
mMapToolGroup->addAction( mActionMeasureAngle ); |
948 |
mMapToolGroup->addAction( mActionCaptureLine ); |
|
949 |
mMapToolGroup->addAction( mActionCapturePoint ); |
|
950 |
mMapToolGroup->addAction( mActionCapturePolygon ); |
|
937 |
mMapToolGroup->addAction( mActionAddFeature ); |
|
951 | 938 |
mMapToolGroup->addAction( mActionMoveFeature ); |
952 | 939 |
mMapToolGroup->addAction( mActionReshapeFeatures ); |
953 | 940 |
mMapToolGroup->addAction( mActionSplitFeatures ); |
954 | 941 |
mMapToolGroup->addAction( mActionDeleteSelected ); |
955 | 942 |
mMapToolGroup->addAction( mActionAddRing ); |
956 |
mMapToolGroup->addAction( mActionAddIsland );
|
|
943 |
mMapToolGroup->addAction( mActionAddPart );
|
|
957 | 944 |
mMapToolGroup->addAction( mActionSimplifyFeature ); |
958 | 945 |
mMapToolGroup->addAction( mActionDeleteRing ); |
959 | 946 |
mMapToolGroup->addAction( mActionDeletePart ); |
... | ... | |
1375 | 1362 |
mActionCutFeatures->setIcon( getThemeIcon( "/mActionEditCut.png" ) ); |
1376 | 1363 |
mActionCopyFeatures->setIcon( getThemeIcon( "/mActionEditCopy.png" ) ); |
1377 | 1364 |
mActionPasteFeatures->setIcon( getThemeIcon( "/mActionEditPaste.png" ) ); |
1378 |
mActionCapturePoint->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); |
|
1379 |
mActionCaptureLine->setIcon( getThemeIcon( "/mActionCaptureLine.png" ) ); |
|
1380 |
mActionCapturePolygon->setIcon( getThemeIcon( "/mActionCapturePolygon.png" ) ); |
|
1365 |
mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); |
|
1381 | 1366 |
mActionMoveFeature->setIcon( getThemeIcon( "/mActionMoveFeature.png" ) ); |
1382 | 1367 |
mActionReshapeFeatures->setIcon( getThemeIcon( "/mActionReshape.png" ) ); |
1383 | 1368 |
mActionSplitFeatures->setIcon( getThemeIcon( "/mActionSplitFeatures.png" ) ); |
1384 | 1369 |
mActionDeleteSelected->setIcon( getThemeIcon( "/mActionDeleteSelected.png" ) ); |
1385 |
#if 0 //these three icons to be deprecated |
|
1386 |
mActionAddVertex->setIcon( getThemeIcon( "/mActionAddVertex.png" ) ); |
|
1387 |
mActionMoveVertex->setIcon( getThemeIcon( "/mActionMoveVertex.png" ) ); |
|
1388 |
mActionDeleteVertex->setIcon( getThemeIcon( "/mActionDeleteVertex.png" ) ); |
|
1389 |
#endif |
|
1390 | 1370 |
mActionNodeTool->setIcon( getThemeIcon( "/mActionNodeTool.png" ) ); |
1391 | 1371 |
mActionSimplifyFeature->setIcon( getThemeIcon( "/mActionSimplify.png" ) ); |
1392 | 1372 |
mActionUndo->setIcon( getThemeIcon( "/mActionUndo.png" ) ); |
1393 | 1373 |
mActionRedo->setIcon( getThemeIcon( "/mActionRedo.png" ) ); |
1394 | 1374 |
mActionAddRing->setIcon( getThemeIcon( "/mActionAddRing.png" ) ); |
1395 |
mActionAddIsland->setIcon( getThemeIcon( "/mActionAddIsland.png" ) );
|
|
1375 |
mActionAddPart->setIcon( getThemeIcon( "/mActionAddPart.png" ) );
|
|
1396 | 1376 |
mActionDeleteRing->setIcon( getThemeIcon( "/mActionDeleteRing.png" ) ); |
1397 | 1377 |
mActionDeletePart->setIcon( getThemeIcon( "/mActionDeletePart.png" ) ); |
1398 | 1378 |
mActionMergeFeatures->setIcon( getThemeIcon( "/mActionMergeFeatures.png" ) ); |
... | ... | |
1542 | 1522 |
mMapTools.mFormAnnotation->setAction( mActionFormAnnotation ); |
1543 | 1523 |
mMapTools.mAnnotation = new QgsMapToolAnnotation( mMapCanvas ); |
1544 | 1524 |
mMapTools.mAnnotation->setAction( mActionAnnotation ); |
1545 |
mMapTools.mCapturePoint = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePoint ); |
|
1546 |
mMapTools.mCapturePoint->setAction( mActionCapturePoint ); |
|
1547 |
mActionCapturePoint->setVisible( false ); |
|
1548 |
mMapTools.mCaptureLine = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CaptureLine ); |
|
1549 |
mMapTools.mCaptureLine->setAction( mActionCaptureLine ); |
|
1550 |
mActionCaptureLine->setVisible( false ); |
|
1551 |
mMapTools.mCapturePolygon = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePolygon ); |
|
1552 |
mMapTools.mCapturePolygon->setAction( mActionCapturePolygon ); |
|
1553 |
mActionCapturePolygon->setVisible( false ); |
|
1525 |
mMapTools.mAddFeature = new QgsMapToolAddFeature( mMapCanvas ); |
|
1526 |
mMapTools.mAddFeature->setAction( mActionAddFeature ); |
|
1554 | 1527 |
mMapTools.mMoveFeature = new QgsMapToolMoveFeature( mMapCanvas ); |
1555 | 1528 |
mMapTools.mMoveFeature->setAction( mActionMoveFeature ); |
1556 | 1529 |
mMapTools.mReshapeFeatures = new QgsMapToolReshape( mMapCanvas ); |
... | ... | |
1567 | 1540 |
mMapTools.mSelectFreehand->setAction( mActionSelectFreehand ); |
1568 | 1541 |
mMapTools.mSelectRadius = new QgsMapToolSelectRadius( mMapCanvas ); |
1569 | 1542 |
mMapTools.mSelectRadius->setAction( mActionSelectRadius ); |
1570 | ||
1571 |
#if 0 //these three tools to be deprecated - use node tool rather |
|
1572 |
mMapTools.mVertexAdd = new QgsMapToolAddVertex( mMapCanvas ); |
|
1573 |
mMapTools.mVertexAdd->setAction( mActionAddVertex ); |
|
1574 |
mMapTools.mVertexMove = new QgsMapToolMoveVertex( mMapCanvas ); |
|
1575 |
mMapTools.mVertexMove->setAction( mActionMoveVertex ); |
|
1576 |
mMapTools.mVertexDelete = new QgsMapToolDeleteVertex( mMapCanvas ); |
|
1577 |
mMapTools.mVertexDelete->setAction( mActionDeleteVertex ); |
|
1578 |
#endif |
|
1579 | 1543 |
mMapTools.mAddRing = new QgsMapToolAddRing( mMapCanvas ); |
1580 | 1544 |
mMapTools.mAddRing->setAction( mActionAddRing ); |
1581 |
mMapTools.mAddIsland = new QgsMapToolAddIsland( mMapCanvas );
|
|
1545 |
mMapTools.mAddPart = new QgsMapToolAddPart( mMapCanvas );
|
|
1582 | 1546 |
mMapTools.mSimplifyFeature = new QgsMapToolSimplify( mMapCanvas ); |
1583 | 1547 |
mMapTools.mSimplifyFeature->setAction( mActionSimplifyFeature ); |
1584 | 1548 |
mMapTools.mDeleteRing = new QgsMapToolDeleteRing( mMapCanvas ); |
... | ... | |
3976 | 3940 |
mMapCanvas->setMapTool( mMapTools.mReshapeFeatures ); |
3977 | 3941 |
} |
3978 | 3942 | |
3979 |
void QgisApp::capturePoint() |
|
3980 |
{ |
|
3981 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
|
3982 |
{ |
|
3983 |
return; |
|
3984 |
} |
|
3985 | ||
3986 |
// set current map tool to select |
|
3987 |
mMapCanvas->setMapTool( mMapTools.mCapturePoint ); |
|
3988 |
} |
|
3989 | ||
3990 |
void QgisApp::captureLine() |
|
3943 |
void QgisApp::addFeature() |
|
3991 | 3944 |
{ |
3992 | 3945 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
3993 | 3946 |
{ |
3994 | 3947 |
return; |
3995 | 3948 |
} |
3996 | ||
3997 |
mMapCanvas->setMapTool( mMapTools.mCaptureLine ); |
|
3998 |
} |
|
3999 | ||
4000 |
void QgisApp::capturePolygon() |
|
4001 |
{ |
|
4002 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
|
4003 |
{ |
|
4004 |
return; |
|
4005 |
} |
|
4006 |
mMapCanvas->setMapTool( mMapTools.mCapturePolygon ); |
|
3949 |
mMapCanvas->setMapTool( mMapTools.mAddFeature ); |
|
4007 | 3950 |
} |
4008 | 3951 | |
4009 | 3952 |
void QgisApp::select() |
... | ... | |
4058 | 4001 |
mMapCanvas->setRenderFlag( true ); |
4059 | 4002 |
} |
4060 | 4003 | |
4061 |
void QgisApp::addVertex() |
|
4062 |
{ |
|
4063 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
|
4064 |
{ |
|
4065 |
return; |
|
4066 |
} |
|
4067 |
mMapCanvas->setMapTool( mMapTools.mVertexAdd ); |
|
4068 | ||
4069 |
} |
|
4070 | ||
4071 |
void QgisApp::moveVertex() |
|
4072 |
{ |
|
4073 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
|
4074 |
{ |
|
4075 |
return; |
|
4076 |
} |
|
4077 |
mMapCanvas->setMapTool( mMapTools.mVertexMove ); |
|
4078 |
} |
|
4079 | ||
4080 | 4004 |
void QgisApp::addRing() |
4081 | 4005 |
{ |
4082 | 4006 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
... | ... | |
4086 | 4010 |
mMapCanvas->setMapTool( mMapTools.mAddRing ); |
4087 | 4011 |
} |
4088 | 4012 | |
4089 |
void QgisApp::addIsland() |
|
4090 |
{ |
|
4091 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
|
4092 |
{ |
|
4093 |
return; |
|
4094 |
} |
|
4095 |
mMapCanvas->setMapTool( mMapTools.mAddIsland ); |
|
4096 |
} |
|
4097 | ||
4098 | ||
4099 |
void QgisApp::deleteVertex() |
|
4013 |
void QgisApp::addPart() |
|
4100 | 4014 |
{ |
4101 | 4015 |
if ( mMapCanvas && mMapCanvas->isDrawing() ) |
4102 | 4016 |
{ |
4103 | 4017 |
return; |
4104 | 4018 |
} |
4105 |
mMapCanvas->setMapTool( mMapTools.mVertexDelete );
|
|
4019 |
mMapCanvas->setMapTool( mMapTools.mAddPart );
|
|
4106 | 4020 |
} |
4107 | 4021 | |
4108 | 4022 | |
... | ... | |
5769 | 5683 |
mActionLayerSubsetString->setEnabled( false ); |
5770 | 5684 |
mActionAddToOverview->setEnabled( false ); |
5771 | 5685 | |
5772 |
mActionCapturePoint->setEnabled( false ); |
|
5773 |
mActionCaptureLine->setEnabled( false ); |
|
5774 |
mActionCapturePolygon->setEnabled( false ); |
|
5686 |
mActionAddFeature->setEnabled( false ); |
|
5775 | 5687 |
mActionMoveFeature->setEnabled( false ); |
5776 | 5688 |
mActionNodeTool->setEnabled( false ); |
5777 | 5689 |
mActionDeleteSelected->setEnabled( false ); |
... | ... | |
5783 | 5695 |
mActionRedo->setEnabled( false ); |
5784 | 5696 |
mActionSimplifyFeature->setEnabled( false ); |
5785 | 5697 |
mActionAddRing->setEnabled( false ); |
5786 |
mActionAddIsland->setEnabled( false );
|
|
5698 |
mActionAddPart->setEnabled( false );
|
|
5787 | 5699 |
mActionDeleteRing->setEnabled( false ); |
5788 | 5700 |
mActionDeletePart->setEnabled( false ); |
5789 | 5701 |
mActionReshapeFeatures->setEnabled( false ); |
... | ... | |
5792 | 5704 |
mActionMergeFeatureAttributes->setEnabled( false ); |
5793 | 5705 |
mActionRotatePointSymbols->setEnabled( false ); |
5794 | 5706 | |
5795 |
mActionCapturePoint->setVisible( false ); |
|
5796 |
mActionCaptureLine->setVisible( false ); |
|
5797 |
mActionCapturePolygon->setVisible( false ); |
|
5798 | ||
5799 | 5707 |
mActionMoveLabel->setEnabled( false ); |
5800 | 5708 |
mActionRotateLabel->setEnabled( false ); |
5801 | 5709 |
mActionChangeLabelProperties->setEnabled( false ); |
... | ... | |
5858 | 5766 |
if ( dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) |
5859 | 5767 |
{ |
5860 | 5768 |
mActionPasteFeatures->setEnabled( vlayer->isEditable() && !clipboard()->empty() ); |
5769 |
mActionAddFeature->setEnabled( vlayer->isEditable() ); |
|
5861 | 5770 |
} |
5862 | 5771 |
else |
5863 | 5772 |
{ |
5864 | 5773 |
mActionPasteFeatures->setEnabled( false ); |
5774 |
mActionAddFeature->setEnabled( !vlayer->isEditable() ); |
|
5865 | 5775 |
} |
5866 | 5776 | |
5867 | 5777 |
//does provider allow deleting of features? |
... | ... | |
5894 | 5804 |
// moving enabled if geometry changes are supported |
5895 | 5805 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) |
5896 | 5806 |
{ |
5807 |
mActionAddPart->setEnabled( true ); |
|
5808 |
mActionDeletePart->setEnabled( true ); |
|
5897 | 5809 |
mActionMoveFeature->setEnabled( true ); |
5898 | 5810 |
mActionNodeTool->setEnabled( true ); |
5899 | 5811 |
} |
5900 | 5812 |
else |
5901 | 5813 |
{ |
5814 |
mActionAddPart->setEnabled( false ); |
|
5815 |
mActionDeletePart->setEnabled( false ); |
|
5902 | 5816 |
mActionMoveFeature->setEnabled( false ); |
5903 | 5817 |
mActionNodeTool->setEnabled( false ); |
5904 | 5818 |
} |
5905 | 5819 | |
5906 | 5820 |
if ( vlayer->geometryType() == QGis::Point ) |
5907 | 5821 |
{ |
5908 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) |
|
5909 |
{ |
|
5910 |
mActionCapturePoint->setEnabled( true ); |
|
5911 |
mActionCapturePoint->setVisible( true ); |
|
5912 |
mActionDeletePart->setEnabled( true ); |
|
5913 |
mActionAddIsland->setEnabled( true ); |
|
5914 |
} |
|
5915 |
else |
|
5916 |
{ |
|
5917 |
mActionCapturePoint->setEnabled( false ); |
|
5918 |
mActionCapturePoint->setVisible( false ); |
|
5919 |
mActionDeletePart->setEnabled( false ); |
|
5920 |
mActionAddIsland->setEnabled( false ); |
|
5921 |
} |
|
5922 |
mActionCaptureLine->setEnabled( false ); |
|
5923 |
mActionCapturePolygon->setEnabled( false ); |
|
5924 |
mActionCaptureLine->setVisible( false ); |
|
5925 |
mActionCapturePolygon->setVisible( false ); |
|
5926 |
#if 0 //these three tools to be deprecated - use node tool rather |
|
5927 |
mActionAddVertex->setEnabled( false ); |
|
5928 |
mActionDeleteVertex->setEnabled( false ); |
|
5929 |
mActionMoveVertex->setEnabled( false ); |
|
5930 |
#endif |
|
5822 |
mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); |
|
5823 | ||
5931 | 5824 |
mActionAddRing->setEnabled( false ); |
5932 |
#if 0 |
|
5933 |
mActionAddIsland->setEnabled( false ); |
|
5934 |
#endif |
|
5935 |
mActionAddIsland->setEnabled( false ); |
|
5936 | 5825 |
mActionReshapeFeatures->setEnabled( false ); |
5937 | 5826 |
mActionSplitFeatures->setEnabled( false ); |
5938 | 5827 |
mActionSimplifyFeature->setEnabled( false ); |
5939 | 5828 |
mActionDeleteRing->setEnabled( false ); |
5940 | 5829 |
mActionRotatePointSymbols->setEnabled( false ); |
5941 | 5830 | |
5942 |
#if 0 |
|
5943 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) |
|
5944 |
{ |
|
5945 |
mActionMoveVertex->setEnabled( true ); |
|
5946 |
} |
|
5947 |
#endif |
|
5948 | ||
5949 | 5831 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) |
5950 | 5832 |
{ |
5951 | 5833 |
if ( QgsMapToolRotatePointSymbols::layerIsRotatable( vlayer ) ) |
... | ... | |
5957 | 5839 |
} |
5958 | 5840 |
else if ( vlayer->geometryType() == QGis::Line ) |
5959 | 5841 |
{ |
5842 |
mActionAddFeature->setIcon( getThemeIcon( "/mActionCaptureLine.png" ) ); |
|
5843 | ||
5960 | 5844 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) |
5961 | 5845 |
{ |
5962 |
mActionCaptureLine->setEnabled( true ); |
|
5963 |
mActionCaptureLine->setVisible( true ); |
|
5964 | 5846 |
mActionReshapeFeatures->setEnabled( true ); |
5965 | 5847 |
mActionSplitFeatures->setEnabled( true ); |
5966 | 5848 |
mActionSimplifyFeature->setEnabled( true ); |
5967 |
mActionDeletePart->setEnabled( true ); |
|
5968 | ||
5969 | 5849 |
} |
5970 | 5850 |
else |
5971 | 5851 |
{ |
5972 |
mActionCaptureLine->setEnabled( false ); |
|
5973 |
mActionCaptureLine->setVisible( false ); |
|
5974 | 5852 |
mActionReshapeFeatures->setEnabled( false ); |
5975 | 5853 |
mActionSplitFeatures->setEnabled( false ); |
5976 | 5854 |
mActionSimplifyFeature->setEnabled( false ); |
5977 |
mActionDeletePart->setEnabled( false ); |
|
5978 | 5855 |
} |
5979 |
mActionCapturePoint->setEnabled( false ); |
|
5980 |
mActionCapturePolygon->setEnabled( false ); |
|
5981 |
mActionCapturePoint->setVisible( false ); |
|
5982 |
mActionCapturePolygon->setVisible( false ); |
|
5856 | ||
5983 | 5857 |
mActionAddRing->setEnabled( false ); |
5984 |
mActionAddIsland->setEnabled( false ); |
|
5985 | 5858 |
mActionDeleteRing->setEnabled( false ); |
5986 | 5859 |
} |
5987 | 5860 |
else if ( vlayer->geometryType() == QGis::Polygon ) |
5988 | 5861 |
{ |
5862 |
mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePolygon.png" ) ); |
|
5863 | ||
5989 | 5864 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) |
5990 | 5865 |
{ |
5991 |
mActionCapturePolygon->setEnabled( true ); |
|
5992 |
mActionCapturePolygon->setVisible( true ); |
|
5993 | 5866 |
mActionAddRing->setEnabled( true ); |
5994 |
mActionAddIsland->setEnabled( true ); |
|
5995 | 5867 |
mActionReshapeFeatures->setEnabled( true ); |
5996 | 5868 |
mActionSplitFeatures->setEnabled( true ); |
5997 | 5869 |
mActionSimplifyFeature->setEnabled( true ); |
5998 | 5870 |
mActionDeleteRing->setEnabled( true ); |
5999 |
mActionDeletePart->setEnabled( true ); |
|
6000 | 5871 |
} |
6001 | 5872 |
else |
6002 | 5873 |
{ |
6003 |
mActionCapturePolygon->setEnabled( false ); |
|
6004 |
mActionCapturePolygon->setVisible( false ); |
|
6005 | 5874 |
mActionAddRing->setEnabled( false ); |
6006 |
mActionAddIsland->setEnabled( false ); |
|
6007 | 5875 |
mActionReshapeFeatures->setEnabled( false ); |
6008 | 5876 |
mActionSplitFeatures->setEnabled( false ); |
6009 | 5877 |
mActionSimplifyFeature->setEnabled( false ); |
6010 | 5878 |
mActionDeleteRing->setEnabled( false ); |
6011 |
mActionDeletePart->setEnabled( false ); |
|
6012 | 5879 |
} |
6013 |
mActionCapturePoint->setEnabled( false ); |
|
6014 |
mActionCaptureLine->setEnabled( false ); |
|
6015 |
mActionCapturePoint->setVisible( false ); |
|
6016 |
mActionCaptureLine->setVisible( false ); |
|
6017 | 5880 |
} |
6018 | 5881 | |
6019 |
//are add/delete/move vertex supported? |
|
6020 |
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) |
|
6021 |
{ |
|
6022 |
#if 0 // these three tools to be deprecated - use node tool rather |
|
6023 |
mActionAddVertex->setEnabled( true ); |
|
6024 |
mActionMoveVertex->setEnabled( true ); |
|
6025 |
mActionDeleteVertex->setEnabled( true ); |
|
6026 |
#endif |
|
6027 |
if ( vlayer->geometryType() == QGis::Polygon ) |
|
6028 |
{ |
|
6029 |
mActionAddRing->setEnabled( true ); |
|
6030 |
//some polygon layers contain also multipolygon features. |
|
6031 |
//Therefore, the test for multipolygon is done in QgsGeometry |
|
6032 |
mActionAddIsland->setEnabled( true ); |
|
6033 |
} |
|
6034 |
} |
|
6035 |
else |
|
6036 |
{ |
|
6037 |
#if 0 |
|
6038 |
mActionAddVertex->setEnabled( false ); |
|
6039 |
mActionMoveVertex->setEnabled( false ); |
|
6040 |
mActionDeleteVertex->setEnabled( false ); |
|
6041 |
#endif |
|
6042 |
} |
|
6043 | 5882 |
return; |
6044 | 5883 |
} |
6045 | 5884 | |
... | ... | |
6079 | 5918 |
mActionSaveEdits->setEnabled( false ); |
6080 | 5919 |
mActionLayerSaveAs->setEnabled( false ); |
6081 | 5920 |
mActionLayerSelectionSaveAs->setEnabled( false ); |
6082 |
mActionCapturePoint->setEnabled( false ); |
|
6083 |
mActionCaptureLine->setEnabled( false ); |
|
6084 |
mActionCapturePolygon->setEnabled( false ); |
|
5921 |
mActionAddFeature->setEnabled( false ); |
|
6085 | 5922 |
mActionDeleteSelected->setEnabled( false ); |
6086 | 5923 |
mActionAddRing->setEnabled( false ); |
6087 |
mActionAddIsland->setEnabled( false ); |
|
6088 |
#if 0 //these three tools to be deprecated - use node tool rather |
|
6089 |
mActionAddVertex->setEnabled( false ); |
|
6090 |
mActionDeleteVertex->setEnabled( false ); |
|
6091 |
mActionMoveVertex->setEnabled( false ); |
|
6092 |
#endif |
|
5924 |
mActionAddPart->setEnabled( false ); |
|
6093 | 5925 |
mActionNodeTool->setEnabled( false ); |
6094 | 5926 |
mActionMoveFeature->setEnabled( false ); |
6095 | 5927 |
mActionCopyFeatures->setEnabled( false ); |
src/app/qgisapp.h | ||
---|---|---|
226 | 226 |
QAction *actionCutFeatures() { return mActionCutFeatures; } |
227 | 227 |
QAction *actionCopyFeatures() { return mActionCopyFeatures; } |
228 | 228 |
QAction *actionPasteFeatures() { return mActionPasteFeatures; } |
229 |
QAction *actionCapturePoint() { return mActionCapturePoint; } |
|
230 |
QAction *actionCaptureLine() { return mActionCaptureLine; } |
|
231 |
QAction *actionCapturePolygon() { return mActionCapturePolygon; } |
|
232 | 229 |
QAction *actionDeleteSelected() { return mActionDeleteSelected; } |
230 |
QAction *actionAddFeature() { return mActionAddFeature; } |
|
233 | 231 |
QAction *actionMoveFeature() { return mActionMoveFeature; } |
234 | 232 |
QAction *actionSplitFeatures() { return mActionSplitFeatures; } |
235 | 233 |
QAction *actionAddRing() { return mActionAddRing; } |
236 |
QAction *actionAddIsland() { return mActionAddIsland; }
|
|
234 |
QAction *actionAddPart() { return mActionAddPart; }
|
|
237 | 235 |
QAction *actionSimplifyFeature() { return mActionSimplifyFeature; } |
238 | 236 |
QAction *actionDeleteRing() { return mActionDeleteRing; } |
239 | 237 |
QAction *actionDeletePart() { return mActionDeletePart; } |
... | ... | |
607 | 605 |
void showBookmarks(); |
608 | 606 |
//! Create a new spatial bookmark |
609 | 607 |
void newBookmark(); |
610 |
//! activates the capture point tool |
|
611 |
void capturePoint(); |
|
612 |
//! activates the capture line tool |
|
613 |
void captureLine(); |
|
614 |
//! activates the capture polygon tool |
|
615 |
void capturePolygon(); |
|
608 |
//! activates the add feature tool |
|
609 |
void addFeature(); |
|
616 | 610 |
//! activates the move feature tool |
617 | 611 |
void moveFeature(); |
618 | 612 |
//! activates the reshape features tool |
619 | 613 |
void reshapeFeatures(); |
620 | 614 |
//! activates the split features tool |
621 | 615 |
void splitFeatures(); |
622 |
//! activates the add vertex tool |
|
623 |
void addVertex(); |
|
624 |
//! activates the move vertex tool |
|
625 |
void moveVertex(); |
|
626 |
//! activates the delete vertex tool |
|
627 |
void deleteVertex(); |
|
628 | 616 |
//! activates the add ring tool |
629 | 617 |
void addRing(); |
630 |
//! activates the add island tool
|
|
631 |
void addIsland();
|
|
618 |
//! activates the add part tool
|
|
619 |
void addPart();
|
|
632 | 620 |
//! simplifies feature |
633 | 621 |
void simplifyFeature(); |
634 | 622 |
//! deletes ring in polygon |
... | ... | |
923 | 911 |
QgsMapTool* mMeasureDist; |
924 | 912 |
QgsMapTool* mMeasureArea; |
925 | 913 |
QgsMapTool* mMeasureAngle; |
926 |
QgsMapTool* mCapturePoint; |
|
927 |
QgsMapTool* mCaptureLine; |
|
928 |
QgsMapTool* mCapturePolygon; |
|
914 |
QgsMapTool* mAddFeature; |
|
929 | 915 |
QgsMapTool* mMoveFeature; |
930 | 916 |
QgsMapTool* mReshapeFeatures; |
931 | 917 |
QgsMapTool* mSplitFeatures; |
... | ... | |
938 | 924 |
QgsMapTool* mVertexMove; |
939 | 925 |
QgsMapTool* mVertexDelete; |
940 | 926 |
QgsMapTool* mAddRing; |
941 |
QgsMapTool* mAddIsland;
|
|
927 |
QgsMapTool* mAddPart;
|
|
942 | 928 |
QgsMapTool* mSimplifyFeature; |
943 | 929 |
QgsMapTool* mDeleteRing; |
944 | 930 |
QgsMapTool* mDeletePart; |
... | ... | |
986 | 972 |
QMenu *toolPopupOverviews; |
987 | 973 |
//! Popup menu for the display tools |
988 | 974 |
QMenu *toolPopupDisplay; |
989 |
//! Popup menu for the capture tools |
|
990 |
QMenu *toolPopupCapture; |
|
991 | 975 |
//! Map canvas |
992 | 976 |
QgsMapCanvas *mMapCanvas; |
993 | 977 |
//! Table of contents (legend) for the map |
src/app/qgisappinterface.cpp | ||
---|---|---|
313 | 313 |
QAction *QgisAppInterface::actionCopyFeatures() { return qgis->actionCopyFeatures(); } |
314 | 314 |
QAction *QgisAppInterface::actionPasteFeatures() { return qgis->actionPasteFeatures(); } |
315 | 315 |
QAction *QgisAppInterface::actionEditSeparator1() { return 0; } |
316 |
QAction *QgisAppInterface::actionCapturePoint() { return qgis->actionCapturePoint(); } |
|
317 |
QAction *QgisAppInterface::actionCaptureLine() { return qgis->actionCaptureLine(); } |
|
318 |
QAction *QgisAppInterface::actionCapturePolygon() { return qgis->actionCapturePolygon(); } |
|
316 |
QAction *QgisAppInterface::actionAddFeature() { return qgis->actionAddFeature(); } |
|
317 |
QAction *QgisAppInterface::actionCapturePoint() { return qgis->actionAddFeature(); } |
|
318 |
QAction *QgisAppInterface::actionCaptureLine() { return qgis->actionAddFeature(); } |
|
319 |
QAction *QgisAppInterface::actionCapturePolygon() { return qgis->actionAddFeature(); } |
|
319 | 320 |
QAction *QgisAppInterface::actionDeleteSelected() { return qgis->actionDeleteSelected(); } |
320 | 321 |
QAction *QgisAppInterface::actionMoveFeature() { return qgis->actionMoveFeature(); } |
321 | 322 |
QAction *QgisAppInterface::actionSplitFeatures() { return qgis->actionSplitFeatures(); } |
... | ... | |
326 | 327 |
QAction *QgisAppInterface::actionDeleteVertex() { return 0; } |
327 | 328 |
QAction *QgisAppInterface::actionMoveVertex() { return 0; } |
328 | 329 |
QAction *QgisAppInterface::actionAddRing() { return qgis->actionAddRing(); } |
329 |
QAction *QgisAppInterface::actionAddIsland() { return qgis->actionAddIsland(); } |
|
330 |
QAction *QgisAppInterface::actionAddPart() { return qgis->actionAddPart(); } |
|
331 |
QAction *QgisAppInterface::actionAddIsland() { return qgis->actionAddPart(); } |
|
330 | 332 |
QAction *QgisAppInterface::actionSimplifyFeature() { return qgis->actionSimplifyFeature(); } |
331 | 333 |
QAction *QgisAppInterface::actionDeleteRing() { return qgis->actionDeleteRing(); } |
332 | 334 |
QAction *QgisAppInterface::actionDeletePart() { return qgis->actionDeletePart(); } |
src/app/qgisappinterface.h | ||
---|---|---|
203 | 203 |
virtual QAction *actionCopyFeatures(); |
204 | 204 |
virtual QAction *actionPasteFeatures(); |
205 | 205 |
virtual QAction *actionEditSeparator1(); |
206 |
virtual QAction *actionCapturePoint(); |
|
207 |
virtual QAction *actionCaptureLine(); |
|
208 |
virtual QAction *actionCapturePolygon(); |
|
206 |
virtual QAction *actionAddFeature(); |
|
207 |
Q_DECL_DEPRECATED virtual QAction *actionCapturePoint(); |
|
208 |
Q_DECL_DEPRECATED virtual QAction *actionCaptureLine(); |
|
209 |
Q_DECL_DEPRECATED virtual QAction *actionCapturePolygon(); |
|
209 | 210 |
virtual QAction *actionDeleteSelected(); |
210 | 211 |
virtual QAction *actionMoveFeature(); |
211 | 212 |
virtual QAction *actionSplitFeatures(); |
... | ... | |
213 | 214 |
virtual QAction *actionDeleteVertex(); |
214 | 215 |
virtual QAction *actionMoveVertex(); |
215 | 216 |
virtual QAction *actionAddRing(); |
216 |
virtual QAction *actionAddIsland(); |
|
217 |
virtual QAction *actionAddPart(); |
|
218 |
Q_DECL_DEPRECATED virtual QAction *actionAddIsland(); |
|
217 | 219 |
virtual QAction *actionSimplifyFeature(); |
218 | 220 |
virtual QAction *actionDeleteRing(); |
219 | 221 |
virtual QAction *actionDeletePart(); |
src/app/qgsmaptooladdfeature.cpp | ||
---|---|---|
33 | 33 |
#include <QMouseEvent> |
34 | 34 |
#include <QSettings> |
35 | 35 | |
36 |
QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas, CaptureMode tool ): QgsMapToolCapture( canvas, tool )
|
|
36 |
QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas )
|
|
37 | 37 |
{ |
38 | 38 |
} |
39 | 39 | |
... | ... | |
112 | 112 |
} |
113 | 113 |
} |
114 | 114 | |
115 |
// emit signal - QgisApp can catch it and save point position to clipboard |
|
116 |
// FIXME: is this still actual or something old that's not used anymore? |
|
117 |
//emit xyClickCoordinates(idPoint); |
|
118 | ||
119 | 115 |
//only do the rest for provider with feature addition support |
120 | 116 |
//note that for the grass provider, this will return false since |
121 | 117 |
//grass provider has its own mechanism of feature addition |
... | ... | |
123 | 119 |
{ |
124 | 120 |
QgsFeature* f = new QgsFeature( 0, "WKBPoint" ); |
125 | 121 | |
126 |
int size = 0; |
|
127 |
char endian = QgsApplication::endian(); |
|
128 |
unsigned char *wkb = NULL; |
|
129 |
int wkbtype = 0; |
|
130 |
double x = savePoint.x(); |
|
131 |
double y = savePoint.y(); |
|
132 | ||
122 |
QgsGeometry *g; |
|
133 | 123 |
if ( layerWKBType == QGis::WKBPoint || layerWKBType == QGis::WKBPoint25D ) |
134 | 124 |
{ |
135 |
size = 1 + sizeof( int ) + 2 * sizeof( double ); |
|
136 |
wkb = new unsigned char[size]; |
|
137 |
wkbtype = QGis::WKBPoint; |
|
138 |
memcpy( &wkb[0], &endian, 1 ); |
|
139 |
memcpy( &wkb[1], &wkbtype, sizeof( int ) ); |
|
140 |
memcpy( &wkb[5], &x, sizeof( double ) ); |
|
141 |
memcpy( &wkb[5] + sizeof( double ), &y, sizeof( double ) ); |
|
125 |
g = QgsGeometry::fromPoint( savePoint ); |
|
142 | 126 |
} |
143 | 127 |
else if ( layerWKBType == QGis::WKBMultiPoint || layerWKBType == QGis::WKBMultiPoint25D ) |
144 | 128 |
{ |
145 |
size = 2 + 3 * sizeof( int ) + 2 * sizeof( double ); |
|
146 |
wkb = new unsigned char[size]; |
|
147 |
wkbtype = QGis::WKBMultiPoint; |
|
148 |
int position = 0; |
|
149 |
memcpy( &wkb[position], &endian, 1 ); |
|
150 |
position += 1; |
|
151 |
memcpy( &wkb[position], &wkbtype, sizeof( int ) ); |
|
152 |
position += sizeof( int ); |
|
153 |
int npoint = 1; |
|
154 |
memcpy( &wkb[position], &npoint, sizeof( int ) ); |
|
155 |
position += sizeof( int ); |
|
156 |
memcpy( &wkb[position], &endian, 1 ); |
|
157 |
position += 1; |
|
158 |
int pointtype = QGis::WKBPoint; |
|
159 |
memcpy( &wkb[position], &pointtype, sizeof( int ) ); |
|
160 |
position += sizeof( int ); |
|
161 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
162 |
position += sizeof( double ); |
|
163 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
129 |
g = QgsGeometry::fromMultiPoint( QgsMultiPoint() << savePoint ); |
|
164 | 130 |
} |
165 | 131 | |
166 |
f->setGeometryAndOwnership( &wkb[0], size );
|
|
132 |
f->setGeometry( g );
|
|
167 | 133 | |
168 | 134 |
vlayer->beginEditCommand( tr( "Feature added" ) ); |
169 | 135 | |
... | ... | |
237 | 203 | |
238 | 204 |
//create QgsFeature with wkb representation |
239 | 205 |
QgsFeature* f = new QgsFeature( 0, "WKBLineString" ); |
240 |
unsigned char* wkb; |
|
241 |
int wkbsize; |
|
242 |
char endian = QgsApplication::endian(); |
|
206 | ||
207 |
QgsGeometry *g; |
|
243 | 208 | |
244 | 209 |
if ( mode() == CaptureLine ) |
245 | 210 |
{ |
246 | 211 |
if ( layerWKBType == QGis::WKBLineString || layerWKBType == QGis::WKBLineString25D ) |
247 | 212 |
{ |
248 |
wkbsize = 1 + 2 * sizeof( int ) + 2 * size() * sizeof( double ); |
|
249 |
wkb = new unsigned char[wkbsize]; |
|
250 |
int wkbtype = QGis::WKBLineString; |
|
251 |
int length = size(); |
|
252 |
memcpy( &wkb[0], &endian, 1 ); |
|
253 |
memcpy( &wkb[1], &wkbtype, sizeof( int ) ); |
|
254 |
memcpy( &wkb[1+sizeof( int )], &length, sizeof( int ) ); |
|
255 |
int position = 1 + 2 * sizeof( int ); |
|
256 |
double x, y; |
|
257 |
for ( QList<QgsPoint>::iterator it = begin(); it != end(); ++it ) |
|
258 |
{ |
|
259 |
QgsPoint savePoint = *it; |
|
260 |
x = savePoint.x(); |
|
261 |
y = savePoint.y(); |
|
262 | ||
263 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
264 |
position += sizeof( double ); |
|
265 | ||
266 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
267 |
position += sizeof( double ); |
|
268 |
} |
|
213 |
g = QgsGeometry::fromPolyline( points().toVector() ); |
|
269 | 214 |
} |
270 | 215 |
else if ( layerWKBType == QGis::WKBMultiLineString || layerWKBType == QGis::WKBMultiLineString25D ) |
271 | 216 |
{ |
272 |
wkbsize = 1 + 2 * sizeof( int ) + 1 + 2 * sizeof( int ) + 2 * size() * sizeof( double ); |
|
273 |
wkb = new unsigned char[wkbsize]; |
|
274 |
int position = 0; |
|
275 |
int wkbtype = QGis::WKBMultiLineString; |
|
276 |
memcpy( &wkb[position], &endian, 1 ); |
|
277 |
position += 1; |
|
278 |
memcpy( &wkb[position], &wkbtype, sizeof( int ) ); |
|
279 |
position += sizeof( int ); |
|
280 |
int nlines = 1; |
|
281 |
memcpy( &wkb[position], &nlines, sizeof( int ) ); |
|
282 |
position += sizeof( int ); |
|
283 |
memcpy( &wkb[position], &endian, 1 ); |
|
284 |
position += 1; |
|
285 |
int linewkbtype = QGis::WKBLineString; |
|
286 |
memcpy( &wkb[position], &linewkbtype, sizeof( int ) ); |
|
287 |
position += sizeof( int ); |
|
288 |
int length = size(); |
|
289 |
memcpy( &wkb[position], &length, sizeof( int ) ); |
|
290 |
position += sizeof( int ); |
|
291 |
double x, y; |
|
292 |
for ( QList<QgsPoint>::iterator it = begin(); it != end(); ++it ) |
|
293 |
{ |
|
294 |
QgsPoint savePoint = *it; |
|
295 |
x = savePoint.x(); |
|
296 |
y = savePoint.y(); |
|
297 | ||
298 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
299 |
position += sizeof( double ); |
|
300 | ||
301 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
302 |
position += sizeof( double ); |
|
303 |
} |
|
217 |
g = QgsGeometry::fromMultiPolyline( QgsMultiPolyline() << points().toVector() ); |
|
304 | 218 |
} |
305 | 219 |
else |
306 | 220 |
{ |
... | ... | |
308 | 222 |
stopCapturing(); |
309 | 223 |
return; //unknown wkbtype |
310 | 224 |
} |
311 |
f->setGeometryAndOwnership( &wkb[0], wkbsize ); |
|
225 | ||
226 |
f->setGeometry( g ); |
|
312 | 227 |
} |
313 | 228 |
else // polygon |
314 | 229 |
{ |
230 |
QgsGeometry *g; |
|
315 | 231 |
if ( layerWKBType == QGis::WKBPolygon || layerWKBType == QGis::WKBPolygon25D ) |
316 | 232 |
{ |
317 |
wkbsize = 1 + 3 * sizeof( int ) + 2 * ( size() + 1 ) * sizeof( double ); |
|
318 |
wkb = new unsigned char[wkbsize]; |
|
319 |
int wkbtype = QGis::WKBPolygon; |
|
320 |
int length = size() + 1;//+1 because the first point is needed twice |
|
321 |
int numrings = 1; |
|
322 |
memcpy( &wkb[0], &endian, 1 ); |
|
323 |
memcpy( &wkb[1], &wkbtype, sizeof( int ) ); |
|
324 |
memcpy( &wkb[1+sizeof( int )], &numrings, sizeof( int ) ); |
|
325 |
memcpy( &wkb[1+2*sizeof( int )], &length, sizeof( int ) ); |
|
326 |
int position = 1 + 3 * sizeof( int ); |
|
327 |
double x, y; |
|
328 |
QList<QgsPoint>::iterator it; |
|
329 |
for ( it = begin(); it != end(); ++it ) |
|
330 |
{ |
|
331 |
QgsPoint savePoint = *it; |
|
332 |
x = savePoint.x(); |
|
333 |
y = savePoint.y(); |
|
334 | ||
335 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
336 |
position += sizeof( double ); |
|
337 | ||
338 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
339 |
position += sizeof( double ); |
|
340 |
} |
|
341 |
// close the polygon |
|
342 |
it = begin(); |
|
343 |
QgsPoint savePoint = *it; |
|
344 |
x = savePoint.x(); |
|
345 |
y = savePoint.y(); |
|
346 | ||
347 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
348 |
position += sizeof( double ); |
|
349 | ||
350 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
233 |
g = QgsGeometry::fromPolygon( QgsPolygon() << points().toVector() ); |
|
351 | 234 |
} |
352 | 235 |
else if ( layerWKBType == QGis::WKBMultiPolygon || layerWKBType == QGis::WKBMultiPolygon25D ) |
353 | 236 |
{ |
354 |
wkbsize = 2 + 5 * sizeof( int ) + 2 * ( size() + 1 ) * sizeof( double ); |
|
355 |
wkb = new unsigned char[wkbsize]; |
|
356 |
int wkbtype = QGis::WKBMultiPolygon; |
|
357 |
int polygontype = QGis::WKBPolygon; |
|
358 |
int length = size() + 1;//+1 because the first point is needed twice |
|
359 |
int numrings = 1; |
|
360 |
int numpolygons = 1; |
|
361 |
int position = 0; //pointer position relative to &wkb[0] |
|
362 |
memcpy( &wkb[position], &endian, 1 ); |
|
363 |
position += 1; |
|
364 |
memcpy( &wkb[position], &wkbtype, sizeof( int ) ); |
|
365 |
position += sizeof( int ); |
|
366 |
memcpy( &wkb[position], &numpolygons, sizeof( int ) ); |
|
367 |
position += sizeof( int ); |
|
368 |
memcpy( &wkb[position], &endian, 1 ); |
|
369 |
position += 1; |
|
370 |
memcpy( &wkb[position], &polygontype, sizeof( int ) ); |
|
371 |
position += sizeof( int ); |
|
372 |
memcpy( &wkb[position], &numrings, sizeof( int ) ); |
|
373 |
position += sizeof( int ); |
|
374 |
memcpy( &wkb[position], &length, sizeof( int ) ); |
|
375 |
position += sizeof( int ); |
|
376 |
double x, y; |
|
377 |
QList<QgsPoint>::iterator it; |
|
378 |
for ( it = begin(); it != end(); ++it ) //add the captured points to the polygon |
|
379 |
{ |
|
380 |
QgsPoint savePoint = *it; |
|
381 |
x = savePoint.x(); |
|
382 |
y = savePoint.y(); |
|
383 | ||
384 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
385 |
position += sizeof( double ); |
|
386 | ||
387 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
388 |
position += sizeof( double ); |
|
389 |
} |
|
390 |
// close the polygon |
|
391 |
it = begin(); |
|
392 |
QgsPoint savePoint = *it; |
|
393 |
x = savePoint.x(); |
|
394 |
y = savePoint.y(); |
|
395 |
memcpy( &wkb[position], &x, sizeof( double ) ); |
|
396 |
position += sizeof( double ); |
|
397 |
memcpy( &wkb[position], &y, sizeof( double ) ); |
|
237 |
g = QgsGeometry::fromMultiPolygon( QgsMultiPolygon() << ( QgsPolygon() << points().toVector() ) ); |
|
398 | 238 |
} |
399 | 239 |
else |
400 | 240 |
{ |
... | ... | |
402 | 242 |
stopCapturing(); |
403 | 243 |
return; //unknown wkbtype |
404 | 244 |
} |
405 |
f->setGeometryAndOwnership( &wkb[0], wkbsize ); |
|
245 | ||
246 |
f->setGeometry( g ); |
|
406 | 247 | |
407 | 248 |
int avoidIntersectionsReturn = f->geometry()->avoidIntersections(); |
408 | 249 |
if ( avoidIntersectionsReturn == 1 ) |
src/app/qgsmaptooladdfeature.h | ||
---|---|---|
22 | 22 |
{ |
23 | 23 |
Q_OBJECT |
24 | 24 |
public: |
25 |
QgsMapToolAddFeature( QgsMapCanvas* canvas, CaptureMode mode );
|
|
25 |
QgsMapToolAddFeature( QgsMapCanvas* canvas ); |
|
26 | 26 |
virtual ~QgsMapToolAddFeature(); |
27 | 27 |
void canvasReleaseEvent( QMouseEvent * e ); |
28 | 28 |
src/app/qgsmaptooladdisland.cpp | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgsmaptooladdisland.cpp - map tool to add new polygons to multipolygon features |
|
3 |
----------------------- |
|
4 |
begin : Mai 2007 |
|
5 |
copyright : (C) 2007 by Marco Hugentobler |
|
6 |
email : marco dot hugentobler at karto dot baug dot ethz dot ch |
|
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 "qgsmaptooladdisland.h" |
|
18 |
#include "qgsgeometry.h" |
|
19 |
#include "qgsmapcanvas.h" |
|
20 |
#include "qgsproject.h" |
|
21 |
#include "qgsrubberband.h" |
|
22 |
#include "qgsvectorlayer.h" |
|
23 |
#include <QMessageBox> |
|
24 |
#include <QMouseEvent> |
|
25 | ||
26 |
QgsMapToolAddIsland::QgsMapToolAddIsland( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas, QgsMapToolCapture::CapturePolygon ) |
|
27 |
{ |
|
28 | ||
29 |
} |
|
30 | ||
31 |
QgsMapToolAddIsland::~QgsMapToolAddIsland() |
|
32 |
{ |
|
33 | ||
34 |
} |
|
35 | ||
36 |
void QgsMapToolAddIsland::canvasReleaseEvent( QMouseEvent * e ) |
|
37 |
{ |
|
38 |
//check if we operate on a vector layer |
|
39 |
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ); |
|
40 | ||
41 |
if ( !vlayer ) |
|
42 |
{ |
|
43 |
QMessageBox::information( 0, |
|
44 |
tr( "Not a vector layer" ), |
|
45 |
tr( "The current layer is not a vector layer" ) ); |
|
46 |
return; |
|
47 |
} |
|
48 | ||
49 |
if ( !vlayer->isEditable() ) |
|
50 |
{ |
|
51 |
QMessageBox::information( 0, |
|
52 |
tr( "Layer not editable" ), |
|
53 |
tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) |
|
54 |
); |
|
55 |
return; |
|
56 |
} |
|
57 | ||
58 |
//inform user at the begin of the digitising action that the island tool only works if exactly one feature is selected |
|
59 |
int nSelectedFeatures = vlayer->selectedFeatureCount(); |
|
60 |
QString selectionErrorMsg; |
|
61 |
if ( nSelectedFeatures < 1 ) |
|
62 |
{ |
|
63 |
selectionErrorMsg = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); |
|
64 |
} |
|
65 |
else if ( nSelectedFeatures > 1 ) |
|
66 |
{ |
|
67 |
selectionErrorMsg = tr( "Several features are selected. Please select only one feature to which an island should be added." ); |
|
68 |
} |
|
69 | ||
70 |
if ( !selectionErrorMsg.isEmpty() ) |
|
71 |
{ |
|
72 |
QMessageBox::critical( 0, tr( "Error, could not add island" ), selectionErrorMsg ); |
|
73 |
stopCapturing(); |
|
74 |
return; |
|
75 |
} |
|
76 | ||
77 |
//add point to list and to rubber band |
|
78 |
int error = addVertex( e->pos() ); |
|
79 |
if ( error == 1 ) |
|
80 |
{ |
|
81 |
//current layer is not a vector layer |
|
82 |
return; |
|
83 |
} |
|
84 |
else if ( error == 2 ) |
|
85 |
{ |
|
86 |
//problem with coordinate transformation |
|
87 |
QMessageBox::information( 0, |
|
88 |
tr( "Coordinate transform error" ), |
|
89 |
tr( "Cannot transform the point to the layers coordinate system" ) ); |
|
90 |
return; |
|
91 |
} |
|
92 | ||
93 |
if ( e->button() == Qt::LeftButton ) |
|
94 |
{ |
|
95 |
startCapturing(); |
|
96 |
} |
|
97 |
else if ( e->button() == Qt::RightButton ) |
|
98 |
{ |
|
99 |
//close polygon |
|
100 |
closePolygon(); |
|
101 | ||
102 |
vlayer->beginEditCommand( tr( "Part added" ) ); |
|
103 |
int errorCode = vlayer->addIsland( points() ); |
|
104 |
QString errorMessage; |
|
105 | ||
106 |
if ( errorCode != 0 ) |
|
107 |
{ |
|
108 |
if ( errorCode == 1 ) |
|
109 |
{ |
|
110 |
errorMessage = tr( "Selected feature is not a multipolygon" ); |
|
111 |
} |
|
112 |
else if ( errorCode == 2 ) |
|
113 |
{ |
|
114 |
errorMessage = tr( "New ring is not a valid geometry" ); |
|
115 |
} |
|
116 |
else if ( errorCode == 3 ) |
|
117 |
{ |
|
118 |
errorMessage = tr( "New polygon ring not disjoint with existing polygons" ); |
|
119 |
} |
|
120 |
else if ( errorCode == 4 ) |
|
121 |
{ |
|
122 |
errorMessage = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); |
|
123 |
} |
|
124 |
else if ( errorCode == 5 ) |
|
125 |
{ |
|
126 |
errorMessage = tr( "Several features are selected. Please select only one feature to which an island should be added." ); |
|
127 |
} |
|
128 |
else if ( errorCode == 6 ) |
|
129 |
{ |
|
130 |
errorMessage = tr( "Selected geometry could not be found" ); |
|
131 |
} |
|
132 |
QMessageBox::critical( 0, tr( "Error, could not add island" ), errorMessage ); |
|
133 | ||
134 |
vlayer->destroyEditCommand(); |
|
135 |
} |
|
136 |
else |
|
137 |
{ |
|
138 |
//add points to other features to keep topology up-to-date |
|
139 |
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); |
|
140 |
if ( topologicalEditing ) |
|
141 |
{ |
|
142 |
addTopologicalPoints( points() ); |
|
143 |
} |
|
144 | ||
145 |
vlayer->endEditCommand(); |
|
146 |
} |
|
147 | ||
148 |
stopCapturing(); |
|
149 |
} |
|
150 |
} |
src/app/qgsmaptooladdisland.h | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgsmaptooladdisland.h - map tool to add new polygons to multipolygon features |
|
3 |
--------------------- |
|
4 |
begin : Mai 2007 |
|
5 |
copyright : (C) 2007 by Marco Hugentobler |
|
6 |
email : marco dot hugentobler at karto dot baug dot ethz dot ch |
|
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 "qgsmaptoolcapture.h" |
|
18 | ||
19 |
/**A map tool that adds new polygons to multipolygon features*/ |
|
20 |
class QgsMapToolAddIsland: public QgsMapToolCapture |
|
21 |
{ |
|
22 |
Q_OBJECT |
|
23 |
public: |
|
24 |
QgsMapToolAddIsland( QgsMapCanvas* canvas ); |
|
25 |
virtual ~QgsMapToolAddIsland(); |
|
26 |
void canvasReleaseEvent( QMouseEvent * e ); |
|
27 |
}; |
src/app/qgsmaptooladdpart.cpp | ||
---|---|---|
1 |
/*************************************************************************** |
|
2 |
qgsmaptooladdpart.cpp - map tool to add new parts to multipart features |
|
3 |
----------------------- |
|
4 |
begin : Mai 2007 |
|
5 |
copyright : (C) 2007 by Marco Hugentobler |
|
6 |
email : marco dot hugentobler at karto dot baug dot ethz dot ch |
|
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 "qgsmaptooladdpart.h" |
|
18 |
#include "qgsgeometry.h" |
|
19 |
#include "qgsmapcanvas.h" |
|
20 |
#include "qgsproject.h" |
|
21 |
#include "qgsrubberband.h" |
|
22 |
#include "qgsvectorlayer.h" |
|
23 |
#include "qgslogger.h" |
|
24 | ||
25 |
#include <QMessageBox> |
|
26 |
#include <QMouseEvent> |
|
27 | ||
28 |
QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas* canvas ) |
|
29 |
: QgsMapToolCapture( canvas ) |
|
30 |
{ |
|
31 |
} |
|
32 | ||
33 |
QgsMapToolAddPart::~QgsMapToolAddPart() |
|
34 |
{ |
|
35 |
} |
|
36 | ||
37 |
void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e ) |
|
38 |
{ |
|
39 |
//check if we operate on a vector layer |
|
40 |
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ); |
|
41 |
if ( !vlayer ) |
|
42 |
{ |
|
43 |
QMessageBox::information( 0, |
|
44 |
tr( "Not a vector layer" ), |
|
45 |
tr( "The current layer is not a vector layer" ) ); |
|
46 |
return; |
|
47 |
} |
|
48 | ||
49 |
if ( !vlayer->isEditable() ) |
|
50 |
{ |
|
51 |
QMessageBox::information( 0, |
|
52 |
tr( "Layer not editable" ), |
|
53 |
tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) |
|
54 |
); |
|
55 |
return; |
|
56 |
} |
|
57 | ||
58 |
//inform user at the begin of the digitising action that the island tool only works if exactly one feature is selected |
|
59 |
int nSelectedFeatures = vlayer->selectedFeatureCount(); |
|
60 |
QString selectionErrorMsg; |
|
61 |
if ( nSelectedFeatures < 1 ) |
|
62 |
{ |
|
63 |
selectionErrorMsg = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); |
|
64 |
} |
|
65 |
else if ( nSelectedFeatures > 1 ) |
|
66 |
{ |
|
67 |
selectionErrorMsg = tr( "Several features are selected. Please select only one feature to which an part should be added." ); |
|
68 |
} |
|
69 | ||
70 |
if ( !selectionErrorMsg.isEmpty() ) |
|
71 |
{ |
|
72 |
QMessageBox::critical( 0, tr( "Error. Could not add part." ), selectionErrorMsg ); |
|
73 |
stopCapturing(); |
|
74 |
return; |
|
75 |
} |
|
76 | ||
77 |
int errorCode; |
|
78 |
switch ( mode() ) |
|
79 |
{ |
|
80 |
case CapturePoint: |
|
81 |
{ |
|
82 |
QgsPoint layerPoint; |
|
83 |
QgsPoint mapPoint; |
|
84 | ||
85 |
if ( nextPoint( e->pos(), layerPoint, mapPoint ) != 0 ) |
|
86 |
{ |
|
87 |
QgsDebugMsg( "nextPoint failed" ); |
|
88 |
return; |
|
89 |
} |
|
90 | ||
91 |
vlayer->beginEditCommand( tr( "Part added" ) ); |
|
92 |
errorCode = vlayer->addPart( QList<QgsPoint>() << layerPoint ); |
|
93 |
} |
|
94 |
break; |
|
95 | ||
96 |
case CaptureLine: |
|
97 |
case CapturePolygon: |
|
98 |
{ |
|
99 |
//add point to list and to rubber band |
|
100 |
int error = addVertex( e->pos() ); |
|
101 |
if ( error == 1 ) |
|
102 |
{ |
|
103 |
QgsDebugMsg( "current layer is not a vector layer" ); |
|
104 |
return; |
|
105 |
} |
|
106 |
else if ( error == 2 ) |
|
107 |
{ |
|
108 |
//problem with coordinate transformation |
|
109 |
QMessageBox::information( 0, |
|
110 |
tr( "Coordinate transform error" ), |
|
111 |
tr( "Cannot transform the point to the layers coordinate system" ) ); |
|
112 |
return; |
|
113 |
} |
|
114 | ||
115 |
if ( e->button() == Qt::LeftButton ) |
|
116 |
{ |
|
117 |
startCapturing(); |
|
118 |
return; |
|
119 |
} |
|
120 |
else if ( e->button() != Qt::RightButton ) |
|
121 |
{ |
|
122 |
return; |
|
123 |
} |
|
124 | ||
125 |
if ( mode() == CapturePolygon ) |
|
126 |
{ |
|
127 |
//close polygon |
|
128 |
closePolygon(); |
|
129 |
} |
|
130 | ||
131 |
vlayer->beginEditCommand( tr( "Part added" ) ); |
|
132 |
errorCode = vlayer->addPart( points() ); |
|
133 | ||
134 |
stopCapturing(); |
|
135 |
} |
|
136 |
break; |
|
137 |
} |
|
138 | ||
139 |
QString errorMessage; |
|
140 |
switch ( errorCode ) |
|
141 |
{ |
|
142 |
case 0: |
|
143 |
{ |
|
144 |
//add points to other features to keep topology up-to-date |
|
145 |
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); |
|
146 |
if ( topologicalEditing ) |
|
147 |
{ |
|
148 |
addTopologicalPoints( points() ); |
|
149 |
} |
|
150 | ||
151 |
vlayer->endEditCommand(); |
|
152 | ||
153 |
mCanvas->refresh(); |
|
154 |
return; |
|
155 |
} |