24 from PyQt4
import QtCore, QtGui
25 from color_select_widget
import ColorSelectWidget
26 from gradient_preset_widget
import GradientPresetWidget
31 QtGui.QWidget.__init__(self, parent)
35 gradient_label = QtGui.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 = QtGui.QGridLayout()
55 grid.setContentsMargins(0,5,0,0)
56 grid.addWidget(gradient_label, 0, 0, 1, 1)
60 grid.setRowStretch(4, 1)
66 QtCore.QObject.connect(self.
gradient_preset_, QtCore.SIGNAL(
"gradientSelected"), 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 QtGui.QWidget.__init__(self, parent)
107 QtGui.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 QtGui.QWidget.__init__(self, parent)
146 self.
add_ = QtGui.QAction(
"Add", self)
147 QtCore.QObject.connect(self.
add_, QtCore.SIGNAL(
"triggered()"), self.
Add)
148 self.addAction(self.
add_)
149 self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
152 pal = QtGui.QPalette(self.palette())
153 pal.setColor(QtGui.QPalette.Window, QtGui.QColor(255, 255, 255, 128))
155 self.setAutoFillBackground(
True)
168 self.stops.remove(stop)
173 self.emit(QtCore.SIGNAL(
"gradientUpdated"),(self))
176 if(len(self.
stops)>2):
179 QtGui.QMessageBox.question(self,
"Information",
"Please keep in mind, at least two stops are needed for a gradient!")
183 QtCore.QObject.connect(stop, QtCore.SIGNAL(
"gradientChanged"), self.
UpdateGradient)
184 QtCore.QObject.connect(stop, QtCore.SIGNAL(
"colorChanged"), self.
UpdateGradient)
185 QtCore.QObject.connect(stop, QtCore.SIGNAL(
"colorChanged"), self.parent().Update)
186 QtCore.QObject.connect(stop, QtCore.SIGNAL(
"gradientUpdated"), self.parent().Update)
187 QtCore.QObject.connect(stop, QtCore.SIGNAL(
"removeStop"), self.
RemoveStopGui)
189 self.stops.append(stop)
191 self.emit(QtCore.SIGNAL(
"gradientUpdated"),(self))
194 self.
AddStop(QtGui.QCursor.pos().x() - self.mapToGlobal(QtCore.QPoint(0, 0)).x())
197 self.gradient_preview_.SetGradient(self.
GetGradient())
203 gradient.SetColorAt(s.GetRel(), gfx.RGB(c.redF(), c.greenF(), c.blueF()));
212 gradient.setColorAt(s.GetRel(), s.GetColor())
216 stopcpy = self.
stops[:]
220 gradStops = gradient.stops()
221 for stop
in gradStops:
229 factor = 1/(float(self.
width_)/event.size().width())
232 s.SetPos(s.GetPos() * factor)
234 self.
width_ = event.size().width()
238 def __init__(self, pos, offset, parent, color=None):
246 ColorSelectWidget.__init__(self, self.
length_,self.
length_, color, parent)
258 QtCore.QObject.connect(self.
remove_, QtCore.SIGNAL(
"triggered()"), self.
Remove)
262 self.emit(QtCore.SIGNAL(
"removeStop"),(self))
272 rel = self.
pos_ / float(self.parent().width() - 2 * self.
offset_)
282 self.emit(QtCore.SIGNAL(
"gradientChanged"))
288 elif self.
pos_ >= self.parent().width() - 2*self.
offset_:
289 self.
pos_ = self.parent().width() - (2*self.
offset_ + 1)
296 if entity.button() == QtCore.Qt.LeftButton:
297 self.emit(QtCore.SIGNAL(
"gradientUpdated"))
graphical rendering of mol::EntityHandle entites