@@ -43,28 +43,32 @@ def getSnapPoint(self, point, entity):
4343 fromPoint: [Geoent.Pointfloat]
4444 fromEnt: [GeoEnt.*]
4545 """
46+ def pointReturn (pointCalculated ,realPoint ):
47+ if pointCalculated == None :
48+ return realPoint
49+ return pointCalculated
50+
4651 if self .activeSnap == SNAP_POINT_ARRAY ["NONE" ]:
4752 return point
4853 else :
4954 snapPoint = point
5055 if SNAP_POINT_ARRAY ["MID" ] == self .activeSnap :
51- snapPoint = self .getSnapMiddlePoint (entity )
56+ return pointReturn ( self .getSnapMiddlePoint (entity ), point )
5257 elif SNAP_POINT_ARRAY ["END" ] == self .activeSnap :
53- snapPoint = self .getSnapEndPoint (entity , point )
58+ return pointReturn ( self .getSnapEndPoint (entity , point ), point )
5459 elif SNAP_POINT_ARRAY ["ORTHO" ] == self .activeSnap :
55- snapPoint = self .getSnapOrtoPoint (entity , point )
60+ return pointReturn ( self .getSnapOrtoPoint (entity , point ), point )
5661 elif SNAP_POINT_ARRAY ["CENTER" ]== self .activeSnap :
57- snapPoint = self .getSnapCenterPoint (entity )
62+ return pointReturn ( self .getSnapCenterPoint (entity ), point )
5863 elif SNAP_POINT_ARRAY ["QUADRANT" ]== self .activeSnap :
59- snapPoint = self .getSnapQuadrantPoint (entity , snapPoint )
64+ return pointReturn ( self .getSnapQuadrantPoint (entity , snapPoint ), point )
6065 elif SNAP_POINT_ARRAY ["ORIG" ]== self .activeSnap :
61- snapPoint = Point (0.0 , 0.0 )
66+ return Point (0.0 , 0.0 )
6267 elif SNAP_POINT_ARRAY ["INTERSECTION" ]== self .activeSnap :
63- snapPoint = self .getIntersection (entity ,snapPoint )
68+ return pointReturn ( self .getIntersection (entity ,snapPoint ), point )
6469 elif SNAP_POINT_ARRAY ["LIST" ]== self .activeSnap :
65- #this should be used when checklist of snap will be enabled
70+ #TODO: this should be used when checklist of snap will be enabled
6671 snapPoints = []
67-
6872 if ACTIVE_SNAP_LIST .count (SNAP_POINT_ARRAY ["MID" ])> 0 :
6973 pnt = self .getSnapMiddlePoint (entity )
7074 if pnt != None :
@@ -102,14 +106,12 @@ def getSnapPoint(self, point, entity):
102106 else :
103107 if outPoint [0 ]!= None :
104108 snapPoint = outPoint [0 ]
109+ return pointReturn (snapPoint ,point )
105110
106- if snapPoint == None :
107- return point
108- return snapPoint
109111
110112 def getSnapOrtoPoint (self , entity , point ):
111113 """
112- this fucnticion compute the orto to point snap constraint
114+ this function compute the orto to point snap constraint
113115 """
114116 # Now only works for segments and arcs. USES THE getPROJECTION METHOD
115117 if self ._scene .fromPoint == None or entity == None :
@@ -125,7 +127,7 @@ def getSnapOrtoPoint(self, entity, point):
125127
126128 def getSnapTangentPoint (self , point ):
127129 """
128- this fucnticion compute the Tangent to point snap constraint
130+ this function compute the Tangent to point snap constraint
129131 """
130132 #TODO: getSnapTangentPoint
131133 returnVal = None
@@ -136,7 +138,7 @@ def getSnapTangentPoint(self, point):
136138
137139 def getSnapMiddlePoint (self , entity ):
138140 """
139- this fucnticion compute midpoint snap constraint to the entity argument
141+ this function compute midpoint snap constraint to the entity argument
140142 """
141143 returnVal = None
142144 if getattr (entity , 'geoItem' , None ):
@@ -146,7 +148,7 @@ def getSnapMiddlePoint(self, entity):
146148
147149 def getSnapEndPoint (self , entity , point ):
148150 """
149- this fucnticion compute the snap endpoint
151+ this function compute the snap endpoint
150152 """
151153 if point == None or entity == None :
152154 return None
@@ -166,7 +168,7 @@ def getSnapEndPoint(self, entity, point):
166168
167169 def getSnapCenterPoint (self , entity ):
168170 """
169- this fucnticion compute the snap from the center of an entity
171+ this function compute the snap from the center of an entity
170172 """
171173 returnVal = None
172174 if getattr (entity , 'geoItem' , None ):
@@ -179,22 +181,17 @@ def getSnapCenterPoint(self, entity):
179181
180182 def getIntersection (self , entity , point ):
181183 """
182- this fucnticion compute the snap intersection point
184+ this function compute the snap intersection point
183185 """
184186 returnVal = None
185187 distance = None
186188 if entity != None :
187189 geoEntityFrom = entity .geoItem
188- import time
189- #startTime=time.clock()
190190 entityList = self ._scene .collidingItems (entity )
191- #endTime=time.clock()-startTime
192- #print "getIntersection, collidingItems in %s"%str(endTime)
193- #startTime=time.clock()
194191 for ent in entityList :
192+ if not isinstance (ent ,BaseEntity ):
193+ continue
195194 if isinstance (ent , BaseEntity ):
196- #print "geoitem", ent.geoItem
197- #print "geoEntityFrom", geoEntityFrom
198195 intPoint = find_intersections (ent .geoItem ,geoEntityFrom )
199196 for tp in intPoint :
200197 iPoint = Point (tp [0 ], tp [1 ])
@@ -206,13 +203,11 @@ def getIntersection(self, entity, point):
206203 if distance > spoolDist :
207204 distance = spoolDist
208205 returnVal = iPoint
209- #endTime=time.clock()-startTime
210- #print "find intersection in %s"%str(endTime)
211206 return returnVal
212207
213208 def getSnapQuadrantPoint (self , entity , point ):
214209 """
215- this fucnticion compute the snap from the quadrant
210+ this function compute the snap from the quadrant
216211 """
217212 returnVal = None
218213 if getattr (entity , 'geoItem' , None ):
@@ -244,7 +239,10 @@ def __init__(self):
244239 self .setFlag (QtGui .QGraphicsItem .ItemIsSelectable , False )
245240 self .setFlag (QtGui .QGraphicsItem .ItemIgnoresTransformations , True )
246241 self .hide ()
247-
242+
243+ def collidesWithItem (self ,other ,mode ):
244+ return False
245+
248246 def shape (self ):
249247 """
250248 overloading of the shape method
@@ -277,7 +275,11 @@ def __init__(self, x, y):
277275 self .setToolTip ("EndPoint" )
278276 self .x = x
279277 self .y = y
280-
278+
279+ def collidesWithItem (self ,other ,mode ):
280+ print "collidesWithItem"
281+ return False
282+
281283 def definePath (self ):
282284 rect = QtCore .QRectF (self .x - 5.0 , self .y - 5.0 , 10.0 , 10.0 )
283285 path = QtGui .QPainterPath ()
0 commit comments