[QGIS Commit] r8998 - in trunk/qgis/src/plugins: . coordinate_capture

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Aug 5 20:24:31 EDT 2008


Author: timlinux
Date: 2008-08-05 20:24:31 -0400 (Tue, 05 Aug 2008)
New Revision: 8998

Added:
   trunk/qgis/src/plugins/coordinate_capture/
   trunk/qgis/src/plugins/coordinate_capture/CMakeLists.txt
   trunk/qgis/src/plugins/coordinate_capture/README
   trunk/qgis/src/plugins/coordinate_capture/coordinate_capture.svg
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.png
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.qrc
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.cpp
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.h
   trunk/qgis/src/plugins/coordinate_capture/coordinatecaptureguibase.ui
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.h
Modified:
   trunk/qgis/src/plugins/CMakeLists.txt
Log:
Added capture point plugin to cater for various user requests

Modified: trunk/qgis/src/plugins/CMakeLists.txt
===================================================================
--- trunk/qgis/src/plugins/CMakeLists.txt	2008-08-05 21:11:58 UTC (rev 8997)
+++ trunk/qgis/src/plugins/CMakeLists.txt	2008-08-06 00:24:31 UTC (rev 8998)
@@ -20,3 +20,5 @@
 
 SUBDIRS (quick_print)
 
+
+SUBDIRS (coordinate_capture)

