00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 from ost import gui
00022 from ost import gfx
00023 from datetime import datetime
00024 from datetime import datetime
00025 from PyQt4 import QtCore, QtGui
00026 from color_select_widget import ColorSelectWidget
00027 from gradient_preset_widget import GradientPresetWidget
00028 from gradient_editor_widget import GradientPreview
00029 from gradient_editor_widget import GradientEdit
00030 from preset_editor_list_model import PresetEditorListModel
00031 from immutable_gradient_info_handler import ImmutableGradientInfoHandler
00032 from ost.mol import Prop
00033 from ost.gfx import ByElementColorOp
00034 from ost.gfx import ByChainColorOp
00035 from ost.gfx import GradientLevelColorOp
00036 from ost.gfx import UniformColorOp
00037 from preset import Preset
00038 from render_op import RenderOp
00039 from visibility_op import VisibilityOp
00040
00041
00042 class PresetEditor(QtGui.QDialog):
00043 def __init__(self, parent=None):
00044 QtGui.QDialog.__init__(self, parent)
00045
00046 self.setWindowTitle("Preset Editor")
00047
00048
00049 self.list_view_ = QtGui.QListView()
00050
00051 self.combo_box_ = QtGui.QComboBox()
00052
00053 self.ufcow_=UniformColorOpWidget(self)
00054 self.glcow_=GradientLevelColorOpWidget(self)
00055 self.beow_=ByElementColorOpWidget(self)
00056 self.bcow_=ByChainColorOpWidget(self)
00057 self.row_=RenderOpWidget(self)
00058 self.vow_=VisibilityOpWidget(self)
00059 self.combo_box_.addItem("Uniform Color Operation", QtCore.QVariant(self.ufcow_))
00060 self.combo_box_.addItem("Gradient Operation", QtCore.QVariant(self.glcow_))
00061 self.combo_box_.addItem("By Element Operation", QtCore.QVariant(self.beow_))
00062 self.combo_box_.addItem("By Chain Operation", QtCore.QVariant(self.bcow_))
00063 self.combo_box_.addItem("RenderMode Operation", QtCore.QVariant(self.row_))
00064 self.combo_box_.addItem("Visibility Operation", QtCore.QVariant(self.vow_))
00065
00066 self.add_button_ = QtGui.QPushButton("Add")
00067
00068
00069 self.list_view_.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
00070
00071 self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
00072 QtCore.QObject.connect(self.list_view_, QtCore.SIGNAL("customContextMenuRequested(const QPoint)"), self.contextMenuEvent)
00073
00074 self.hbox_ = QtGui.QHBoxLayout()
00075 self.ok_button_ = QtGui.QPushButton("OK")
00076 self.cancel_button_ = QtGui.QPushButton("Cancel")
00077 self.hbox_.addWidget(self.ok_button_)
00078 self.hbox_.addStretch()
00079 self.hbox_.addWidget(self.cancel_button_)
00080
00081 grid = QtGui.QGridLayout()
00082 grid.setContentsMargins(0,5,0,0)
00083 grid.addWidget(self.combo_box_,0,0,1,1)
00084 grid.addWidget(self.add_button_,0,1,1,1)
00085 grid.addWidget(self.list_view_,1,0,3,3)
00086 grid.addLayout(self.hbox_,5,0,1,3)
00087 grid.setRowStretch(1, 1)
00088 self.setLayout(grid)
00089
00090 QtCore.QObject.connect(self.add_button_, QtCore.SIGNAL("clicked()"), self.Add)
00091 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00092 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00093
00094 self.CreateContextMenu()
00095
00096 def SetPreset(self, preset):
00097 self.list_model_ = PresetEditorListModel(preset, self)
00098 self.list_view_.setModel(self.list_model_)
00099
00100 def CreateContextMenu(self):
00101 self.context_menu_ = QtGui.QMenu("Context menu", self)
00102 self.edit_ = QtGui.QAction("Edit", self.list_view_)
00103 self.remove_ = QtGui.QAction("Remove", self.list_view_)
00104 self.moveup_ = QtGui.QAction("Move Up", self.list_view_)
00105 self.movedown_ = QtGui.QAction("Move Down", self.list_view_)
00106 self.context_menu_.addAction(self.edit_)
00107 self.context_menu_.addAction(self.remove_)
00108 self.context_menu_.addAction(self.moveup_)
00109 self.context_menu_.addAction(self.movedown_)
00110
00111 QtCore.QObject.connect(self.edit_, QtCore.SIGNAL("triggered()"), self.Edit)
00112 QtCore.QObject.connect(self.remove_, QtCore.SIGNAL("triggered()"), self.Remove)
00113 QtCore.QObject.connect(self.moveup_, QtCore.SIGNAL("triggered()"), self.MoveUp)
00114 QtCore.QObject.connect(self.movedown_, QtCore.SIGNAL("triggered()"), self.MoveDown)
00115
00116 def contextMenuEvent(self, pos):
00117
00118 index = self.list_view_.indexAt(pos)
00119 if index.isValid():
00120 self.context_menu_.popup(QtGui.QCursor.pos())
00121
00122 def Add(self):
00123 dialog = self.combo_box_.itemData(self.combo_box_.currentIndex()).toPyObject()
00124 if(dialog.exec_()):
00125 row = self.list_model_.rowCount()
00126 op = dialog.GetOp()
00127 self.list_model_.AddItem(op, row)
00128
00129 def Edit(self):
00130 current_index = self.list_view_.currentIndex()
00131 op = self.list_model_.GetOp(current_index)
00132 if isinstance(op, gfx.UniformColorOp):
00133 self.ufcow_.SetOp(op)
00134 if self.ufcow_.exec_():
00135 self.list_model_.SetItem(current_index, self.ufcow_.GetOp())
00136 elif isinstance(op, gfx.GradientLevelColorOp):
00137 self.glcow_.SetOp(op)
00138 if self.glcow_.exec_():
00139 self.list_model_.SetItem(current_index, self.glcow_.GetOp())
00140 elif isinstance(op, gfx.ByElementColorOp):
00141 self.beow_.SetOp(op)
00142 if self.beow_.exec_():
00143 self.list_model_.SetItem(current_index, self.beow_.GetOp())
00144 elif isinstance(op, gfx.ByChainColorOp):
00145 self.bcow_.SetOp(op)
00146 if self.bcow_.exec_():
00147 self.list_model_.SetItem(current_index, self.bcow_.GetOp())
00148 elif isinstance(op, RenderOp):
00149 self.row_.SetOp(op)
00150 if self.row_.exec_():
00151 self.list_model_.SetItem(current_index, self.row_.GetOp())
00152 elif isinstance(op, VisibilityOp):
00153 self.vow_.SetOp(op)
00154 if self.vow_.exec_():
00155 self.list_model_.SetItem(current_index, self.vow_.GetOp())
00156
00157 def Remove(self):
00158 current_index = self.list_view_.currentIndex()
00159 self.list_model_.RemoveItem(current_index.row())
00160
00161 def MoveDown(self):
00162 current_index = self.list_view_.currentIndex()
00163 if self.list_model_.GetLastRow != current_index.row():
00164 op = self.list_model_.GetOp(current_index)
00165 self.list_model_.RemoveItem(current_index.row())
00166 self.list_model_.AddItem(op, current_index.row()+1)
00167
00168 def MoveUp(self):
00169 current_index = self.list_view_.currentIndex()
00170 if self.list_model_.GetLastRow != 0:
00171 op = self.list_model_.GetOp(current_index)
00172 self.list_model_.RemoveItem(current_index.row())
00173 self.list_model_.AddItem(op, current_index.row()-1)
00174
00175 def Ok(self):
00176 self.accept()
00177
00178 def Cancel(self):
00179 self.reject()
00180
00181 class UniformColorOpWidget(QtGui.QDialog):
00182 def __init__(self, parent=None):
00183 QtGui.QDialog.__init__(self, parent)
00184 selection_label = QtGui.QLabel("Selection")
00185 self.selection_edit_ = QtGui.QLineEdit()
00186
00187 detail_label = QtGui.QLabel("Parts")
00188 self.detail_selection_cb_ = QtGui.QComboBox()
00189 self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3))
00190 self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2))
00191 self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1))
00192
00193 color_label = QtGui.QLabel("Color")
00194 self.color_select_widget_ = ColorSelectWidget(30,30,QtGui.QColor("White"))
00195
00196 self.hbox_ = QtGui.QHBoxLayout()
00197 self.ok_button_ = QtGui.QPushButton("OK")
00198 self.cancel_button_ = QtGui.QPushButton("Cancel")
00199 self.hbox_.addWidget(self.ok_button_)
00200 self.hbox_.addStretch()
00201 self.hbox_.addWidget(self.cancel_button_)
00202
00203
00204 grid = QtGui.QGridLayout()
00205 grid.setContentsMargins(0,5,0,0)
00206 grid.addWidget(selection_label, 0, 0, 1, 1)
00207 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00208 grid.addWidget(detail_label, 1, 0, 1, 1)
00209 grid.addWidget(self.detail_selection_cb_, 1, 1, 1, 1)
00210 grid.addWidget(color_label, 2, 0, 1, 1)
00211 grid.addWidget(self.color_select_widget_, 2, 1, 1, 1)
00212 grid.addLayout(self.hbox_,3,0,1,2)
00213 grid.setRowStretch(2, 1)
00214 self.setLayout(grid)
00215
00216 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00217 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00218
00219 def GetOp(self):
00220 ufco = UniformColorOp("",gfx.Color(1,1,1,1))
00221
00222 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
00223 ufco.SetMask(detail)
00224 qcolor = self.color_select_widget_.GetColor()
00225 color=gfx.Color(qcolor.red()/255.0,qcolor.green()/255.0,qcolor.blue()/255.0,qcolor.alpha()/255.0)
00226 ufco.SetColor(color)
00227 ufco.SetSelection(str(self.selection_edit_.text()))
00228 return ufco
00229
00230 def SetOp(self, ufco):
00231 self.selection_edit_.setText(ufco.GetSelection())
00232 found=False
00233 for i in range(0,self.detail_selection_cb_.count()):
00234 mask = self.detail_selection_cb_.itemData(i).toPyObject()
00235 if mask == ufco.GetMask():
00236 self.detail_selection_cb_.setCurrentIndex(i)
00237 found = True
00238 break
00239 if not found:
00240 self.detail_selection_cb_.setCurrentIndex(0)
00241
00242 color = ufco.GetColor()
00243 qcolor = QtGui.QColor(color.Red()*255, color.Green()*255, color.Blue()*255, color.Alpha()*255)
00244 self.color_select_widget_.SetColor(qcolor)
00245
00246 def Ok(self):
00247 self.accept()
00248
00249 def Cancel(self):
00250 self.reject()
00251
00252 class GradientLevelColorOpWidget(QtGui.QDialog):
00253 def __init__(self, parent=None):
00254 QtGui.QDialog.__init__(self, parent)
00255
00256 selection_label = QtGui.QLabel("Selection")
00257 self.selection_edit_ = QtGui.QLineEdit()
00258
00259 detail_label = QtGui.QLabel("Parts")
00260 self.detail_selection_cb_ = QtGui.QComboBox()
00261 self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3))
00262 self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2))
00263 self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1))
00264
00265 property_label = QtGui.QLabel("Property")
00266 self.property_edit_ = QtGui.QLineEdit()
00267
00268 self.prop_combo_box_ = QtGui.QComboBox()
00269 self.prop_combo_box_.addItem("atom B-factor",QtCore.QVariant("abfac"))
00270 self.prop_combo_box_.addItem("average residue B-factor",QtCore.QVariant("rbfac"))
00271 self.prop_combo_box_.addItem("X-Coordinate",QtCore.QVariant("x"))
00272 self.prop_combo_box_.addItem("Y-Coordinate",QtCore.QVariant("y"))
00273 self.prop_combo_box_.addItem("Z-Coordinate",QtCore.QVariant("z"))
00274 self.prop_combo_box_.addItem("Residue Number",QtCore.QVariant("rnum"))
00275 self.prop_combo_box_.addItem("Atom Charge",QtCore.QVariant("acharge"))
00276 self.prop_combo_box_.addItem("Custom",QtCore.QVariant("custom"))
00277
00278
00279 level_label = QtGui.QLabel("Level")
00280 self.combo_box_ = QtGui.QComboBox(self);
00281 self.combo_box_.addItem("Atom",QtCore.QVariant(Prop.Level.ATOM))
00282 self.combo_box_.addItem("Residue",QtCore.QVariant(Prop.Level.RESIDUE))
00283 self.combo_box_.addItem("Chain",QtCore.QVariant(Prop.Level.CHAIN))
00284 self.combo_box_.addItem("Unspecified",QtCore.QVariant(Prop.Level.UNSPECIFIED))
00285
00286 gradient_label = QtGui.QLabel("Gradient")
00287 self.gradient_preview_ = GradientPreview()
00288 self.gradient_edit_ = GradientEdit(self.gradient_preview_,self)
00289
00290 self.minmax_label_ = QtGui.QLabel("Min Max")
00291 self.auto_calc_ = QtGui.QCheckBox("Auto calculate")
00292 self.auto_calc_.setChecked(True)
00293
00294 self.minv_label_ = QtGui.QLabel("Min Value")
00295 self.maxv_label_ = QtGui.QLabel("Max Value")
00296
00297 self.minv_ = QtGui.QDoubleSpinBox(self)
00298 self.minv_.setDecimals(2)
00299 self.minv_.setMinimum(-9999.99)
00300 self.minv_.setValue(0)
00301 self.maxv_ = QtGui.QDoubleSpinBox(self)
00302 self.maxv_.setDecimals(2)
00303 self.maxv_.setValue(1)
00304 self.maxv_.setMinimum(-9999.99)
00305
00306 self.hbox_ = QtGui.QHBoxLayout()
00307 self.ok_button_ = QtGui.QPushButton("OK")
00308 self.cancel_button_ = QtGui.QPushButton("Cancel")
00309 self.hbox_.addWidget(self.ok_button_)
00310 self.hbox_.addStretch()
00311 self.hbox_.addWidget(self.cancel_button_)
00312
00313
00314 grid = QtGui.QGridLayout()
00315 grid.setContentsMargins(0,5,0,0)
00316 grid.addWidget(selection_label, 0, 0, 1, 1)
00317 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00318 grid.addWidget(detail_label, 1, 0, 1, 1)
00319 grid.addWidget(self.detail_selection_cb_, 1, 1, 1, 1)
00320 grid.addWidget(property_label, 2, 0, 1, 1)
00321 grid.addWidget(self.prop_combo_box_, 2, 1, 1, 1)
00322 grid.addWidget(self.property_edit_, 3, 1, 1, 1)
00323 grid.addWidget(level_label, 4, 0, 1, 1)
00324 grid.addWidget(self.combo_box_, 4, 1, 1, 1)
00325 grid.addWidget(gradient_label, 5, 0, 1, 1)
00326 grid.addWidget(self.gradient_preview_, 5, 1, 1, 1)
00327 grid.addWidget(self.gradient_edit_, 6, 1, 1, 1)
00328 grid.addWidget(self.gradient_edit_, 6, 1, 1, 1)
00329 grid.addWidget(self.minmax_label_,7,0,1,1)
00330 grid.addWidget(self.auto_calc_,7,1,1,1)
00331 grid.addWidget(self.minv_label_,8,0,1,1)
00332 grid.addWidget(self.minv_,8,1,1,1)
00333 grid.addWidget(self.maxv_label_,9,0,1,1)
00334 grid.addWidget(self.maxv_,9,1,1,1)
00335 grid.addLayout(self.hbox_,10,0,1,2)
00336 grid.setRowStretch(1, 1)
00337 self.setLayout(grid)
00338
00339 QtCore.QObject.connect(self.prop_combo_box_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateGui)
00340 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00341 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00342 QtCore.QObject.connect(self.auto_calc_, QtCore.SIGNAL("stateChanged (int)"), self.UpdateGui)
00343
00344 self.UpdateGui()
00345
00346 def GetOp(self):
00347 gradient = self.gradient_edit_.GetGfxGradient()
00348
00349 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
00350 selection = str(self.selection_edit_.text())
00351 prop = str()
00352 level = Prop.Level()
00353 if(self.property_edit_.isEnabled()):
00354 prop = str(self.property_edit_.text())
00355 level = Prop.Level(self.combo_box_.itemData(self.combo_box_.currentIndex()).toPyObject())
00356 else:
00357 prop = str(self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex()).toPyObject())
00358
00359 if(self.auto_calc_.isChecked()):
00360 return GradientLevelColorOp(selection, detail, prop, gradient, level)
00361 else:
00362 minv = self.minv_.value()
00363 maxv = self.maxv_.value()
00364 return GradientLevelColorOp(selection, detail, prop, gradient, minv, maxv, level)
00365
00366
00367 def SetOp(self, glco):
00368 self.selection_edit_.setText(glco.GetSelection())
00369 found=False
00370 for i in range(0,self.detail_selection_cb_.count()):
00371 mask = self.detail_selection_cb_.itemData(i).toPyObject()
00372 if mask == glco.GetMask():
00373 self.detail_selection_cb_.setCurrentIndex(i)
00374 found = True
00375 break
00376 if not found:
00377 self.detail_selection_cb_.setCurrentIndex(0)
00378
00379 found = False
00380 for i in range(0,self.prop_combo_box_.count()):
00381 prop = str(self.prop_combo_box_.itemData(i).toPyObject())
00382 if prop == glco.GetProperty():
00383 self.prop_combo_box_.setCurrentIndex(i)
00384 found = True
00385 if not found:
00386 self.prop_combo_box_.setCurrentIndex(self.prop_combo_box_.count()-1)
00387 self.property_edit_.setText(glco.GetProperty())
00388
00389 self.combo_box_.setCurrentIndex(glco.GetLevel())
00390 self.gradient_edit_.LoadGradient(ImmutableGradientInfoHandler.ConvertToQGradient(glco.GetGradient()))
00391 self.auto_calc_.setChecked(glco.GetCalculateMinMax());
00392 if(not glco.GetCalculateMinMax()):
00393 self.minv_.setValue(glco.GetMinV())
00394 self.maxv_.setValue(glco.GetMaxV())
00395 self.UpdateGui()
00396
00397 def UpdateGui(self):
00398 prop = self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex()).toPyObject()
00399 if(prop == "custom"):
00400 self.combo_box_.setEnabled(True)
00401 self.property_edit_.setEnabled(True)
00402 else:
00403 self.combo_box_.setEnabled(False)
00404 self.property_edit_.setEnabled(False)
00405
00406 if(self.auto_calc_.isChecked()):
00407 self.minv_.setEnabled(False)
00408 self.maxv_.setEnabled(False)
00409 else:
00410 self.minv_.setEnabled(True)
00411 self.maxv_.setEnabled(True)
00412
00413 def Ok(self):
00414 self.accept()
00415
00416 def Cancel(self):
00417 self.reject()
00418
00419 def Update(self):
00420 pass
00421
00422 class ByElementColorOpWidget(QtGui.QDialog):
00423 def __init__(self, parent=None):
00424 QtGui.QDialog.__init__(self, parent)
00425 selection_label = QtGui.QLabel("Selection")
00426 self.selection_edit_ = QtGui.QLineEdit()
00427
00428 detail_label = QtGui.QLabel("Parts")
00429 self.detail_selection_cb_ = QtGui.QComboBox()
00430 self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3))
00431 self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2))
00432 self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1))
00433
00434 self.hbox_ = QtGui.QHBoxLayout()
00435 self.ok_button_ = QtGui.QPushButton("OK")
00436 self.cancel_button_ = QtGui.QPushButton("Cancel")
00437 self.hbox_.addWidget(self.ok_button_)
00438 self.hbox_.addStretch()
00439 self.hbox_.addWidget(self.cancel_button_)
00440
00441 grid = QtGui.QGridLayout()
00442 grid.setContentsMargins(0,5,0,0)
00443 grid.addWidget(selection_label, 0, 0, 1, 1)
00444 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00445 grid.addWidget(detail_label, 1, 0, 1, 1)
00446 grid.addWidget(self.detail_selection_cb_, 1, 1, 1, 1)
00447 grid.addLayout(self.hbox_,2,0,1,2)
00448 grid.setRowStretch(1, 1)
00449 self.setLayout(grid)
00450
00451 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00452 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00453
00454 def GetOp(self):
00455 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
00456 selection = str(self.selection_edit_.text())
00457 beco = ByElementColorOp(selection, detail)
00458 return beco
00459
00460 def SetOp(self, beco):
00461 self.selection_edit_.setText(beco.GetSelection())
00462 found=False
00463 for i in range(0,self.detail_selection_cb_.count()):
00464 mask = self.detail_selection_cb_.itemData(i).toPyObject()
00465 if mask == beco.GetMask():
00466 self.detail_selection_cb_.setCurrentIndex(i)
00467 found = True
00468 break
00469 if not found:
00470 self.detail_selection_cb_.setCurrentIndex(0)
00471
00472 def Ok(self):
00473 self.accept()
00474
00475 def Cancel(self):
00476 self.reject()
00477
00478
00479 class ByChainColorOpWidget(QtGui.QDialog):
00480 def __init__(self, parent=None):
00481 QtGui.QDialog.__init__(self, parent)
00482 selection_label = QtGui.QLabel("Selection")
00483 self.selection_edit_ = QtGui.QLineEdit()
00484
00485 detail_label = QtGui.QLabel("Parts")
00486 self.detail_selection_cb_ = QtGui.QComboBox()
00487 self.detail_selection_cb_.addItem("Main and Detail",QtCore.QVariant(3))
00488 self.detail_selection_cb_.addItem("Main",QtCore.QVariant(2))
00489 self.detail_selection_cb_.addItem("Detail",QtCore.QVariant(1))
00490
00491 self.hbox_ = QtGui.QHBoxLayout()
00492 self.ok_button_ = QtGui.QPushButton("OK")
00493 self.cancel_button_ = QtGui.QPushButton("Cancel")
00494 self.hbox_.addWidget(self.ok_button_)
00495 self.hbox_.addStretch()
00496 self.hbox_.addWidget(self.cancel_button_)
00497
00498 grid = QtGui.QGridLayout()
00499 grid.setContentsMargins(0,5,0,0)
00500 grid.addWidget(selection_label, 0, 0, 1, 1)
00501 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00502 grid.addWidget(detail_label, 1, 0, 1, 1)
00503 grid.addWidget(self.detail_selection_cb_, 1, 1, 1, 1)
00504 grid.addLayout(self.hbox_,2,0,1,2)
00505 grid.setRowStretch(1, 1)
00506 self.setLayout(grid)
00507
00508 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00509 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00510
00511 def GetOp(self):
00512 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
00513 selection = str(self.selection_edit_.text())
00514 bcco = ByChainColorOp(selection, detail)
00515 return bcco
00516
00517 def SetOp(self, bcco):
00518 self.selection_edit_.setText(bcco.GetSelection())
00519 found=False
00520 for i in range(0,self.detail_selection_cb_.count()):
00521 mask = self.detail_selection_cb_.itemData(i).toPyObject()
00522 if mask == bcco.GetMask():
00523 self.detail_selection_cb_.setCurrentIndex(i)
00524 found = True
00525 break
00526 if not found:
00527 self.detail_selection_cb_.setCurrentIndex(0)
00528
00529 def Ok(self):
00530 self.accept()
00531
00532 def Cancel(self):
00533 self.reject()
00534
00535
00536 class RenderOpWidget(QtGui.QDialog):
00537 def __init__(self, parent=None):
00538 QtGui.QDialog.__init__(self, parent)
00539 selection_label = QtGui.QLabel("Selection")
00540 self.selection_edit_ = QtGui.QLineEdit()
00541
00542 self.keep_ = QtGui.QCheckBox("Keep")
00543 self.keep_.setChecked(False)
00544
00545 render_label = QtGui.QLabel("Rendermode")
00546 self.render_modes_ = QtGui.QComboBox()
00547 self.render_modes_.addItem("Fast Bonds")
00548 self.render_modes_.addItem("Ball & Stick")
00549 self.render_modes_.addItem("Spheres")
00550 self.render_modes_.addItem("Fast Trace")
00551 self.render_modes_.addItem("Trace")
00552 self.render_modes_.addItem("Fast Spline")
00553 self.render_modes_.addItem("Smooth Tube")
00554 self.render_modes_.addItem("Helix & Strand Cartoon")
00555
00556 self.render_modes_list_ = [gfx.RenderMode.SIMPLE,
00557 gfx.RenderMode.CUSTOM,
00558 gfx.RenderMode.CPK,
00559 gfx.RenderMode.LINE_TRACE,
00560 gfx.RenderMode.TRACE,
00561 gfx.RenderMode.SLINE,
00562 gfx.RenderMode.TUBE,
00563 gfx.RenderMode.HSC]
00564
00565 self.hbox_ = QtGui.QHBoxLayout()
00566 self.ok_button_ = QtGui.QPushButton("OK")
00567 self.cancel_button_ = QtGui.QPushButton("Cancel")
00568 self.hbox_.addWidget(self.ok_button_)
00569 self.hbox_.addStretch()
00570 self.hbox_.addWidget(self.cancel_button_)
00571
00572 grid = QtGui.QGridLayout()
00573 grid.setContentsMargins(0,5,0,0)
00574 grid.addWidget(selection_label, 0, 0, 1, 1)
00575 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00576 grid.addWidget(self.keep_, 1, 1, 1, 1)
00577 grid.addWidget(render_label,2,0,1,1)
00578 grid.addWidget(self.render_modes_,2,1,1,1)
00579 grid.addLayout(self.hbox_,3,0,1,2)
00580 grid.setRowStretch(1, 1)
00581 self.setLayout(grid)
00582
00583 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00584 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00585
00586 def GetOp(self):
00587 selection = str(self.selection_edit_.text())
00588 render_mode = self.render_modes_list_[self.render_modes_.currentIndex()]
00589 ro = RenderOp(render_mode, selection, self.keep_.isChecked())
00590 return ro
00591
00592 def SetOp(self, ro):
00593 self.selection_edit_.setText(ro.GetSelection())
00594 found=False
00595 for i in range(0,self.render_modes_.count()):
00596 render_mode = self.render_modes_list_[i]
00597 if render_mode == ro.GetRenderMode():
00598 self.render_modes_.setCurrentIndex(i)
00599 found = True
00600 break
00601 if not found:
00602 self.render_modes_.setCurrentIndex(0)
00603 self.keep_.setChecked(ro.IsKept())
00604
00605 def Ok(self):
00606 self.accept()
00607
00608 def Cancel(self):
00609 self.reject()
00610
00611 class VisibilityOpWidget(QtGui.QDialog):
00612 def __init__(self, parent=None):
00613 QtGui.QDialog.__init__(self, parent)
00614 selection_label = QtGui.QLabel("Selection")
00615 self.selection_edit_ = QtGui.QLineEdit()
00616
00617 self.visible_ = QtGui.QCheckBox("Visible")
00618 self.visible_.setChecked(True)
00619
00620 self.hbox_ = QtGui.QHBoxLayout()
00621 self.ok_button_ = QtGui.QPushButton("OK")
00622 self.cancel_button_ = QtGui.QPushButton("Cancel")
00623 self.hbox_.addWidget(self.ok_button_)
00624 self.hbox_.addStretch()
00625 self.hbox_.addWidget(self.cancel_button_)
00626
00627 grid = QtGui.QGridLayout()
00628 grid.setContentsMargins(0,5,0,0)
00629 grid.addWidget(selection_label, 0, 0, 1, 1)
00630 grid.addWidget(self.selection_edit_, 0, 1, 1, 1)
00631 grid.addWidget(self.visible_, 1, 1, 1, 1)
00632 grid.addLayout(self.hbox_,2,0,1,2)
00633 grid.setRowStretch(1, 1)
00634 self.setLayout(grid)
00635
00636 QtCore.QObject.connect(self.ok_button_, QtCore.SIGNAL("clicked()"), self.Ok)
00637 QtCore.QObject.connect(self.cancel_button_, QtCore.SIGNAL("clicked()"), self.Cancel)
00638
00639 def GetOp(self):
00640 selection = str(self.selection_edit_.text())
00641 vo = VisibilityOp(selection, self.visible_.isChecked())
00642 return vo
00643
00644 def SetOp(self, ro):
00645 self.selection_edit_.setText(ro.GetSelection())
00646 self.visible_.setChecked(ro.IsVisible())
00647
00648 def Ok(self):
00649 self.accept()
00650
00651 def Cancel(self):
00652 self.reject()