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_combo_box_.addItem(
"Uniform Color Operation", QtCore.QVariant(self.
ufcow_ufcow_))
62 self.
combo_box_combo_box_.addItem(
"Gradient Operation", QtCore.QVariant(self.
glcow_glcow_))
63 self.
combo_box_combo_box_.addItem(
"By Element Operation", QtCore.QVariant(self.
beow_beow_))
64 self.
combo_box_combo_box_.addItem(
"By Chain Operation", QtCore.QVariant(self.
bcow_bcow_))
65 self.
combo_box_combo_box_.addItem(
"RenderMode Operation", QtCore.QVariant(self.
row_row_))
66 self.
combo_box_combo_box_.addItem(
"Visibility Operation", QtCore.QVariant(self.
vow_vow_))
71 self.
list_view_list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
73 self.
list_view_list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
76 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
80 self.
hbox_hbox_.addStretch()
83 grid = QtWidgets.QGridLayout()
84 grid.setContentsMargins(0,5,0,0)
85 grid.addWidget(self.
combo_box_combo_box_,0,0,1,1)
87 grid.addWidget(self.
list_view_list_view_,1,0,3,3)
88 grid.addLayout(self.
hbox_hbox_,5,0,1,3)
89 grid.setRowStretch(1, 1)
113 self.
edit_edit_.triggered.connect(self.
EditEdit)
120 index = self.
list_view_list_view_.indexAt(pos)
122 self.
context_menu_context_menu_.popup(QtWidgets.QCursor.pos())
125 dialog = self.
combo_box_combo_box_.itemData(self.
combo_box_combo_box_.currentIndex()).toPyObject()
132 current_index = self.
list_view_list_view_.currentIndex()
133 op = self.
list_model_list_model_.GetOp(current_index)
135 self.
ufcow_ufcow_.SetOp(op)
136 if self.
ufcow_ufcow_.exec_():
139 self.
glcow_glcow_.SetOp(op)
140 if self.
glcow_glcow_.exec_():
143 self.
beow_beow_.SetOp(op)
144 if self.
beow_beow_.exec_():
147 self.
bcow_bcow_.SetOp(op)
148 if self.
bcow_bcow_.exec_():
150 elif isinstance(op, RenderOp):
151 self.
row_row_.SetOp(op)
152 if self.
row_row_.exec_():
153 self.
list_model_list_model_.SetItem(current_index, self.
row_row_.GetOp())
154 elif isinstance(op, VisibilityOp):
155 self.
vow_vow_.SetOp(op)
156 if self.
vow_vow_.exec_():
157 self.
list_model_list_model_.SetItem(current_index, self.
vow_vow_.GetOp())
160 current_index = self.
list_view_list_view_.currentIndex()
161 self.
list_model_list_model_.RemoveItem(current_index.row())
164 current_index = self.
list_view_list_view_.currentIndex()
165 if self.
list_model_list_model_.GetLastRow != current_index.row():
166 op = self.
list_model_list_model_.GetOp(current_index)
167 self.
list_model_list_model_.RemoveItem(current_index.row())
168 self.
list_model_list_model_.AddItem(op, current_index.row()+1)
171 current_index = self.
list_view_list_view_.currentIndex()
173 op = self.
list_model_list_model_.GetOp(current_index)
174 self.
list_model_list_model_.RemoveItem(current_index.row())
175 self.
list_model_list_model_.AddItem(op, current_index.row()-1)
185 QtWidgets.QDialog.__init__(self, parent)
188 detail_label = QtWidgets.QLabel(
"Parts")
194 color_label = QtWidgets.QLabel(
"Color")
197 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
201 self.
hbox_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_hbox_,3,0,1,2)
213 grid.setRowStretch(2, 1)
226 color=gfx.RGBAb(qcolor.red(),qcolor.green(),qcolor.blue(),qcolor.alpha())
231 self.
query_editor_query_editor_.SetQuery(ufco.GetSelection())
232 self.
query_editor_query_editor_.SetQueryFlags(ufco.GetSelectionFlags())
236 if mask == ufco.GetMask():
243 color = ufco.GetColor()
244 qcolor = QtGui.QColor(color.Red()*255, color.Green()*255, color.Blue()*255, color.Alpha()*255)
255 QtWidgets.QDialog.__init__(self, parent)
259 detail_label = QtWidgets.QLabel(
"Parts")
265 property_label = QtWidgets.QLabel(
"Property")
269 self.
prop_combo_box_prop_combo_box_.addItem(
"atom B-factor",QtCore.QVariant(
"abfac"))
270 self.
prop_combo_box_prop_combo_box_.addItem(
"average residue B-factor",QtCore.QVariant(
"rbfac"))
271 self.
prop_combo_box_prop_combo_box_.addItem(
"X-Coordinate",QtCore.QVariant(
"x"))
272 self.
prop_combo_box_prop_combo_box_.addItem(
"Y-Coordinate",QtCore.QVariant(
"y"))
273 self.
prop_combo_box_prop_combo_box_.addItem(
"Z-Coordinate",QtCore.QVariant(
"z"))
274 self.
prop_combo_box_prop_combo_box_.addItem(
"Residue Number",QtCore.QVariant(
"rnum"))
275 self.
prop_combo_box_prop_combo_box_.addItem(
"Atom Charge",QtCore.QVariant(
"acharge"))
276 self.
prop_combo_box_prop_combo_box_.addItem(
"Custom",QtCore.QVariant(
"custom"))
279 level_label = QtWidgets.QLabel(
"Level")
281 self.
combo_box_combo_box_.addItem(
"Atom",QtCore.QVariant(Prop.Level.ATOM))
282 self.
combo_box_combo_box_.addItem(
"Residue",QtCore.QVariant(Prop.Level.RESIDUE))
283 self.
combo_box_combo_box_.addItem(
"Chain",QtCore.QVariant(Prop.Level.CHAIN))
284 self.
combo_box_combo_box_.addItem(
"Unspecified",QtCore.QVariant(Prop.Level.UNSPECIFIED))
286 gradient_label = QtWidgets.QLabel(
"Gradient")
291 self.
auto_calc_auto_calc_ = QtWidgets.QCheckBox(
"Auto calculate")
297 self.
minv_minv_ = QtWidgets.QDoubleSpinBox(self)
298 self.
minv_minv_.setDecimals(2)
299 self.
minv_minv_.setMinimum(-9999.99)
300 self.
minv_minv_.setValue(0)
301 self.
maxv_maxv_ = QtWidgets.QDoubleSpinBox(self)
302 self.
maxv_maxv_.setDecimals(2)
303 self.
maxv_maxv_.setValue(1)
304 self.
maxv_maxv_.setMinimum(-9999.99)
306 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
310 self.
hbox_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)
323 grid.addWidget(self.
combo_box_combo_box_, 4, 1, 1, 1)
324 grid.addWidget(gradient_label, 5, 0, 1, 1)
329 grid.addWidget(self.
auto_calc_auto_calc_,7,1,1,1)
330 grid.addWidget(self.
minv_label_minv_label_,8,0,1,1)
331 grid.addWidget(self.
minv_minv_,8,1,1,1)
332 grid.addWidget(self.
maxv_label_maxv_label_,9,0,1,1)
333 grid.addWidget(self.
maxv_maxv_,9,1,1,1)
334 grid.addLayout(self.
hbox_hbox_,10,0,1,2)
335 grid.setRowStretch(1, 1)
354 level = Prop.Level(self.
combo_box_combo_box_.itemData(self.
combo_box_combo_box_.currentIndex()).toPyObject())
361 minv = self.
minv_minv_.value()
362 maxv = self.
maxv_maxv_.value()
367 self.
query_editor_query_editor_.SetQuery(glco.GetSelection())
368 self.
query_editor_query_editor_.SetQueryFlags(glco.GetSelectionFlags())
372 if mask == glco.GetMask():
381 prop = str(self.
prop_combo_box_prop_combo_box_.itemData(i).toPyObject())
382 if prop == glco.GetProperty():
389 self.
combo_box_combo_box_.setCurrentIndex(glco.GetLevel())
390 self.
gradient_edit_gradient_edit_.LoadGradient(ImmutableGradientInfoHandler.ConvertToQGradient(glco.GetGradient()))
391 self.
auto_calc_auto_calc_.setChecked(glco.GetCalculateMinMax());
392 if(
not glco.GetCalculateMinMax()):
393 self.
minv_minv_.setValue(glco.GetMinV())
394 self.
maxv_maxv_.setValue(glco.GetMaxV())
399 if(prop ==
"custom"):
407 self.
minv_minv_.setEnabled(
False)
408 self.
maxv_maxv_.setEnabled(
False)
410 self.
minv_minv_.setEnabled(
True)
411 self.
maxv_maxv_.setEnabled(
True)
424 QtWidgets.QDialog.__init__(self, parent)
427 detail_label = QtWidgets.QLabel(
"Parts")
433 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
437 self.
hbox_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_hbox_,2,0,1,2)
446 grid.setRowStretch(1, 1)
459 self.
query_editor_query_editor_.SetQuery(beco.GetSelection())
460 self.
query_editor_query_editor_.SetQueryFlags(beco.GetSelectionFlags())
464 if mask == beco.GetMask():
480 QtWidgets.QDialog.__init__(self, parent)
483 detail_label = QtWidgets.QLabel(
"Parts")
489 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
493 self.
hbox_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_hbox_,2,0,1,2)
502 grid.setRowStretch(1, 1)
515 self.
query_editor_query_editor_.SetQuery(bcco.GetSelection())
516 self.
query_editor_query_editor_.SetQueryFlags(bcco.GetSelectionFlags())
520 if mask == bcco.GetMask():
536 QtWidgets.QDialog.__init__(self, parent)
539 self.
keep_keep_ = QtWidgets.QCheckBox(
"Keep")
540 self.
keep_keep_.setChecked(
False)
542 render_label = QtWidgets.QLabel(
"Rendermode")
551 self.
render_modes_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_hbox_ = QtWidgets.QHBoxLayout()
566 self.
hbox_hbox_.addStretch()
569 grid = QtWidgets.QGridLayout()
570 grid.setContentsMargins(0,5,0,0)
572 grid.addWidget(self.
keep_keep_, 1, 1, 1, 1)
573 grid.addWidget(render_label,2,0,1,1)
575 grid.addLayout(self.
hbox_hbox_,3,0,1,2)
576 grid.setRowStretch(1, 1)
586 ro =
RenderOp(render_mode, selection, flags, self.
keep_keep_.isChecked())
591 self.
query_editor_query_editor_.SetQueryFlags(ro.GetSelectionFlags())
595 if render_mode == ro.GetRenderMode():
601 self.
keep_keep_.setChecked(ro.IsKept())
611 QtWidgets.QDialog.__init__(self, parent)
614 self.
visible_visible_ = QtWidgets.QCheckBox(
"Visible")
615 self.
visible_visible_.setChecked(
True)
617 self.
hbox_hbox_ = QtWidgets.QHBoxLayout()
621 self.
hbox_hbox_.addStretch()
624 grid = QtWidgets.QGridLayout()
625 grid.setContentsMargins(0,5,0,0)
627 grid.addWidget(self.
visible_visible_, 1, 1, 1, 1)
628 grid.addLayout(self.
hbox_hbox_,2,0,1,2)
629 grid.setRowStretch(1, 1)
643 self.
query_editor_query_editor_.SetQueryFlags(vo.GetSelectionFlags())
644 self.
visible_visible_.setChecked(vo.IsVisible())