Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
measure in chart
Browse files Browse the repository at this point in the history
  • Loading branch information
wilhelmberg committed Oct 15, 2014
1 parent c74d469 commit ca23b53
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 43 deletions.
Binary file modified VoGisProfilTool.zip
Binary file not shown.
12 changes: 11 additions & 1 deletion VoGisProfilTool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ PLUGINNAME = VoGisProfilTool
QGISPIDIR = .qgis2

PY_FILES = vogisprofiltoolmain.py vogisprofiltoolmaindialog.py vogisprofiltoolplot.py __init__.py
EXTRAS = icons/icon.png icons/home.png icons/pan.png icons/save.png icons/zoomlast.png icons/zoomnext.png icons/zoomrectangle.png icons/zoomselect.png icons/identify.png
EXTRAS = icons/home.png \
icons/icon.png \
icons/identify.png \
icons/measure.png \
icons/pan.png \
icons/save.png \
icons/zoomlast.png \
icons/zoomnext.png \
icons/zoomrectangle.png \
icons/zoomselect.png
BO_FILES = bo/__init__.py \
bo/chartpoint.py \
bo/intersection.py \
bo/line.py \
bo/lineCollection.py \
Expand Down
2 changes: 1 addition & 1 deletion VoGisProfilTool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def description():


def version():
return "1.8.8"
return "1.8.9"


def icon():
Expand Down
15 changes: 15 additions & 0 deletions VoGisProfilTool/bo/chartpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class ChartPoint:

def __init__(self, xpixel=0, ypixel=0, xdata=0, ydata=0):
self.xpixel = xpixel
self.ypixel = ypixel
self.xdata = xdata
self.ydata = ydata


def toString(self):
return 'pixel:{0}/{1} data:{2}/{3}'.format(
self.xpixel,
self.ypixel,
self.xdata,
self.ydata)
Binary file added VoGisProfilTool/icons/measure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion VoGisProfilTool/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name=VoGIS-ProfilTool
qgisMinimumVersion=1.8
qgisMaximumVersion=2.99
description=Create profiles from DHMs using vector geometries or a digitized line.
version=1.8.8
version=1.8.9
author=BergWerk GIS
email=wb@BergWerk-GIS.at

Expand Down
3 changes: 2 additions & 1 deletion VoGisProfilTool/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<RCC>
<qresource prefix="/plugins/vogisprofiltoolmain" >
<file>icons/icon.png</file>
<file>icons/identify.png</file>
<file>icons/home.png</file>
<file>icons/measure.png</file>
<file>icons/pan.png</file>
<file>icons/save.png</file>
<file>icons/zoomlast.png</file>
<file>icons/zoomnext.png</file>
<file>icons/zoomrectangle.png</file>
<file>icons/zoomselect.png</file>
<file>icons/identify.png</file>
</qresource>
</RCC>
49 changes: 38 additions & 11 deletions VoGisProfilTool/resources_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@

# Resource object code
#
# Created: Mi. M�r 26 17:48:20 2014
# by: The Resource Compiler for PyQt (Qt v4.8.1)
# Created: Mi. Okt 15 11:30:18 2014
# by: The Resource Compiler for PyQt (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore

