13 QMenu.__init__(self, parent)
15 gui.AddMenuAction(self,
'Open', self.
_Open, shortcut=
'Ctrl+O')
16 gui.AddMenuAction(self,
'Save As...', self.
_SaveAs,
17 shortcut=
'Ctrl+Shift+S',
20 filename,_=QFileDialog.getOpenFileName(
None,
'Open file',
'')
21 if(QFileInfo(filename).isFile()):
22 gui.FileLoader.LoadObject(str(filename))
25 sel_node=gui.SceneSelection.Instance().GetActiveNode(0)
26 filename=QFileDialog.getSaveFileName(
None,
'Save As',
27 '%s.pdb' % sel_node.name)
28 io.SavePDB(sel_node.view, str(filename))
32 QWidget.__init__(self)
33 self.setWindowFlags(Qt.Tool)
35 l.addWidget(QLabel(
"Near"), 0, 0)
36 l.addWidget(QLabel(
"Far"), 1, 0)
37 bounds_near = QLineEdit(str(0))
38 bounds_near.setValidator(QIntValidator(0, 9999, bounds_near))
39 bounds_near.setMaxLength(4)
40 bounds_near.setMaximumWidth(50)
41 bounds_far = QLineEdit(str(200))
42 bounds_far.setValidator(QIntValidator(0, 9999, bounds_far))
43 bounds_far.setMaxLength(4)
44 bounds_far.setMaximumWidth(50)
45 l.addWidget(bounds_near, 0, 1, 2, 1)
46 l.addWidget(bounds_far, 0, 3, 2, 1)
47 self.
near_ = QSlider(Qt.Horizontal)
48 self.near_.setMinimum(int(bounds_near.text()))
49 self.near_.setMaximum(int(bounds_far.text()))
50 self.near_.setValue(int(
gfx.Scene().near))
51 self.
far_ = QSlider(Qt.Horizontal)
52 self.far_.setMinimum(int(bounds_near.text()))
53 self.far_.setMaximum(int(bounds_far.text()))
57 self.far_.setValue(far)
58 self.
auto_ = QCheckBox(
"Continuous Automatic Clipping")
59 self.auto_.setChecked(
gfx.Scene().GetAutoAutoslab())
61 l.addWidget(self.
near_, 0, 2)
62 l.addWidget(self.
far_, 1, 2)
63 l.addWidget(self.
auto_, 2, 0, 1, 4)
64 self.near_.valueChanged.connect(self.
SetNear)
65 self.far_.valueChanged.connect(self.
SetFar)
66 self.auto_.stateChanged.connect(self.
SetAuto)
78 gfx.Scene().near = int(self.near_.value())
83 self.near_.setMinimum(int(text))
84 self.far_.setMinimum(int(text))
88 self.near_.setMaximum(int(text))
89 self.far_.setMaximum(int(text))
93 QDialog.__init__(self)
95 l.setColumnMinimumWidth(0, 100)
96 l.addWidget(QLabel(
"Width (px)"), 0, 0)
97 l.addWidget(QLabel(
"Height (px)"), 1, 0)
100 self.width_.setValidator(QIntValidator(50, 3000, self.
width_))
101 self.height_.setValidator(QIntValidator(50, 3000, self.
height_))
102 self.
opaque_=QCheckBox(
"Force Opaque Background")
103 l.addWidget(self.
width_, 0, 1)
104 l.addWidget(self.
height_, 1, 1)
105 l.addWidget(self.
opaque_, 2, 1)
107 cancel=QPushButton(
"Cancel")
108 cancel.clicked.connect(self.reject)
109 hbox.addWidget(cancel)
110 export=QPushButton(
"Export")
111 hbox.addWidget(export)
112 export.setDefault(
True)
113 l.addLayout(hbox, 3, 1, 2, 1)
114 export.clicked.connect(self.accept)
117 return not self.opaque_.isChecked()
121 return int(self.width_.text())
125 return int(self.height_.text())
129 QMenu.__init__(self, parent)
130 self.setTitle(
'Scene')
134 shortcut=
'Ctrl+Shift+F', checkable=
True,
136 gui.AddMenuAction(self,
'Center', self.
_Center,
138 gui.AddMenuAction(self,
'Fit To Screen', self.
_FitToScreen,
142 gui.AddMenuAction(self,
'Save Snapshot', self.
_ExportScene)
143 gui.AddMenuAction(self,
'Scene Clipping', self.
_ClipScene, shortcut=
'Ctrl+Shift+C')
145 def _ExportScene(self):
150 options = QFileDialog.Options()
151 options |= QFileDialog.DontUseNativeDialog
152 filename, _ = QFileDialog.getSaveFileName(self,
"Save Snapshot",
"snapshot.png",
"", options=options)
155 gfx.Scene().Export(str(filename), qd.width, qd.height, qd.transparent)
157 def _ClipScene(self):
161 def _AboutToShow(self):
162 self.fog_action.setChecked(
gfx.Scene().fog)
165 sel=gui.SceneSelection.Instance()
166 gfx.Scene().center=sel.GetActiveNode(0).center
168 def _SetSceneBackground(self):
173 def _ToggleFog(self):
175 self.fog_action.setChecked(
gfx.Scene().fog)
177 def _FitToScreen(self):
178 sel=gui.SceneSelection.Instance()
179 gfx.FitToScreen(sel.GetActiveNode(0))
181 def _SuperposeDialog(self):
182 sel=gui.SceneSelection.Instance()
183 act_count=sel.GetActiveNodeCount()
187 gfx_ent_1 = sel.GetActiveNode(i)
190 gfx_ent_1 = sel.GetActiveNode(i)
192 gfx_ent_2 = sel.GetActiveNode(i)
195 gfx_ent_2 = sel.GetActiveNode(i)
197 if sd.rmsd_superposed_atoms !=
None:
198 if sd.reference == 0:
199 gfx_ent_2.UpdatePositions()
202 gfx_ent_1.UpdatePositions()
204 LogScript(
'RMSD: %.3f'%sd.rmsd)
205 LogScript(
'RMSD superposed atoms: %.3f'%sd.rmsd_superposed_atoms)
206 LogScript(
'fraction superposed: %.3f'%sd.fraction_superposed)
207 elif sd.rmsd !=
None:
208 if sd.reference == 0:
209 gfx_ent_2.UpdatePositions()
212 gfx_ent_1.UpdatePositions()
214 LogScript(
'RMSD: %.3f'%sd.rmsd)
218 QMenu.__init__(self, parent)
219 self.setTitle(
'Window')
220 gosty=gui.GostyApp.Instance()
222 inspector_visible=gosty.GetWidget(
'InspectorDialog').isVisible()
225 checked=gosty.gl_win.qobject.isVisible(),
230 checked=inspector_visible,
233 self.addMenu(gosty.perspective.panels.menu)
234 gui.AddMenuAction(self,
'Reset View', self.
_ResetView)
235 def _AboutToShow(self):
236 gosty=gui.GostyApp.Instance()
237 self._gl_win_action.setChecked(gosty.gl_win.qobject.isVisible())
238 inspector_visible=gosty.GetWidget(
'InspectorDialog').isVisible()
239 self._inspector_action.setChecked(inspector_visible)
241 def _ToggleShowGLWindow(self):
242 gosty=gui.GostyApp.Instance()
243 gl_win=gosty.GetGLWin()
244 if gl_win
and gl_win.qobject.isHidden():
249 def _ToggleShowInspector(self):
250 gosty=gui.GostyApp.Instance()
251 inspector=gosty.GetWidget(
'InspectorDialog')
252 if inspector
and inspector.isHidden():
257 def _ResetView(self):
258 msg_box = QMessageBox()
259 msg_box.setWindowTitle(
"Reset the Panels and Widget");
260 msg_box.setIcon(QMessageBox.Question)
261 msg_box.setText(
"Do you really want to reset the Panels and Widgets?");
262 msg_box.setStandardButtons(QMessageBox.Yes |
264 msg_box.setDefaultButton(QMessageBox.Cancel);
265 ret = msg_box.exec_();
266 if(ret == QMessageBox.Yes):
267 settings = QSettings()
268 settings.setValue(
"restore_settings",QVariant(
False))
269 info_box = QMessageBox()
270 info_box.setStandardButtons(QMessageBox.Ok)
271 info_box.setIcon(QMessageBox.Information)
272 info_box.setWindowTitle(
"Restart OpenStructure")
273 info_box.setText(
"You must restart OpenStructure for the changes to take effect!");
278 QMenu.__init__(self, parent)
279 self.setTitle(
'Help')
280 gui.AddMenuAction(self,
'Documentation', self.
_VisitDocs)
282 if sys.platform==
'darwin':
283 gui.AddMenuAction(self,
'Install Command Line Tool',
284 termuse.InstallTerminalPrograms)
285 def _VisitDocs(self):
286 QDesktopServices.openUrl(QUrl(
"http://www.openstructure.org/docs/"))
288 def _ShowAboutDialog(self):
292 _InitMenu.mbar=gui.GostyApp.Instance().perspective.GetMenuBar()
297 _InitMenu.mbar.addMenu(file_menu)
298 _InitMenu.mbar.addMenu(scene_menu)
299 _InitMenu.mbar.addMenu(win_menu)
300 _InitMenu.mbar.addMenu(help_menu)
main class for organization and root for the graphical display
main class for all graphic objects
graphical rendering of mol::EntityHandle entites