Skip to content
Permalink
Browse files
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/qgis@9001 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 6, 2008
1 parent 3c83558 commit 5befedc82a0c21c56cfba601af4b28594295a932
@@ -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
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/coordinatecapture/" >
<file>coordinatecapture.png</file>
<file>coordinate_capture.png</file>
<file>geographic.png</file>
<file>transformed.png</file>
</qresource>
</RCC>
@@ -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();
}

Binary file not shown.
@@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
width="32"
height="32"
sodipodi:docname="geographic.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<g
id="g3277"
transform="translate(1.1000006,1.26432)"
style="stroke:#b9b9b9;stroke-opacity:1">
<path
transform="matrix(0.9280961,0,0,0.9390144,0.784577,0.5089359)"
d="M 31.12,15.56 A 15.48,15.36 0 1 1 0.1600008,15.56 A 15.48,15.36 0 1 1 31.12,15.56 z"
sodipodi:ry="15.36"
sodipodi:rx="15.48"
sodipodi:cy="15.56"
sodipodi:cx="15.64"
id="path3279"
style="opacity:0.9264214;fill:#171717;fill-opacity:0;fill-rule:nonzero;stroke:#b9b9b9;stroke-width:1.07119215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
sodipodi:type="arc" />
<g
id="g3281"
style="stroke:#b9b9b9;stroke-opacity:1">
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.42234,0.65423457 C 3.1947729,14.932363 15.545765,29.505765 15.545765,29.505765"
id="path3283"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.089071,0.63866496 C -7.651345,14.971795 15.318612,29.601335 15.318612,29.601335"
id="path3285"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.851905,0.6142346 C 27.079472,14.892363 14.72848,29.465765 14.72848,29.465765"
id="path3287"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.185174,0.598665 C 37.92559,14.931795 14.955633,29.561335 14.955633,29.561335"
id="path3289"
sodipodi:nodetypes="cc" />
</g>
<g
transform="matrix(0,1,-0.9933511,0,30.359601,-0.4571225)"
id="g3291"
style="stroke:#b9b9b9;stroke-opacity:1">
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.42234,0.65423457 C 3.1947729,14.932363 15.545765,29.505765 15.545765,29.505765"
id="path3293"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.089071,0.63866496 C -7.651345,14.971795 15.318612,29.601335 15.318612,29.601335"
id="path3295"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.851905,0.6142346 C 27.079472,14.892363 14.72848,29.465765 14.72848,29.465765"
id="path3297"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#b9b9b9;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.185174,0.598665 C 37.92559,14.931795 14.955633,29.561335 14.955633,29.561335"
id="path3299"
sodipodi:nodetypes="cc" />
</g>
</g>
<metadata
id="metadata15">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs13">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective17" />
</defs>
<sodipodi:namedview
inkscape:window-height="986"
inkscape:window-width="1680"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
guidetolerance="10.0"
gridtolerance="10.0"
objecttolerance="10.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base"
showgrid="false"
inkscape:zoom="25"
inkscape:cx="9.06"
inkscape:cy="16.15568"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:current-layer="svg2" />
<!-- Generator: Xara Xtreme 2.0, SVG Export Plug-In Version: 0.4 --><!-- Generated 2008-08-06 12:16:14 --><!-- not very useful exporter for now... --><!-- entity tag="40" --><!-- entity tag="1" --><!-- entity tag="4114" --><!-- entity tag="4116" --><!-- entity tag="4124" --><!-- entity tag="80" --><!-- entity tag="41" --><!-- entity tag="1" --><!-- entity tag="42" --><!-- entity tag="1" --><!-- entity tag="45" --><!-- entity tag="53" --><!-- entity tag="4031" --><!-- entity tag="43" --><!-- entity tag="1" --><!-- entity tag="48" --><!-- entity tag="51" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="152" --><!-- entity tag="150" --><!-- entity tag="151" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="152" --><!-- entity tag="150" --><!-- entity tag="151" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="152" --><!-- entity tag="150" --><!-- entity tag="151" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="152" --><!-- entity tag="150" --><!-- entity tag="151" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="152" --><!-- entity tag="150" --><!-- entity tag="151" --><!-- entity tag="0" --><!-- entity tag="104" --><!-- entity tag="1" --><!-- entity tag="151" --><!-- entity tag="152" --><!-- entity tag="1100" --> <rect
x="674598"
y="1046995"
width="375942"
height="375108"
id="rect4" />
<!-- entity tag="1" --><!-- entity tag="176" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="104" --><!-- entity tag="1" --><!-- entity tag="151" --><!-- entity tag="152" --><!-- entity tag="1100" --> <rect
x="674599"
y="1046736"
width="375942"
height="375108"
id="rect6" />
<!-- entity tag="1" --><!-- entity tag="176" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="104" --><!-- entity tag="1" --><!-- entity tag="151" --><!-- entity tag="152" --><!-- entity tag="1100" --> <rect
x="674599"
y="1046736"
width="375942"
height="375108"
id="rect8" />
<!-- entity tag="1" --><!-- entity tag="176" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="4050" --><!-- entity tag="1" --><!-- entity tag="151" --><!-- entity tag="152" --><!-- entity tag="4051" --><!-- entity tag="1" --><!-- entity tag="166" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="104" --><!-- entity tag="1" --><!-- entity tag="104" --><!-- entity tag="1" --><!-- entity tag="1100" --> <rect
x="313420"
y="236536"
width="375942"
height="375108"
id="rect10" />
<!-- entity tag="1" --><!-- entity tag="176" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="115" --><!-- entity tag="1" --><!-- entity tag="111" --><!-- entity tag="150" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="46" --><!-- entity tag="47" --><!-- entity tag="0" --><!-- entity tag="4070" --><!-- entity tag="1" --><!-- entity tag="4087" --><!-- entity tag="0" --><!-- entity tag="0" --><!-- entity tag="4119" --><!-- entity tag="1" --><!-- entity tag="180" --><!-- entity tag="160" --><!-- entity tag="193" --><!-- entity tag="4120" --><!-- entity tag="150" --><!-- entity tag="4120" --><!-- entity tag="152" --><!-- entity tag="2906" --><!-- entity tag="166" --><!-- entity tag="4120" --><!-- entity tag="2000" --><!-- entity tag="2907" --><!-- entity tag="163" --><!-- entity tag="0" --><!-- entity tag="4119" --><!-- entity tag="1" --><!-- entity tag="160" --><!-- entity tag="150" --><!-- entity tag="4120" --><!-- entity tag="151" --><!-- entity tag="4120" --><!-- entity tag="152" --><!-- entity tag="166" --><!-- entity tag="4120" --><!-- entity tag="163" --><!-- entity tag="180" --><!-- entity tag="0" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="51" --><!-- entity tag="87" --><!-- entity tag="91" --><!-- entity tag="92" --><!-- entity tag="93" --><!-- entity tag="3506" --><!-- entity tag="3507" --><!-- entity tag="82" --><!-- entity tag="0" --> <g
id="g3264"
transform="translate(0.72,0.4)">
<path
transform="matrix(0.9280961,0,0,0.9390144,0.784577,0.5089359)"
d="M 31.12,15.56 A 15.48,15.36 0 1 1 0.1600008,15.56 A 15.48,15.36 0 1 1 31.12,15.56 z"
sodipodi:ry="15.36"
sodipodi:rx="15.48"
sodipodi:cy="15.56"
sodipodi:cx="15.64"
id="path2468"
style="opacity:0.9264214;fill:#171717;fill-opacity:0;fill-rule:nonzero;stroke:#000000;stroke-width:1.07119215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
sodipodi:type="arc" />
<g
id="g3248">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.42234,0.65423457 C 3.1947729,14.932363 15.545765,29.505765 15.545765,29.505765"
id="path3240"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.089071,0.63866496 C -7.651345,14.971795 15.318612,29.601335 15.318612,29.601335"
id="path3242"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.851905,0.6142346 C 27.079472,14.892363 14.72848,29.465765 14.72848,29.465765"
id="path3244"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.185174,0.598665 C 37.92559,14.931795 14.955633,29.561335 14.955633,29.561335"
id="path3246"
sodipodi:nodetypes="cc" />
</g>
<g
transform="matrix(0,1,-0.9933511,0,30.359601,-0.4571225)"
id="g3254">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.42234,0.65423457 C 3.1947729,14.932363 15.545765,29.505765 15.545765,29.505765"
id="path3256"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.089071,0.63866496 C -7.651345,14.971795 15.318612,29.601335 15.318612,29.601335"
id="path3258"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.851905,0.6142346 C 27.079472,14.892363 14.72848,29.465765 14.72848,29.465765"
id="path3260"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.07732987px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 15.185174,0.598665 C 37.92559,14.931795 14.955633,29.561335 14.955633,29.561335"
id="path3262"
sodipodi:nodetypes="cc" />
</g>
</g>
</svg>
Binary file not shown.

0 comments on commit 5befedc

Please sign in to comment.