qt_resource_data = "\
\x00\x00\x01\x32\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x18\x00\x00\x00\x18\x08\x06\x00\x00\x00\xe0\x77\x3d\xf8\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x00\xaf\x49\x44\
\x41\x54\x48\x89\x63\xfc\xff\xff\x3f\x03\x2d\x01\x13\x4d\x4d\x1f\
\xb5\x80\x64\x0b\x6c\xa3\xf3\x29\x8e\x71\x74\x33\x68\xee\x03\x16\
\x42\x2e\xa0\x14\xd0\xdf\x07\x87\x97\x4e\x64\xa4\xc4\x40\xf4\x10\
\x60\x1c\xf2\x39\x99\x85\x81\x81\x81\x21\x2c\x22\xe4\x2f\x4c\xe0\
\xef\x9f\x7f\x8c\xcc\x2c\x4c\xff\x29\x65\x33\x30\x30\x30\xac\x5a\
\xb1\x86\x99\xe1\xff\xff\xff\x0c\xa1\xe1\xc1\x7f\x2f\x5f\x3f\xff\
\xf7\xf2\xf5\xf3\x7f\x03\x02\x02\xfe\x53\x83\x1d\x1a\x1e\xfc\xf7\
\xff\xff\xff\x03\x50\x54\x38\x3a\xdb\xff\xc7\xc6\x26\x46\x0d\x36\
\xf5\x18\x16\x38\xb9\x38\xfc\xc7\xc6\x26\x46\x0d\x36\xf5\x44\x07\
\x11\x2e\xdf\x10\x02\x44\x5b\x80\xcb\x37\x84\x00\x3c\x27\x37\x35\
\xb4\x90\xa3\x9f\x20\x18\xfa\x39\x79\xe8\x5b\x00\x00\x5b\x42\x8b\
\xed\x7c\x0b\x21\x7e\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x04\x3a\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
Expand Down Expand Up @@ -711,6 +733,10 @@
\x00\x6f\xa6\x53\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x0b\
\x0c\x63\x26\x07\
\x00\x6d\
\x00\x65\x00\x61\x00\x73\x00\x75\x00\x72\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0c\
\x08\x8b\x9f\x27\
\x00\x7a\
Expand Down Expand Up @@ -754,16 +780,17 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x40\x00\x02\x00\x00\x00\x09\x00\x00\x00\x04\
\x00\x00\x00\xd6\x00\x00\x00\x00\x00\x01\x00\x00\x12\x59\
\x00\x00\x00\x6e\x00\x00\x00\x00\x00\x01\x00\x00\x04\x3e\
\x00\x00\x01\x20\x00\x00\x00\x00\x00\x01\x00\x00\x1a\xbe\
\x00\x00\x01\x36\x00\x00\x00\x00\x00\x01\x00\x00\x25\x98\
\x00\x00\x00\xfe\x00\x00\x00\x00\x00\x01\x00\x00\x16\x5e\
\x00\x00\x00\x40\x00\x02\x00\x00\x00\x0a\x00\x00\x00\x04\
\x00\x00\x00\xf2\x00\x00\x00\x00\x00\x01\x00\x00\x13\x8f\
\x00\x00\x00\x8a\x00\x00\x00\x00\x00\x01\x00\x00\x05\x74\
\x00\x00\x01\x3c\x00\x00\x00\x00\x00\x01\x00\x00\x1b\xf4\
\x00\x00\x01\x52\x00\x00\x00\x00\x00\x01\x00\x00\x26\xce\
\x00\x00\x01\x1a\x00\x00\x00\x00\x00\x01\x00\x00\x17\x94\
\x00\x00\x00\x6c\x00\x00\x00\x00\x00\x01\x00\x00\x01\x36\
\x00\x00\x00\xbe\x00\x00\x00\x00\x00\x01\x00\x00\x0d\x7b\
\x00\x00\x00\xa8\x00\x00\x00\x00\x00\x01\x00\x00\x09\xef\
\x00\x00\x00\x50\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x01\x00\x00\x0c\x45\
\x00\x00\x00\x8c\x00\x00\x00\x00\x00\x01\x00\x00\x08\xb9\
\x00\x00\x00\xb8\x00\x00\x00\x00\x00\x01\x00\x00\x0e\x06\
\x00\x00\x00\xd4\x00\x00\x00\x00\x00\x01\x00\x00\x0f\x3c\
"

def qInitResources():
Expand Down
59 changes: 33 additions & 26 deletions VoGisProfilTool/vogisprofiltoolplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from random import randrange
from ui.ui_vogisprofiltoolplot import Ui_VoGISProfilToolPlot
from bo.plotExtent import PlotExtent
from bo.chartpoint import ChartPoint
from util.u import Util
from util.exportShape import ExportShape
from util.exportDxf import ExportDxf
Expand Down Expand Up @@ -109,6 +110,9 @@ def __init__(self, interface, settings, profiles, intersections):
# for t in plt_toolbar.toolitems:
# QgsMessageLog.logMessage('{0}'.format(t), 'VoGis')
#lstActions = plt_toolbar.actions()

#https://hub.qgis.org/wiki/17/Icons_20

firstaction = None
for a in plt_toolbar.actions():
atxt = a.text()
Expand Down Expand Up @@ -158,22 +162,23 @@ def __init__(self, interface, settings, profiles, intersections):
#insert identify label to show name of clicked dhm
self.dhmLbl = QLabel()
plt_toolbar.insertWidget(firstaction, self.dhmLbl)
#measure in figure
self.click1 = None
self.click2 = None
self.click1pnt = None
self.click2pnt = None
self.measureLbl = QLabel()
self.measureLbl.setText(u' ')
plt_toolbar.insertWidget(firstaction, self.measureLbl)

#insert measure tool
self.measuring = False
self.measure_tool = QPushButton()
self.measure_tool.setIcon(QIcon(":/plugins/vogisprofiltoolmain/icons/identify.png"))
self.measure_tool.setIcon(QIcon(":/plugins/vogisprofiltoolmain/icons/measure.png"))
self.measure_tool.clicked.connect(self.__measure)
plt_toolbar.insertWidget(firstaction, self.measure_tool)

#show measure results
self.click1 = None
self.click2 = None
self.click1pnt = None
self.click2pnt = None
self.measure_lbl = QLabel()
self.measure_lbl.setText(u' ')
plt_toolbar.insertWidget(firstaction, self.measure_lbl)

