Skip to content

Commit

Permalink
fixed bug where distance does not lock
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed Feb 3, 2014
1 parent 846a4ba commit 131f63b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
32 changes: 22 additions & 10 deletions CadEventFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ def _constrain(self, p3):

p3.setY( y )

else:
if self.inputwidget.rx:
self.inputwidget.x = p3.x()-self.p2.x()
else:
self.inputwidget.x = p3.x()



#Y
Expand Down Expand Up @@ -238,6 +244,12 @@ def _constrain(self, p3):

p3.setX( x )

else:
if self.inputwidget.ry:
self.inputwidget.y = p3.y()-self.p2.y()
else:
self.inputwidget.y = p3.y()

#A
dx = p3.x()-self.p2.x()
dy = p3.y()-self.p2.y()
Expand Down Expand Up @@ -269,6 +281,13 @@ def _constrain(self, p3):
if l1.intersect(l2, intP) == QLineF.UnboundedIntersection and not (ang < t or ang > 360-t or (ang > 180-t and ang < 180+t) ):
p3.setX( intP.x() )
p3.setY( intP.y() )

else:
if self.inputwidget.ra:
lastA = math.atan2(self.p2.y() - self.p1.y(), self.p2.x() - self.p1.x())
self.inputwidget.a = (math.atan2( dy, dx )-lastA)/math.pi*180
else:
self.inputwidget.a = math.atan2( dy, dx )/math.pi*180



Expand Down Expand Up @@ -322,11 +341,11 @@ def sgn(x): return -1 if x<0 else 1
else:
p3.setX( ax )
p3.setY( ay )

else:
self.inputwidget.d = math.sqrt( dx*dx + dy*dy )


#Update the widget's values
#Update the widget's x&y values (for display only)
if self.inputwidget.rx:
self.inputwidget.x = p3.x()-self.p2.x()
else:
Expand All @@ -336,14 +355,7 @@ def sgn(x): return -1 if x<0 else 1
self.inputwidget.y = p3.y()-self.p2.y()
else:
self.inputwidget.y = p3.y()

if self.inputwidget.ra:
lastA = math.atan2(self.p2.y() - self.p1.y(), self.p2.x() - self.p1.x())
self.inputwidget.a = (math.atan2( dy, dx )-lastA)/math.pi*180
else:
self.inputwidget.a = math.atan2( dy, dx )/math.pi*180

self.inputwidget.d = math.sqrt( dx*dx + dy*dy )

return p3
def _alignToSegment(self):
Expand Down
6 changes: 2 additions & 4 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name=CadInput
qgisMinimumVersion=2.0
description=Provides CAD-like input for QGIS : digitize features with precise numerical mouse constraints (demo : https://vimeo.com/85052231)
version=0.4
version=0.41
author=Olivier Dalang
email=olivier.dalang@gmail.com

Expand All @@ -21,9 +21,7 @@ email=olivier.dalang@gmail.com
# Optional items:

# Uncomment the following line and add your changelog entries:
changelog=- 2014-01-31 - version 0.4
- improved performances on more complex files (thanks 3nids)
- snapping preferences now taken into account
changelog=bug where distance does not lock fixed

# tags are comma separated with spaces allowed
tags=digitizing, cad, vector
Expand Down

0 comments on commit 131f63b

Please sign in to comment.