From 2f2deade4a1ff3916d6b1cdac57aea049eb5268f Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Thu, 11 Nov 2010 12:49:04 +0000 Subject: [PATCH] ENH: Adding new masks to notebook list, not showing in slices. --- invesalius/data/mask.py | 6 ++++++ invesalius/data/slice_.py | 67 ++++++++++++++++++++++++++++++++++++------------------------------- invesalius/gui/data_notebook.py | 2 +- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/invesalius/data/mask.py b/invesalius/data/mask.py index 75b7cfe..9edfebd 100644 --- a/invesalius/data/mask.py +++ b/invesalius/data/mask.py @@ -20,7 +20,9 @@ import os import plistlib import random +import tempfile +import numpy import vtk import constants as const @@ -81,3 +83,7 @@ class Mask(): def _set_class_index(self, index): Mask.general_index = index + + def create_mask(self, shape): + self.temp_file = tempfile.mktemp() + self.matrix = numpy.memmap(self.temp_file, mode='w+', dtype='uint8', shape=shape) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 97a6f85..5d92fae 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -261,9 +261,9 @@ class Slice(object): proj.mask_dict[index].colour = colour (r,g,b) = colour - scalar_range = int(self.imagedata.GetScalarRange()[1]) - self.lut_mask.SetTableValue(0, 0, 0, 0, 0.0) - self.lut_mask.SetTableValue(scalar_range - 1, r, g, b, 1.0) + #scalar_range = int(self.imagedata.GetScalarRange()[1]) + #self.lut_mask.SetTableValue(0, 0, 0, 0, 0.0) + #self.lut_mask.SetTableValue(scalar_range - 1, r, g, b, 1.0) colour_wx = [r*255, g*255, b*255] ps.Publisher().sendMessage('Change mask colour in notebook', @@ -536,6 +536,11 @@ class Slice(object): opacity=None, threshold_range=None, edition_threshold_range = None, edited_points=None): + + # TODO: mask system to new system. + future_mask = Mask() + future_mask.create_mask(self.matrix.shape) + future_mask = Mask() if colour: @@ -547,40 +552,40 @@ class Slice(object): if edited_points: future_mask.edited_points = edited_points - # this is not the first mask, so we will import data from old imagedata - if imagedata is None: - old_mask = self.current_mask - imagedata = old_mask.imagedata - future_mask.threshold_range = old_mask.threshold_range - - if threshold_range: - future_mask.threshold_range = threshold_range - future_mask.imagedata = self.__create_mask_threshold(self.imagedata, - threshold_range) - else: - future_mask.imagedata = vtk.vtkImageData() - future_mask.imagedata.DeepCopy(imagedata) - future_mask.imagedata.Update() - - - # when this is not the first instance, user will have defined a name - if name is not None: - future_mask.name = name - if future_mask.is_shown: - self.blend_filter.SetOpacity(1, future_mask.opacity) - else: - self.blend_filter.SetOpacity(1, 0) - self.blend_filter.Update() + ## this is not the first mask, so we will import data from old imagedata + #if imagedata is None: + #old_mask = self.current_mask + #imagedata = old_mask.imagedata + #future_mask.threshold_range = old_mask.threshold_range + + #if threshold_range: + #future_mask.threshold_range = threshold_range + #future_mask.imagedata = self.__create_mask_threshold(self.imagedata, + #threshold_range) + #else: + #future_mask.imagedata = vtk.vtkImageData() + #future_mask.imagedata.DeepCopy(imagedata) + #future_mask.imagedata.Update() + + + ## when this is not the first instance, user will have defined a name + #if name is not None: + #future_mask.name = name + #if future_mask.is_shown: + #self.blend_filter.SetOpacity(1, future_mask.opacity) + #else: + #self.blend_filter.SetOpacity(1, 0) + #self.blend_filter.Update() # insert new mask into project and retrieve its index proj = Project() index = proj.AddMask(future_mask) future_mask.index = index - if threshold_range: - self.SetMaskThreshold(index, threshold_range) - future_mask.edited_points = {} + #if threshold_range: + #self.SetMaskThreshold(index, threshold_range) + #future_mask.edited_points = {} - # update gui related to mask + ## update gui related to mask ps.Publisher().sendMessage('Add mask', (future_mask.index, future_mask.name, diff --git a/invesalius/gui/data_notebook.py b/invesalius/gui/data_notebook.py index aae5b2f..d63d4d2 100644 --- a/invesalius/gui/data_notebook.py +++ b/invesalius/gui/data_notebook.py @@ -839,7 +839,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): index = pubsub_evt.data[0] name = pubsub_evt.data[1] colour = pubsub_evt.data[2] - volume = "%d"%(int(pubsub_evt.data[3])) + volume = "%.3f"%pubsub_evt.data[3] transparency = "%d%%"%(int(100*pubsub_evt.data[4])) if index not in self.surface_list_index: -- libgit2 0.21.2