24 from datetime
import datetime
25 from datetime
import datetime
26 from PyQt5
import QtCore, QtWidgets, QtGui
27 from .color_select_widget
import ColorSelectWidget
28 from .gradient_preset_widget
import GradientPresetWidget
29 from .gradient_editor_widget
import GradientPreview
30 from .gradient_editor_widget
import GradientEdit
31 from .preset_editor_list_model
import PresetEditorListModel
32 from .immutable_gradient_info_handler
import ImmutableGradientInfoHandler
33 from .query_editor
import QueryEditorWidget
35 from ost.gfx import ByElementColorOp
36 from ost.gfx import ByChainColorOp
37 from ost.gfx import GradientLevelColorOp
38 from ost.gfx import UniformColorOp
39 from .preset
import Preset
40 from .render_op
import RenderOp
41 from .visibility_op
import VisibilityOp
46 QtWidgets.QDialog.__init__(self, parent)
48 self.setWindowTitle(
"Preset Editor")
61 self.combo_box_.addItem(
"Uniform Color Operation", QtCore.QVariant(self.
ufcow_))
62 self.combo_box_.addItem(
"Gradient Operation", QtCore.QVariant(self.
glcow_))
63 self.combo_box_.addItem(
"By Element Operation", QtCore.QVariant(self.
beow_))
64 self.combo_box_.addItem(
"By Chain Operation", QtCore.QVariant(self.
bcow_))
65 self.combo_box_.addItem(
"RenderMode Operation", QtCore.QVariant(self.
row_))
66 self.combo_box_.addItem(
"Visibility Operation", QtCore.QVariant(self.
vow_))
71 self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
73 self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
76 self.
hbox_ = QtWidgets.QHBoxLayout()
80 self.hbox_.addStretch()
83 grid = QtWidgets.QGridLayout()
84 grid.setContentsMargins(0,5,0,0)
88 grid.addLayout(self.
hbox_,5,0,1,3)
89 grid.setRowStretch(1, 1)
92 self.add_button_.clicked.connect(self.
Add)
93 self.ok_button_.clicked.connect(self.
Ok)
94 self.cancel_button_.clicked.connect(self.
Cancel)
108 self.context_menu_.addAction(self.
edit_)
109 self.context_menu_.addAction(self.
remove_)
110 self.context_menu_.addAction(self.
moveup_)
111 self.context_menu_.addAction(self.
movedown_)
113 self.edit_.triggered.connect(self.
Edit)
114 self.remove_.triggered.connect(self.
Remove)
115 self.moveup_.triggered.connect(self.
MoveUp)
116 self.movedown_.triggered.connect(self.
MoveDown)
120 index = self.list_view_.indexAt(pos)
122 self.context_menu_.popup(QtWidgets.QCursor.pos())
125 dialog = self.combo_box_.itemData(self.combo_box_.currentIndex()).toPyObject()
127 row = self.list_model_.rowCount()
129 self.list_model_.AddItem(op, row)
132 current_index = self.list_view_.currentIndex()
133 op = self.list_model_.GetOp(current_index)
135 self.ufcow_.SetOp(op)
136 if self.ufcow_.exec_():
137 self.list_model_.SetItem(current_index, self.ufcow_.GetOp())
139 self.glcow_.SetOp(op)
140 if self.glcow_.exec_():
141 self.list_model_.SetItem(current_index, self.glcow_.GetOp())
144 if self.beow_.exec_():
145 self.list_model_.SetItem(current_index, self.beow_.GetOp())
148 if self.bcow_.exec_():
149 self.list_model_.SetItem(current_index, self.bcow_.GetOp())
150 elif isinstance(op, RenderOp):
152 if self.row_.exec_():
153 self.list_model_.SetItem(current_index, self.row_.GetOp())
154 elif isinstance(op, VisibilityOp):
156 if self.vow_.exec_():
157 self.list_model_.SetItem(current_index, self.vow_.GetOp())
160 current_index = self.list_view_.currentIndex()
161 self.list_model_.RemoveItem(current_index.row())
164 current_index = self.list_view_.currentIndex()
165 if self.list_model_.GetLastRow != current_index.row():
166 op = self.list_model_.GetOp(current_index)
167 self.list_model_.RemoveItem(current_index.row())
168 self.list_model_.AddItem(op, current_index.row()+1)
171 current_index = self.list_view_.currentIndex()
172 if self.list_model_.GetLastRow != 0:
173 op = self.list_model_.GetOp(current_index)
174 self.list_model_.RemoveItem(current_index.row())
175 self.list_model_.AddItem(op, current_index.row()-1)
185 QtWidgets.QDialog.__init__(self, parent)
188 detail_label = QtWidgets.QLabel(
"Parts")
190 self.detail_selection_cb_.addItem(
"Main and Detail",QtCore.QVariant(3))
191 self.detail_selection_cb_.addItem(
"Main",QtCore.QVariant(2))
192 self.detail_selection_cb_.addItem(
"Detail",QtCore.QVariant(1))
194 color_label = QtWidgets.QLabel(
"Color")
197 self.
hbox_ = QtWidgets.QHBoxLayout()
201 self.hbox_.addStretch()
205 grid = QtWidgets.QGridLayout()
206 grid.setContentsMargins(0,5,0,0)
208 grid.addWidget(detail_label, 1, 0, 1, 1)
210 grid.addWidget(color_label, 2, 0, 1, 1)
212 grid.addLayout(self.
hbox_,3,0,1,2)
213 grid.setRowStretch(2, 1)
216 self.ok_button_.clicked.connect(self.
Ok)
217 self.cancel_button_.clicked.connect(self.
Cancel)
223 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
225 qcolor = self.color_select_widget_.GetColor()
226 color=gfx.RGBAb(qcolor.red(),qcolor.green(),qcolor.blue(),qcolor.alpha())
231 self.query_editor_.SetQuery(ufco.GetSelection())
232 self.query_editor_.SetQueryFlags(ufco.GetSelectionFlags())
234 for i
in range(0,self.detail_selection_cb_.count()):
235 mask = self.detail_selection_cb_.itemData(i).toPyObject()
236 if mask == ufco.GetMask():
237 self.detail_selection_cb_.setCurrentIndex(i)
241 self.detail_selection_cb_.setCurrentIndex(0)
243 color = ufco.GetColor()
244 qcolor = QtGui.QColor(color.Red()*255, color.Green()*255, color.Blue()*255, color.Alpha()*255)
245 self.color_select_widget_.SetColor(qcolor)
255 QtWidgets.QDialog.__init__(self, parent)
259 detail_label = QtWidgets.QLabel(
"Parts")
261 self.detail_selection_cb_.addItem(
"Main and Detail",QtCore.QVariant(3))
262 self.detail_selection_cb_.addItem(
"Main",QtCore.QVariant(2))
263 self.detail_selection_cb_.addItem(
"Detail",QtCore.QVariant(1))
265 property_label = QtWidgets.QLabel(
"Property")
269 self.prop_combo_box_.addItem(
"atom B-factor",QtCore.QVariant(
"abfac"))
270 self.prop_combo_box_.addItem(
"average residue B-factor",QtCore.QVariant(
"rbfac"))
271 self.prop_combo_box_.addItem(
"X-Coordinate",QtCore.QVariant(
"x"))
272 self.prop_combo_box_.addItem(
"Y-Coordinate",QtCore.QVariant(
"y"))
273 self.prop_combo_box_.addItem(
"Z-Coordinate",QtCore.QVariant(
"z"))
274 self.prop_combo_box_.addItem(
"Residue Number",QtCore.QVariant(
"rnum"))
275 self.prop_combo_box_.addItem(
"Atom Charge",QtCore.QVariant(
"acharge"))
276 self.prop_combo_box_.addItem(
"Custom",QtCore.QVariant(
"custom"))
279 level_label = QtWidgets.QLabel(
"Level")
281 self.combo_box_.addItem(
"Atom",QtCore.QVariant(Prop.Level.ATOM))
282 self.combo_box_.addItem(
"Residue",QtCore.QVariant(Prop.Level.RESIDUE))
283 self.combo_box_.addItem(
"Chain",QtCore.QVariant(Prop.Level.CHAIN))
284 self.combo_box_.addItem(
"Unspecified",QtCore.QVariant(Prop.Level.UNSPECIFIED))
286 gradient_label = QtWidgets.QLabel(
"Gradient")
292 self.auto_calc_.setChecked(
True)
297 self.
minv_ = QtWidgets.QDoubleSpinBox(self)
298 self.minv_.setDecimals(2)
299 self.minv_.setMinimum(-9999.99)
300 self.minv_.setValue(0)
301 self.
maxv_ = QtWidgets.QDoubleSpinBox(self)
302 self.maxv_.setDecimals(2)
303 self.maxv_.setValue(1)
304 self.maxv_.setMinimum(-9999.99)
306 self.
hbox_ = QtWidgets.QHBoxLayout()
310 self.hbox_.addStretch()
314 grid = QtWidgets.QGridLayout()
315 grid.setContentsMargins(0,5,0,0)
317 grid.addWidget(detail_label, 1, 0, 1, 1)
319 grid.addWidget(property_label, 2, 0, 1, 1)
322 grid.addWidget(level_label, 4, 0, 1, 1)
324 grid.addWidget(gradient_label, 5, 0, 1, 1)
331 grid.addWidget(self.
minv_,8,1,1,1)
333 grid.addWidget(self.
maxv_,9,1,1,1)
334 grid.addLayout(self.
hbox_,10,0,1,2)
335 grid.setRowStretch(1, 1)
338 self.prop_combo_box_.currentIndexChanged.connect(self.
UpdateGui)
339 self.ok_button_.clicked.connect(self.
Ok)
340 self.cancel_button_.clicked.connect(self.
Cancel)
341 self.auto_calc_.stateChanged.connect(self.
UpdateGui)
346 gradient = self.gradient_edit_.GetGfxGradient()
348 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
352 if(self.property_edit_.isEnabled()):
353 prop = str(self.property_edit_.text())
354 level = Prop.Level(self.combo_box_.itemData(self.combo_box_.currentIndex()).toPyObject())
356 prop = str(self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex()).toPyObject())
358 if(self.auto_calc_.isChecked()):
361 minv = self.minv_.value()
362 maxv = self.maxv_.value()
367 self.query_editor_.SetQuery(glco.GetSelection())
368 self.query_editor_.SetQueryFlags(glco.GetSelectionFlags())
370 for i
in range(0,self.detail_selection_cb_.count()):
371 mask = self.detail_selection_cb_.itemData(i).toPyObject()
372 if mask == glco.GetMask():
373 self.detail_selection_cb_.setCurrentIndex(i)
377 self.detail_selection_cb_.setCurrentIndex(0)
380 for i
in range(0,self.prop_combo_box_.count()):
381 prop = str(self.prop_combo_box_.itemData(i).toPyObject())
382 if prop == glco.GetProperty():
383 self.prop_combo_box_.setCurrentIndex(i)
386 self.prop_combo_box_.setCurrentIndex(self.prop_combo_box_.count()-1)
387 self.property_edit_.setText(glco.GetProperty())
389 self.combo_box_.setCurrentIndex(glco.GetLevel())
390 self.gradient_edit_.LoadGradient(ImmutableGradientInfoHandler.ConvertToQGradient(glco.GetGradient()))
391 self.auto_calc_.setChecked(glco.GetCalculateMinMax());
392 if(
not glco.GetCalculateMinMax()):
393 self.minv_.setValue(glco.GetMinV())
394 self.maxv_.setValue(glco.GetMaxV())
398 prop = str(self.prop_combo_box_.itemData(self.prop_combo_box_.currentIndex()))
399 if(prop ==
"custom"):
400 self.combo_box_.setEnabled(
True)
401 self.property_edit_.setEnabled(
True)
403 self.combo_box_.setEnabled(
False)
404 self.property_edit_.setEnabled(
False)
406 if(self.auto_calc_.isChecked()):
407 self.minv_.setEnabled(
False)
408 self.maxv_.setEnabled(
False)
410 self.minv_.setEnabled(
True)
411 self.maxv_.setEnabled(
True)
424 QtWidgets.QDialog.__init__(self, parent)
427 detail_label = QtWidgets.QLabel(
"Parts")
429 self.detail_selection_cb_.addItem(
"Main and Detail",QtCore.QVariant(3))
430 self.detail_selection_cb_.addItem(
"Main",QtCore.QVariant(2))
431 self.detail_selection_cb_.addItem(
"Detail",QtCore.QVariant(1))
433 self.
hbox_ = QtWidgets.QHBoxLayout()
437 self.hbox_.addStretch()
440 grid = QtWidgets.QGridLayout()
441 grid.setContentsMargins(0,5,0,0)
443 grid.addWidget(detail_label, 1, 0, 1, 1)
445 grid.addLayout(self.
hbox_,2,0,1,2)
446 grid.setRowStretch(1, 1)
449 self.ok_button_.clicked.connect(self.
Ok)
450 self.cancel_button_.clicked.connect(self.
Cancel)
453 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
459 self.query_editor_.SetQuery(beco.GetSelection())
460 self.query_editor_.SetQueryFlags(beco.GetSelectionFlags())
462 for i
in range(0,self.detail_selection_cb_.count()):
463 mask = self.detail_selection_cb_.itemData(i).toPyObject()
464 if mask == beco.GetMask():
465 self.detail_selection_cb_.setCurrentIndex(i)
469 self.detail_selection_cb_.setCurrentIndex(0)
480 QtWidgets.QDialog.__init__(self, parent)
483 detail_label = QtWidgets.QLabel(
"Parts")
485 self.detail_selection_cb_.addItem(
"Main and Detail",QtCore.QVariant(3))
486 self.detail_selection_cb_.addItem(
"Main",QtCore.QVariant(2))
487 self.detail_selection_cb_.addItem(
"Detail",QtCore.QVariant(1))
489 self.
hbox_ = QtWidgets.QHBoxLayout()
493 self.hbox_.addStretch()
496 grid = QtWidgets.QGridLayout()
497 grid.setContentsMargins(0,5,0,0)
499 grid.addWidget(detail_label, 1, 0, 1, 1)
501 grid.addLayout(self.
hbox_,2,0,1,2)
502 grid.setRowStretch(1, 1)
505 self.ok_button_.clicked.connect(self.
Ok)
506 self.cancel_button_.clicked.connect(self.
Cancel)
509 detail = self.detail_selection_cb_.itemData(self.detail_selection_cb_.currentIndex()).toPyObject()
515 self.query_editor_.SetQuery(bcco.GetSelection())
516 self.query_editor_.SetQueryFlags(bcco.GetSelectionFlags())
518 for i
in range(0,self.detail_selection_cb_.count()):
519 mask = self.detail_selection_cb_.itemData(i).toPyObject()
520 if mask == bcco.GetMask():
521 self.detail_selection_cb_.setCurrentIndex(i)
525 self.detail_selection_cb_.setCurrentIndex(0)
536 QtWidgets.QDialog.__init__(self, parent)
539 self.
keep_ = QtWidgets.QCheckBox(
"Keep")
540 self.keep_.setChecked(
False)
542 render_label = QtWidgets.QLabel(
"Rendermode")
544 self.render_modes_.addItem(
"Fast Bonds")
545 self.render_modes_.addItem(
"Ball & Stick")
546 self.render_modes_.addItem(
"Spheres")
547 self.render_modes_.addItem(
"Fast Trace")
548 self.render_modes_.addItem(
"Trace")
549 self.render_modes_.addItem(
"Fast Spline")
550 self.render_modes_.addItem(
"Smooth Tube")
551 self.render_modes_.addItem(
"Helix & Strand Cartoon")
554 gfx.RenderMode.CUSTOM,
556 gfx.RenderMode.LINE_TRACE,
557 gfx.RenderMode.TRACE,
558 gfx.RenderMode.SLINE,
562 self.
hbox_ = QtWidgets.QHBoxLayout()
566 self.hbox_.addStretch()
569 grid = QtWidgets.QGridLayout()
570 grid.setContentsMargins(0,5,0,0)
572 grid.addWidget(self.
keep_, 1, 1, 1, 1)
573 grid.addWidget(render_label,2,0,1,1)
575 grid.addLayout(self.
hbox_,3,0,1,2)
576 grid.setRowStretch(1, 1)
579 self.ok_button_.clicked.connect(self.
Ok)
580 self.cancel_button_.clicked.connect(self.
Cancel)
583 selection = self.query_editor_.GetQueryText()
584 flags = self.query_editor_.GetQueryFlags()
586 ro = RenderOp(render_mode, selection, flags, self.keep_.isChecked())
590 self.query_editor_.SetQuery(ro.GetSelection())
591 self.query_editor_.SetQueryFlags(ro.GetSelectionFlags())
593 for i
in range(0,self.render_modes_.count()):
595 if render_mode == ro.GetRenderMode():
596 self.render_modes_.setCurrentIndex(i)
600 self.render_modes_.setCurrentIndex(0)
601 self.keep_.setChecked(ro.IsKept())
611 QtWidgets.QDialog.__init__(self, parent)
615 self.visible_.setChecked(
True)
617 self.
hbox_ = QtWidgets.QHBoxLayout()
621 self.hbox_.addStretch()
624 grid = QtWidgets.QGridLayout()
625 grid.setContentsMargins(0,5,0,0)
627 grid.addWidget(self.
visible_, 1, 1, 1, 1)
628 grid.addLayout(self.
hbox_,2,0,1,2)
629 grid.setRowStretch(1, 1)
632 self.ok_button_.clicked.connect(self.
Ok)
633 self.cancel_button_.clicked.connect(self.
Cancel)
636 selection = self.query_editor_.GetQueryText()
637 flags = self.query_editor_.GetQueryFlags()
638 vo = VisibilityOp(selection, flags, self.visible_.isChecked())
642 self.query_editor_.SetQuery(vo.GetSelection())
643 self.query_editor_.SetQueryFlags(vo.GetSelectionFlags())
644 self.visible_.setChecked(vo.IsVisible())