Skip to content

Commit

Permalink
py3: Draft: use ordered dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
looooo authored and wwmayer committed Feb 4, 2017
1 parent 76a4e74 commit 915a1b1
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions src/Mod/Draft/DraftSnap.py
Expand Up @@ -32,7 +32,9 @@
# This module provides tools to handle point snapping and
# everything that goes with it (toolbar buttons, cursor icons, etc)


import FreeCAD, FreeCADGui, math, Draft, DraftGui, DraftTrackers, DraftVecUtils
from collections import OrderedDict
from FreeCAD import Vector
from pivy import coin
from PySide import QtCore,QtGui
Expand Down Expand Up @@ -93,43 +95,44 @@ def __init__(self):

# the snapmarker has "dot","circle" and "square" available styles
if self.snapStyle:
self.mk = {'passive':'empty',
'extension':'empty',
'parallel':'empty',
'grid':'quad',
'endpoint':'quad',
'midpoint':'quad',
'perpendicular':'quad',
'angle':'quad',
'center':'quad',
'ortho':'quad',
'intersection':'quad',
'special':'quad'}
self.mk = OrderedDict([('passive', 'empty'),
('extension', 'empty'),
('parallel', 'empty'),
('grid', 'quad'),
('endpoint', 'quad'),
('midpoint', 'quad'),
('perpendicular','quad'),
('angle', 'quad'),
('center', 'quad'),
('ortho', 'quad'),
('intersection', 'quad'),
('special', 'quad')])
else:
self.mk = {'passive':'circle',
'extension':'circle',
'parallel':'circle',
'grid':'circle',
'endpoint':'dot',
'midpoint':'square',
'perpendicular':'dot',
'angle':'square',
'center':'dot',
'ortho':'dot',
'intersection':'dot',
'special':'dot'}
self.cursors = {'passive':':/icons/Snap_Near.svg',
'extension':':/icons/Snap_Extension.svg',
'parallel':':/icons/Snap_Parallel.svg',
'grid':':/icons/Snap_Grid.svg',
'endpoint':':/icons/Snap_Endpoint.svg',
'midpoint':':/icons/Snap_Midpoint.svg',
'perpendicular':':/icons/Snap_Perpendicular.svg',
'angle':':/icons/Snap_Angle.svg',
'center':':/icons/Snap_Center.svg',
'ortho':':/icons/Snap_Ortho.svg',
'intersection':':/icons/Snap_Intersection.svg',
'special':':/icons/Snap_Special.svg'}
self.mk = OrderedDict([('passive', 'circle'),
('extension', 'circle'),
('parallel', 'circle'),
('grid', 'circle'),
('endpoint', 'dot'),
('midpoint', 'square'),
('perpendicular','dot'),
('angle', 'square'),
('center', 'dot'),
('ortho', 'dot'),
('intersection', 'dot'),
('special', 'dot')])

self.cursors = OrderedDict([('passive', ':/icons/Snap_Near.svg'),
('extension', ':/icons/Snap_Extension.svg'),
('parallel', ':/icons/Snap_Parallel.svg'),
('grid', ':/icons/Snap_Grid.svg'),
('endpoint', ':/icons/Snap_Endpoint.svg'),
('midpoint', ':/icons/Snap_Midpoint.svg'),
('perpendicular', ':/icons/Snap_Perpendicular.svg'),
('angle', ':/icons/Snap_Angle.svg'),
('center', ':/icons/Snap_Center.svg'),
('ortho', ':/icons/Snap_Ortho.svg'),
('intersection', ':/icons/Snap_Intersection.svg'),
('special', ':/icons/Snap_Special.svg')])

def snap(self,screenpos,lastpoint=None,active=True,constrain=False,noTracker=False):
"""snap(screenpos,lastpoint=None,active=True,constrain=False,noTracker=False): returns a snapped
Expand Down

0 comments on commit 915a1b1

Please sign in to comment.