py3: Draft: use ordered dicts

This commit is contained in:
looooo 2017-02-03 11:24:55 +01:00 committed by wmayer
parent 76a4e7469b
commit 915a1b18c4

View File

@ -32,7 +32,9 @@ __url__ = "http://www.freecadweb.org"
# 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
@ -93,43 +95,44 @@ class Snapper:
# 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