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()
52 self.
propsprops=[
"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)
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_parent_.GetCarbonsOnly():
93 if self.
parent_parent_.GetCarbonsOnly():
102 QtWidgets.QWidget.__init__(self, parent)
107 QtWidgets.QWidget.__init__(self, parent)
119 if self.isEnabled()
and self.
gradient_gradient_
is not None:
121 paint = QtGui.QPainter()
122 if paint.begin(self):
123 brush = QtGui.QBrush(self.
gradient_gradient_)
124 paint.setBrush(brush)
134 gradientUpdated = QtCore.pyqtSignal()
137 QtWidgets.QWidget.__init__(self, parent)
149 self.
add_add_ = QtWidgets.QAction(
"Add", self)
150 self.
add_add_.triggered.connect(self.
AddAdd)
151 self.addAction(self.
add_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.
stopsstops.remove(stop)
179 if(len(self.
stopsstops)>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.
stopsstops.append(stop)
198 self.
AddStopAddStop(QtWidgets.QCursor.pos().x() - self.mapToGlobal(QtCore.QPoint(0, 0)).x())
205 for s
in self.
stopsstops:
207 gradient.SetColorAt(s.GetRel(), gfx.RGB(c.redF(), c.greenF(), c.blueF()));
211 gradient = QtGui.QLinearGradient(self.
border_offset_border_offset_,
215 for s
in self.
stopsstops:
216 gradient.setColorAt(s.GetRel(), s.GetColor())
220 stopcpy = self.
stopsstops[:]
224 gradStops = gradient.stops()
225 for stop
in gradStops:
233 factor = 1/(float(self.
width_width_)/event.size().width())
235 for s
in self.
stopsstops:
236 s.SetPos(s.GetPos() * factor)
238 self.
width_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_length_,self.
length_length_, color, parent)
264 self.
remove_remove_ = QtWidgets.QAction(
"Remove", self)
266 self.addAction(self.
remove_remove_)
279 rel = self.
pos_pos_ / float(self.parent().width() - 2 * self.
offset_offset_)
295 elif self.
pos_pos_ >= self.parent().width() - 2*self.
offset_offset_:
296 self.
pos_pos_ = self.parent().width() - (2*self.
offset_offset_ + 1)
303 if entity.button() == QtCore.Qt.LeftButton:
graphical rendering of mol::EntityHandle entites