#for less thatn 10 colors:
#alternative method: http://stackoverflow.com/a/14720445
colors = [(1.0, 0.0, 0.0, 1.0),
Expand Down Expand Up @@ -526,22 +531,21 @@ def __mouse_move(self, event):
if event.xdata is None or event.ydata is None:
return

dx = event.xdata - self.click1[0]
dy = event.ydata - self.click1[1]
dx = event.xdata - self.click1.xdata
dy = event.ydata - self.click1.ydata

if self.debug:
#QgsMessageLog.logMessage('mouse move name {0}'.format(event.name), 'VoGis')
#QgsMessageLog.logMessage('mouse move xdata {0}'.format(event.xdata), 'VoGis')
#QgsMessageLog.logMessage('mouse move ydata {0}'.format(event.ydata), 'VoGis')
QgsMessageLog.logMessage('dx/dy {0}/{1}'.format(dx, dy), 'VoGis')
self.measureLbl.setText(u' x/y:{0:.1f}/{1:.1f} dx/dy:{2:.1f}/{3:.1f}'.format(
self.click1[0],
self.click1[1],
self.measure_lbl.setText(u' x/y:{0:.1f}/{1:.1f} dx/dy:{2:.1f}/{3:.1f}'.format(
self.click1.xdata,
self.click1.ydata,
dx,
dy
))
#self.plt_widget.draw_rubberband('xy', self.click1[0], self.click1[1], event.xdata, event.ydata)
self.plt_toolbar.draw_rubberband('xy', self.click1[0], self.click1[1], event.xdata, event.ydata)
self.plt_toolbar.draw_rubberband('xy', self.click1.xpixel, self.click1.ypixel, event.x, event.y)

def __buttonPressed(self, event):
if self.debug:
Expand All @@ -550,6 +554,8 @@ def __buttonPressed(self, event):
if self.plotpicked is False:
self.dhmLbl.setText(' ? ')

self.plotpicked = False

if self.measuring is False:
return

Expand All @@ -559,14 +565,16 @@ def __buttonPressed(self, event):
QgsMessageLog.logMessage('{0}'.format(dir(event.ydata)), 'VoGis')
QgsMessageLog.logMessage(
'x:{0} y:{1} xdata:{2} ydata:{3} click1:{4} click2:{5} click1pnt:{6} click2pnt:{7}'.format(
event.x, event.y, event.xdata, event.ydata, self.click1, self.click2,self.click1pnt, self.click2pnt), 'VoGis')
event.x, event.y, event.xdata, event.ydata, self.click1, self.click2, self.click1pnt, self.click2pnt), 'VoGis')
QgsMessageLog.logMessage('click1pnt: {0}'.format(dir(self.click1pnt)), 'VoGis')

if event.xdata is None or event.ydata is None:
return
if self.click1 is None:
self.click1 = [event.xdata, event.ydata]
self.click1 = ChartPoint(event.x, event.y, event.xdata, event.ydata)
self.click2 = None
#self.measureLbl.setText(u'')
self.measureLbl.setText(u' x/y:{0:.1f}/{1:.1f} '.format(event.xdata, event.ydata))
#self.measure_lbl.setText(u'')
self.measure_lbl.setText(u' x/y:{0:.1f}/{1:.1f} dx/dy:0/0'.format(event.xdata, event.ydata))
if not self.click1pnt is None:
p = self.click1pnt.pop(0);
p.remove()
Expand All @@ -579,15 +587,15 @@ def __buttonPressed(self, event):
self.click2pnt = None
self.click1pnt = self.subplot.plot(event.xdata, event.ydata, 'ro')
elif self.click2 is None:
self.click2 = [event.xdata, event.ydata]
self.click2 = ChartPoint(event.x, event.y, event.xdata, event.ydata)
#delta_x = abs(self.click2[0] - self.click1[0])
#delta_y = abs(self.click2[1] - self.click1[1])
#dist = ((delta_x ** 2) + (delta_y ** 2)) ** 0.5
#self.measureLbl.setText(u' dist: {0:.1f} '.format(dist))
delta_x = self.click2[0] - self.click1[0]
delta_y = self.click2[1] - self.click1[1]
#self.measure_lbl.setText(u' dist: {0:.1f} '.format(dist))
delta_x = self.click2.xdata - self.click1.xdata
delta_y = self.click2.ydata - self.click1.ydata
dist = sqrt(pow(delta_x, 2) + pow(delta_y, 2))
self.measureLbl.setText(u' dx/dy:{0:.1f}/{1:.1f} d:{2:.1f}'.format(delta_x, delta_y, dist))
self.measure_lbl.setText(u' dx/dy:{0:.1f}/{1:.1f} d:{2:.1f}'.format(delta_x, delta_y, dist))
self.click1 = None
self.measuring = False
if not self.click2pnt is None:
Expand All @@ -601,7 +609,6 @@ def __buttonPressed(self, event):
#if self.plotpicked is True:
if self.plt_toolbar._active is None:
self.plt_widget.draw()
self.plotpicked = False


def __createMatplotlibCanvas(self, plt_extent):
Expand Down
4 changes: 2 additions & 2 deletions plugins.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<plugins>
<pyqgis_plugin name="VoGIS-ProfilTool" version="1.8.8">
<pyqgis_plugin name="VoGIS-ProfilTool" version="1.8.9">
<description><![CDATA[Create profiles from DHMs using vector geometries or a digitized line.]]></description>
<version>1.8.7</version>
<version>1.8.9</version>
<qgis_minimum_version>1.8.0</qgis_minimum_version>
<qgis_maximum_version>2.99.0</qgis_maximum_version>
<homepage>https://github.com/BergWerkGIS/VoGIS-Profil-Tool/</homepage>
Expand Down

0 comments on commit ca23b53

Please sign in to comment.