24 from PyQt5
import QtCore, QtGui, QtWidgets
25 from .color_select_widget
import ColorSelectWidget
26 from .gradient_preset_widget
import GradientPresetWidget
31 QtWidgets.QWidget.__init__(self, parent)
35 gradient_label = QtWidgets.QLabel(
"Gradient Editor")
36 font = gradient_label.font()
44 self.prop_combo_box_.addItem(
"atom B-factor")
45 self.prop_combo_box_.addItem(
"average residue B-factor")
46 self.prop_combo_box_.addItem(
"X-Coordinate")
47 self.prop_combo_box_.addItem(
"Y-Coordinate")
48 self.prop_combo_box_.addItem(
"Z-Coordinate")
49 self.prop_combo_box_.addItem(
"Residue Number")
50 self.prop_combo_box_.addItem(
"Atom Charge")
52 self.
props=[
"abfac",
"rbfac",
"x",
"y",
"z",
"rnum",
"acharge"]
54 grid = QtWidgets.QGridLayout()
55 grid.setContentsMargins(0,5,0,0)
56 grid.addWidget(gradient_label, 0, 0, 1, 1)
60 grid.setRowStretch(4, 1)
64 self.prop_combo_box_.currentIndexChanged.connect(self.
Update)
65 self.gradient_edit_.gradientUpdated.connect(self.
Update)
66 self.gradient_preset_.gradientSelected.connect(self.gradient_edit_.LoadGradient)
68 self.setMinimumSize(250,300)
71 scene_selection = gui.SceneSelection.Instance()
72 for i
in range(0,scene_selection.GetActiveNodeCount()):
73 node = scene_selection.GetActiveNode(i)
76 if(scene_selection.GetActiveViewCount() > 0):
77 entity = scene_selection.GetViewEntity()
78 view = scene_selection.GetViewUnion()
84 if self.parent_.GetCarbonsOnly():
85 node.ColorBy(self.
props[self.prop_combo_box_.currentIndex()],
86 self.gradient_edit_.GetGfxGradient(),
"ele=C")
88 node.ColorBy(self.
props[self.prop_combo_box_.currentIndex()],
89 self.gradient_edit_.GetGfxGradient())
93 if self.parent_.GetCarbonsOnly():
102 QtWidgets.QWidget.__init__(self, parent)
107 QtWidgets.QWidget.__init__(self, parent)
119 if self.isEnabled()
and self.
gradient_ is not None:
121 paint = QtGui.QPainter()
122 if paint.begin(self):
124 paint.setBrush(brush)
134 gradientUpdated = QtCore.pyqtSignal()
137 QtWidgets.QWidget.__init__(self, parent)
149 self.
add_ = QtWidgets.QAction(
"Add", self)
150 self.add_.triggered.connect(self.
Add)
151 self.addAction(self.
add_)
152 self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
155 pal = QtGui.QPalette(self.palette())
156 pal.setColor(QtGui.QPalette.Window, QtGui.QColor(255, 255, 255, 128))
158 self.setAutoFillBackground(
True)
171 self.stops.remove(stop)
176 self.gradientUpdated.emit()
179 if(len(self.
stops)>2):
182 QtWidgets.QMessageBox.question(self,
"Information",
"Please keep in mind, at least two stops are needed for a gradient!")
188 stop.colorChanged.connect(self.parent().Update)
189 stop.gradientUpdated.connect(self.parent().Update)
193 self.stops.append(stop)
195 self.gradientUpdated.emit()
198 self.
AddStop(QtWidgets.QCursor.pos().x() - self.mapToGlobal(QtCore.QPoint(0, 0)).x())
201 self.gradient_preview_.SetGradient(self.
GetGradient())
207 gradient.SetColorAt(s.GetRel(), gfx.RGB(c.redF(), c.greenF(), c.blueF()));
216 gradient.setColorAt(s.GetRel(), s.GetColor())
220 stopcpy = self.
stops[:]
224 gradStops = gradient.stops()
225 for stop
in gradStops:
233 factor = 1/(float(self.
width_)/event.size().width())
236 s.SetPos(s.GetPos() * factor)
238 self.
width_ = event.size().width()
243 removeStop = QtCore.pyqtSignal()
244 gradientChanged = QtCore.pyqtSignal()
245 gradientUpdated = QtCore.pyqtSignal()
247 def __init__(self, pos, offset, parent, color=None):
255 ColorSelectWidget.__init__(self, self.
length_,self.
length_, color, parent)
264 self.
remove_ = QtWidgets.QAction(
"Remove", self)
265 self.remove_.triggered.connect(self.
Remove)
269 self.removeStop.emit()
279 rel = self.
pos_ / float(self.parent().width() - 2 * self.
offset_)
289 self.gradientChanged.emit()
295 elif self.
pos_ >= self.parent().width() - 2*self.
offset_:
296 self.
pos_ = self.parent().width() - (2*self.
offset_ + 1)
303 if entity.button() == QtCore.Qt.LeftButton:
304 self.gradientUpdated.emit()
graphical rendering of mol::EntityHandle entites