commit 9e61488d52ab0ccfaf33b2ef351acbc9288c0fd2 Author: Juergen E. Fischer Date: Mon Apr 25 16:57:59 2011 +0200 digitizing update: allow adding parts to points and line plus some refactoring diff --git a/images/images.qrc b/images/images.qrc index 6d2aa9e..4431d36 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -21,7 +21,7 @@ themes/default/mActionAddArrow.png themes/default/mActionAddBasicShape.png themes/default/mActionAddImage.png - themes/default/mActionAddIsland.png + themes/default/mActionAddPart.png themes/default/mActionAddLayer.png themes/default/mActionAddLegend.png themes/default/mActionAddMap.png @@ -219,7 +219,7 @@ themes/gis/mActionAddBasicShape.png themes/gis/mActionAddGPSLayer.png themes/gis/mActionAddImage.png - themes/gis/mActionAddIsland.png + themes/gis/mActionAddPart.png themes/gis/mActionAddLayer.png themes/gis/mActionAddLegend.png themes/gis/mActionAddMap.png diff --git a/images/themes/classic/mActionAddIsland.png b/images/themes/classic/mActionAddIsland.png deleted file mode 100644 index db77d984359177a6b67b05377e443a711c41a43d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 841 zcmV-P1GfB$P)Lm0L&@Q5eU6XJ*!GSCf*m5RD4D5LskBv|9v~MS(#V z=%FZzh$wsLC8D)LB8Z6Iy3tE?g(4z-=yHUL#fp~fVwde=nU$-ers=vnr-#{{-OX7O z`rt6%ob%0(|M$&z&Vm25Q+JvcctJ@}N=hZ8{(nLDU3@#t2`WJuv7o{!#W(ZD6$Spg&5N@_eFdrbm1IB#5G;NhJsyPY7SMgXAP@eC`3AQcoq8?3@a`xn#; z=LQ59%q=B5CoisC({b-O!2zYn@cB|fpO&Am+u;Zvkv|zB1fOfG=x+OA&*w~>#koBz z0LabFCBx@Sf*#V1?wx1-8;)5rIH}U@&Mw zygsB4+^XVq@e;aze5C7V zLu)M7;4ka#Y=wma?pq!3VEZw9O?n{cv!IogmH7RBMitH=7_dsBlqphztq7QUa2=D1 z7jb?0RvRh-SyE!vR9c}eJV(@sq*hD+SrheQV=zQd91eI?HUUq z?2X`LUYQJCdHW1_Aahl2JkbQvDf@W%+5#3|Ji?Y|_w2d7UtdxFsSbdfrCUIPk&%sZ zE2|Vr*~HAU4K^cT+piE- zj%K(oRd`Hs+>bel2fb;UBGlWR(fzAqXejhMQz<2c&`e#^Bbu&9G~EbmnjSF>SJ-f+ zgLm0L&@Q5eU6XJ*!GSCf*m5RD4D5LskBv|9v~MS(#V z=%FZzh$wsLC8D)LB8Z6Iy3tE?g(4z-=yHUL#fp~fVwde=nU$-ers=vnr-#{{-OX7O z`rt6%ob%0(|M$&z&Vm25Q+JvcctJ@}N=hZ8{(nLDU3@#t2`WJuv7o{!#W(ZD6$Spg&5N@_eFdrbm1IB#5G;NhJsyPY7SMgXAP@eC`3AQcoq8?3@a`xn#; z=LQ59%q=B5CoisC({b-O!2zYn@cB|fpO&Am+u;Zvkv|zB1fOfG=x+OA&*w~>#koBz z0LabFCBx@Sf*#V1?wx1-8;)5rIH}U@&Mw zygsB4+^XVq@e;aze5C7V zLu)M7;4ka#Y=wma?pq!3VEZw9O?n{cv!IogmH7RBMitH=7_dsBlqphztq7QUa2=D1 z7jb?0RvRh-SyE!vR9c}eJV(@sq*hD+SrheQV=zQd91eI?HUUq z?2X`LUYQJCdHW1_Aahl2JkbQvDf@W%+5#3|Ji?Y|_w2d7UtdxFsSbdfrCUIPk&%sZ zE2|Vr*~HAU4K^cT+piE- zj%K(oRd`Hs+>bel2fb;UBGlWR(fzAqXejhMQz<2c&`e#^Bbu&9G~EbmnjSF>SJ-f+ zg1VJ_v%NA>m5{xVg7F?iER*|L9p+Ie!&UEJZ zN9WZk%(N7UC%Jj|y!-C?efPe5-+f0^mHJFXS^?vMOu!9z!dJUo15QUN+f?EF&V;1vgz5*dOaq4@ z9LZhCfzLl6Joul0Y*nqWwTvj@y@3qGApY?j#OaFqif+n8==jWJ`psC0>5K>H4UCO^ z41n48VGK|6TNjV8Hoc#s>*%SrJ6S|(bfW<{0iEQGod5CfxtnDBGP<7eFCE@YqiLd)C}hh|CeM+tt1z(k&Lim%wrW-!}{J?O6-K zsyhOZlGc${S^aJIxu^hIy)P#Kt3j#QI+qKx`rutLk*hzh!e4y!wjf$|?Ppgz0$9-= zQq_=%ybOeZ=ha`~^cC*FSGa>qo50<95Uobf!qMoi1_PwD$*2Vo?G@M%K~;STXbcPn z<^u%)WxwT9G*3E(hcO{<3Lqj~MC5l7IV2+MMC6_bpnTvVV0XxWjiMzJIRC?{n+7l~C-I&X z+f9o0DV_xE0XhL0z{rAveNP4g6SJe_=0FaA@IQGRmTrS*w(-6TxrCqJ8 zS%e~z2&@B!0(9$^#e@m3a^}ogI&{cbw0QASd_JE7yG5jrs$LV35!Dbn?C|m_q|Don zm5^9JfWPKItc=_RGvean9`XDAOq%otvu1sW!{MlD?A5CmmSssG5a@~b@byb1^zwP;r@aVe(Gb$@9J*!u*V&1$twZs9sbm>e^&Re$ok%%;_ zj;F;yF2KcodG(L}zv&04wAVln!!Sbq`t@bRh^J$Ao;GbNiHV5-2|&AurriJ)#U~mJ zU;(J=!o7Qc9%-6ppSn6b91dEvXhBg?5kSj`rc{9VCM~1(i!|TWOSJ%Mc0p!lr&X2} z^}|@p($d=Ca5&0sQ4xs)UI1`4Pph~8zBTjh>Pg^=6%NwGG|jhFmE*^YNKH+R8DR6~ zTtsAy)0wa_d@BcNXC@@kdhqx<#V?)sgM-^v*zPn{tug>q)f)^3gP~A}4I4Jb3;^Ku zdI^Ps-Y|G7Fde{kcRFTV-CJ)S?AgE7=POsAuUtz?igm+=b?WiB?Sx}1U_|sC3S0@dsg>Z?<_`|k)U1JOI^(ZT zR+iREey+=e(g81^+1Z2i@@21f@7`T4%Zd!}C*X;aMRf$W02SPrA)N*m0TTgtOn`8p zM@8h^`t@tS_xZ|~cs%Yi;UHIlO+edv(z$qG2rvzJ4;TiR4NA>KBtccLh3kWXQedyD k2BR*H+pw6q;s0g-0@@6f?Z%$9WdHyG07*qoM6N<$f=lkR4FCWD diff --git a/images/themes/default/mActionAddPart.png b/images/themes/default/mActionAddPart.png new file mode 100644 index 0000000000000000000000000000000000000000..fbecdea9175da6120a04a01ac9aeab9e678ff106 GIT binary patch literal 1482 zcmV;*1vUDKP)1VJ_v%NA>m5{xVg7F?iER*|L9p+Ie!&UEJZ zN9WZk%(N7UC%Jj|y!-C?efPe5-+f0^mHJFXS^?vMOu!9z!dJUo15QUN+f?EF&V;1vgz5*dOaq4@ z9LZhCfzLl6Joul0Y*nqWwTvj@y@3qGApY?j#OaFqif+n8==jWJ`psC0>5K>H4UCO^ z41n48VGK|6TNjV8Hoc#s>*%SrJ6S|(bfW<{0iEQGod5CfxtnDBGP<7eFCE@YqiLd)C}hh|CeM+tt1z(k&Lim%wrW-!}{J?O6-K zsyhOZlGc${S^aJIxu^hIy)P#Kt3j#QI+qKx`rutLk*hzh!e4y!wjf$|?Ppgz0$9-= zQq_=%ybOeZ=ha`~^cC*FSGa>qo50<95Uobf!qMoi1_PwD$*2Vo?G@M%K~;STXbcPn z<^u%)WxwT9G*3E(hcO{<3Lqj~MC5l7IV2+MMC6_bpnTvVV0XxWjiMzJIRC?{n+7l~C-I&X z+f9o0DV_xE0XhL0z{rAveNP4g6SJe_=0FaA@IQGRmTrS*w(-6TxrCqJ8 zS%e~z2&@B!0(9$^#e@m3a^}ogI&{cbw0QASd_JE7yG5jrs$LV35!Dbn?C|m_q|Don zm5^9JfWPKItc=_RGvean9`XDAOq%otvu1sW!{MlD?A5CmmSssG5a@~b@byb1^zwP;r@aVe(Gb$@9J*!u*V&1$twZs9sbm>e^&Re$ok%%;_ zj;F;yF2KcodG(L}zv&04wAVln!!Sbq`t@bRh^J$Ao;GbNiHV5-2|&AurriJ)#U~mJ zU;(J=!o7Qc9%-6ppSn6b91dEvXhBg?5kSj`rc{9VCM~1(i!|TWOSJ%Mc0p!lr&X2} z^}|@p($d=Ca5&0sQ4xs)UI1`4Pph~8zBTjh>Pg^=6%NwGG|jhFmE*^YNKH+R8DR6~ zTtsAy)0wa_d@BcNXC@@kdhqx<#V?)sgM-^v*zPn{tug>q)f)^3gP~A}4I4Jb3;^Ku zdI^Ps-Y|G7Fde{kcRFTV-CJ)S?AgE7=POsAuUtz?igm+=b?WiB?Sx}1U_|sC3S0@dsg>Z?<_`|k)U1JOI^(ZT zR+iREey+=e(g81^+1Z2i@@21f@7`T4%Zd!}C*X;aMRf$W02SPrA)N*m0TTgtOn`8p zM@8h^`t@tS_xZ|~cs%Yi;UHIlO+edv(z$qG2rvzJ4;TiR4NA>KBtccLh3kWXQedyD k2BR*H+pw6q;s0g-0@@6f?Z%$9WdHyG07*qoM6N<$f=lkR4FCWD literal 0 HcmV?d00001 diff --git a/images/themes/gis/mActionAddIsland.png b/images/themes/gis/mActionAddIsland.png deleted file mode 100644 index 09b4d122577fff3f5c35ea7a19453c7133c29916..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1421 zcmV;81#`;tk{%$)iD|Nkc6KSU{oLiqjuI^EQ^GD;RHKv#e!g&ef()aQ0eojiE( z;KZy$cLB){;P?9*bcgn~l5%a+(q)?0<7EJ#0K{TZ3=ZCikA=eq=KTAXnqr5sKPE6}^Y_dL&LubF&zZB4CfS<`Z=l**Ax zDWR0geFH#ANhwN7N_qYL4IUu`Y}+<;T?Zk=0D!C4t}ed(+r{?*G!vy10)h2wO{eq7 zhTuz1P19y%o}Ybo%yn=1kW%8yV@H!#O01#)KskS6>5?X=rfIoM=gK}i|2t4h;qz5O zQS}f70M6Ka(=g{GD-8Hg!5QaJ(m?@05n?FJCi}1C0KhqCgb}BIr_*VKLZcWQ`ZFFH3psR6PkFswxuCMDsJeO~ zDI`xM5*Q1IxKi|F&Ij!;`ZrQa_p~&xbS$c=C8^XD28V|5$Bpap@$s2iaROq_{Z6Zrmzvy*8ny}j$>o_A+CS<~6)wy*g_-*Oem6JRA&qM*%FD`WBy!72PEAhPLT%~U-}4Dj&?@o{>YQ`0 ztLwVy1EYhIG5gS!M1gPtfLCQcsynO9UUE3cJFQh9$_Xq=&AOYWp(Aw z$y<}Sd0}WII+3X9>+4IM`G~Ah5<3addbdkfz&S#(l^1TbZwzeL9CSzhQ;p8z1#Spi zz;mw`vC&wu64(ylO(n6D>+V*^yu~2Q1Z5`bA3uRh#~*_fQ&3_G$@oC4osRCL`Q*V3 zZLe{I?`V0s)#i~cNt*+7*Xiguv?g3>c0Dv+RT=zh8`rs;U z0RdWb6$CcC;Aa|tYk8pAp}90jJ42q8km(ErD9-+0c8?#$m5*ZLdKZc-9tHqZE_ofX z&}o#`1QEOWHDV**fKO|_h8gU`2LjCwqu78Hv)#)y2Bk1BJC6()DNiXb!5)dw&3&68E&(pthOwZwU{YQ7PoIiq*AgkzXGPa0VoueuY#xgX%v;O z0-(TjHzGqvGXa#MPN&x?rOXh|)!3}0h0&i!l9nys%dYwAH^bMk1p}vohz=h^#eJ_L zI(!TRr-JY`Y=N(SGXQ`qsxC}iA7|sgkHfRjGfSGO+eutGapjH_YESR}-t*b@(3K91 zT;2sJiOAp~l-2|>aJqfEy2GGU2QY24Kw$lYRObgMr$wg6VLMBlrjknD8Be5=ktBzW zZQb3U?#Vvn{d>vTLX)k2Md7=>Gy9$b&gGoEY11Yx8V%P8uv$RY0T4v8pLAV6U)YEK bjg$WZmIMUgntT-o00000NkvXXu0mjfv0s=) diff --git a/images/themes/gis/mActionAddPart.png b/images/themes/gis/mActionAddPart.png new file mode 100644 index 0000000000000000000000000000000000000000..09b4d122577fff3f5c35ea7a19453c7133c29916 GIT binary patch literal 1421 zcmV;81#`;tk{%$)iD|Nkc6KSU{oLiqjuI^EQ^GD;RHKv#e!g&ef()aQ0eojiE( z;KZy$cLB){;P?9*bcgn~l5%a+(q)?0<7EJ#0K{TZ3=ZCikA=eq=KTAXnqr5sKPE6}^Y_dL&LubF&zZB4CfS<`Z=l**Ax zDWR0geFH#ANhwN7N_qYL4IUu`Y}+<;T?Zk=0D!C4t}ed(+r{?*G!vy10)h2wO{eq7 zhTuz1P19y%o}Ybo%yn=1kW%8yV@H!#O01#)KskS6>5?X=rfIoM=gK}i|2t4h;qz5O zQS}f70M6Ka(=g{GD-8Hg!5QaJ(m?@05n?FJCi}1C0KhqCgb}BIr_*VKLZcWQ`ZFFH3psR6PkFswxuCMDsJeO~ zDI`xM5*Q1IxKi|F&Ij!;`ZrQa_p~&xbS$c=C8^XD28V|5$Bpap@$s2iaROq_{Z6Zrmzvy*8ny}j$>o_A+CS<~6)wy*g_-*Oem6JRA&qM*%FD`WBy!72PEAhPLT%~U-}4Dj&?@o{>YQ`0 ztLwVy1EYhIG5gS!M1gPtfLCQcsynO9UUE3cJFQh9$_Xq=&AOYWp(Aw z$y<}Sd0}WII+3X9>+4IM`G~Ah5<3addbdkfz&S#(l^1TbZwzeL9CSzhQ;p8z1#Spi zz;mw`vC&wu64(ylO(n6D>+V*^yu~2Q1Z5`bA3uRh#~*_fQ&3_G$@oC4osRCL`Q*V3 zZLe{I?`V0s)#i~cNt*+7*Xiguv?g3>c0Dv+RT=zh8`rs;U z0RdWb6$CcC;Aa|tYk8pAp}90jJ42q8km(ErD9-+0c8?#$m5*ZLdKZc-9tHqZE_ofX z&}o#`1QEOWHDV**fKO|_h8gU`2LjCwqu78Hv)#)y2Bk1BJC6()DNiXb!5)dw&3&68E&(pthOwZwU{YQ7PoIiq*AgkzXGPa0VoueuY#xgX%v;O z0-(TjHzGqvGXa#MPN&x?rOXh|)!3}0h0&i!l9nys%dYwAH^bMk1p}vohz=h^#eJ_L zI(!TRr-JY`Y=N(SGXQ`qsxC}iA7|sgkHfRjGfSGO+eutGapjH_YESR}-t*b@(3K91 zT;2sJiOAp~l-2|>aJqfEy2GGU2QY24Kw$lYRObgMr$wg6VLMBlrjknD8Be5=ktBzW zZQb3U?#Vvn{d>vTLX)k2Md7=>Gy9$b&gGoEY11Yx8V%P8uv$RY0T4v8pLAV6U)YEK bjg$WZmIMUgntT-o00000NkvXXu0mjfv0s=) literal 0 HcmV?d00001 diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index ca12ada..b3109a3 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -201,9 +201,10 @@ class QgisInterface : QObject virtual QAction *actionCopyFeatures() = 0; virtual QAction *actionPasteFeatures() = 0; virtual QAction *actionEditSeparator1() = 0 /Deprecated/; - virtual QAction *actionCapturePoint() = 0; - virtual QAction *actionCaptureLine() = 0; - virtual QAction *actionCapturePolygon() = 0; + virtual QAction *actionAddFeature() = 0; + virtual QAction *actionCapturePoint() = 0 /Deprecated/; + virtual QAction *actionCaptureLine() = 0 /Deprecated/; + virtual QAction *actionCapturePolygon() = 0 /Deprecated/; virtual QAction *actionDeleteSelected() = 0; virtual QAction *actionMoveFeature() = 0; virtual QAction *actionSplitFeatures() = 0; @@ -211,7 +212,8 @@ class QgisInterface : QObject virtual QAction *actionDeleteVertex() = 0 /Deprecated/; virtual QAction *actionMoveVertex() = 0 /Deprecated/; virtual QAction *actionAddRing() = 0; - virtual QAction *actionAddIsland() = 0; + virtual QAction *actionAddPart() = 0; + virtual QAction *actionAddIsland() = 0 /Deprecated/; virtual QAction *actionSimplifyFeature() = 0; virtual QAction *actionDeleteRing() = 0; virtual QAction *actionDeletePart() = 0; diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 93b55c3..2245c2a 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -34,7 +34,7 @@ SET(QGIS_APP_SRCS qgslabelpreview.cpp qgsmaptooladdfeature.cpp qgsmaptooladdvertex.cpp - qgsmaptooladdisland.cpp + qgsmaptooladdpart.cpp qgsmaptooladdring.cpp qgsmaptoolannotation.cpp qgsmaptoolcapture.cpp @@ -172,7 +172,8 @@ SET (QGIS_APP_MOC_HDRS qgslabelpropertydialog.h qgsmanageconnectionsdialog.h qgsmaptooladdfeature.h - qgsmaptooladdisland.h + qgsmaptoolcapture.h + qgsmaptooladdpart.h qgsmaptooladdring.h qgsmaptooladdvertex.h qgsmaptoolchangelabelproperties.h diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 8221afe..54bb915 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -187,7 +187,7 @@ // Map tools // #include "qgsmaptooladdfeature.h" -#include "qgsmaptooladdisland.h" +#include "qgsmaptooladdpart.h" #include "qgsmaptooladdring.h" #include "qgsmaptooladdvertex.h" #include "qgsmaptoolannotation.h" @@ -598,9 +598,7 @@ QgisApp::~QgisApp() delete mMapTools.mTextAnnotation; delete mMapTools.mFormAnnotation; delete mMapTools.mAnnotation; - delete mMapTools.mCapturePoint; - delete mMapTools.mCaptureLine; - delete mMapTools.mCapturePolygon; + delete mMapTools.mAddFeature; delete mMapTools.mMoveFeature; delete mMapTools.mReshapeFeatures; delete mMapTools.mSplitFeatures; @@ -609,18 +607,11 @@ QgisApp::~QgisApp() delete mMapTools.mSelectPolygon; delete mMapTools.mSelectFreehand; delete mMapTools.mSelectRadius; - -#if 0 //these three tools to be deprecated - use node tool rather - delete mMapTools.mVertexAdd; - delete mMapTools.mVertexMove; - delete mMapTools.mVertexDelete; -#endif - delete mMapTools.mAddRing; delete mMapTools.mSimplifyFeature; delete mMapTools.mDeleteRing; delete mMapTools.mDeletePart; - delete mMapTools.mAddIsland; + delete mMapTools.mAddPart; delete mMapTools.mNodeTool; delete mMapTools.mMoveLabel; delete mMapTools.mRotateLabel; @@ -733,15 +724,13 @@ void QgisApp::createActions() connect( mActionCutFeatures, SIGNAL( triggered() ), this, SLOT( editCut() ) ); connect( mActionCopyFeatures, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); connect( mActionPasteFeatures, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); - connect( mActionCapturePoint, SIGNAL( triggered() ), this, SLOT( capturePoint() ) ); - connect( mActionCaptureLine, SIGNAL( triggered() ), this, SLOT( captureLine() ) ); - connect( mActionCapturePolygon, SIGNAL( triggered() ), this, SLOT( capturePolygon() ) ); + connect( mActionAddFeature, SIGNAL( triggered() ), this, SLOT( addFeature() ) ); connect( mActionMoveFeature, SIGNAL( triggered() ), this, SLOT( moveFeature() ) ); connect( mActionReshapeFeatures, SIGNAL( triggered() ), this, SLOT( reshapeFeatures() ) ); connect( mActionSplitFeatures, SIGNAL( triggered() ), this, SLOT( splitFeatures() ) ); connect( mActionDeleteSelected, SIGNAL( triggered() ), this, SLOT( deleteSelected() ) ); connect( mActionAddRing, SIGNAL( triggered() ), this, SLOT( addRing() ) ); - connect( mActionAddIsland, SIGNAL( triggered() ), this, SLOT( addIsland() ) ); + connect( mActionAddPart, SIGNAL( triggered() ), this, SLOT( addPart() ) ); connect( mActionSimplifyFeature, SIGNAL( triggered() ), this, SLOT( simplifyFeature() ) ); connect( mActionDeleteRing, SIGNAL( triggered() ), this, SLOT( deleteRing() ) ); connect( mActionDeletePart, SIGNAL( triggered() ), this, SLOT( deletePart() ) ); @@ -945,15 +934,13 @@ void QgisApp::createActionGroups() mMapToolGroup->addAction( mActionMeasure ); mMapToolGroup->addAction( mActionMeasureArea ); mMapToolGroup->addAction( mActionMeasureAngle ); - mMapToolGroup->addAction( mActionCaptureLine ); - mMapToolGroup->addAction( mActionCapturePoint ); - mMapToolGroup->addAction( mActionCapturePolygon ); + mMapToolGroup->addAction( mActionAddFeature ); mMapToolGroup->addAction( mActionMoveFeature ); mMapToolGroup->addAction( mActionReshapeFeatures ); mMapToolGroup->addAction( mActionSplitFeatures ); mMapToolGroup->addAction( mActionDeleteSelected ); mMapToolGroup->addAction( mActionAddRing ); - mMapToolGroup->addAction( mActionAddIsland ); + mMapToolGroup->addAction( mActionAddPart ); mMapToolGroup->addAction( mActionSimplifyFeature ); mMapToolGroup->addAction( mActionDeleteRing ); mMapToolGroup->addAction( mActionDeletePart ); @@ -1375,24 +1362,17 @@ void QgisApp::setTheme( QString theThemeName ) mActionCutFeatures->setIcon( getThemeIcon( "/mActionEditCut.png" ) ); mActionCopyFeatures->setIcon( getThemeIcon( "/mActionEditCopy.png" ) ); mActionPasteFeatures->setIcon( getThemeIcon( "/mActionEditPaste.png" ) ); - mActionCapturePoint->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); - mActionCaptureLine->setIcon( getThemeIcon( "/mActionCaptureLine.png" ) ); - mActionCapturePolygon->setIcon( getThemeIcon( "/mActionCapturePolygon.png" ) ); + mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); mActionMoveFeature->setIcon( getThemeIcon( "/mActionMoveFeature.png" ) ); mActionReshapeFeatures->setIcon( getThemeIcon( "/mActionReshape.png" ) ); mActionSplitFeatures->setIcon( getThemeIcon( "/mActionSplitFeatures.png" ) ); mActionDeleteSelected->setIcon( getThemeIcon( "/mActionDeleteSelected.png" ) ); -#if 0 //these three icons to be deprecated - mActionAddVertex->setIcon( getThemeIcon( "/mActionAddVertex.png" ) ); - mActionMoveVertex->setIcon( getThemeIcon( "/mActionMoveVertex.png" ) ); - mActionDeleteVertex->setIcon( getThemeIcon( "/mActionDeleteVertex.png" ) ); -#endif mActionNodeTool->setIcon( getThemeIcon( "/mActionNodeTool.png" ) ); mActionSimplifyFeature->setIcon( getThemeIcon( "/mActionSimplify.png" ) ); mActionUndo->setIcon( getThemeIcon( "/mActionUndo.png" ) ); mActionRedo->setIcon( getThemeIcon( "/mActionRedo.png" ) ); mActionAddRing->setIcon( getThemeIcon( "/mActionAddRing.png" ) ); - mActionAddIsland->setIcon( getThemeIcon( "/mActionAddIsland.png" ) ); + mActionAddPart->setIcon( getThemeIcon( "/mActionAddPart.png" ) ); mActionDeleteRing->setIcon( getThemeIcon( "/mActionDeleteRing.png" ) ); mActionDeletePart->setIcon( getThemeIcon( "/mActionDeletePart.png" ) ); mActionMergeFeatures->setIcon( getThemeIcon( "/mActionMergeFeatures.png" ) ); @@ -1542,15 +1522,8 @@ void QgisApp::createCanvasTools() mMapTools.mFormAnnotation->setAction( mActionFormAnnotation ); mMapTools.mAnnotation = new QgsMapToolAnnotation( mMapCanvas ); mMapTools.mAnnotation->setAction( mActionAnnotation ); - mMapTools.mCapturePoint = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePoint ); - mMapTools.mCapturePoint->setAction( mActionCapturePoint ); - mActionCapturePoint->setVisible( false ); - mMapTools.mCaptureLine = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CaptureLine ); - mMapTools.mCaptureLine->setAction( mActionCaptureLine ); - mActionCaptureLine->setVisible( false ); - mMapTools.mCapturePolygon = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePolygon ); - mMapTools.mCapturePolygon->setAction( mActionCapturePolygon ); - mActionCapturePolygon->setVisible( false ); + mMapTools.mAddFeature = new QgsMapToolAddFeature( mMapCanvas ); + mMapTools.mAddFeature->setAction( mActionAddFeature ); mMapTools.mMoveFeature = new QgsMapToolMoveFeature( mMapCanvas ); mMapTools.mMoveFeature->setAction( mActionMoveFeature ); mMapTools.mReshapeFeatures = new QgsMapToolReshape( mMapCanvas ); @@ -1567,18 +1540,9 @@ void QgisApp::createCanvasTools() mMapTools.mSelectFreehand->setAction( mActionSelectFreehand ); mMapTools.mSelectRadius = new QgsMapToolSelectRadius( mMapCanvas ); mMapTools.mSelectRadius->setAction( mActionSelectRadius ); - -#if 0 //these three tools to be deprecated - use node tool rather - mMapTools.mVertexAdd = new QgsMapToolAddVertex( mMapCanvas ); - mMapTools.mVertexAdd->setAction( mActionAddVertex ); - mMapTools.mVertexMove = new QgsMapToolMoveVertex( mMapCanvas ); - mMapTools.mVertexMove->setAction( mActionMoveVertex ); - mMapTools.mVertexDelete = new QgsMapToolDeleteVertex( mMapCanvas ); - mMapTools.mVertexDelete->setAction( mActionDeleteVertex ); -#endif mMapTools.mAddRing = new QgsMapToolAddRing( mMapCanvas ); mMapTools.mAddRing->setAction( mActionAddRing ); - mMapTools.mAddIsland = new QgsMapToolAddIsland( mMapCanvas ); + mMapTools.mAddPart = new QgsMapToolAddPart( mMapCanvas ); mMapTools.mSimplifyFeature = new QgsMapToolSimplify( mMapCanvas ); mMapTools.mSimplifyFeature->setAction( mActionSimplifyFeature ); mMapTools.mDeleteRing = new QgsMapToolDeleteRing( mMapCanvas ); @@ -3976,34 +3940,13 @@ void QgisApp::reshapeFeatures() mMapCanvas->setMapTool( mMapTools.mReshapeFeatures ); } -void QgisApp::capturePoint() -{ - if ( mMapCanvas && mMapCanvas->isDrawing() ) - { - return; - } - - // set current map tool to select - mMapCanvas->setMapTool( mMapTools.mCapturePoint ); -} - -void QgisApp::captureLine() +void QgisApp::addFeature() { if ( mMapCanvas && mMapCanvas->isDrawing() ) { return; } - - mMapCanvas->setMapTool( mMapTools.mCaptureLine ); -} - -void QgisApp::capturePolygon() -{ - if ( mMapCanvas && mMapCanvas->isDrawing() ) - { - return; - } - mMapCanvas->setMapTool( mMapTools.mCapturePolygon ); + mMapCanvas->setMapTool( mMapTools.mAddFeature ); } void QgisApp::select() @@ -4058,25 +4001,6 @@ void QgisApp::deselectAll() mMapCanvas->setRenderFlag( true ); } -void QgisApp::addVertex() -{ - if ( mMapCanvas && mMapCanvas->isDrawing() ) - { - return; - } - mMapCanvas->setMapTool( mMapTools.mVertexAdd ); - -} - -void QgisApp::moveVertex() -{ - if ( mMapCanvas && mMapCanvas->isDrawing() ) - { - return; - } - mMapCanvas->setMapTool( mMapTools.mVertexMove ); -} - void QgisApp::addRing() { if ( mMapCanvas && mMapCanvas->isDrawing() ) @@ -4086,23 +4010,13 @@ void QgisApp::addRing() mMapCanvas->setMapTool( mMapTools.mAddRing ); } -void QgisApp::addIsland() -{ - if ( mMapCanvas && mMapCanvas->isDrawing() ) - { - return; - } - mMapCanvas->setMapTool( mMapTools.mAddIsland ); -} - - -void QgisApp::deleteVertex() +void QgisApp::addPart() { if ( mMapCanvas && mMapCanvas->isDrawing() ) { return; } - mMapCanvas->setMapTool( mMapTools.mVertexDelete ); + mMapCanvas->setMapTool( mMapTools.mAddPart ); } @@ -5769,9 +5683,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) mActionLayerSubsetString->setEnabled( false ); mActionAddToOverview->setEnabled( false ); - mActionCapturePoint->setEnabled( false ); - mActionCaptureLine->setEnabled( false ); - mActionCapturePolygon->setEnabled( false ); + mActionAddFeature->setEnabled( false ); mActionMoveFeature->setEnabled( false ); mActionNodeTool->setEnabled( false ); mActionDeleteSelected->setEnabled( false ); @@ -5783,7 +5695,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) mActionRedo->setEnabled( false ); mActionSimplifyFeature->setEnabled( false ); mActionAddRing->setEnabled( false ); - mActionAddIsland->setEnabled( false ); + mActionAddPart->setEnabled( false ); mActionDeleteRing->setEnabled( false ); mActionDeletePart->setEnabled( false ); mActionReshapeFeatures->setEnabled( false ); @@ -5792,10 +5704,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) mActionMergeFeatureAttributes->setEnabled( false ); mActionRotatePointSymbols->setEnabled( false ); - mActionCapturePoint->setVisible( false ); - mActionCaptureLine->setVisible( false ); - mActionCapturePolygon->setVisible( false ); - mActionMoveLabel->setEnabled( false ); mActionRotateLabel->setEnabled( false ); mActionChangeLabelProperties->setEnabled( false ); @@ -5858,10 +5766,12 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) if ( dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) { mActionPasteFeatures->setEnabled( vlayer->isEditable() && !clipboard()->empty() ); + mActionAddFeature->setEnabled( vlayer->isEditable() ); } else { mActionPasteFeatures->setEnabled( false ); + mActionAddFeature->setEnabled( !vlayer->isEditable() ); } //does provider allow deleting of features? @@ -5894,58 +5804,30 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) // moving enabled if geometry changes are supported if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) { + mActionAddPart->setEnabled( true ); + mActionDeletePart->setEnabled( true ); mActionMoveFeature->setEnabled( true ); mActionNodeTool->setEnabled( true ); } else { + mActionAddPart->setEnabled( false ); + mActionDeletePart->setEnabled( false ); mActionMoveFeature->setEnabled( false ); mActionNodeTool->setEnabled( false ); } if ( vlayer->geometryType() == QGis::Point ) { - if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) - { - mActionCapturePoint->setEnabled( true ); - mActionCapturePoint->setVisible( true ); - mActionDeletePart->setEnabled( true ); - mActionAddIsland->setEnabled( true ); - } - else - { - mActionCapturePoint->setEnabled( false ); - mActionCapturePoint->setVisible( false ); - mActionDeletePart->setEnabled( false ); - mActionAddIsland->setEnabled( false ); - } - mActionCaptureLine->setEnabled( false ); - mActionCapturePolygon->setEnabled( false ); - mActionCaptureLine->setVisible( false ); - mActionCapturePolygon->setVisible( false ); -#if 0 //these three tools to be deprecated - use node tool rather - mActionAddVertex->setEnabled( false ); - mActionDeleteVertex->setEnabled( false ); - mActionMoveVertex->setEnabled( false ); -#endif + mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePoint.png" ) ); + mActionAddRing->setEnabled( false ); -#if 0 - mActionAddIsland->setEnabled( false ); -#endif - mActionAddIsland->setEnabled( false ); mActionReshapeFeatures->setEnabled( false ); mActionSplitFeatures->setEnabled( false ); mActionSimplifyFeature->setEnabled( false ); mActionDeleteRing->setEnabled( false ); mActionRotatePointSymbols->setEnabled( false ); -#if 0 - if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) - { - mActionMoveVertex->setEnabled( true ); - } -#endif - if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) { if ( QgsMapToolRotatePointSymbols::layerIsRotatable( vlayer ) ) @@ -5957,89 +5839,46 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) } else if ( vlayer->geometryType() == QGis::Line ) { + mActionAddFeature->setIcon( getThemeIcon( "/mActionCaptureLine.png" ) ); + if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) { - mActionCaptureLine->setEnabled( true ); - mActionCaptureLine->setVisible( true ); mActionReshapeFeatures->setEnabled( true ); mActionSplitFeatures->setEnabled( true ); mActionSimplifyFeature->setEnabled( true ); - mActionDeletePart->setEnabled( true ); - } else { - mActionCaptureLine->setEnabled( false ); - mActionCaptureLine->setVisible( false ); mActionReshapeFeatures->setEnabled( false ); mActionSplitFeatures->setEnabled( false ); mActionSimplifyFeature->setEnabled( false ); - mActionDeletePart->setEnabled( false ); } - mActionCapturePoint->setEnabled( false ); - mActionCapturePolygon->setEnabled( false ); - mActionCapturePoint->setVisible( false ); - mActionCapturePolygon->setVisible( false ); + mActionAddRing->setEnabled( false ); - mActionAddIsland->setEnabled( false ); mActionDeleteRing->setEnabled( false ); } else if ( vlayer->geometryType() == QGis::Polygon ) { + mActionAddFeature->setIcon( getThemeIcon( "/mActionCapturePolygon.png" ) ); + if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures ) { - mActionCapturePolygon->setEnabled( true ); - mActionCapturePolygon->setVisible( true ); mActionAddRing->setEnabled( true ); - mActionAddIsland->setEnabled( true ); mActionReshapeFeatures->setEnabled( true ); mActionSplitFeatures->setEnabled( true ); mActionSimplifyFeature->setEnabled( true ); mActionDeleteRing->setEnabled( true ); - mActionDeletePart->setEnabled( true ); } else { - mActionCapturePolygon->setEnabled( false ); - mActionCapturePolygon->setVisible( false ); mActionAddRing->setEnabled( false ); - mActionAddIsland->setEnabled( false ); mActionReshapeFeatures->setEnabled( false ); mActionSplitFeatures->setEnabled( false ); mActionSimplifyFeature->setEnabled( false ); mActionDeleteRing->setEnabled( false ); - mActionDeletePart->setEnabled( false ); } - mActionCapturePoint->setEnabled( false ); - mActionCaptureLine->setEnabled( false ); - mActionCapturePoint->setVisible( false ); - mActionCaptureLine->setVisible( false ); } - //are add/delete/move vertex supported? - if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) - { -#if 0 // these three tools to be deprecated - use node tool rather - mActionAddVertex->setEnabled( true ); - mActionMoveVertex->setEnabled( true ); - mActionDeleteVertex->setEnabled( true ); -#endif - if ( vlayer->geometryType() == QGis::Polygon ) - { - mActionAddRing->setEnabled( true ); - //some polygon layers contain also multipolygon features. - //Therefore, the test for multipolygon is done in QgsGeometry - mActionAddIsland->setEnabled( true ); - } - } - else - { -#if 0 - mActionAddVertex->setEnabled( false ); - mActionMoveVertex->setEnabled( false ); - mActionDeleteVertex->setEnabled( false ); -#endif - } return; } @@ -6079,17 +5918,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer ) mActionSaveEdits->setEnabled( false ); mActionLayerSaveAs->setEnabled( false ); mActionLayerSelectionSaveAs->setEnabled( false ); - mActionCapturePoint->setEnabled( false ); - mActionCaptureLine->setEnabled( false ); - mActionCapturePolygon->setEnabled( false ); + mActionAddFeature->setEnabled( false ); mActionDeleteSelected->setEnabled( false ); mActionAddRing->setEnabled( false ); - mActionAddIsland->setEnabled( false ); -#if 0 //these three tools to be deprecated - use node tool rather - mActionAddVertex->setEnabled( false ); - mActionDeleteVertex->setEnabled( false ); - mActionMoveVertex->setEnabled( false ); -#endif + mActionAddPart->setEnabled( false ); mActionNodeTool->setEnabled( false ); mActionMoveFeature->setEnabled( false ); mActionCopyFeatures->setEnabled( false ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 850866f..68b454c 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -226,14 +226,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QAction *actionCutFeatures() { return mActionCutFeatures; } QAction *actionCopyFeatures() { return mActionCopyFeatures; } QAction *actionPasteFeatures() { return mActionPasteFeatures; } - QAction *actionCapturePoint() { return mActionCapturePoint; } - QAction *actionCaptureLine() { return mActionCaptureLine; } - QAction *actionCapturePolygon() { return mActionCapturePolygon; } QAction *actionDeleteSelected() { return mActionDeleteSelected; } + QAction *actionAddFeature() { return mActionAddFeature; } QAction *actionMoveFeature() { return mActionMoveFeature; } QAction *actionSplitFeatures() { return mActionSplitFeatures; } QAction *actionAddRing() { return mActionAddRing; } - QAction *actionAddIsland() { return mActionAddIsland; } + QAction *actionAddPart() { return mActionAddPart; } QAction *actionSimplifyFeature() { return mActionSimplifyFeature; } QAction *actionDeleteRing() { return mActionDeleteRing; } QAction *actionDeletePart() { return mActionDeletePart; } @@ -607,28 +605,18 @@ class QgisApp : public QMainWindow, private Ui::MainWindow void showBookmarks(); //! Create a new spatial bookmark void newBookmark(); - //! activates the capture point tool - void capturePoint(); - //! activates the capture line tool - void captureLine(); - //! activates the capture polygon tool - void capturePolygon(); + //! activates the add feature tool + void addFeature(); //! activates the move feature tool void moveFeature(); //! activates the reshape features tool void reshapeFeatures(); //! activates the split features tool void splitFeatures(); - //! activates the add vertex tool - void addVertex(); - //! activates the move vertex tool - void moveVertex(); - //! activates the delete vertex tool - void deleteVertex(); //! activates the add ring tool void addRing(); - //! activates the add island tool - void addIsland(); + //! activates the add part tool + void addPart(); //! simplifies feature void simplifyFeature(); //! deletes ring in polygon @@ -923,9 +911,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QgsMapTool* mMeasureDist; QgsMapTool* mMeasureArea; QgsMapTool* mMeasureAngle; - QgsMapTool* mCapturePoint; - QgsMapTool* mCaptureLine; - QgsMapTool* mCapturePolygon; + QgsMapTool* mAddFeature; QgsMapTool* mMoveFeature; QgsMapTool* mReshapeFeatures; QgsMapTool* mSplitFeatures; @@ -938,7 +924,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QgsMapTool* mVertexMove; QgsMapTool* mVertexDelete; QgsMapTool* mAddRing; - QgsMapTool* mAddIsland; + QgsMapTool* mAddPart; QgsMapTool* mSimplifyFeature; QgsMapTool* mDeleteRing; QgsMapTool* mDeletePart; @@ -986,8 +972,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow QMenu *toolPopupOverviews; //! Popup menu for the display tools QMenu *toolPopupDisplay; - //! Popup menu for the capture tools - QMenu *toolPopupCapture; //! Map canvas QgsMapCanvas *mMapCanvas; //! Table of contents (legend) for the map diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index bbc74df..548de0a 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -313,9 +313,10 @@ QAction *QgisAppInterface::actionCutFeatures() { return qgis->actionCutFeatures( QAction *QgisAppInterface::actionCopyFeatures() { return qgis->actionCopyFeatures(); } QAction *QgisAppInterface::actionPasteFeatures() { return qgis->actionPasteFeatures(); } QAction *QgisAppInterface::actionEditSeparator1() { return 0; } -QAction *QgisAppInterface::actionCapturePoint() { return qgis->actionCapturePoint(); } -QAction *QgisAppInterface::actionCaptureLine() { return qgis->actionCaptureLine(); } -QAction *QgisAppInterface::actionCapturePolygon() { return qgis->actionCapturePolygon(); } +QAction *QgisAppInterface::actionAddFeature() { return qgis->actionAddFeature(); } +QAction *QgisAppInterface::actionCapturePoint() { return qgis->actionAddFeature(); } +QAction *QgisAppInterface::actionCaptureLine() { return qgis->actionAddFeature(); } +QAction *QgisAppInterface::actionCapturePolygon() { return qgis->actionAddFeature(); } QAction *QgisAppInterface::actionDeleteSelected() { return qgis->actionDeleteSelected(); } QAction *QgisAppInterface::actionMoveFeature() { return qgis->actionMoveFeature(); } QAction *QgisAppInterface::actionSplitFeatures() { return qgis->actionSplitFeatures(); } @@ -326,7 +327,8 @@ QAction *QgisAppInterface::actionAddVertex() { return 0; } QAction *QgisAppInterface::actionDeleteVertex() { return 0; } QAction *QgisAppInterface::actionMoveVertex() { return 0; } QAction *QgisAppInterface::actionAddRing() { return qgis->actionAddRing(); } -QAction *QgisAppInterface::actionAddIsland() { return qgis->actionAddIsland(); } +QAction *QgisAppInterface::actionAddPart() { return qgis->actionAddPart(); } +QAction *QgisAppInterface::actionAddIsland() { return qgis->actionAddPart(); } QAction *QgisAppInterface::actionSimplifyFeature() { return qgis->actionSimplifyFeature(); } QAction *QgisAppInterface::actionDeleteRing() { return qgis->actionDeleteRing(); } QAction *QgisAppInterface::actionDeletePart() { return qgis->actionDeletePart(); } diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index e5a64e2..ed95d42 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -203,9 +203,10 @@ class QgisAppInterface : public QgisInterface virtual QAction *actionCopyFeatures(); virtual QAction *actionPasteFeatures(); virtual QAction *actionEditSeparator1(); - virtual QAction *actionCapturePoint(); - virtual QAction *actionCaptureLine(); - virtual QAction *actionCapturePolygon(); + virtual QAction *actionAddFeature(); + Q_DECL_DEPRECATED virtual QAction *actionCapturePoint(); + Q_DECL_DEPRECATED virtual QAction *actionCaptureLine(); + Q_DECL_DEPRECATED virtual QAction *actionCapturePolygon(); virtual QAction *actionDeleteSelected(); virtual QAction *actionMoveFeature(); virtual QAction *actionSplitFeatures(); @@ -213,7 +214,8 @@ class QgisAppInterface : public QgisInterface virtual QAction *actionDeleteVertex(); virtual QAction *actionMoveVertex(); virtual QAction *actionAddRing(); - virtual QAction *actionAddIsland(); + virtual QAction *actionAddPart(); + Q_DECL_DEPRECATED virtual QAction *actionAddIsland(); virtual QAction *actionSimplifyFeature(); virtual QAction *actionDeleteRing(); virtual QAction *actionDeletePart(); diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index f8d4993..385cf8b 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -33,7 +33,7 @@ #include #include -QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas, CaptureMode tool ): QgsMapToolCapture( canvas, tool ) +QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas ) { } @@ -112,10 +112,6 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) } } - // emit signal - QgisApp can catch it and save point position to clipboard - // FIXME: is this still actual or something old that's not used anymore? - //emit xyClickCoordinates(idPoint); - //only do the rest for provider with feature addition support //note that for the grass provider, this will return false since //grass provider has its own mechanism of feature addition @@ -123,47 +119,17 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) { QgsFeature* f = new QgsFeature( 0, "WKBPoint" ); - int size = 0; - char endian = QgsApplication::endian(); - unsigned char *wkb = NULL; - int wkbtype = 0; - double x = savePoint.x(); - double y = savePoint.y(); - + QgsGeometry *g; if ( layerWKBType == QGis::WKBPoint || layerWKBType == QGis::WKBPoint25D ) { - size = 1 + sizeof( int ) + 2 * sizeof( double ); - wkb = new unsigned char[size]; - wkbtype = QGis::WKBPoint; - memcpy( &wkb[0], &endian, 1 ); - memcpy( &wkb[1], &wkbtype, sizeof( int ) ); - memcpy( &wkb[5], &x, sizeof( double ) ); - memcpy( &wkb[5] + sizeof( double ), &y, sizeof( double ) ); + g = QgsGeometry::fromPoint( savePoint ); } else if ( layerWKBType == QGis::WKBMultiPoint || layerWKBType == QGis::WKBMultiPoint25D ) { - size = 2 + 3 * sizeof( int ) + 2 * sizeof( double ); - wkb = new unsigned char[size]; - wkbtype = QGis::WKBMultiPoint; - int position = 0; - memcpy( &wkb[position], &endian, 1 ); - position += 1; - memcpy( &wkb[position], &wkbtype, sizeof( int ) ); - position += sizeof( int ); - int npoint = 1; - memcpy( &wkb[position], &npoint, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &endian, 1 ); - position += 1; - int pointtype = QGis::WKBPoint; - memcpy( &wkb[position], &pointtype, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - memcpy( &wkb[position], &y, sizeof( double ) ); + g = QgsGeometry::fromMultiPoint( QgsMultiPoint() << savePoint ); } - f->setGeometryAndOwnership( &wkb[0], size ); + f->setGeometry( g ); vlayer->beginEditCommand( tr( "Feature added" ) ); @@ -237,70 +203,18 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) //create QgsFeature with wkb representation QgsFeature* f = new QgsFeature( 0, "WKBLineString" ); - unsigned char* wkb; - int wkbsize; - char endian = QgsApplication::endian(); + + QgsGeometry *g; if ( mode() == CaptureLine ) { if ( layerWKBType == QGis::WKBLineString || layerWKBType == QGis::WKBLineString25D ) { - wkbsize = 1 + 2 * sizeof( int ) + 2 * size() * sizeof( double ); - wkb = new unsigned char[wkbsize]; - int wkbtype = QGis::WKBLineString; - int length = size(); - memcpy( &wkb[0], &endian, 1 ); - memcpy( &wkb[1], &wkbtype, sizeof( int ) ); - memcpy( &wkb[1+sizeof( int )], &length, sizeof( int ) ); - int position = 1 + 2 * sizeof( int ); - double x, y; - for ( QList::iterator it = begin(); it != end(); ++it ) - { - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - - memcpy( &wkb[position], &y, sizeof( double ) ); - position += sizeof( double ); - } + g = QgsGeometry::fromPolyline( points().toVector() ); } else if ( layerWKBType == QGis::WKBMultiLineString || layerWKBType == QGis::WKBMultiLineString25D ) { - wkbsize = 1 + 2 * sizeof( int ) + 1 + 2 * sizeof( int ) + 2 * size() * sizeof( double ); - wkb = new unsigned char[wkbsize]; - int position = 0; - int wkbtype = QGis::WKBMultiLineString; - memcpy( &wkb[position], &endian, 1 ); - position += 1; - memcpy( &wkb[position], &wkbtype, sizeof( int ) ); - position += sizeof( int ); - int nlines = 1; - memcpy( &wkb[position], &nlines, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &endian, 1 ); - position += 1; - int linewkbtype = QGis::WKBLineString; - memcpy( &wkb[position], &linewkbtype, sizeof( int ) ); - position += sizeof( int ); - int length = size(); - memcpy( &wkb[position], &length, sizeof( int ) ); - position += sizeof( int ); - double x, y; - for ( QList::iterator it = begin(); it != end(); ++it ) - { - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - - memcpy( &wkb[position], &y, sizeof( double ) ); - position += sizeof( double ); - } + g = QgsGeometry::fromMultiPolyline( QgsMultiPolyline() << points().toVector() ); } else { @@ -308,93 +222,19 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) stopCapturing(); return; //unknown wkbtype } - f->setGeometryAndOwnership( &wkb[0], wkbsize ); + + f->setGeometry( g ); } else // polygon { + QgsGeometry *g; if ( layerWKBType == QGis::WKBPolygon || layerWKBType == QGis::WKBPolygon25D ) { - wkbsize = 1 + 3 * sizeof( int ) + 2 * ( size() + 1 ) * sizeof( double ); - wkb = new unsigned char[wkbsize]; - int wkbtype = QGis::WKBPolygon; - int length = size() + 1;//+1 because the first point is needed twice - int numrings = 1; - memcpy( &wkb[0], &endian, 1 ); - memcpy( &wkb[1], &wkbtype, sizeof( int ) ); - memcpy( &wkb[1+sizeof( int )], &numrings, sizeof( int ) ); - memcpy( &wkb[1+2*sizeof( int )], &length, sizeof( int ) ); - int position = 1 + 3 * sizeof( int ); - double x, y; - QList::iterator it; - for ( it = begin(); it != end(); ++it ) - { - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - - memcpy( &wkb[position], &y, sizeof( double ) ); - position += sizeof( double ); - } - // close the polygon - it = begin(); - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - - memcpy( &wkb[position], &y, sizeof( double ) ); + g = QgsGeometry::fromPolygon( QgsPolygon() << points().toVector() ); } else if ( layerWKBType == QGis::WKBMultiPolygon || layerWKBType == QGis::WKBMultiPolygon25D ) { - wkbsize = 2 + 5 * sizeof( int ) + 2 * ( size() + 1 ) * sizeof( double ); - wkb = new unsigned char[wkbsize]; - int wkbtype = QGis::WKBMultiPolygon; - int polygontype = QGis::WKBPolygon; - int length = size() + 1;//+1 because the first point is needed twice - int numrings = 1; - int numpolygons = 1; - int position = 0; //pointer position relative to &wkb[0] - memcpy( &wkb[position], &endian, 1 ); - position += 1; - memcpy( &wkb[position], &wkbtype, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &numpolygons, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &endian, 1 ); - position += 1; - memcpy( &wkb[position], &polygontype, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &numrings, sizeof( int ) ); - position += sizeof( int ); - memcpy( &wkb[position], &length, sizeof( int ) ); - position += sizeof( int ); - double x, y; - QList::iterator it; - for ( it = begin(); it != end(); ++it ) //add the captured points to the polygon - { - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - - memcpy( &wkb[position], &y, sizeof( double ) ); - position += sizeof( double ); - } - // close the polygon - it = begin(); - QgsPoint savePoint = *it; - x = savePoint.x(); - y = savePoint.y(); - memcpy( &wkb[position], &x, sizeof( double ) ); - position += sizeof( double ); - memcpy( &wkb[position], &y, sizeof( double ) ); + g = QgsGeometry::fromMultiPolygon( QgsMultiPolygon() << ( QgsPolygon() << points().toVector() ) ); } else { @@ -402,7 +242,8 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) stopCapturing(); return; //unknown wkbtype } - f->setGeometryAndOwnership( &wkb[0], wkbsize ); + + f->setGeometry( g ); int avoidIntersectionsReturn = f->geometry()->avoidIntersections(); if ( avoidIntersectionsReturn == 1 ) diff --git a/src/app/qgsmaptooladdfeature.h b/src/app/qgsmaptooladdfeature.h index e6173b8..688d578 100644 --- a/src/app/qgsmaptooladdfeature.h +++ b/src/app/qgsmaptooladdfeature.h @@ -22,7 +22,7 @@ class QgsMapToolAddFeature : public QgsMapToolCapture { Q_OBJECT public: - QgsMapToolAddFeature( QgsMapCanvas* canvas, CaptureMode mode ); + QgsMapToolAddFeature( QgsMapCanvas* canvas ); virtual ~QgsMapToolAddFeature(); void canvasReleaseEvent( QMouseEvent * e ); diff --git a/src/app/qgsmaptooladdisland.cpp b/src/app/qgsmaptooladdisland.cpp deleted file mode 100644 index 255307f..0000000 --- a/src/app/qgsmaptooladdisland.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/*************************************************************************** - qgsmaptooladdisland.cpp - map tool to add new polygons to multipolygon features - ----------------------- - begin : Mai 2007 - copyright : (C) 2007 by Marco Hugentobler - email : marco dot hugentobler at karto dot baug dot ethz dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/* $Id$ */ - -#include "qgsmaptooladdisland.h" -#include "qgsgeometry.h" -#include "qgsmapcanvas.h" -#include "qgsproject.h" -#include "qgsrubberband.h" -#include "qgsvectorlayer.h" -#include -#include - -QgsMapToolAddIsland::QgsMapToolAddIsland( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas, QgsMapToolCapture::CapturePolygon ) -{ - -} - -QgsMapToolAddIsland::~QgsMapToolAddIsland() -{ - -} - -void QgsMapToolAddIsland::canvasReleaseEvent( QMouseEvent * e ) -{ - //check if we operate on a vector layer - QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); - - if ( !vlayer ) - { - QMessageBox::information( 0, - tr( "Not a vector layer" ), - tr( "The current layer is not a vector layer" ) ); - return; - } - - if ( !vlayer->isEditable() ) - { - QMessageBox::information( 0, - tr( "Layer not editable" ), - tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) - ); - return; - } - - //inform user at the begin of the digitising action that the island tool only works if exactly one feature is selected - int nSelectedFeatures = vlayer->selectedFeatureCount(); - QString selectionErrorMsg; - if ( nSelectedFeatures < 1 ) - { - selectionErrorMsg = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); - } - else if ( nSelectedFeatures > 1 ) - { - selectionErrorMsg = tr( "Several features are selected. Please select only one feature to which an island should be added." ); - } - - if ( !selectionErrorMsg.isEmpty() ) - { - QMessageBox::critical( 0, tr( "Error, could not add island" ), selectionErrorMsg ); - stopCapturing(); - return; - } - - //add point to list and to rubber band - int error = addVertex( e->pos() ); - if ( error == 1 ) - { - //current layer is not a vector layer - return; - } - else if ( error == 2 ) - { - //problem with coordinate transformation - QMessageBox::information( 0, - tr( "Coordinate transform error" ), - tr( "Cannot transform the point to the layers coordinate system" ) ); - return; - } - - if ( e->button() == Qt::LeftButton ) - { - startCapturing(); - } - else if ( e->button() == Qt::RightButton ) - { - //close polygon - closePolygon(); - - vlayer->beginEditCommand( tr( "Part added" ) ); - int errorCode = vlayer->addIsland( points() ); - QString errorMessage; - - if ( errorCode != 0 ) - { - if ( errorCode == 1 ) - { - errorMessage = tr( "Selected feature is not a multipolygon" ); - } - else if ( errorCode == 2 ) - { - errorMessage = tr( "New ring is not a valid geometry" ); - } - else if ( errorCode == 3 ) - { - errorMessage = tr( "New polygon ring not disjoint with existing polygons" ); - } - else if ( errorCode == 4 ) - { - errorMessage = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); - } - else if ( errorCode == 5 ) - { - errorMessage = tr( "Several features are selected. Please select only one feature to which an island should be added." ); - } - else if ( errorCode == 6 ) - { - errorMessage = tr( "Selected geometry could not be found" ); - } - QMessageBox::critical( 0, tr( "Error, could not add island" ), errorMessage ); - - vlayer->destroyEditCommand(); - } - else - { - //add points to other features to keep topology up-to-date - int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); - if ( topologicalEditing ) - { - addTopologicalPoints( points() ); - } - - vlayer->endEditCommand(); - } - - stopCapturing(); - } -} diff --git a/src/app/qgsmaptooladdisland.h b/src/app/qgsmaptooladdisland.h deleted file mode 100644 index 2fcc1e0..0000000 --- a/src/app/qgsmaptooladdisland.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - qgsmaptooladdisland.h - map tool to add new polygons to multipolygon features - --------------------- - begin : Mai 2007 - copyright : (C) 2007 by Marco Hugentobler - email : marco dot hugentobler at karto dot baug dot ethz dot ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/* $Id$ */ - -#include "qgsmaptoolcapture.h" - -/**A map tool that adds new polygons to multipolygon features*/ -class QgsMapToolAddIsland: public QgsMapToolCapture -{ - Q_OBJECT - public: - QgsMapToolAddIsland( QgsMapCanvas* canvas ); - virtual ~QgsMapToolAddIsland(); - void canvasReleaseEvent( QMouseEvent * e ); -}; diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp new file mode 100644 index 0000000..85eff4e --- /dev/null +++ b/src/app/qgsmaptooladdpart.cpp @@ -0,0 +1,184 @@ +/*************************************************************************** + qgsmaptooladdpart.cpp - map tool to add new parts to multipart features + ----------------------- + begin : Mai 2007 + copyright : (C) 2007 by Marco Hugentobler + email : marco dot hugentobler at karto dot baug dot ethz dot ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* $Id$ */ + +#include "qgsmaptooladdpart.h" +#include "qgsgeometry.h" +#include "qgsmapcanvas.h" +#include "qgsproject.h" +#include "qgsrubberband.h" +#include "qgsvectorlayer.h" +#include "qgslogger.h" + +#include +#include + +QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas* canvas ) + : QgsMapToolCapture( canvas ) +{ +} + +QgsMapToolAddPart::~QgsMapToolAddPart() +{ +} + +void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e ) +{ + //check if we operate on a vector layer + QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); + if ( !vlayer ) + { + QMessageBox::information( 0, + tr( "Not a vector layer" ), + tr( "The current layer is not a vector layer" ) ); + return; + } + + if ( !vlayer->isEditable() ) + { + QMessageBox::information( 0, + tr( "Layer not editable" ), + tr( "Cannot edit the vector layer. Use 'Toggle Editing' to make it editable." ) + ); + return; + } + + //inform user at the begin of the digitising action that the island tool only works if exactly one feature is selected + int nSelectedFeatures = vlayer->selectedFeatureCount(); + QString selectionErrorMsg; + if ( nSelectedFeatures < 1 ) + { + selectionErrorMsg = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); + } + else if ( nSelectedFeatures > 1 ) + { + selectionErrorMsg = tr( "Several features are selected. Please select only one feature to which an part should be added." ); + } + + if ( !selectionErrorMsg.isEmpty() ) + { + QMessageBox::critical( 0, tr( "Error. Could not add part." ), selectionErrorMsg ); + stopCapturing(); + return; + } + + int errorCode; + switch ( mode() ) + { + case CapturePoint: + { + QgsPoint layerPoint; + QgsPoint mapPoint; + + if ( nextPoint( e->pos(), layerPoint, mapPoint ) != 0 ) + { + QgsDebugMsg( "nextPoint failed" ); + return; + } + + vlayer->beginEditCommand( tr( "Part added" ) ); + errorCode = vlayer->addPart( QList() << layerPoint ); + } + break; + + case CaptureLine: + case CapturePolygon: + { + //add point to list and to rubber band + int error = addVertex( e->pos() ); + if ( error == 1 ) + { + QgsDebugMsg( "current layer is not a vector layer" ); + return; + } + else if ( error == 2 ) + { + //problem with coordinate transformation + QMessageBox::information( 0, + tr( "Coordinate transform error" ), + tr( "Cannot transform the point to the layers coordinate system" ) ); + return; + } + + if ( e->button() == Qt::LeftButton ) + { + startCapturing(); + return; + } + else if ( e->button() != Qt::RightButton ) + { + return; + } + + if ( mode() == CapturePolygon ) + { + //close polygon + closePolygon(); + } + + vlayer->beginEditCommand( tr( "Part added" ) ); + errorCode = vlayer->addPart( points() ); + + stopCapturing(); + } + break; + } + + QString errorMessage; + switch ( errorCode ) + { + case 0: + { + //add points to other features to keep topology up-to-date + int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); + if ( topologicalEditing ) + { + addTopologicalPoints( points() ); + } + + vlayer->endEditCommand(); + + mCanvas->refresh(); + return; + } + + case 1: + errorMessage = tr( "Selected feature is not multi part." ); + break; + + case 2: + errorMessage = tr( "New part's geometry is not valid." ); + break; + + case 3: + errorMessage = tr( "New polygon ring not disjoint with existing polygons." ); + break; + + case 4: + errorMessage = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" ); + break; + + case 5: + errorMessage = tr( "Several features are selected. Please select only one feature to which an island should be added." ); + break; + + case 6: + errorMessage = tr( "Selected geometry could not be found" ); + break; + } + + QMessageBox::critical( 0, tr( "Error, could not add part" ), errorMessage ); + vlayer->destroyEditCommand(); +} diff --git a/src/app/qgsmaptooladdpart.h b/src/app/qgsmaptooladdpart.h new file mode 100644 index 0000000..d4d16bc --- /dev/null +++ b/src/app/qgsmaptooladdpart.h @@ -0,0 +1,27 @@ +/*************************************************************************** + qgsmaptooladdpart.h - map tool to add new polygons to multipolygon features + --------------------- + begin : May 2007 + copyright : (C) 2007 by Marco Hugentobler + email : marco dot hugentobler at karto dot baug dot ethz dot ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* $Id$ */ + +#include "qgsmaptoolcapture.h" + +/**A map tool that adds new parts to multipart features*/ +class QgsMapToolAddPart : public QgsMapToolCapture +{ + Q_OBJECT + public: + QgsMapToolAddPart( QgsMapCanvas* canvas ); + virtual ~QgsMapToolAddPart(); + void canvasReleaseEvent( QMouseEvent * e ); +}; diff --git a/src/app/qgsmaptoolcapture.cpp b/src/app/qgsmaptoolcapture.cpp index c82d19f..1518ef2 100644 --- a/src/app/qgsmaptoolcapture.cpp +++ b/src/app/qgsmaptoolcapture.cpp @@ -23,6 +23,7 @@ #include "qgsmapcanvas.h" #include "qgsmaprenderer.h" #include "qgsvectorlayer.h" +#include "qgslogger.h" #include #include @@ -32,29 +33,91 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, enum CaptureMode tool ) - : QgsMapToolEdit( canvas ), mCaptureMode( tool ), mRubberBand( 0 ) + : QgsMapToolEdit( canvas ) + , mCaptureMode( tool ) + , mRubberBand( 0 ) { + mCaptureModeFromLayer = tool == CaptureNone; mCapturing = false; QPixmap mySelectQPixmap = QPixmap(( const char ** ) capture_point_cursor ); mCursor = QCursor( mySelectQPixmap, 8, 8 ); - mSnapper.setMapCanvas( canvas ); + connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer * ) ), + this, SLOT( currentLayerChanged( QgsMapLayer * ) ) ); } QgsMapToolCapture::~QgsMapToolCapture() { + while ( !mSnappingMarkers.isEmpty() ) + delete mSnappingMarkers.takeFirst(); + stopCapturing(); } +void QgsMapToolCapture::deactivate() +{ + while ( !mSnappingMarkers.isEmpty() ) + delete mSnappingMarkers.takeFirst(); + + QgsMapToolEdit::deactivate(); +} + +void QgsMapToolCapture::currentLayerChanged( QgsMapLayer *layer ) +{ + if ( !mCaptureModeFromLayer ) + return; + + mCaptureMode = CaptureNone; + + QgsVectorLayer *vlayer = qobject_cast( layer ); + if ( !vlayer ) + { + return; + } + + switch ( vlayer->geometryType() ) + { + case QGis::Point: + mCaptureMode = CapturePoint; + break; + case QGis::Line: + mCaptureMode = CaptureLine; + break; + case QGis::Polygon: + mCaptureMode = CapturePolygon; + break; + default: + mCaptureMode = CaptureNone; + break; + } +} + + void QgsMapToolCapture::canvasMoveEvent( QMouseEvent * e ) { + if ( mCaptureMode == CapturePoint ) + return; + if ( mRubberBand && mCapturing ) { QgsPoint mapPoint; QList snapResults; if ( mSnapper.snapToBackgroundLayers( e->pos(), snapResults ) == 0 ) { + while ( !mSnappingMarkers.isEmpty() ) + delete mSnappingMarkers.takeFirst(); + + foreach( const QgsSnappingResult &r, snapResults ) + { + QgsVertexMarker *m = new QgsVertexMarker( mCanvas ); + m->setIconType( QgsVertexMarker::ICON_CROSS ); + m->setColor( Qt::green ); + m->setPenWidth( 1 ); + m->setCenter( r.snappedVertex ); + mSnappingMarkers << m; + } + mapPoint = snapPointFromResults( snapResults, e->pos() ); mRubberBand->movePoint( mapPoint ); } @@ -72,27 +135,15 @@ void QgsMapToolCapture::renderComplete() { } -void QgsMapToolCapture::deactivate() -{ - // don't stopCapturing() here, because the user might just want to - // pan or zoom and then continue digitizing. - QgsMapTool::deactivate(); -} - -int QgsMapToolCapture::addVertex( const QPoint& p ) +int QgsMapToolCapture::nextPoint( const QPoint &p, QgsPoint &layerPoint, QgsPoint &mapPoint ) { QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); - if ( !vlayer ) { + QgsDebugMsg( "no vector layer" ); return 1; } - if ( !mRubberBand ) - { - mRubberBand = createRubberBand( mCaptureMode == CapturePolygon ); - } - QgsPoint digitisedPoint; try { @@ -101,12 +152,10 @@ int QgsMapToolCapture::addVertex( const QPoint& p ) catch ( QgsCsException &cse ) { Q_UNUSED( cse ); + QgsDebugMsg( "transformation to layer coordinate failed" ); return 2; } - QgsPoint mapPoint; - QgsPoint layerPoint; - QList snapResults; if ( mSnapper.snapToBackgroundLayers( p, snapResults ) == 0 ) { @@ -118,14 +167,43 @@ int QgsMapToolCapture::addVertex( const QPoint& p ) catch ( QgsCsException &cse ) { Q_UNUSED( cse ); + QgsDebugMsg( "transformation to layer coordinate failed" ); return 2; } - mRubberBand->addPoint( mapPoint ); - mCaptureList.append( layerPoint ); + } - validateGeometry(); + return 0; +} + + +int QgsMapToolCapture::addVertex( const QPoint &p ) +{ + QgsPoint layerPoint; + QgsPoint mapPoint; + + if ( mode() == CaptureNone ) + { + QgsDebugMsg( "invalid capture mode" ); + return 2; } + int res = nextPoint( p, layerPoint, mapPoint ); + if ( res != 0 ) + { + QgsDebugMsg( "nextPoint failed: " + QString::number( res ) ); + return res; + } + + if ( !mRubberBand ) + { + mRubberBand = createRubberBand( mCaptureMode == CapturePolygon ); + } + + mRubberBand->addPoint( mapPoint ); + mCaptureList.append( layerPoint ); + + validateGeometry(); + return 0; } @@ -193,10 +271,7 @@ void QgsMapToolCapture::closePolygon() void QgsMapToolCapture::validateGeometry() { - QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); - mGeomErrors.clear(); - while ( !mGeomErrorMarkers.isEmpty() ) { delete mGeomErrorMarkers.takeFirst(); @@ -204,6 +279,7 @@ void QgsMapToolCapture::validateGeometry() switch ( mCaptureMode ) { + case CaptureNone: case CapturePoint: return; case CaptureLine: @@ -218,6 +294,10 @@ void QgsMapToolCapture::validateGeometry() break; } + QgsVectorLayer *vlayer = qobject_cast( mCanvas->currentLayer() ); + if ( !vlayer ) + return; + QString tip; for ( int i = 0; i < mGeomErrors.size(); i++ ) { diff --git a/src/app/qgsmaptoolcapture.h b/src/app/qgsmaptoolcapture.h index e71a4b2..ba7ba2e 100644 --- a/src/app/qgsmaptoolcapture.h +++ b/src/app/qgsmaptoolcapture.h @@ -21,27 +21,32 @@ #include "qgsmaptooledit.h" #include "qgspoint.h" #include "qgsgeometry.h" +#include "qgslegend.h" class QgsGeometry; class QgsRubberBand; class QgsVertexMarker; +class QgsMapLayer; #include #include class QgsMapToolCapture : public QgsMapToolEdit { + Q_OBJECT + public: enum CaptureMode { + CaptureNone, CapturePoint, CaptureLine, CapturePolygon }; //! constructor - QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode mode ); + QgsMapToolCapture( QgsMapCanvas* canvas, CaptureMode mode = CaptureNone ); //! destructor virtual ~QgsMapToolCapture(); @@ -60,17 +65,15 @@ class QgsMapToolCapture : public QgsMapToolEdit //! Resize rubber band virtual void renderComplete(); - + //! deactive the tool virtual void deactivate(); - /* - // FIXME: is this still actual or something old that's not used anymore? - signals: - //! emits mouse position when the canvas is clicked - void xyClickCoordinates(QgsPoint &p); - */ + public slots: + void currentLayerChanged( QgsMapLayer *layer ); protected: + int nextPoint( const QPoint &p, QgsPoint &layerPoint, QgsPoint &mapPoint ); + /**Adds a point to the rubber band (in map coordinates) and to the capture list (in layer coordinates) @return 0 in case of success, 1 if current layer is not a vector layer, 2 if coordinate transformation failed*/ int addVertex( const QPoint& p ); @@ -83,7 +86,6 @@ class QgsMapToolCapture : public QgsMapToolEdit CaptureMode mode() { return mCaptureMode; } - int size() { return mCaptureList.size(); } QList::iterator begin() { return mCaptureList.begin(); } QList::iterator end() { return mCaptureList.end(); } @@ -106,6 +108,10 @@ class QgsMapToolCapture : public QgsMapToolEdit void validateGeometry(); QList< QgsGeometry::Error > mGeomErrors; QList< QgsVertexMarker * > mGeomErrorMarkers; + + bool mCaptureModeFromLayer; + + QList mSnappingMarkers; }; #endif diff --git a/src/app/qgsmaptooledit.cpp b/src/app/qgsmaptooledit.cpp index c9a13a7..571c57d 100644 --- a/src/app/qgsmaptooledit.cpp +++ b/src/app/qgsmaptooledit.cpp @@ -22,7 +22,8 @@ #include #include -QgsMapToolEdit::QgsMapToolEdit( QgsMapCanvas* canvas ): QgsMapTool( canvas ) +QgsMapToolEdit::QgsMapToolEdit( QgsMapCanvas* canvas ) + : QgsMapTool( canvas ) { mSnapper.setMapCanvas( canvas ); } diff --git a/src/app/qgsmaptooledit.h b/src/app/qgsmaptooledit.h index cde32e2..c638187 100644 --- a/src/app/qgsmaptooledit.h +++ b/src/app/qgsmaptooledit.h @@ -63,6 +63,7 @@ class QgsMapToolEdit: public QgsMapTool @param geom list of points (in layer coordinate system) @return 0 in case of success*/ int addTopologicalPoints( const QList& geom ); + }; #endif diff --git a/src/core/qgsgeometry.cpp b/src/core/qgsgeometry.cpp index 981ac8c..0d607f2 100644 --- a/src/core/qgsgeometry.cpp +++ b/src/core/qgsgeometry.cpp @@ -2814,31 +2814,54 @@ int QgsGeometry::addRing( const QList& ring ) return 0; } -int QgsGeometry::addIsland( const QList& ring ) +int QgsGeometry::addPart( const QList &points ) { - //Ring needs to have at least three points and must be closed - if ( ring.size() < 4 ) - { - return 2; - } + QGis::GeometryType geomType = type(); - //ring must be closed - if ( ring.first() != ring.last() ) + switch ( geomType ) { - return 2; - } + case QGis::Point: + // only one part at a time + if ( points.size() != 1 ) + { + QgsDebugMsg( "expected 1 point: " + QString::number( points.size() ) ); + return 2; + } + break; - if ( wkbType() == QGis::WKBPolygon || wkbType() == QGis::WKBPolygon25D ) - { - if ( !convertToMultiType() ) - { - return 1; - } + case QGis::Line: + // Line needs to have at least two points and must be closed + if ( points.size() < 3 ) + { + QgsDebugMsg( "line must at least have two points: " + QString::number( points.size() ) ); + return 2; + } + break; + + case QGis::Polygon: + // Ring needs to have at least three points and must be closed + if ( points.size() < 4 ) + { + QgsDebugMsg( "polygon must at least have three points: " + QString::number( points.size() ) ); + return 2; + } + + // ring must be closed + if ( points.first() != points.last() ) + { + QgsDebugMsg( "polygon not closed" ); + return 2; + } + break; + + default: + QgsDebugMsg( "unsupported geometry type: " + QString::number( geomType ) ); + return 2; } - //bail out if wkbtype is not multipolygon - if ( wkbType() != QGis::WKBMultiPolygon && wkbType() != QGis::WKBMultiPolygon25D ) + if ( !isMultipart() && !convertToMultiType() ) { + QgsDebugMsg( "could not convert to multipart" ); return 1; } @@ -2846,67 +2869,107 @@ int QgsGeometry::addIsland( const QList& ring ) if ( !mGeos || mDirtyGeos ) { if ( !exportWkbToGeos() ) + { + QgsDebugMsg( "could not export to GEOS geometry" ); return 4; + } } - if ( GEOSGeomTypeId( mGeos ) != GEOS_MULTIPOLYGON ) - return 1; + int geosType = GEOSGeomTypeId( mGeos ); + GEOSGeometry *newPart = 0; + + switch ( geomType ) + { + case QGis::Point: + newPart = createGeosPoint( points[0] ); + break; + + case QGis::Line: + newPart = createGeosLineString( points.toVector() ); + break; - //create new polygon from ring + case QGis::Polygon: + { + //create new polygon from ring + GEOSGeometry *newRing = 0; - //coordinate sequence first - GEOSGeometry *newRing = 0; - GEOSGeometry *newPolygon = 0; + try + { + newRing = createGeosLinearRing( points.toVector() ); + if ( !GEOSisValid( newRing ) ) + throw GEOSException( "ring invalid" ); + + newPart = createGeosPolygon( newRing ); + } + catch ( GEOSException &e ) + { + Q_UNUSED( e ); + if ( newRing ) + GEOSGeom_destroy( newRing ); + + return 2; + } + } + break; + + default: + QgsDebugMsg( "unsupported type: " + QString::number( type() ) ); + return 2; + } + + Q_ASSERT( newPart ); try { - newRing = createGeosLinearRing( ring.toVector() ); - if ( !GEOSisValid( newRing ) ) - throw GEOSException( "ring invalid" ); - newPolygon = createGeosPolygon( newRing ); - if ( !GEOSisValid( newPolygon ) ) - throw GEOSException( "polygon invalid" ); + if ( !GEOSisValid( newPart ) ) + throw GEOSException( "new part geometry invalid" ); } catch ( GEOSException &e ) { Q_UNUSED( e ); - if ( newPolygon ) - GEOSGeom_destroy( newPolygon ); - else if ( newRing ) - GEOSGeom_destroy( newRing ); + + if ( newPart ) + GEOSGeom_destroy( newPart ); + + QgsDebugMsg( "part invalid: " + e.what() ); return 2; } - QVector polygons; + QVector parts; //create new multipolygon int n = GEOSGetNumGeometries( mGeos ); int i; for ( i = 0; i < n; ++i ) { - const GEOSGeometry *polygonN = GEOSGetGeometryN( mGeos, i ); + const GEOSGeometry *partN = GEOSGetGeometryN( mGeos, i ); - if ( !GEOSDisjoint( polygonN, newPolygon ) ) + if ( geomType == QGis::Polygon && !GEOSDisjoint( partN, newPart ) ) //bail out if new polygon is not disjoint with existing ones break; - polygons << GEOSGeom_clone( polygonN ); + parts << GEOSGeom_clone( partN ); } if ( i < n ) { // bailed out - for ( int i = 0; i < polygons.size(); i++ ) - GEOSGeom_destroy( polygons[i] ); + for ( int i = 0; i < parts.size(); i++ ) + GEOSGeom_destroy( parts[i] ); + + QgsDebugMsg( "new polygon part not disjoint" ); return 3; } - polygons << newPolygon; + parts << newPart; GEOSGeom_destroy( mGeos ); - mGeos = createGeosCollection( GEOS_MULTIPOLYGON, polygons ); + + mGeos = createGeosCollection( geosType, parts ); + mDirtyWkb = true; mDirtyGeos = false; + return 0; } diff --git a/src/core/qgsgeometry.h b/src/core/qgsgeometry.h index 06c70f6..138f25b 100644 --- a/src/core/qgsgeometry.h +++ b/src/core/qgsgeometry.h @@ -254,7 +254,8 @@ class CORE_EXPORT QgsGeometry /**Adds a new island polygon to a multipolygon feature @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing polygons of the feature*/ - int addIsland( const QList& ring ); + int addPart( const QList &points ); + Q_DECL_DEPRECATED int addIsland( const QList &points ); /**Translate this geometry by dx, dy @return 0 in case of success*/ diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index b41a38c..8c46a16 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -2127,7 +2127,7 @@ int QgsVectorLayer::addRing( const QList& ring ) return addRingReturnCode; } -int QgsVectorLayer::addIsland( const QList& ring ) +int QgsVectorLayer::addPart( const QList &points ) { if ( !hasGeometryType() ) return 6; @@ -2152,7 +2152,7 @@ int QgsVectorLayer::addIsland( const QList& ring ) if ( changedIt != mChangedGeometries.end() ) { QgsGeometry geom = *changedIt; - int returnValue = geom.addIsland( ring ); + int returnValue = geom.addPart( points ); editGeometryChange( selectedFeatureId, geom ); mCachedGeometries[selectedFeatureId] = geom; return returnValue; @@ -2174,7 +2174,7 @@ int QgsVectorLayer::addIsland( const QList& ring ) QgsGeometryMap::iterator cachedIt = mCachedGeometries.find( selectedFeatureId ); if ( cachedIt != mCachedGeometries.end() ) { - int errorCode = cachedIt->addIsland( ring ); + int errorCode = cachedIt->addPart( points ); if ( errorCode == 0 ) { editGeometryChange( selectedFeatureId, *cachedIt ); @@ -2192,7 +2192,7 @@ int QgsVectorLayer::addIsland( const QList& ring ) fGeom = f.geometryAndOwnership(); if ( fGeom ) { - int errorCode = fGeom->addIsland( ring ); + int errorCode = fGeom->addPart( points ); editGeometryChange( selectedFeatureId, *fGeom ); setModified( true, true ); delete fGeom; diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index a8df6a4..8c6f559 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -380,7 +380,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer 4 if no feature was selected, 5 if several features are selected, 6 if selected geometry not found*/ - int addIsland( const QList& ring ); + int addPart( const QList& ring ); + Q_DECL_DEPRECATED int addIsland( const QList& ring ); /**Translates feature by dx, dy @param featureId id of the feature to translate diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index 5be8a8d..755b582 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -276,8 +276,18 @@ class GUI_EXPORT QgisInterface : public QObject Q_DECL_DEPRECATED #endif virtual QAction *actionEditSeparator1() = 0; + virtual QAction *actionAddFeature() = 0; +#ifndef Q_MOC_RUN + Q_DECL_DEPRECATED +#endif virtual QAction *actionCapturePoint() = 0; +#ifndef Q_MOC_RUN + Q_DECL_DEPRECATED +#endif virtual QAction *actionCaptureLine() = 0; +#ifndef Q_MOC_RUN + Q_DECL_DEPRECATED +#endif virtual QAction *actionCapturePolygon() = 0; virtual QAction *actionDeleteSelected() = 0; virtual QAction *actionMoveFeature() = 0; @@ -295,7 +305,11 @@ class GUI_EXPORT QgisInterface : public QObject #endif virtual QAction *actionMoveVertex() = 0; virtual QAction *actionAddRing() = 0; +#ifndef Q_MOC_RUN + Q_DECL_DEPRECATED +#endif virtual QAction *actionAddIsland() = 0; + virtual QAction *actionAddPart() = 0; virtual QAction *actionSimplifyFeature() = 0; virtual QAction *actionDeleteRing() = 0; virtual QAction *actionDeletePart() = 0; diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 4d254fb..a519818 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -31,15 +31,13 @@ - - - + - + @@ -255,9 +253,7 @@ - - - + @@ -279,7 +275,7 @@ - + @@ -530,51 +526,21 @@ Ctrl+V - + true - :/images/themes/default/mActionCapturePoint.png:/images/themes/default/mActionCapturePoint.png + :/images/themes/default/mActionAddFeature.png:/images/themes/default/mActionAddFeature.png - Capture Point + Add feature Ctrl+. - - - true - - - - :/images/themes/default/mActionCaptureLine.png:/images/themes/default/mActionCaptureLine.png - - - Capture Line - - - Ctrl+/ - - - - - true - - - - :/images/themes/default/mActionCapturePolygon.png:/images/themes/default/mActionCapturePolygon.png - - - Capture Polygon - - - Ctrl+? - - true @@ -632,13 +598,13 @@ Add Ring - + true - :/images/themes/default/mActionAddIsland.png:/images/themes/default/mActionAddIsland.png + :/images/themes/default/mActionAddPart.png:/images/themes/default/mActionAddPart.png Add Part