-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSketchArchCommands.py
100 lines (86 loc) · 5.02 KB
/
SketchArchCommands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#***************************************************************************
#* *
#* Copyright (c) 2018, 2019 *
#* Paul Lee <[email protected]> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD, FreeCADGui, Part, Draft, Sketcher
from PySide import QtGui, QtCore
App = FreeCAD
Gui = FreeCADGui
#----------------------------------------------------------------------------#
# Class Definition #
#----------------------------------------------------------------------------#
class selectObjectObserver:
''' General Purpose Selection Observer '''
def __init__(self, callerNextDef, filterDoc=None,
filterObj=None, filterSub=None):
self.filterDoc=str(filterDoc)
self.filterObj=str(filterObj)
self.filterSub=str(filterSub)
self.av = FreeCADGui.activeDocument().activeView()
self.escape = self.av.addEventCallback("SoKeyboardEvent",self.escape)
FreeCAD.Console.PrintMessage('\n'+'\n')
FreeCAD.Console.PrintWarning('PRESS [ESC] to Exit \n')
def addSelection(self,doc,obj,sub,pnt):
if self.filterSub:
if self.filterSub in sub:
self.proceed(doc, obj, sub, pnt)
def removeSelection(self,doc,obj,sub):
App.Console.PrintMessage("removeSelection"+ "\n")
def setSelection(self,doc):
App.Console.PrintMessage("setSelection"+ "\n")
def clearSelection(self,doc):
App.Console.PrintMessage("clearSelection"+ "\n")
def escape(self,info):
k=info['Key']
if k=="ESCAPE":
FreeCAD.Console.PrintMessage("Escaped \n")
self.av.removeEventCallback("SoKeyboardEvent",self.escape)
FreeCADGui.Selection.removeObserver(self)
class selectObject:
''' General Purpose Selection Observer '''
def __init__(self, callerInstance, callerNextDef, filterDoc=None,
filterObj=None, filterSub=None):
self.callerInstance=callerInstance
self.callerNextDef=str(callerNextDef)
self.filterDoc=str(filterDoc)
self.filterObj=str(filterObj)
self.filterSub=str(filterSub)
self.av = FreeCADGui.activeDocument().activeView()
self.escape = self.av.addEventCallback("SoKeyboardEvent",self.escape)
FreeCAD.Console.PrintMessage('\n'+'\n')
FreeCAD.Console.PrintWarning('PRESS [ESC] to Exit \n')
def addSelection(self,doc,obj,sub,pnt):
if self.filterSub:
if self.filterSub in sub:
self.callerInstance.proceed(doc, obj, sub, pnt)
def removeSelection(self,doc,obj,sub):
App.Console.PrintMessage("removeSelection"+ "\n")
def setSelection(self,doc):
App.Console.PrintMessage("setSelection"+ "\n")
def clearSelection(self,doc):
App.Console.PrintMessage("clearSelection"+ "\n")
def escape(self,info):
down = (info["State"] == "DOWN")
k=info['Key']
if k=="ESCAPE":
FreeCAD.Console.PrintMessage("Escaped \n")
self.av.removeEventCallback("SoKeyboardEvent",self.escape)
FreeCADGui.Selection.removeObserver(self)