Added: trunk/qgis/src/plugins/coordinate_capture/CMakeLists.txt
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/CMakeLists.txt	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/CMakeLists.txt	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,51 @@
+
+########################################################
+# Files
+
+SET (coordinatecapture_SRCS
+     coordinatecapture.cpp
+     coordinatecapturegui.cpp
+     coordinatecapturemaptool.cpp
+)
+
+SET (coordinatecapture_UIS coordinatecaptureguibase.ui)
+
+SET (coordinatecapture_MOC_HDRS
+     coordinatecapture.h
+     coordinatecapturegui.h
+     coordinatecapturemaptool.h
+)
+
+SET (coordinatecapture_RCCS  coordinatecapture.qrc)
+
+########################################################
+# Build
+
+QT4_WRAP_UI (coordinatecapture_UIS_H  ${coordinatecapture_UIS})
+
+QT4_WRAP_CPP (coordinatecapture_MOC_SRCS  ${coordinatecapture_MOC_HDRS})
+
+QT4_ADD_RESOURCES(coordinatecapture_RCC_SRCS ${coordinatecapture_RCCS})
+
+ADD_LIBRARY (coordinatecaptureplugin MODULE ${coordinatecapture_SRCS} ${coordinatecapture_MOC_SRCS} ${coordinatecapture_RCC_SRCS} ${coordinatecapture_UIS_H})
+
+INCLUDE_DIRECTORIES(
+     ${CMAKE_CURRENT_BINARY_DIR}
+     ../../core ../../core/raster ../../core/renderer ../../core/symbology
+     ../../gui
+     ..
+)
+
+TARGET_LINK_LIBRARIES(coordinatecaptureplugin
+  qgis_core
+  qgis_gui
+)
+
+
+########################################################
+# Install
+
+INSTALL(TARGETS coordinatecaptureplugin
+  RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
+  LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
+

Added: trunk/qgis/src/plugins/coordinate_capture/README
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/README	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/README	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,6 @@
+Coordinate Capture Plugin for Quantum GIS
+
+       Tim Sutton 2008
+
+A simple plugin that allows you to copy the 
+coordinates of mouse clicks to the clipboard.

Added: trunk/qgis/src/plugins/coordinate_capture/coordinate_capture.svg
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinate_capture.svg	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinate_capture.svg	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<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"
+   width="32"
+   height="32"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   version="1.0"
+   sodipodi:docname="coordinate_capture.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <defs
+     id="defs4">
+    <marker
+       inkscape:stockid="Arrow1Lend"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="Arrow1Lend"
+       style="overflow:visible;">
+      <path
+         id="path3161"
+         d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
+         transform="scale(0.8) rotate(180) translate(12.5,0)" />
+    </marker>
+    <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="perspective10" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="25"
+     inkscape:cx="9.06"
+     inkscape:cy="16"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1680"
+     inkscape:window-height="986"
+     inkscape:window-x="0"
+     inkscape:window-y="0" />
+  <metadata
+     id="metadata7">
+    <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>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <path
+       sodipodi:type="arc"
+       style="opacity:0.92642139999999995;fill:#171717;fill-opacity:0.90980392000000021;fill-rule:nonzero;stroke:#409fcc;stroke-width:0.69999999000000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       id="path3939"
+       sodipodi:cx="16.879999"
+       sodipodi:cy="15.5"
+       sodipodi:rx="7.1599998"
+       sodipodi:ry="6.6599998"
+       d="M 24.039999,15.5 A 7.1599998,6.6599998 0 1 1 9.7199993,15.5 A 7.1599998,6.6599998 0 1 1 24.039999,15.5 z"
+       transform="translate(-0.52,0)" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.83856803px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
+       d="M 16.280361,5.9152738 L 16.361976,13.800716"
+       id="path2383" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.83856803px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
+       d="M 16.319888,25.918422 L 16.401503,18.03298"
+       id="path3933" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.83856803px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
+       d="M 26.318423,15.839888 L 18.432981,15.921503"
+       id="path3935" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.83856803px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
+       d="M 6.2815774,16.120112 L 14.167019,16.038497"
+       id="path3937" />
+  </g>
+</svg>

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,227 @@
+/***************************************************************************
+  coordinatecapture.cpp 
+  Capture mouse coordinates in different CRS
+  -------------------
+         begin                : [PluginDate]
+         copyright            : [(C) Your Name and Date]
+         email                : [Your Email]
+
+ ***************************************************************************
+ *                                                                         *
+ *   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: plugin.cpp 8053 2008-01-26 13:59:53Z timlinux $ */
+
+//
+// QGIS Specific includes
+//
+
+#include <qgisinterface.h>
+#include <qgisgui.h>
+#include <qgspoint.h>
+#include <qgsmapcanvas.h>
+
+#include "coordinatecapture.h"
+#include "coordinatecapturegui.h"
+
+//
+// Qt4 Related Includes
+//
+
+#include <QAction>
+#include <QToolBar>
+#include <QDockWidget>
+#include <QLayout>
+#include <QLineEdit>
+#include <QClipboard>
+#include <QPushButton>
+
+static const char * const sIdent = "$Id: plugin.cpp 8053 2008-01-26 13:59:53Z timlinux $";
+static const QString sName = QObject::tr("Coordinate Capture");
+static const QString sDescription = QObject::tr("Capture mouse coordinates in different CRS");
+static const QString sPluginVersion = QObject::tr("Version 0.1");
+static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
+
+//////////////////////////////////////////////////////////////////////
+//
+// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
+//
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * Constructor for the plugin. The plugin is passed a pointer 
+ * an interface object that provides access to exposed functions in QGIS.
+ * @param theQGisInterface - Pointer to the QGIS interface object
+ */
+CoordinateCapture::CoordinateCapture(QgisInterface * theQgisInterface):
+                 QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
+                 mQGisIface(theQgisInterface)
+{
+}
+
+CoordinateCapture::~CoordinateCapture()
+{
+
+}
+
+/*
+ * Initialize the GUI interface for the plugin - this is only called once when the plugin is 
+ * added to the plugin registry in the QGIS application.
+ */
+void CoordinateCapture::initGui()
+{
+
+  // Create the action for tool
+  mQActionPointer = new QAction(QIcon(":/coordinatecapture/coordinatecapture.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
+  connect(mQActionPointer, SIGNAL(triggered()), this, SLOT(run()));
+  // Add the icon to the toolbar
+  mQGisIface->addToolBarIcon(mQActionPointer);
+  mQGisIface->addPluginMenu(tr("&Coordinate Capture"), mQActionPointer);
+
+  // create our map tool
+  mpMapTool = new CoordinateCaptureMapTool(mQGisIface->getMapCanvas());
+  connect(mpMapTool, SIGNAL(pointCaptured(QgsPoint)), this, SLOT(update(QgsPoint)));
+
+
+  // create a little widget with x and y display to put into our dock widget
+  QWidget * mypWidget = new QWidget();
+  QLayout * mypLayout = new QVBoxLayout();
+  mypWidget->setLayout(mypLayout);
+  
+  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);
+
+  
+  //create the dock widget
+  mpDockWidget = new QDockWidget(tr("Coordinate Capture"),mQGisIface->getMainWindow());
+  mpDockWidget->setObjectName("CoordinateCapture");
+  mpDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+  mQGisIface->addDockWidget(Qt::LeftDockWidgetArea, mpDockWidget);
+
+  // now add our custom widget to the dock - ownership of the widget is passed to the dock
+  mpDockWidget->setWidget(mypWidget);
+
+
+}
+//method defined in interface
+void CoordinateCapture::help()
+{
+  //implement me!
+}
+
+void CoordinateCapture::update(QgsPoint thePoint)
+{
+  mpXEdit->setText(QString::number( thePoint.x(),'f'));
+  mpYEdit->setText(QString::number( thePoint.y(),'f'));
+}
+void CoordinateCapture::copy()
+{
+  QClipboard *myClipboard = QApplication::clipboard(); 
+  //if we are on x11 system put text into selection ready for middle button pasting 
+  if (myClipboard->supportsSelection()) 
+  { 
+    myClipboard->setText(mpXEdit->text() + "," + mpYEdit->text(),QClipboard::Selection); 
+    //QString myMessage = tr("Clipboard contents set to: "); 
+    //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Selection)); 
+  } 
+  else 
+  { 
+    //user has an inferior operating system.... 
+    myClipboard->setText(mpXEdit->text() + "," + mpYEdit->text(),QClipboard::Clipboard ); 
+    //QString myMessage = tr("Clipboard contents set to: "); 
+    //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Clipboard)); 
+  } 
+}
+
+
+// Slot called when the menu item is triggered
+// If you created more menu items / toolbar buttons in initiGui, you should 
+// create a separate handler for each action - this single run() method will
+// not be enough
+void CoordinateCapture::run()
+{
+  mQGisIface->getMapCanvas()->setMapTool(mpMapTool);
+  //CoordinateCaptureGui *myPluginGui=new CoordinateCaptureGui(mQGisIface->getMainWindow(), QgisGui::ModalDialogFlags);
+  //myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
+  
+  //myPluginGui->show();
+}
+
+// Unload the plugin by cleaning up the GUI
+void CoordinateCapture::unload()
+{
+  // remove the GUI
+  mQGisIface->removePluginMenu("&Coordinate Capture",mQActionPointer);
+  mQGisIface->removeToolBarIcon(mQActionPointer);
+  mpMapTool->deactivate();
+  delete mpMapTool;
+  delete mpDockWidget;
+  delete mQActionPointer;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+//
+//
+//  THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
+//    YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
+//      MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
+//
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+/** 
+ * Required extern functions needed  for every plugin 
+ * These functions can be called prior to creating an instance
+ * of the plugin class
+ */
+// Class factory to return a new instance of the plugin class
+QGISEXTERN QgisPlugin * classFactory(QgisInterface * theQgisInterfacePointer)
+{
+  return new CoordinateCapture(theQgisInterfacePointer);
+}
+// Return the name of the plugin - note that we do not user class members as
+// the class may not yet be insantiated when this method is called.
+QGISEXTERN QString name()
+{
+  return sName;
+}
+
+// Return the description
+QGISEXTERN QString description()
+{
+  return sDescription;
+}
+
+// Return the type (either UI or MapLayer plugin)
+QGISEXTERN int type()
+{
+  return sPluginType;
+}
+
+// Return the version number for the plugin
+QGISEXTERN QString version()
+{
+  return sPluginVersion;
+}
+
+// Delete ourself
+QGISEXTERN void unload(QgisPlugin * thePluginPointer)
+{
+  delete thePluginPointer;
+}

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,127 @@
+/***************************************************************************
+    coordinatecapture.h 
+    -------------------
+    begin                : Jan 21, 2004
+    copyright            : (C) 2004 by Tim Sutton
+    email                : tim at linfiniti.com
+  
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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: plugin.h 7796 2007-12-16 22:11:38Z homann $ */
+/***************************************************************************
+ *   QGIS Programming conventions:
+ *   
+ *   mVariableName - a class level member variable
+ *   sVariableName - a static class level member variable
+ *   variableName() - accessor for a class member (no 'get' in front of name)
+ *   setVariableName() - mutator for a class member (prefix with 'set')
+ *
+ *   Additional useful conventions:
+ *
+ *   theVariableName - a method parameter (prefix with 'the')
+ *   myVariableName - a locally declared variable within a method ('my' prefix)
+ * 
+ *   DO: Use mixed case variable names - myVariableName
+ *   DON'T: separate variable names using underscores: my_variable_name (NO!)
+ *
+ * **************************************************************************/
+#ifndef COORDINATECAPTURE_H
+#define COORDINATECAPTURE_H
+
+//QT4 includes
+#include <QObject>
+#include <QPointer>
+
+//QGIS includes
+#include "../qgisplugin.h"
+#include "coordinatecapturemaptool.h"
+
+//forward declarations
+class QAction;
+class QToolBar;
+class QDockWidget;
+class QLineEdit;
+
+class QgisInterface;
+class QgsPoint;
+
+/**
+* \class Plugin
+* \brief [name] plugin for QGIS
+* [description]
+*/
+class CoordinateCapture:public QObject, public QgisPlugin
+{
+  Q_OBJECT;
+  public:
+      
+  //////////////////////////////////////////////////////////////////////
+  //
+  //                MANDATORY PLUGIN METHODS FOLLOW
+  //
+  //////////////////////////////////////////////////////////////////////
+
+  /** 
+  * Constructor for a plugin. The QgisInterface pointer is passed by 
+  * QGIS when it attempts to instantiate the plugin.
+  * @param theInterface Pointer to the QgisInterface object. 
+   */
+  CoordinateCapture(QgisInterface * theInterface);
+  //! Destructor
+  virtual ~CoordinateCapture();
+
+public slots:
+  //! init the gui
+  virtual void initGui();
+  //! Show the dialog box
+  void run();
+  //! unload the plugin
+  void unload();
+  //! show the help document
+  void help();
+  //! Called when mouse is clicked on the canvas
+  void update(QgsPoint thePoint);
+  //! Called when user clicks the copy button
+  void copy();
+
+
+private:
+  //! Container for the coordinate info
+  QPointer<QDockWidget> mpDockWidget;
+
+  //!output display for x coord
+  QPointer<QLineEdit> mpXEdit;
+
+  //!output display for y coord
+  QPointer<QLineEdit> mpYEdit;
+
+  //!Our custom map tool to capture clicks
+  CoordinateCaptureMapTool * mpMapTool;
+
+  ////////////////////////////////////////////////////////////////////
+  //
+  // MANDATORY PLUGIN PROPERTY DECLARATIONS  .....
+  //
+  ////////////////////////////////////////////////////////////////////
+  
+  int mPluginType;
+  //! Pointer to the QGIS interface object
+  QgisInterface *mQGisIface;
+  //!pointer to the qaction for this plugin
+  QAction * mQActionPointer;
+  ////////////////////////////////////////////////////////////////////
+  //
+  // ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
+  //
+  ////////////////////////////////////////////////////////////////////
+};
+
+#endif //CoordinateCapture_H

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.qrc
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.qrc	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.qrc	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/coordinatecapture/" >
+        <file>coordinatecapture.png</file>
+    </qresource>
+</RCC>

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.cpp
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.cpp	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.cpp	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   Copyright (C) 2003 by Tim Sutton                                      *
+ *   tim at linfiniti.com                                                     *
+ *                                                                         *
+ *   This is a plugin generated from the QGIS plugin template              *
+ *                                                                         *
+ *   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.                                   *
+ ***************************************************************************/
+#include "coordinatecapturegui.h"
+#include "qgscontexthelp.h"
+
+//qt includes
+
+//standard includes
+
+CoordinateCaptureGui::CoordinateCaptureGui( QWidget* parent, Qt::WFlags fl )
+: QDialog ( parent, fl )
+{
+  setupUi(this);
+
+  // Below is an example of how to make the translators job
+  // much easier. Please follow this general guideline for LARGE
+  // pieces of text. One-liners can be added in the .ui file
+
+  // Note: Format does not relate to translation.
+  QString format("<html><body><h3>%1</h3>%2<h3>%3</h3>%4<p><a href=http://svn.qgis.org/api_doc/html>"
+                 "http://svn.qgis.org/api_doc/html</a><p>"
+                 "%5<p>%6<p>%7<p>%8<p><h3>%9</h3>"
+                 "<h4>CMakeLists.txt</h4>%11"
+                 "<h4>coordinatecapture.h, coordinatecapture.cpp</h4>%12"
+                 "<h4>coordinatecapturegui.ui</h4>%13"
+                 "<h4>coordinatecapturegui.cpp, coordinatecapturegui.h</h4>%14"
+                 "<h4>coordinatecapture.qrc</h4>%15"
+                 "<h4>coordinatecapture.png</h4>%16"
+                 "<h4>README</h4>%17"
+                 "<h3>%18</h3>%19<ul>%20</ul>%21<p>%22"
+                 "<p><b>The QGIS Team<br>2007</b>"
+                 "</body></html>");
+
+  // Note: Table does not translate
+  QString table("<table><tr><td>QGisInterface<td><a href=http://svn.qgis.org/api_doc/html/classQgisInterface.html>"
+                "http://svn.qgis.org/api_doc/html/classQgisInterface.htm</a>"
+                "<tr><td>QgsMapCanvas<td><a href=http://svn.qgis.org/api_doc/html/classQgsMapCanvas.html>"
+                "http://svn.qgis.org/api_doc/html/classQgsMapCanvas.html</a>"
+                "<tr><td>QgsMapTool<td><a href=http://svn.qgis.org/api_doc/html/classQgsMapTool.html>"
+                "http://svn.qgis.org/api_doc/html/classQgsMapTool.html</a>"
+                "<tr><td>QgsPlugin<td><a href=http://svn.qgis.org/api_doc/html/classQgisPlugin.html>"
+                "http://svn.qgis.org/api_doc/html/classQgisPlugin.html</a></table>");
+
+  // Note: Translatable strings below
+  QString text = format 
+    .arg(tr("Welcome to your automatically generated plugin!"))
+    .arg(tr("This is just a starting point. You now need to modify the code to make it do something useful....read on for a more information to get yourself started."))
+    .arg(tr("Documentation:"))
+    .arg(tr("You really need to read the QGIS API Documentation now at:"))
+    .arg(tr("In particular look at the following classes:"))
+    .arg(table)
+    .arg("QGisInterface is an abstract base class (ABC) that specifies what publicly available features of QGIS are exposed to third party code and plugins. An instance of the QgisInterface is passed to the plugin when it loads. Please consult the QGIS development team if there is functionality required in the QGisInterface that is not available.")
+    .arg(tr("QgsPlugin is an ABC that defines required behaviour your plugin must provide. See below for more details."))
+    .arg(tr("What are all the files in my generated plugin directory for?"))
+    .arg(tr("This is the generated CMake file that builds the plugin. You should add you application specific dependencies and source files to this file."))
+    .arg(tr("This is the class that provides the 'glue' between your custom application logic and the QGIS application. You will see that a number of methods are already implemented for you - including some examples of how to add a raster or vector layer to the main application map canvas. This class is a concrete instance of the QgisPlugin interface which defines required behaviour for a plugin. In particular, a plugin has a number of static methods and members so that the QgsPluginManager and plugin loader logic can identify each plugin, create an appropriate menu entry for it etc. Note there is nothing stopping you creating multiple toolbar icons and menu entries for a single plugin. By default though a single menu entry and toolbar button is created and its pre-configured to call the run() method in this class when selected. This default implementation provided for you by the plugin builder is well documented, so please refer to the code for further advice."))
+    .arg(tr("This is a Qt designer 'ui' file. It defines the look of the default plugin dialog without implementing any application logic. You can modify this form to suite your needs or completely remove it if your plugin does not need to display a user form (e.g. for custom MapTools)."))
+    .arg(tr("This is the concrete class where application logic for the above mentioned dialog should go. The world is your oyster here really...."))
+    .arg(tr("This is the Qt4 resources file for your plugin. The Makefile generated for your plugin is all set up to compile the resource file so all you need to do is add your additional icons etc using the simple xml file format. Note the namespace used for all your resources e.g. (':/Homann/'). It is important to use this prefix for all your resources. We suggest you include any other images and run time data in this resurce file too."))
+    .arg(tr("This is the icon that will be used for your plugin menu entry and toolbar icon. Simply replace this icon with your own icon to make your plugin disctinctive from the rest."))
+    .arg(tr("This file contains the documentation you are reading now!"))
+    .arg(tr("Getting developer help:"))
+    .arg(tr("For Questions and Comments regarding the plugin builder template and creating your features in QGIS using the plugin interface please contact us via:"))
+    .arg(tr("<li> the QGIS developers mailing list, or </li><li> IRC (#qgis on freenode.net)</li>"))
+    .arg(tr("QGIS is distributed under the Gnu Public License. If you create a useful plugin please consider contributing it back to the community."))
+    .arg(tr("Have fun and thank you for choosing QGIS."));
+  
+  textBrowser->setHtml(text);
+}  
+
+CoordinateCaptureGui::~CoordinateCaptureGui()
+{
+}
+
+void CoordinateCaptureGui::on_buttonBox_accepted()
+{
+  //close the dialog
+  accept();
+} 
+
+void CoordinateCaptureGui::on_buttonBox_rejected()
+{
+  reject();
+}
+
+void CoordinateCaptureGui::on_buttonBox_helpRequested()
+{
+  QgsContextHelp::run(context_id);
+}
+

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.h
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.h	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapturegui.h	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *   Copyright (C) 2003 by Tim Sutton                                      *
+ *   tim at linfiniti.com                                                     *
+ *                                                                         *
+ *   This is a plugin generated from the QGIS plugin template              *
+ *                                                                         *
+ *   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.                                   *
+ ***************************************************************************/
+#ifndef CoordinateCaptureGUI_H
+#define CoordinateCaptureGUI_H
+
+#include <QDialog>
+#include <ui_coordinatecaptureguibase.h>
+
+/**
+ at author Tim Sutton
+*/
+class CoordinateCaptureGui : public QDialog, private Ui::CoordinateCaptureGuiBase
+{
+Q_OBJECT
+public:
+    CoordinateCaptureGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
+    ~CoordinateCaptureGui();
+
+private:
+    static const int context_id = 0;
+
+private slots:
+    void on_buttonBox_accepted();
+    void on_buttonBox_rejected();
+    void on_buttonBox_helpRequested();
+
+};
+
+#endif

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecaptureguibase.ui
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecaptureguibase.ui	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecaptureguibase.ui	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,76 @@
+<ui version="4.0" >
+ <class>CoordinateCaptureGuiBase</class>
+ <widget class="QDialog" name="CoordinateCaptureGuiBase" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>584</width>
+    <height>435</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>QGIS Plugin Template</string>
+  </property>
+  <property name="windowIcon" >
+   <iconset/>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QLabel" name="txtHeading" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>5</hsizetype>
+       <vsizetype>1</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="font" >
+      <font>
+       <family>Sans Serif</family>
+       <pointsize>24</pointsize>
+       <weight>75</weight>
+       <italic>false</italic>
+       <bold>true</bold>
+       <underline>false</underline>
+       <strikeout>false</strikeout>
+      </font>
+     </property>
+     <property name="text" >
+      <string>Plugin Template</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QTextBrowser" name="textBrowser" >
+     <property name="openExternalLinks" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::SaveAll</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <resources/>
+ <connections/>
+</ui>

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,75 @@
+/***************************************************************************
+    coordinatecapturemaptool.cpp  -  map tool for getting click coords
+    ---------------------
+    begin                : August 2008
+    copyright            : (C) 2008 by Tim Sutton
+    email                : tim at linfiniti.com
+ ***************************************************************************
+ *                                                                         *
+ *   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 "coordinatecapturemaptool.h"
+#include "qgscursors.h"
+#include "qgsmapcanvas.h"
+#include "qgsmaptopixel.h"
+#include "qgsrubberband.h"
+#include "qgsspatialrefsys.h"
+
+#include <QSettings>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QCursor>
+#include <QPixmap>
+
+CoordinateCaptureMapTool::CoordinateCaptureMapTool(QgsMapCanvas* thepCanvas)
+  : QgsMapTool(thepCanvas)
+{
+  // set cursor
+  QPixmap myIdentifyCursor = QPixmap((const char **) identify_cursor);
+  mCursor = QCursor(myIdentifyCursor, 1, 1);
+  mpMapCanvas = thepCanvas;
+  mpRubberBand = new QgsRubberBand(mpMapCanvas,false); //false - not a polygon
+}
+
+CoordinateCaptureMapTool::~CoordinateCaptureMapTool()
+{
+  if (mpRubberBand != 0)
+  delete mpRubberBand;
+}
+
+void CoordinateCaptureMapTool::canvasMoveEvent(QMouseEvent * e)
+{
+}
+
+void CoordinateCaptureMapTool::canvasPressEvent(QMouseEvent * thepEvent)
+{
+}
+
+void CoordinateCaptureMapTool::canvasReleaseEvent(QMouseEvent * thepEvent)
+{
+  if(!mpMapCanvas || mpMapCanvas->isDrawing())
+  {
+    return;
+  }
+
+  mpRubberBand->reset(false);
+
+  // convert screen coordinates to map coordinates
+  QgsPoint myPoint = 
+    mCanvas->getCoordinateTransform()->toMapCoordinates(thepEvent->x(), thepEvent->y());
+  mpRubberBand->addPoint(myPoint,true); //true - update canvas
+  emit pointCaptured(myPoint);
+}
+
+
+void CoordinateCaptureMapTool::deactivate()
+{
+  mpRubberBand->reset(false);
+  QgsMapTool::deactivate();
+}

Added: trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.h
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.h	                        (rev 0)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapturemaptool.h	2008-08-06 00:24:31 UTC (rev 8998)
@@ -0,0 +1,64 @@
+/***************************************************************************
+    coordinatecapturemaptool.h  -  map tool for getting map coordinates
+    ---------------------
+    begin                : August 2008
+    copyright            : (C) 2008 by Tim Sutton
+    email                : tim at linfiniti.com
+ ***************************************************************************
+ *                                                                         *
+ *   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$ */
+
+#ifndef COORDINATECAPTUREMAPTOOL_H
+#define COORDINATECAPTUREMAPTOOL_H
+
+#include "qgsmaptool.h"
+#include "qgspoint.h"
+
+#include <QObject>
+#include <QPointer>
+
+class QgsRubberBand;
+
+/**
+  \brief Map tool for capturing mouse clicks to clipboard
+*/
+class CoordinateCaptureMapTool : public QgsMapTool
+{
+  Q_OBJECT;
+
+  public:
+    CoordinateCaptureMapTool(QgsMapCanvas* thepCanvas);
+
+    ~CoordinateCaptureMapTool();
+
+    //! Overridden mouse move event
+    virtual void canvasMoveEvent(QMouseEvent * e);
+
+    //! Overridden mouse press event
+    virtual void canvasPressEvent(QMouseEvent * e);
+
+    //! Overridden mouse release event
+    virtual void canvasReleaseEvent(QMouseEvent * e);
+
+    //! called when map tool is being deactivated
+    virtual void deactivate();
+
+  public slots:
+  
+  signals:
+    void pointCaptured(QgsPoint);
+  private:
+
+    //! Rubber band for highlighting identified feature
+    QgsRubberBand * mpRubberBand;
+    QPointer<QgsMapCanvas> mpMapCanvas;
+
+};
+
+#endif



More information about the QGIS-commit mailing list