12 QMenu.__init__(self, parent)
14 gui.AddMenuAction(self,
'Open', self.
_Open, shortcut=
'Ctrl+O')
15 gui.AddMenuAction(self,
'Save As...', self.
_SaveAs,
16 shortcut=
'Ctrl+Shift+S',
19 filename=QFileDialog.getOpenFileName(
None,
'Open file',
'')
20 if(QFileInfo(filename).isFile()):
21 gui.FileLoader.LoadObject(str(filename))
24 sel_node=gui.SceneSelection.Instance().GetActiveNode(0)
25 filename=QFileDialog.getSaveFileName(
None,
'Save As',
26 '%s.pdb' % sel_node.name)
27 io.SavePDB(sel_node.view, str(filename))
31 QWidget.__init__(self)
32 self.setWindowFlags(Qt.Tool)
34 l.addWidget(QLabel(
"Near"), 0, 0)
35 l.addWidget(QLabel(
"Far"), 1, 0)
36 bounds_near = QLineEdit(str(0))
37 bounds_near.setValidator(QIntValidator(0, 9999, bounds_near))
38 bounds_near.setMaxLength(4)
39 bounds_near.setMaximumWidth(50)
40 bounds_far = QLineEdit(str(200))
41 bounds_far.setValidator(QIntValidator(0, 9999, bounds_far))
42 bounds_far.setMaxLength(4)
43 bounds_far.setMaximumWidth(50)
44 l.addWidget(bounds_near, 0, 1, 2, 1)
45 l.addWidget(bounds_far, 0, 3, 2, 1)
46 self.
near_ = QSlider(Qt.Horizontal)
47 self.near_.setMinimum(int(bounds_near.text()))
48 self.near_.setMaximum(int(bounds_far.text()))
49 self.near_.setValue(int(
gfx.Scene().near))
50 self.
far_ = QSlider(Qt.Horizontal)
51 self.far_.setMinimum(int(bounds_near.text()))
52 self.far_.setMaximum(int(bounds_far.text()))
56 self.far_.setValue(far)
57 self.
auto_ = QCheckBox(
"Continuous Automatic Clipping")
58 self.auto_.setChecked(
gfx.Scene().GetAutoAutoslab())
60 l.addWidget(self.
near_, 0, 2)
61 l.addWidget(self.
far_, 1, 2)
62 l.addWidget(self.
auto_, 2, 0, 1, 4)
63 self.connect(self.
near_, SIGNAL(
'valueChanged(int)'), self.
SetNear)
64 self.connect(self.
far_, SIGNAL(
'valueChanged(int)'), self.
SetFar)
65 self.connect(self.
auto_, SIGNAL(
'stateChanged(int)'), self.
SetAuto)
66 self.connect(bounds_near, SIGNAL(
'textEdited(QString)'), self.
SetNearBounds)
67 self.connect(bounds_far, SIGNAL(
'textEdited(QString)'), self.
SetFarBounds)
77 gfx.Scene().near = int(self.near_.value())
82 self.near_.setMinimum(int(text))
83 self.far_.setMinimum(int(text))
87 self.near_.setMaximum(int(text))
88 self.far_.setMaximum(int(text))
92 QDialog.__init__(self)
94 l.setColumnMinimumWidth(0, 100)
95 l.addWidget(QLabel(
"Width (px)"), 0, 0)
96 l.addWidget(QLabel(
"Height (px)"), 1, 0)
99 self.width_.setValidator(QIntValidator(50, 3000, self.
width_))
100 self.height_.setValidator(QIntValidator(50, 3000, self.
height_))
101 self.
opaque_=QCheckBox(
"Force Opaque Background")
102 l.addWidget(self.
width_, 0, 1)
103 l.addWidget(self.
height_, 1, 1)
104 l.addWidget(self.
opaque_, 2, 1)
106 cancel=QPushButton(
"Cancel")
107 QObject.connect(cancel, SIGNAL(
'clicked()'), self.reject)
108 hbox.addWidget(cancel)
109 export=QPushButton(
"Export")
110 hbox.addWidget(export)
111 export.setDefault(
True)
112 l.addLayout(hbox, 3, 1, 2, 1)
113 QObject.connect(export, SIGNAL(
'clicked()'), self.accept)
116 return not self.opaque_.isChecked()
120 return int(self.width_.text())
124 return int(self.height_.text())
128 QMenu.__init__(self, parent)
129 self.setTitle(
'Scene')
130 QObject.connect(self, SIGNAL(
'aboutToShow()'), self.
_AboutToShow)
133 shortcut=
'Ctrl+Shift+F', checkable=
True,
135 gui.AddMenuAction(self,
'Center', self.
_Center,
137 gui.AddMenuAction(self,
'Fit To Screen', self.
_FitToScreen,
141 gui.AddMenuAction(self,
'Save Snapshot', self.
_ExportScene)
142 gui.AddMenuAction(self,
'Scene Clipping', self.
_ClipScene, shortcut=
'Ctrl+Shift+C')
144 def _ExportScene(self):
148 filename=QFileDialog.getSaveFileName(
None,
'Save Snapshot',
151 gfx.Scene().Export(str(filename), qd.width, qd.height, qd.transparent)
153 def _ClipScene(self):
157 def _AboutToShow(self):
158 self.fog_action.setChecked(
gfx.Scene().fog)
161 sel=gui.SceneSelection.Instance()
162 gfx.Scene().center=sel.GetActiveNode(0).center
164 def _SetSceneBackground(self):
169 def _ToggleFog(self):
171 self.fog_action.setChecked(
gfx.Scene().fog)
173 def _FitToScreen(self):
174 sel=gui.SceneSelection.Instance()
175 gfx.FitToScreen(sel.GetActiveNode(0))
177 def _SuperposeDialog(self):
178 sel=gui.SceneSelection.Instance()
179 act_count=sel.GetActiveNodeCount()
183 gfx_ent_1 = sel.GetActiveNode(i)
186 gfx_ent_1 = sel.GetActiveNode(i)
188 gfx_ent_2 = sel.GetActiveNode(i)
191 gfx_ent_2 = sel.GetActiveNode(i)
194 if sd.reference == 0:
195 gfx_ent_2.UpdatePositions()
198 gfx_ent_1.UpdatePositions()
200 LogScript(
'RMSD: %.3f'%sd.rmsd)
204 QMenu.__init__(self, parent)
205 self.setTitle(
'Window')
206 gosty=gui.GostyApp.Instance()
207 QObject.connect(self, SIGNAL(
'aboutToShow()'), self.
_AboutToShow)
208 inspector_visible=gosty.GetWidget(
'InspectorDialog').isVisible()
211 checked=gosty.gl_win.qobject.isVisible(),
216 checked=inspector_visible,
219 self.addMenu(gosty.perspective.panels.menu)
220 gui.AddMenuAction(self,
'Reset View', self.
_ResetView)
221 def _AboutToShow(self):
222 gosty=gui.GostyApp.Instance()
223 self._gl_win_action.setChecked(gosty.gl_win.qobject.isVisible())
224 inspector_visible=gosty.GetWidget(
'InspectorDialog').isVisible()
225 self._inspector_action.setChecked(inspector_visible)
227 def _ToggleShowGLWindow(self):
228 gosty=gui.GostyApp.Instance()
229 gl_win=gosty.GetGLWin()
230 if gl_win
and gl_win.qobject.isHidden():
235 def _ToggleShowInspector(self):
236 gosty=gui.GostyApp.Instance()
237 inspector=gosty.GetWidget(
'InspectorDialog')
238 if inspector
and inspector.isHidden():
243 def _ResetView(self):
244 msg_box = QMessageBox()
245 msg_box.setWindowTitle(
"Reset the Panels and Widget");
246 msg_box.setIcon(QMessageBox.Question)
247 msg_box.setText(
"Do you really want to reset the Panels and Widgets?");
248 msg_box.setStandardButtons(QMessageBox.Yes |
250 msg_box.setDefaultButton(QMessageBox.Cancel);
251 ret = msg_box.exec_();
252 if(ret == QMessageBox.Yes):
253 settings = QSettings()
254 settings.setValue(
"restore_settings",QVariant(
False))
255 info_box = QMessageBox()
256 info_box.setStandardButtons(QMessageBox.Ok)
257 info_box.setIcon(QMessageBox.Information)
258 info_box.setWindowTitle(
"Restart OpenStructure")
259 info_box.setText(
"You must restart OpenStructure for the changes to take effect!");
264 QMenu.__init__(self, parent)
265 self.setTitle(
'Help')
266 gui.AddMenuAction(self,
'Documentation', self.
_VisitDocs)
268 if sys.platform==
'darwin':
269 gui.AddMenuAction(self,
'Install Command Line Tool',
270 termuse.InstallTerminalPrograms)
271 def _VisitDocs(self):
272 QDesktopServices.openUrl(QUrl(
"http://www.openstructure.org/docs/"))
274 def _ShowAboutDialog(self):
278 _InitMenu.mbar=gui.GostyApp.Instance().perspective.GetMenuBar()
283 _InitMenu.mbar.addMenu(file_menu)
284 _InitMenu.mbar.addMenu(scene_menu)
285 _InitMenu.mbar.addMenu(win_menu)
286 _InitMenu.mbar.addMenu(help_menu)