Repository navigation
Expand file tree
/
Copy pathpycadapp.py
More file actions
119 lines (97 loc) · 3.03 KB
/
Copy pathpycadapp.py
File metadata and controls
119 lines (97 loc) · 3.03 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# Copyright (c) 2010 Matteo Boscolo, Gertwin Groen
#
# This file is part of PythonCAD.
#
# PythonCAD is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PythonCAD 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PythonCAD; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# This module contain global functions
#
# This is only needed for Python v2 but is harmless for Python v3.
#import sip
#sip.setapi('QString', 2)
from PyQt4 import QtGui
class PyCadApp(object):
'''
PyCadApp contain static interface functions to the kernel application object.
'''
# kernel application object
__application = None
# main application window
__cad_window = None
@staticmethod
def CadWindow():
'''
Gets the main window.
The main window is an instance of the CadWindow object.
'''
return PyCadApp.__cad_window
@staticmethod
def SetCadWindow(cad_window):
'''
Sets the main window.
The main window is an instance of the CadWindow object.
'''
PyCadApp.__cad_window = cad_window
@staticmethod
def Application():
'''
Gets the application object from the kernel.
'''
return PyCadApp.__application
@staticmethod
def SetApplication(application):
'''
Sets the application object from the kernel.
'''
PyCadApp.__application = application
@staticmethod
def ActiveDocument():
'''
Gets the current active document in the editor.
'''
if not PyCadApp.__application is None:
return PyCadApp.__application.ActiveDocument
return None
@staticmethod
def CreateNewDocument():
'''
Create a new document.
'''
if not PyCadApp.__application is None:
PyCadApp.__application.newDocument()
return PyCadApp.__application.ActiveDocument
return None
@staticmethod
def OpenDocument(filename):
'''
Open an existing document.
'''
if not PyCadApp.__application is None:
PyCadApp.__application.openDocument(filename)
# return the opened, current active document
return PyCadApp.ActiveDocument()
return None
@staticmethod
def critical(text):
'''
Shows an critical message dialog
'''
dlg = QtGui.QMessageBox()
dlg.setText(text)
dlg.setIcon(QtGui.QMessageBox.Critical)
dlg.exec_()
return