本文整理匯總了Python中volumina.view3d.volumeRendering.RenderingManager.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Python RenderingManager.setColor方法的具體用法?Python RenderingManager.setColor怎麽用?Python RenderingManager.setColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類volumina.view3d.volumeRendering.RenderingManager
的用法示例。
在下文中一共展示了RenderingManager.setColor方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
return parentFun()
def _onLabelChanged(self, parentFun, mapf, slot):
parentFun()
new = list(map(mapf, self.labelListData))
old = slot.value
slot.setValue(_listReplace(old, new))
def _onLabelRemoved(self, parent, start, end):
# Call the base class to update the operator.
super(PixelClassificationGui, self)._onLabelRemoved(parent, start, end)
# Keep colors in sync with names
# (If we deleted a name, delete its corresponding colors, too.)
op = self.topLevelOperatorView
if len(op.PmapColors.value) > len(op.LabelNames.value):
for slot in (op.LabelColors, op.PmapColors):
value = slot.value
value.pop(start)
# Force dirty propagation even though the list id is unchanged.
slot.setValue(value, check_changed=False)
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(PixelClassificationGui, self).getNextLabelName)
def getNextLabelColor(self):
return self._getNext(
self.topLevelOperatorView.LabelColors,
super(PixelClassificationGui, self).getNextLabelColor,
lambda x: QColor(*x)
)
def getNextPmapColor(self):
return self._getNext(
self.topLevelOperatorView.PmapColors,
super(PixelClassificationGui, self).getNextPmapColor,
lambda x: QColor(*x)
)
def onLabelNameChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelNameChanged,
lambda l: l.name,
self.topLevelOperatorView.LabelNames)
def onLabelColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelColorChanged,
lambda l: (l.brushColor().red(),
l.brushColor().green(),
l.brushColor().blue()),
self.topLevelOperatorView.LabelColors)
def onPmapColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onPmapColorChanged,
lambda l: (l.pmapColor().red(),
l.pmapColor().green(),
l.pmapColor().blue()),
self.topLevelOperatorView.PmapColors)
def _update_rendering(self):
if not self.render:
return
shape = self.topLevelOperatorView.InputImages.meta.shape[1:4]
if len(shape) != 5:
#this might be a 2D image, no need for updating any 3D stuff
return
time = self.editor.posModel.slicingPos5D[0]
if not self._renderMgr.ready:
self._renderMgr.setup(shape)
layernames = set(layer.name for layer in self.layerstack)
self._renderedLayers = dict((k, v) for k, v in self._renderedLayers.items()
if k in layernames)
newvolume = numpy.zeros(shape, dtype=numpy.uint8)
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
for ds in layer.datasources:
vol = ds.dataSlot.value[time, ..., 0]
indices = numpy.where(vol != 0)
newvolume[indices] = label
self._renderMgr.volume = newvolume
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
color = layer.tintColor
color = (old_div(color.red(), 255.0), old_div(color.green(), 255.0), old_div(color.blue(), 255.0))
self._renderMgr.setColor(label, color)
示例2: Counting3dGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
return
shape = self.topLevelOperatorView.InputImages.meta.shape[1:4]
time = self.editor.posModel.slicingPos5D[0]
if not self._renderMgr.ready:
self._renderMgr.setup(shape)
layernames = set(layer.name for layer in self.layerstack)
self._renderedLayers = dict((k, v) for k, v in self._renderedLayers.iteritems()
if k in layernames)
newvolume = numpy.zeros(shape, dtype=numpy.uint8)
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
for ds in layer.datasources:
vol = ds.dataSlot.value[time, ..., 0]
indices = numpy.where(vol != 0)
newvolume[indices] = label
self._renderMgr.volume = newvolume
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
color = layer.tintColor
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
def _gui_setNavigation(self):
self._labelControlUi.brushSizeComboBox.setEnabled(False)
self._labelControlUi.brushSizeCaption.setEnabled(False)
self._labelControlUi.arrowToolButton.setChecked(True)
self._labelControlUi.arrowToolButton.setChecked(True)
print "setNavigation"
if not hasattr(self, "rubberbandClickReporter"):
self.rubberbandClickReporter = ClickReportingInterpreter(
self.editor.navInterpret, self.editor.posModel, self.centralWidget() )
self.rubberbandClickReporter.leftClickReleased.connect( self.handleBoxQuery )
self.editor.setNavigationInterpreter(self.rubberbandClickReporter)
def _gui_setBox(self):
print "setBox"
self._labelControlUi.brushSizeComboBox.setEnabled(False)
self._labelControlUi.brushSizeCaption.setEnabled(False)
self._labelControlUi.boxToolButton.setChecked(True)
def _changeInteractionMode( self, toolId ):
"""
Implement the GUI's response to the user selecting a new tool.
"""
# Uncheck all the other buttons
for tool, button in self.toolButtons.items():
if tool != toolId:
button.setChecked(False)
示例3: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
shape = op.InputData.meta.shape[1:4]
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(op.MST.value.nodeNum+1, dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.objects[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.getSuperVoxelSeg() == 2, self._segmentation_3d_label, lut )
import vigra
#with vigra.Timer("remapping"):
self._renderMgr.volume = lut[op.MST.value.supervoxelUint32] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D and self._segmentation_3d_label is not None:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def _getNext(self, slot, parentFun, transform=None):
numLabels = self.labelListData.rowCount()
value = slot.value
if numLabels < len(value):
result = value[numLabels]
if transform is not None:
result = transform(result)
return result
else:
return parentFun()
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(CarvingGui, self).getNextLabelName)
def appletDrawers(self):
return [ ("Carving", self._labelControlUi) ]
def setupLayers( self ):
logger.debug( "setupLayers" )
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.HasSegmentation.value
self.labelingDrawerUi.currentObjectLabel.setText(currObj)
示例4: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
elif act is not None and act.text() == "remove %s from 3D view" % name:
label = self._shownObjects3D.pop(name)
self._renderMgr.removeObject(label)
self._update_rendering()
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView.opCarving
if not self._renderMgr.ready:
self._renderMgr.setup(op.MST.value.raw.shape)
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
self._renderMgr.volume = lut[op.MST.value.regionVol]
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView.opCarving
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
def getNextLabelName(self):
l = len(self._labelControlUi.labelListModel)
if l == 0:
return "Background"
else:
return "Object"
def appletDrawers(self):
return [ ("Carving", self._labelControlUi) ]
def setupLayers( self ):
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.opCarving.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.opCarving.HasSegmentation.value
nzLB = self.topLevelOperatorView.opCarving.opLabeling.NonzeroLabelBlocks[:].wait()[0]
self.labelingDrawerUi.currentObjectLabel.setText("current object: %s" % currObj)
self.labelingDrawerUi.save.setEnabled(currObj != "" and hasSeg)
self.labelingDrawerUi.saveAs.setEnabled(currObj == "" and hasSeg)
#rethink this
#self.labelingDrawerUi.segment.setEnabled(len(nzLB) > 0)
#self.labelingDrawerUi.clear.setEnabled(len(nzLB) > 0)
self.topLevelOperatorView.opCarving.CurrentObjectName.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opCarving.HasSegmentation.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opCarving.opLabeling.NonzeroLabelBlocks.notifyDirty(onButtonsEnabled)
# Labels
labellayer, labelsrc = self.createLabelLayer(direct=True)
示例5: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.segmentation.lut == 2, self._segmentation_3d_label, lut )
self._renderMgr.volume = lut[op.MST.value.regionVol] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D and self._segmentation_3d_label is not None:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def _getNext(self, slot, parentFun, transform=None):
numLabels = self.labelListData.rowCount()
value = slot.value
if numLabels < len(value):
result = value[numLabels]
if transform is not None:
result = transform(result)
return result
else:
return parentFun()
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(CarvingGui, self).getNextLabelName)
def appletDrawers(self):
return [ ("Carving", self._labelControlUi) ]
def setupLayers( self ):
logger.debug( "setupLayers" )
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.HasSegmentation.value
self.labelingDrawerUi.currentObjectLabel.setText(currObj)
示例6: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
return parentFun()
def _onLabelChanged(self, parentFun, mapf, slot):
parentFun()
new = map(mapf, self.labelListData)
old = slot.value
slot.setValue(_listReplace(old, new))
def _onLabelRemoved(self, parent, start, end):
# Call the base class to update the operator.
super(PixelClassificationGui, self)._onLabelRemoved(parent, start, end)
# Keep colors in sync with names
# (If we deleted a name, delete its corresponding colors, too.)
op = self.topLevelOperatorView
if len(op.PmapColors.value) > len(op.LabelNames.value):
for slot in (op.LabelColors, op.PmapColors):
value = slot.value
value.pop(start)
# Force dirty propagation even though the list id is unchanged.
slot.setValue(value, check_changed=False)
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(PixelClassificationGui, self).getNextLabelName)
def getNextLabelColor(self):
return self._getNext(
self.topLevelOperatorView.LabelColors,
super(PixelClassificationGui, self).getNextLabelColor,
lambda x: QColor(*x)
)
def getNextPmapColor(self):
return self._getNext(
self.topLevelOperatorView.PmapColors,
super(PixelClassificationGui, self).getNextPmapColor,
lambda x: QColor(*x)
)
def onLabelNameChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelNameChanged,
lambda l: l.name,
self.topLevelOperatorView.LabelNames)
def onLabelColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelColorChanged,
lambda l: (l.brushColor().red(),
l.brushColor().green(),
l.brushColor().blue()),
self.topLevelOperatorView.LabelColors)
def onPmapColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onPmapColorChanged,
lambda l: (l.pmapColor().red(),
l.pmapColor().green(),
l.pmapColor().blue()),
self.topLevelOperatorView.PmapColors)
def _update_rendering(self):
if not self.render:
return
shape = self.topLevelOperatorView.InputImages.meta.shape[1:4]
if len(shape) != 5:
#this might be a 2D image, no need for updating any 3D stuff
return
time = self.editor.posModel.slicingPos5D[0]
if not self._renderMgr.ready:
self._renderMgr.setup(shape)
layernames = set(layer.name for layer in self.layerstack)
self._renderedLayers = dict((k, v) for k, v in self._renderedLayers.iteritems()
if k in layernames)
newvolume = numpy.zeros(shape, dtype=numpy.uint8)
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
for ds in layer.datasources:
vol = ds.dataSlot.value[time, ..., 0]
indices = numpy.where(vol != 0)
newvolume[indices] = label
self._renderMgr.volume = newvolume
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
color = layer.tintColor
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
示例7: PixelClassificationGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
else:
return parentFun()
def _onLabelChanged(self, parentFun, mapf, slot):
parentFun()
new = map(mapf, self.labelListData)
old = slot.value
slot.setValue(_listReplace(old, new))
def _onLabelRemoved(self, parent, start, end):
# Update the label names/colors BEFORE calling the base class,
# which will update the operator and expects the
# label names list to be correct.
op = self.topLevelOperatorView
for slot in (op.LabelNames, op.LabelColors, op.PmapColors):
value = slot.value
value.pop(start)
slot.setValue(value)
# Call the base class to update the operator.
super(PixelClassificationGui, self)._onLabelRemoved(parent, start, end)
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(PixelClassificationGui, self).getNextLabelName)
def getNextLabelColor(self):
return self._getNext(
self.topLevelOperatorView.LabelColors,
super(PixelClassificationGui, self).getNextLabelColor,
lambda x: QColor(*x)
)
def getNextPmapColor(self):
return self._getNext(
self.topLevelOperatorView.PmapColors,
super(PixelClassificationGui, self).getNextPmapColor,
lambda x: QColor(*x)
)
def onLabelNameChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelNameChanged,
lambda l: l.name,
self.topLevelOperatorView.LabelNames)
def onLabelColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onLabelColorChanged,
lambda l: (l.brushColor().red(),
l.brushColor().green(),
l.brushColor().blue()),
self.topLevelOperatorView.LabelColors)
def onPmapColorChanged(self):
self._onLabelChanged(super(PixelClassificationGui, self).onPmapColorChanged,
lambda l: (l.pmapColor().red(),
l.pmapColor().green(),
l.pmapColor().blue()),
self.topLevelOperatorView.PmapColors)
def _update_rendering(self):
if not self.render:
return
shape = self.topLevelOperatorView.InputImages.meta.shape[1:4]
if len(shape) != 5:
#this might be a 2D image, no need for updating any 3D stuff
return
time = self.editor.posModel.slicingPos5D[0]
if not self._renderMgr.ready:
self._renderMgr.setup(shape)
layernames = set(layer.name for layer in self.layerstack)
self._renderedLayers = dict((k, v) for k, v in self._renderedLayers.iteritems()
if k in layernames)
newvolume = numpy.zeros(shape, dtype=numpy.uint8)
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
for ds in layer.datasources:
vol = ds.dataSlot.value[time, ..., 0]
indices = numpy.where(vol != 0)
newvolume[indices] = label
self._renderMgr.volume = newvolume
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
color = layer.tintColor
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
示例8: CarvingGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
def _update_rendering(self):
if not self.render:
return
op = self.topLevelOperatorView
if not self._renderMgr.ready:
self._renderMgr.setup(op.InputData.meta.shape[1:4])
# remove nonexistent objects
self._shownObjects3D = dict((k, v) for k, v in self._shownObjects3D.iteritems()
if k in op.MST.value.object_lut.keys())
lut = numpy.zeros(len(op.MST.value.objects.lut), dtype=numpy.int32)
for name, label in self._shownObjects3D.iteritems():
objectSupervoxels = op.MST.value.object_lut[name]
lut[objectSupervoxels] = label
if self._showSegmentationIn3D:
# Add segmentation as label, which is green
lut[:] = numpy.where( op.MST.value.segmentation.lut == 2, self._segmentation_3d_label, lut )
self._renderMgr.volume = lut[op.MST.value.regionVol] # (Advanced indexing)
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
op = self.topLevelOperatorView
ctable = self._doneSegmentationLayer.colorTable
for name, label in self._shownObjects3D.iteritems():
color = QColor(ctable[op.MST.value.object_names[name]])
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)
if self._showSegmentationIn3D:
self._renderMgr.setColor(self._segmentation_3d_label, (0.0, 1.0, 0.0)) # Green
def getNextLabelName(self):
l = len(self._labelControlUi.labelListModel)
if l == 0:
return "Background"
else:
return "Object"
def appletDrawers(self):
return [ ("Carving", self._labelControlUi) ]
def setupLayers( self ):
layers = []
def onButtonsEnabled(slot, roi):
currObj = self.topLevelOperatorView.CurrentObjectName.value
hasSeg = self.topLevelOperatorView.HasSegmentation.value
#nzLB = self.topLevelOperatorView.opLabeling.NonzeroLabelBlocks[:].wait()[0]
self.labelingDrawerUi.currentObjectLabel.setText("current object: %s" % currObj)
self.labelingDrawerUi.save.setEnabled(currObj != "" and hasSeg)
self.labelingDrawerUi.saveAs.setEnabled(currObj == "" and hasSeg)
#rethink this
#self.labelingDrawerUi.segment.setEnabled(len(nzLB) > 0)
#self.labelingDrawerUi.clear.setEnabled(len(nzLB) > 0)
self.topLevelOperatorView.CurrentObjectName.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.HasSegmentation.notifyDirty(onButtonsEnabled)
self.topLevelOperatorView.opLabelArray.NonzeroBlocks.notifyDirty(onButtonsEnabled)
示例9: GraphCutsGui
# 需要導入模塊: from volumina.view3d.volumeRendering import RenderingManager [as 別名]
# 或者: from volumina.view3d.volumeRendering.RenderingManager import setColor [as 別名]
#.........這裏部分代碼省略.........
def _getNext(self, slot, parentFun, transform=None):
numLabels = self.labelListData.rowCount()
value = slot.value
if numLabels < len(value):
result = value[numLabels]
if transform is not None:
result = transform(result)
return result
else:
return parentFun()
def _onLabelChanged(self, parentFun, mapf, slot):
parentFun()
new = map(mapf, self.labelListData)
old = slot.value
slot.setValue(_listReplace(old, new))
def _onLabelRemoved(self, parent, start, end):
super(GraphCutsGui, self)._onLabelRemoved(parent, start, end)
op = self.topLevelOperatorView
for slot in (op.LabelNames, op.LabelColors, op.PmapColors):
value = slot.value
value.pop(start)
slot.setValue(value)
def getNextLabelName(self):
return self._getNext(self.topLevelOperatorView.LabelNames,
super(GraphCutsGui, self).getNextLabelName)
def getNextLabelColor(self):
return self._getNext(
self.topLevelOperatorView.LabelColors,
super(GraphCutsGui, self).getNextLabelColor,
lambda x: QColor(*x)
)
def getNextPmapColor(self):
return self._getNext(
self.topLevelOperatorView.PmapColors,
super(GraphCutsGui, self).getNextPmapColor,
lambda x: QColor(*x)
)
def onLabelNameChanged(self):
self._onLabelChanged(super(GraphCutsGui, self).onLabelNameChanged,
lambda l: l.name,
self.topLevelOperatorView.LabelNames)
def onLabelColorChanged(self):
self._onLabelChanged(super(GraphCutsGui, self).onLabelColorChanged,
lambda l: (l.brushColor().red(),
l.brushColor().green(),
l.brushColor().blue()),
self.topLevelOperatorView.LabelColors)
def onPmapColorChanged(self):
self._onLabelChanged(super(GraphCutsGui, self).onPmapColorChanged,
lambda l: (l.pmapColor().red(),
l.pmapColor().green(),
l.pmapColor().blue()),
self.topLevelOperatorView.PmapColors)
def _update_rendering(self):
if not self.render:
return
shape = self.topLevelOperatorView.InputImages.meta.shape[1:4]
time = self.editor.posModel.slicingPos5D[0]
if not self._renderMgr.ready:
self._renderMgr.setup(shape)
layernames = set(layer.name for layer in self.layerstack)
self._renderedLayers = dict((k, v) for k, v in self._renderedLayers.iteritems()
if k in layernames)
newvolume = numpy.zeros(shape, dtype=numpy.uint8)
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
for ds in layer.datasources:
vol = ds.dataSlot.value[time, ..., 0]
indices = numpy.where(vol != 0)
newvolume[indices] = label
self._renderMgr.volume = newvolume
self._update_colors()
self._renderMgr.update()
def _update_colors(self):
for layer in self.layerstack:
try:
label = self._renderedLayers[layer.name]
except KeyError:
continue
color = layer.tintColor
color = (color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0)
self._renderMgr.setColor(label, color)