29 from PyQt5
import QtCore, QtWidgets
31 from .preset_widget
import PresetWidget
35 QtWidgets.QStackedWidget.__init__(self, parent)
40 self.setContentsMargins(0,0,0,0)
41 self.setMinimumSize(self.preset_widget_.minimumSize())
45 scene_selection = gui.SceneSelection.Instance()
48 for i
in range(0,scene_selection.GetActiveNodeCount()):
49 node = scene_selection.GetActiveNode(i)
52 if (
not _img_present)
or (
not isinstance(node,
gfx.MapIso)):
55 self.map_widget_.Update()
56 self.setMinimumSize(self.map_widget_.minimumSize())
57 self.resize(self.map_widget_.minimumSize())
58 self.setMinimumSize(self.map_widget_.minimumSize())
61 self.preset_widget_.Update()
62 self.setMinimumSize(self.preset_widget_.minimumSize())
63 self.resize(self.preset_widget_.minimumSize())
64 self.setMinimumSize(self.preset_widget_.minimumSize())
67 self.setEnabled(
False)
72 QtWidgets.QWidget.__init__(self, parent)
76 self.
font = self.map_level_label_.font()
77 self.font.setBold(
True)
82 self.level_spinbox_.setDecimals(3)
83 self.level_spinbox_.setSingleStep(0.05)
85 grid = QtWidgets.QGridLayout()
86 grid.setContentsMargins(0,5,0,0)
90 grid.setRowStretch(3, 1)
93 self.level_preview_.levelUpdated.connect(self.
UpdateLevel)
95 self.level_spinbox_.valueChanged.connect(self.
UpdateLevel)
97 self.setMinimumSize(250,200)
100 scene_selection = gui.SceneSelection.Instance()
101 if(scene_selection.GetActiveNodeCount()==1):
102 node = scene_selection.GetActiveNode(0)
103 if _img_present
and isinstance(node,
gfx.MapIso):
105 self.level_preview_.SetBins(node.GetHistogram())
106 self.level_preview_.SetMinimum(node.GetMinLevel())
107 self.level_spinbox_.setMinimum(node.GetMinLevel())
108 self.level_preview_.SetMaximum(node.GetMaxLevel())
109 self.level_spinbox_.setMaximum(node.GetMaxLevel())
110 self.level_preview_.SetLevel(node.GetLevel())
111 self.level_spinbox_.show()
112 self.font.setBold(
True)
113 self.map_level_label_.setText(
"Map Contour Level")
114 self.setEnabled(
True)
116 self.font.setBold(
False)
117 self.map_level_label_.setText(
"Map uniformly filled with level %s"%node.GetLevel())
118 self.level_spinbox_.hide()
119 self.setEnabled(
False)
121 self.setEnabled(
False)
123 self.setEnabled(
False)
126 scene_selection = gui.SceneSelection.Instance()
127 if(scene_selection.GetActiveNodeCount()==1):
128 node = scene_selection.GetActiveNode(0)
132 self.level_spinbox_.valueChanged.disconnect(self.
UpdateLevel)
133 self.level_spinbox_.setValue(level)
134 self.level_spinbox_.valueChanged.connect(self.
UpdateLevel)
139 levelUpdated = QtCore.pyqtSignal(int, name=
"levelUpdated")
140 levelModified = QtCore.pyqtSignal(int, name=
"levelModified")
143 QtWidgets.QWidget.__init__(self, parent)
148 QtWidgets.QWidget.__init__(self, parent)
177 if self.isEnabled()
and self.
bins_ is not None:
178 painter = QtWidgets.QPainter()
179 if painter.begin(self):
189 painter.setBrush(QtCore.Qt.white)
190 painter.setPen(QtCore.Qt.white)
198 bin_cnt = len(self.
bins_)
199 bin_width = (size.width()-2* self.
border_offset_) / float(bin_cnt)
206 painter.setBrush(QtCore.Qt.black)
207 painter.setPen(QtCore.Qt.black)
208 for i
in range(0,bin_cnt):
209 bin_height = self.
bins_[i]
223 painter.setBrush(QtCore.Qt.red)
224 painter.setPen(QtCore.Qt.red)
225 painter.drawRect((width / tot_len) * cur_len,
233 painter.setBrush(QtCore.Qt.gray)
234 painter.setPen(QtCore.Qt.gray)
235 pos=self.mapFromGlobal(QtWidgets.QCursor.pos())
236 painter.drawRect(pos.x(),
248 self.levelUpdated.emit(self.
level_)
257 level = self.
minimum_ + float(event.x())/width * tot_len
258 self.levelModified.emit(level)
graphical rendering of mol::EntityHandle entites
isocontour rendering for 3D image data