-
Notifications
You must be signed in to change notification settings - Fork 19
/
osdagMainPage.py.bak
348 lines (279 loc) · 12.8 KB
/
osdagMainPage.py.bak
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#!/home/deepa-c/miniconda2/bin/python
'''
Created on 31-Mar-2016
@author: deepa
'''
import sys
from PyQt5 import Qt
from PyQt5.QtCore import pyqtSlot,pyqtSignal, QObject
from PyQt5.QtWidgets import QMainWindow, QDialog,QMessageBox, QFileDialog, QApplication
from ui_OsdagMainPage import Ui_MainWindow
from ui_tutorial import Ui_Tutorial
from ui_aboutosdag import Ui_AboutOsdag
from ui_ask_question import Ui_AskQuestion
from Connections.Shear.Finplate.finPlateMain import launchFinPlateController
import os
from Connections.Shear.SeatedAngle.seat_angle_main import launchSeatedAngleController
from Connections.Shear.cleatAngle.cleatAngleMain import launch_cleatangle_controller
from Connections.Shear.Endplate.endPlateMain import launch_endplate_controller
from Connections.Moment.BBSpliceCoverPlate.BBSpliceCoverPlateBolted.coverplate_bolted_main import launch_coverplate_controller
from Connections.Moment.ExtendedEndPlate.extended_main import launch_extendedendplate_controller
from Connections.Moment.BCEndPlate.bc_endplate_main import launch_bc_endplate_controller
import os.path
import subprocess
import shutil
import ConfigParser
class MyTutorials(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.ui = Ui_Tutorial()
self.ui.setupUi(self)
self.osdagmainwindow = parent
class MyAboutOsdag(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.ui = Ui_AboutOsdag()
self.ui.setupUi(self)
self.osdagmainwindow = parent
class MyAskQuestion(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.ui = Ui_AskQuestion()
self.ui.setupUi(self)
self.osdagmainwindow = parent
class OsdagMainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
#show_msg = pyqtSignal()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.showMaximized()
list_of_items = {'Osdagpage': 0, 'connectionpage': 1, 'beamtobeampage': 2, 'beamtocolumnpage': 3,'compressionpage': 4, 'flexuralpage': 5}
self.ui.myStackedWidget.setCurrentIndex(list_of_items['Osdagpage'])
self.ui.btn_connection.clicked.connect(lambda: self.change_desgin_page(list_of_items['connectionpage'], list_of_items['Osdagpage']))
self.ui.myListWidget.currentItemChanged.connect(self.change_desgin_page)
self.ui.btn_start.clicked.connect(self.show_shear_connection)
self.ui.btn_start_2.clicked.connect(self.show_moment_connection)
self.ui.btn_start_3.clicked.connect(self.show_moment_connection_bc)
self.ui.btn_beamCol.clicked.connect(self.unavailable)
self.ui.btn_compression.clicked.connect(self.unavailable)
self.ui.btn_flexural.clicked.connect(self.unavailable)
self.ui.btn_truss.clicked.connect(self.unavailable)
self.ui.btn_2dframe.clicked.connect(self.unavailable)
self.ui.btn_3dframe.clicked.connect(self.unavailable)
self.ui.btn_groupdesign.clicked.connect(self.unavailable)
self.ui.btn_tension.clicked.connect(self.unavailable)
self.ui.btn_plate.clicked.connect(self.unavailable)
self.ui.comboBox_help.setCurrentIndex(0)
self.ui.comboBox_help.currentIndexChanged.connect(self.selection_change)
#self.ui.rdbtn_beamtobeam.clicked.connect(lambda: self.change_desgin_page(list_of_items['beamtobeampage'], list_of_items['Osdagpage']))
#self.ui.rdbtn_beamcolumn.clicked.connect(lambda: self.change_desgin_page(list_of_items['beamtocolumnpage'], list_of_items['Osdagpage']))
#self.ui.rdbtn_peb.setDisabled(True)
#self.ui.rdbtn_colcol.setDisabled(True)
def selection_change(self):
loc = self.ui.comboBox_help.currentText()
if loc == "Design Examples":
self.design_examples()
elif loc == "Video Tutorials":
self.open_tutorials()
elif loc == "About Osdag":
self.about_osdag()
elif loc == "Ask Us a Question":
self.ask_question()
# elif loc == "FAQ":
# pass
def disable_desgin_buttons(self):
self.ui.btn_beamCol.setEnabled(False)
self.ui.btn_compression.setEnabled(False)
self.ui.btn_connection.setEnabled(False)
self.ui.btn_flexural.setEnabled(False)
self.ui.btn_gantry.setEnabled(False)
self.ui.btn_plate.setEnabled(False)
self.ui.btn_tension.setEnabled(False)
self.ui.btn_help.setEnabled(False)
def enable_desgin_buttons(self):
self.ui.btn_beamCol.setEnabled(True)
self.ui.btn_compression.setEnabled(True)
self.ui.btn_connection.setEnabled(True)
self.ui.btn_flexural.setEnabled(True)
self.ui.btn_gantry.setEnabled(True)
self.ui.btn_plate.setEnabled(True)
self.ui.btn_tension.setEnabled(True)
self.ui.btn_help.setEnabled(True)
def change_desgin_page(self, current, previous):
if not current:
current = previous
self.ui.myStackedWidget.setCurrentIndex(current)
def select_workspace_folder(self):
# This function prompts the user to select the workspace folder and returns the name of the workspace folder
config = ConfigParser.ConfigParser()
config.readfp(open(r'Osdag.config'))
desktop_path = config.get("desktop_path", "path1")
folder = QFileDialog.getExistingDirectory(self, "Select Workspace Folder (Don't use spaces in the folder name)", desktop_path)
# temporarily disabling the below section, as Osdag will still crash while
# generating design report even if there are spaces in the entire path and not
# just spaces in workspace folder name
# while ' ' in folder:
# """
# The workspace folder shouldn't have any spaces
#
# As long as the user enters spaces in the name of the workspace folder,
# this while loops prompts the user not to use spaces and prompts the user again
# to select the workspace folder
#
# """
# QMessageBox.information(self, "Information", "Please do not use spaces in the name of the workspace folder.")
# folder = QFileDialog.getExistingDirectory(self, 'Select Folder for Workspace', desktop_path)
# Return the folder name (without any spaces)
return folder
def show_shear_connection(self):
folder = self.select_workspace_folder()
folder = str(folder)
if not os.path.exists(folder):
if folder == '':
pass
else:
os.mkdir(folder, 0755)
root_path = folder
images_html_folder = ['images_html']
flag = True
for create_folder in images_html_folder:
if root_path == '':
flag = False
return flag
else:
try:
os.mkdir(os.path.join(root_path, create_folder))
except OSError:
shutil.rmtree(os.path.join(folder, create_folder))
os.mkdir(os.path.join(root_path, create_folder))
if self.ui.rdbtn_finplate.isChecked():
launchFinPlateController(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
elif self.ui.rdbtn_cleat.isChecked():
launch_cleatangle_controller(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
elif self.ui.rdbtn_endplate.isChecked():
launch_endplate_controller(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
# QMessageBox.about(self,"INFO","End plate connection design is coming soon!")
elif self.ui.rdbtn_seat.isChecked():
launchSeatedAngleController(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
else:
QMessageBox.about(self, "INFO", "Please select appropriate connection")
def show_moment_connection(self):
folder = self.select_workspace_folder()
folder = str(folder)
if not os.path.exists(folder):
if folder == '':
pass
else:
os.mkdir(folder, 0755)
root_path = folder
images_html_folder = ['images_html']
flag = True
for create_folder in images_html_folder:
if root_path == '':
flag = False
return flag
else:
try:
os.mkdir(os.path.join(root_path, create_folder))
except OSError:
shutil.rmtree(os.path.join(folder, create_folder))
os.mkdir(os.path.join(root_path, create_folder))
if self.ui.rdbtn_coverplate.isChecked():
launch_coverplate_controller(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
elif self.ui.rdbtn_endplate_ext.isChecked():
launch_extendedendplate_controller(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
else:
QMessageBox.about(self, "INFO", "Please select appropriate connection")
def show_moment_connection_bc(self):
folder = self.select_workspace_folder()
folder = str(folder)
if not os.path.exists(folder):
if folder == '':
pass
else:
os.mkdir(folder, 0755)
root_path = folder
images_html_folder = ['images_html']
flag = True
for create_folder in images_html_folder:
if root_path == '':
flag = False
return flag
else:
try:
os.mkdir(os.path.join(root_path, create_folder))
except OSError:
shutil.rmtree(os.path.join(folder, create_folder))
os.mkdir(os.path.join(root_path, create_folder))
if self.ui.rdbtn_endplate_bc.isChecked():
launch_bc_endplate_controller(self, folder)
self.ui.myStackedWidget.setCurrentIndex(0)
else:
QMessageBox.about(self, "INFO", "Please select appropriate connection")
# ********************************* Help Action *********************************************************************************************
def about_osdag(self):
dialog = MyAboutOsdag(self)
dialog.show()
def open_osdag(self):
self.about_osdag()
def tutorials(self):
dialog = MyTutorials(self)
dialog.show()
def open_tutorials(self):
self.tutorials()
def ask_question(self):
dialog = MyAskQuestion(self)
dialog.show()
def open_question(self):
self.ask_question()
def design_examples(self):
root_path = os.path.join(os.path.dirname(__file__), 'ResourceFiles', 'design_example', '_build', 'html')
for html_file in os.listdir(root_path):
if html_file.startswith('index'):
if sys.platform == ("win32" or "win64"):
os.startfile("%s/%s" % (root_path, html_file))
else:
opener ="open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, "%s/%s" % (root_path, html_file)])
def unavailable(self):
QMessageBox.about(self, "INFO", "This module is not available in the current version.")
# Following code maintain for future coding.
# self.ui.btn_beamCol.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# self.ui.btn_compression.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# self.ui.btn_flexural.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# self.ui.btn_gantry.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# self.ui.btn_plate.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# self.ui.btn_tension.clicked.connect(lambda:self.change_desgin_page(list_of_items['Osdagpage'], list_of_items['tensionpage']))
# Back up the reference to the exceptionhook
sys._excepthook = sys.excepthook
def the_exception_hook(exctype, value, traceback):
'''Finds the error occurs when Osdag crashes
Args:
exctype: type of error
value: information of the error
traceback: trace the object
Returns:
system exit(1)
'''
# Print the error and traceback
print "Error occurred: ", (exctype, value, traceback)
# Call the normal Exception hook after
sys.__excepthook__(exctype, value, traceback)
sys.exit(1)
# Set the exception hook to our wrapping function
sys.excepthook = the_exception_hook
if __name__ == '__main__':
app = QApplication(sys.argv)
window = OsdagMainWindow()
window.show()
try:
sys.exit(app.exec_())
except:
print "ERROR"