Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
finesse
pykat
Commits
6a372be9
Commit
6a372be9
authored
Mar 24, 2015
by
Daniel Brown
Browse files
Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat
parents
c54b8571
599e7966
Changes
1
Hide whitespace changes
Inline
Side-by-side
pykat/finesse.py
View file @
6a372be9
...
...
@@ -1571,13 +1571,23 @@ class kat(object):
gui
=
canvas
.
Full
(
scene
=
scene
)
###
add
menu
and menu item
s
###
get
menu
bar from Optivi
s
menubar
=
gui
.
qMainWindow
.
menuBar
()
fileMenu
=
menubar
.
addMenu
(
'&Pykat'
)
### add new Pykat menu and menu items
pykatMenu
=
menubar
.
addMenu
(
'&Pykat'
)
# save
save
=
PyQt4
.
QtGui
.
QAction
(
'Save'
,
gui
.
qMainWindow
)
save
.
setShortcut
(
'Ctrl+S'
)
save
.
triggered
.
connect
(
lambda
:
self
.
_optivis_doSave
(
gui
))
pykatMenu
.
addAction
(
save
)
# trace
trace
=
PyQt4
.
QtGui
.
QAction
(
'Trace'
,
gui
.
qMainWindow
)
trace
.
setShortcut
(
'Ctrl+T'
)
trace
.
triggered
.
connect
(
lambda
:
self
.
_optivis_doTrace
(
gui
))
file
Menu
.
addAction
(
trace
)
pykat
Menu
.
addAction
(
trace
)
return
gui
...
...
@@ -1631,6 +1641,51 @@ class kat(object):
c
.
label_node2
.
content
[
"Zr_y"
]
=
tdata
[
c
.
nodes
[
1
].
name
][
1
].
zr
gui
.
redraw
()
def
_optivis_doSave
(
self
,
gui
,
**
kwargs
):
"""
Save kat script from Optivis
"""
if
not
HAS_OPTIVIS
:
print
(
"Optivis is not installed"
)
return
None
# generate file path
directory
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
'{0}.kat'
.
format
(
gui
.
scene
.
title
))
# desired save path
path
=
None
# get path to file to export to
while
True
:
dialog
=
PyQt4
.
Qt
.
QFileDialog
(
parent
=
gui
.
qMainWindow
,
caption
=
'Save Finesse Script'
,
directory
=
directory
)
dialog
.
setAcceptMode
(
PyQt4
.
Qt
.
QFileDialog
.
AcceptSave
)
dialog
.
setFileMode
(
PyQt4
.
Qt
.
QFileDialog
.
AnyFile
)
# show dialog
dialog
.
exec_
()
if
len
(
dialog
.
selectedFiles
())
is
0
:
# no filename specified
return
# get file path and format
path
=
str
(
dialog
.
selectedFiles
()[
0
])
try
:
# check if we can write to the path
open
(
path
,
'w'
).
close
()
os
.
unlink
(
path
)
# if we get this far, all is good so we can break out the infinite loop
break
except
OSError
:
PyQt4
.
Qt
.
QMessageBox
.
critical
(
gui
.
qMainWindow
,
'Filename invalid'
,
'The specified filename is invalid'
)
except
IOError
:
PyQt4
.
Qt
.
QMessageBox
.
critical
(
gui
.
qMainWindow
,
'Permission denied'
,
'You do not have permission to save the file to the specified location.'
)
# save kat file
self
.
saveScript
(
filename
=
path
)
def
openGUI
(
self
):
if
not
USE_GUI
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment