From d0135ddff2ac6a37303d80b74bc8527146ba2c7c Mon Sep 17 00:00:00 2001 From: timlinux Date: Wed, 6 Aug 2008 11:59:03 +0000 Subject: [PATCH] Show rubber band on coordinate click position. Make cursor hotspot the center of the cursor Added some icons & changed to grid layout git-svn-id: http://svn.osgeo.org/qgis/trunk@9001 c8812cc2-4d05-0410-92ff-de0c093fc19c --- ...natecapture.png => coordinate_capture.png} | Bin .../coordinate_capture/coordinatecapture.cpp | 17 +- .../coordinate_capture/coordinatecapture.qrc | 4 +- .../coordinatecapturemaptool.cpp | 33 ++- src/plugins/coordinate_capture/geographic.png | Bin 0 -> 2806 bytes src/plugins/coordinate_capture/geographic.svg | 207 ++++++++++++++++++ .../coordinate_capture/transformed.png | Bin 0 -> 994 bytes .../coordinate_capture/transformed.svg | 155 +++++++++++++ 8 files changed, 400 insertions(+), 16 deletions(-) rename src/plugins/coordinate_capture/{coordinatecapture.png => coordinate_capture.png} (100%) create mode 100644 src/plugins/coordinate_capture/geographic.png create mode 100644 src/plugins/coordinate_capture/geographic.svg create mode 100644 src/plugins/coordinate_capture/transformed.png create mode 100644 src/plugins/coordinate_capture/transformed.svg diff --git a/src/plugins/coordinate_capture/coordinatecapture.png b/src/plugins/coordinate_capture/coordinate_capture.png similarity index 100% rename from src/plugins/coordinate_capture/coordinatecapture.png rename to src/plugins/coordinate_capture/coordinate_capture.png diff --git a/src/plugins/coordinate_capture/coordinatecapture.cpp b/src/plugins/coordinate_capture/coordinatecapture.cpp index d4f6801dc2f..806a21334f3 100644 --- a/src/plugins/coordinate_capture/coordinatecapture.cpp +++ b/src/plugins/coordinate_capture/coordinatecapture.cpp @@ -76,7 +76,7 @@ void CoordinateCapture::initGui() { // Create the action for tool - mQActionPointer = new QAction(QIcon(":/coordinatecapture/coordinatecapture.png"),tr("Coordinate Capture"), this); + mQActionPointer = new QAction(QIcon(":/coordinatecapture/coordinate_capture.png"),tr("Coordinate Capture"), this); // Set the what's this text mQActionPointer->setWhatsThis(tr("Click on the map to view coordinates and capture to clipboard.")); // Connect the action to the run @@ -92,18 +92,25 @@ void CoordinateCapture::initGui() // create a little widget with x and y display to put into our dock widget QWidget * mypWidget = new QWidget(); - QLayout * mypLayout = new QVBoxLayout(); + QGridLayout *mypLayout = new QGridLayout ( mypWidget ); + mypLayout->setColumnMinimumWidth( 0, 36 ); mypWidget->setLayout(mypLayout); + QLabel * mypGeoLabel = new QLabel(mypWidget); + mypGeoLabel->setPixmap(QPixmap(":/coordinatecapture/geographic.png")); + QLabel * mypCRSLabel = new QLabel(mypWidget); + mypCRSLabel->setPixmap(QPixmap(":/coordinatecapture/transformed.png")); mpXEdit = new QLineEdit(mypWidget); mpYEdit = new QLineEdit(mypWidget); QPushButton * mypCopyButton = new QPushButton(mypWidget); mypCopyButton->setText(tr("Copy to clipboard")); connect(mypCopyButton, SIGNAL(clicked()), this, SLOT(copy())); - mypLayout->addWidget(mpXEdit); - mypLayout->addWidget(mpYEdit); - mypLayout->addWidget(mypCopyButton); + mypLayout->addWidget(mypGeoLabel, 0,0); + mypLayout->addWidget(mpXEdit, 0,1); + mypLayout->addWidget(mypCRSLabel, 1,0); + mypLayout->addWidget(mpYEdit, 1,1); + mypLayout->addWidget(mypCopyButton, 2,1); //create the dock widget diff --git a/src/plugins/coordinate_capture/coordinatecapture.qrc b/src/plugins/coordinate_capture/coordinatecapture.qrc index c45ab11a641..89e03a8a997 100644 --- a/src/plugins/coordinate_capture/coordinatecapture.qrc +++ b/src/plugins/coordinate_capture/coordinatecapture.qrc @@ -1,5 +1,7 @@ - coordinatecapture.png + coordinate_capture.png + geographic.png + transformed.png diff --git a/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp b/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp index 67397e48aea..9e43697add7 100644 --- a/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp +++ b/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp @@ -31,12 +31,12 @@ CoordinateCaptureMapTool::CoordinateCaptureMapTool(QgsMapCanvas* thepCanvas) : QgsMapTool(thepCanvas) { // set cursor - QPixmap myIdentifyCursor = QPixmap((const char **) capture_point_cursor); - mCursor = QCursor(myIdentifyCursor, 1, 1); + QPixmap myCursor = QPixmap((const char **) capture_point_cursor); + mCursor = QCursor(myCursor, 8, 8); //8,8 is the point in the cursor where clicks register mpMapCanvas = thepCanvas; - mpRubberBand = new QgsRubberBand(mpMapCanvas,false); //false - not a polygon + mpRubberBand = new QgsRubberBand(mpMapCanvas,true); //true - its a polygon mpRubberBand->setColor(Qt::red); - mpRubberBand->setWidth(3); + mpRubberBand->setWidth(1); } CoordinateCaptureMapTool::~CoordinateCaptureMapTool() @@ -60,14 +60,27 @@ void CoordinateCaptureMapTool::canvasReleaseEvent(QMouseEvent * thepEvent) return; } - QgsPoint myPoint = + QgsPoint myOriginalPoint = mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x(), thepEvent->y()); - emit pointCaptured(myPoint); - mpRubberBand->reset(false); + emit pointCaptured(myOriginalPoint); + + //make a little box for display + + QgsPoint myPoint1 = + mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x() - 1, thepEvent->y()-1); + QgsPoint myPoint2 = + mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x() + 1, thepEvent->y()-1); + QgsPoint myPoint3 = + mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x() + 1, thepEvent->y() + 1); + QgsPoint myPoint4 = + mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x() - 1, thepEvent->y() + 1); + + mpRubberBand->reset(true); // convert screen coordinates to map coordinates - mpRubberBand->addPoint(myPoint,false); //true - update canvas - mpRubberBand->addPoint(myPoint,false); //true - update canvas - mpRubberBand->addPoint(myPoint,false); //true - update canvas + mpRubberBand->addPoint(myPoint1,false); //true - update canvas + mpRubberBand->addPoint(myPoint2,false); //true - update canvas + mpRubberBand->addPoint(myPoint3,false); //true - update canvas + mpRubberBand->addPoint(myPoint4,true); //true - update canvas mpRubberBand->show(); } diff --git a/src/plugins/coordinate_capture/geographic.png b/src/plugins/coordinate_capture/geographic.png new file mode 100644 index 0000000000000000000000000000000000000000..c7ac771c4f07e9fcaef95c55f3cfc0440e838a0a GIT binary patch literal 2806 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iOP( z3mq|qMWZ+X019?VL_t(o!>w0)P*Z0X|J|G1n+Hj5AV6L`R6s+Ahd>k;$LA`cBBkpC zJL)*q;sa$|ak~q_X_f92?NDo39XnN9t=dwvxE2sX61v!}545dSi%^P`fK-%+5DW?C zb@z{jj&IAk=0l32oN;k+ zuUIUW+&A8Mqdh!4yxY&uuL^+pSuYO(@P$^ZJzrg2ecfm@z69W~Kp^<($dMyMVzIby z&6+hsk&%%HNRr$c9v#K*@sCMPF1&6zW&ou+A) z&*$42hH=s~?F|kN&H(_6#S*=F^XB%TprB3w0pk@R2f!zb7cUOY&CR_U7#NtR)oTAJ z6bfIJ%jL3xfq^?NmrGevQo@ajin_qE?3XOd+5p(f%F6QE+uK!{nVFuGCr=8lUAx8; z2n0nAhhtY=U7hUMv11p`ojd33>gv)0@cvr#*&2=JqRC`BQ(s@t1u&N+NoPPnfHyBM zucffCurnqmrq66P=Ra<^Y15`)hGD#Vz5cnHnwn)Vzx=X;!{PWuB2fhZL0w&)Y~H+i zeQ|MdZ~xlmBATXel$DiTt*xyM01yelsnKZMXU?1%Fq_R=I2=yRjvYG&>g(&JPjZly zlyogUJ^dd5aQ^&x@xp}*?MkK6D;A5t2M|zPT>QJRurT|qS+jzkWdE1U%*+O((f9&@ zH~_YgkdTM9wY5D)qj3TNK9|dNeE8vqe+MuRKsJDU0L1{_1h7@9RK7QP@?^)D!@Ya= z#s>rhcxTU^JtCD#I{`51>FLJl)2CNGUIPS=$7?xq(=FYJRY;3pP!_-xY##& z^5h9=X=#xFwo(-J2a+TmB9W+5sZ=^;G8up zI5B6=oIkrN8-!*n+`Hs%1>J(h|5tgNg%6h-~G zWX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Ec!>=bd)~5)%^#BO)T+ z9MgUJ>8BAfF)^-`l$5s3n>P;$g+ez)Q7!2*k(7KeX9w_d7Z|Tw!5h?K+)~Oixc&&@}y)OeQ;_)oR`U>v9T{ z$rSAK`4+j|?!{KCb*9y79cgK42~{eU9En8IsaC5UQ>ILzxLj^M%d#~jNt$&!-SGcw zJN|{-ym^!E?(U8p85s$sX*$&B^R*BJ(PgvQI + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/coordinate_capture/transformed.png b/src/plugins/coordinate_capture/transformed.png new file mode 100644 index 0000000000000000000000000000000000000000..2e9c1a740c1eb13e8f7b56f828933125d88ccc43 GIT binary patch literal 994 zcmV<810DQ{P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2iOP( z3my>S0pO(o00Ux4L_t(o!|hkkOCxs_|Ge+axS7~Vwp$ujtspGLExIrhyabdYMGy7R z3Z68qNedF{McW)oJ?=^T3kn_;w^Tt$PM+LTp%+1#QoDt=6ojQ4HyO>3(aihyqDvey zvvrr$!tR5)yw8U>pYQPA=lg~Ld<5VDfE&0R27nrX2K?h)07n2^A3O}eX@N@s-vL-5 z0FRcImi|s85+4$ga>2-Evqn0dZVU_z)coE)J3AX)Sy?%Y#bVV~cs83gQmIs9aB%Qa zjYgwE^Yina%gf83L({aM^7;H@DP>19NmbP!R##U~0!|N2(|+05*f{jVgKC6Ap@Up5 z_oDzn08WYM6ju+4mkif+8${G8aLu7I^NsE8?J$73W`LPvySuxpH}5&c&7GYc-H#Jg zgPFqss-!5&@1vumG26C(Z6*{7h4q9wgFEZ% z>rYf6M0Ig-@u;V#=V3EpVq)TpbUJ-I9*;lt6EHS5_Ejd63HA5)x8wxX7#|=15&%>H zkW$*FX)b#@_)}(n$D8*|L5i89ejG(nK4IoqD_qmG`vB0^CUjlb6+(o9IM+S}?H1si zot<5)fV$&2?G+%UR9?x50EolGLj}Ow-X^Y8Drk{!ZZgzrwQvAOt5&OiH3)ztMN$5U zMx#CDa=Geps!m^v>-AyKw>d44Q(Thz@O}$4%W%XR?Q`0nuyjLkR z-}C0L$jK*@$qCD{?zH#8a4G7|PNo0ZEa zI+(db(= + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + +