Commit 523174cd750832c457cd24becc7346d619dc0f49

Authored by tatiana
1 parent 9fbad510

ADD: Surface data and GUI integration

invesalius/data/surface.py
@@ -18,6 +18,7 @@ class Surface(): @@ -18,6 +18,7 @@ class Surface():
18 self.polydata = None 18 self.polydata = None
19 self.colour = None 19 self.colour = None
20 self.transparency = const.SURFACE_TRANSPARENCY 20 self.transparency = const.SURFACE_TRANSPARENCY
  21 + self.volume = 0
21 self.is_shown = 1 22 self.is_shown = 1
22 self.name = const.SURFACE_NAME_PATTERN %(Surface.general_index+1) 23 self.name = const.SURFACE_NAME_PATTERN %(Surface.general_index+1)
23 24
@@ -45,6 +46,9 @@ class SurfaceManager(): @@ -45,6 +46,9 @@ class SurfaceManager():
45 ps.Publisher().subscribe(self.SetActorColour, 46 ps.Publisher().subscribe(self.SetActorColour,
46 'Set surface colour') 47 'Set surface colour')
47 48
  49 + ps.Publisher().subscribe(self.OnChangeSurfaceName, 'Change surface name')
  50 + ps.Publisher().subscribe(self.OnShowSurface, 'Show surface')
  51 +
48 def AddNewActor(self, pubsub_evt): 52 def AddNewActor(self, pubsub_evt):
49 """ 53 """
50 Create surface actor, save into project and send it to viewer. 54 Create surface actor, save into project and send it to viewer.
@@ -144,13 +148,10 @@ class SurfaceManager(): @@ -144,13 +148,10 @@ class SurfaceManager():
144 filled_polydata.SetInput(polydata) 148 filled_polydata.SetInput(polydata)
145 filled_polydata.SetHoleSize(500) 149 filled_polydata.SetHoleSize(500)
146 filled_polydata.AddObserver("ProgressEvent", lambda obj, evt: 150 filled_polydata.AddObserver("ProgressEvent", lambda obj, evt:
147 - UpdateProgress(filled_polydata,  
148 - "Filling polydata...")) 151 + UpdateProgress(filled_polydata,
  152 + "Filling polydata..."))
149 polydata = filled_polydata.GetOutput() 153 polydata = filled_polydata.GetOutput()
150 154
151 - print "Area: %f mm2" % pu.CalculateSurfaceArea(polydata)  
152 - print "Volume: %f mm3" % pu.CalculateSurfaceVolume(polydata)  
153 -  
154 # Orient normals from inside to outside 155 # Orient normals from inside to outside
155 normals = vtk.vtkPolyDataNormals() 156 normals = vtk.vtkPolyDataNormals()
156 normals.SetInput(polydata) 157 normals.SetInput(polydata)
@@ -183,6 +184,7 @@ class SurfaceManager(): @@ -183,6 +184,7 @@ class SurfaceManager():
183 surface = Surface() 184 surface = Surface()
184 surface.colour = colour 185 surface.colour = colour
185 surface.polydata = polydata 186 surface.polydata = polydata
  187 +
186 188
187 # Set actor colour and transparency 189 # Set actor colour and transparency
188 actor.GetProperty().SetColor(colour) 190 actor.GetProperty().SetColor(colour)
@@ -201,9 +203,17 @@ class SurfaceManager(): @@ -201,9 +203,17 @@ class SurfaceManager():
201 ps.Publisher().sendMessage('Update status text in GUI', 203 ps.Publisher().sendMessage('Update status text in GUI',
202 "Surface created.") 204 "Surface created.")
203 205
  206 + # The following lines have to be here, otherwise all volumes disappear
  207 + measured_polydata = vtk.vtkMassProperties()
  208 + measured_polydata.SetInput(polydata)
  209 + volume = measured_polydata.GetVolume()
  210 + surface.volume = volume
  211 +
204 ps.Publisher().sendMessage('Update surface info in GUI', 212 ps.Publisher().sendMessage('Update surface info in GUI',
205 (surface.index, surface.name, 213 (surface.index, surface.name,
206 - surface.colour, surface.transparency)) 214 + surface.colour, surface.volume,
  215 + surface.transparency))
  216 +
207 217
208 def RemoveActor(self, index): 218 def RemoveActor(self, index):
209 """ 219 """
@@ -216,6 +226,16 @@ class SurfaceManager(): @@ -216,6 +226,16 @@ class SurfaceManager():
216 proj.surface_dict.pop(index) 226 proj.surface_dict.pop(index)
217 227
218 228
  229 + def OnChangeSurfaceName(self, pubsub_evt):
  230 + index, name = pubsub_evt.data
  231 + proj = Project()
  232 + proj.surface_dict[index].name = name
  233 +
  234 + def OnShowSurface(self, pubsub_evt):
  235 + index, value = pubsub_evt.data
  236 + print "OnShowSurface", index, value
  237 + self.ShowActor(index, value)
  238 +
219 def ShowActor(self, index, value): 239 def ShowActor(self, index, value):
220 """ 240 """
221 Show or hide actor, according to given actor index and value. 241 Show or hide actor, according to given actor index and value.
@@ -224,6 +244,7 @@ class SurfaceManager(): @@ -224,6 +244,7 @@ class SurfaceManager():
224 # Update value in project's surface_dict 244 # Update value in project's surface_dict
225 proj = Project() 245 proj = Project()
226 proj.surface_dict[index].is_shown = value 246 proj.surface_dict[index].is_shown = value
  247 + ps.Publisher().sendMessage('Render volume viewer')
227 248
228 def SetActorTransparency(self, pubsub_evt): 249 def SetActorTransparency(self, pubsub_evt):
229 """ 250 """
invesalius/data/viewer_volume.py
@@ -81,15 +81,16 @@ class Viewer(wx.Panel): @@ -81,15 +81,16 @@ class Viewer(wx.Panel):
81 self.UpdateRender() 81 self.UpdateRender()
82 82
83 def LoadActor(self, pubsub_evt): 83 def LoadActor(self, pubsub_evt):
  84 + print "****** Load actor"
84 actor = pubsub_evt.data 85 actor = pubsub_evt.data
85 86
86 ren = self.ren 87 ren = self.ren
87 ren.AddActor(actor) 88 ren.AddActor(actor)
88 ren.ResetCamera() 89 ren.ResetCamera()
89 - ren.GetActiveCamera().Elevation(90)  
90 - ren.GetActiveCamera().SetViewUp(0, 0, 1) 90 + #ren.GetActiveCamera().Elevation(90)
  91 + #ren.GetActiveCamera().SetViewUp(0, 0, 1)
91 92
92 - ren.GetActiveCamera().Dolly(1.5) 93 + #ren.GetActiveCamera().Dolly(1.5)
93 ren.ResetCameraClippingRange() 94 ren.ResetCameraClippingRange()
94 95
95 self.iren.Render() 96 self.iren.Render()
invesalius/gui/data_notebook.py
@@ -120,7 +120,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -120,7 +120,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
120 self.image_gray = Image.open("../icons/object_colour.jpg") 120 self.image_gray = Image.open("../icons/object_colour.jpg")
121 121
122 def OnEditLabel(self, evt): 122 def OnEditLabel(self, evt):
123 - print "Editing label", evt.GetIndex(), evt.GetLabel()  
124 ps.Publisher().sendMessage('Change mask name', (evt.GetIndex(), evt.GetLabel())) 123 ps.Publisher().sendMessage('Change mask name', (evt.GetIndex(), evt.GetLabel()))
125 evt.Skip() 124 evt.Skip()
126 125
@@ -128,7 +127,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -128,7 +127,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
128 self.ToggleItem(evt.m_itemIndex) 127 self.ToggleItem(evt.m_itemIndex)
129 128
130 def OnCheckItem(self, index, flag): 129 def OnCheckItem(self, index, flag):
131 -  
132 if flag: 130 if flag:
133 for key in self.mask_list_index.keys(): 131 for key in self.mask_list_index.keys():
134 if key != index: 132 if key != index:
@@ -183,13 +181,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -183,13 +181,6 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
183 self.imagelist.Replace(image_index, image) 181 self.imagelist.Replace(image_index, image)
184 self.Refresh() 182 self.Refresh()
185 183
186 - def Populate(self):  
187 - dict = ((0,"Mask 1", "(1000,4500)"),  
188 - (1,"Mask 2", "(2000, 4500)"),  
189 - (2,"Background","(0,4500)"))  
190 - for data in dict:  
191 - self.InsertNewItem(data[0], data[1], data[2])  
192 -  
193 class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): 184 class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
194 185
195 def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, 186 def __init__(self, parent, ID=-1, pos=wx.DefaultPosition,
@@ -205,65 +196,87 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -205,65 +196,87 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
205 self.__init_columns() 196 self.__init_columns()
206 self.__init_image_list() 197 self.__init_image_list()
207 self.__init_evt() 198 self.__init_evt()
208 - 199 + self.__bind_events_wx()
209 self.surface_list_index = {} 200 self.surface_list_index = {}
210 self.surface_bmp_idx_to_name = {} 201 self.surface_bmp_idx_to_name = {}
211 202
212 def __init_evt(self): 203 def __init_evt(self):
213 - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)  
214 ps.Publisher().subscribe(self.AddSurface, 204 ps.Publisher().subscribe(self.AddSurface,
215 'Update surface info in GUI') 205 'Update surface info in GUI')
  206 + ps.Publisher().subscribe(self.EditSurfaceTransparency,
  207 + 'Set surface transparency')
  208 + ps.Publisher().subscribe(self.EditSurfaceColour,
  209 + 'Set surface colour')
  210 +
  211 + def __bind_events_wx(self):
  212 + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
  213 + self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel)
216 214
217 def __init_columns(self): 215 def __init_columns(self):
218 216
219 self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) 217 self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER)
220 self.InsertColumn(1, "Name") 218 self.InsertColumn(1, "Name")
221 - self.InsertColumn(2, "Transparency", wx.LIST_FORMAT_RIGHT) 219 + self.InsertColumn(2, "Volume (mm3)")
  220 + self.InsertColumn(3, "Transparency", wx.LIST_FORMAT_RIGHT)
222 221
223 self.SetColumnWidth(0, 20) 222 self.SetColumnWidth(0, 20)
224 - self.SetColumnWidth(1, 120)  
225 - self.SetColumnWidth(2, 90) 223 + self.SetColumnWidth(1, 85)
  224 + self.SetColumnWidth(2, 85)
  225 + self.SetColumnWidth(3, 80)
226 226
227 def __init_image_list(self): 227 def __init_image_list(self):
228 self.imagelist = wx.ImageList(16, 16) 228 self.imagelist = wx.ImageList(16, 16)
229 229
230 - image = wx.Image("../icons//object_visible.jpg") 230 + image = wx.Image("../icons/object_invisible.jpg")
231 bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 231 bitmap = wx.BitmapFromImage(image.Scale(16, 16))
232 bitmap.SetWidth(16) 232 bitmap.SetWidth(16)
233 bitmap.SetHeight(16) 233 bitmap.SetHeight(16)
234 - img_check = self.imagelist.Add(bitmap)  
235 -  
236 - image = wx.Image("../icons/object_invisible.jpg") 234 + img_null = self.imagelist.Add(bitmap)
  235 +
  236 + image = wx.Image("../icons//object_visible.jpg")
237 bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 237 bitmap = wx.BitmapFromImage(image.Scale(16, 16))
238 bitmap.SetWidth(16) 238 bitmap.SetWidth(16)
239 bitmap.SetHeight(16) 239 bitmap.SetHeight(16)
240 - img_null = self.imagelist.Add(bitmap) 240 + img_check = self.imagelist.Add(bitmap)
241 241
242 self.SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL) 242 self.SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL)
243 243
244 self.image_gray = Image.open("../icons/object_colour.jpg") 244 self.image_gray = Image.open("../icons/object_colour.jpg")
245 245
  246 +
  247 + def OnEditLabel(self, evt):
  248 + ps.Publisher().sendMessage('Change surface name', (evt.GetIndex(), evt.GetLabel()))
  249 + evt.Skip()
  250 +
  251 + def OnItemActivated(self, evt):
  252 + self.ToggleItem(evt.m_itemIndex)
  253 + #ps.Publisher().sendMessage('Change surface selected',index)
  254 +
  255 + def OnCheckItem(self, index, flag):
  256 + ps.Publisher().sendMessage('Show surface', (index, flag))
  257 +
246 def AddSurface(self, pubsub_evt): 258 def AddSurface(self, pubsub_evt):
247 index = pubsub_evt.data[0] 259 index = pubsub_evt.data[0]
248 name = pubsub_evt.data[1] 260 name = pubsub_evt.data[1]
249 colour = pubsub_evt.data[2] 261 colour = pubsub_evt.data[2]
250 - transparency = "%d%%"%(int(100*pubsub_evt.data[3])) 262 + volume = "%d"%(int(pubsub_evt.data[3]))
  263 + transparency = "%d%%"%(int(100*pubsub_evt.data[4]))
251 264
252 image = self.CreateColourBitmap(colour) 265 image = self.CreateColourBitmap(colour)
253 image_index = self.imagelist.Add(image) 266 image_index = self.imagelist.Add(image)
254 self.surface_list_index[index] = image_index 267 self.surface_list_index[index] = image_index
255 268
256 - self.InsertNewItem(index, name, str(transparency), colour) 269 + self.InsertNewItem(index, name, volume, transparency, colour)
257 270
258 - def InsertNewItem(self, index=0, label="Surface 1",  
259 - transparency="(1000, 4500)", colour=None): 271 + def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3",
  272 + transparency="0%%", colour=None):
260 self.InsertStringItem(index, "") 273 self.InsertStringItem(index, "")
261 self.SetStringItem(index, 1, label, 274 self.SetStringItem(index, 1, label,
262 imageId = self.surface_list_index[index]) 275 imageId = self.surface_list_index[index])
263 - self.SetStringItem(index, 2, transparency) 276 + self.SetStringItem(index, 2, volume)
  277 + self.SetStringItem(index, 3, transparency)
  278 + self.SetItemImage(index, 1)
264 279
265 -  
266 -  
267 def CreateColourBitmap(self, colour): 280 def CreateColourBitmap(self, colour):
268 """ 281 """
269 Create a wx Image with a mask colour. 282 Create a wx Image with a mask colour.
@@ -280,16 +293,27 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -280,16 +293,27 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
280 wx_image = wx.EmptyImage(new_image.size[0], 293 wx_image = wx.EmptyImage(new_image.size[0],
281 new_image.size[1]) 294 new_image.size[1])
282 wx_image.SetData(new_image.tostring()) 295 wx_image.SetData(new_image.tostring())
283 - return wx.BitmapFromImage(wx_image.Scale(16, 16))  
284 -  
285 - def OnItemActivated(self, evt):  
286 - self.ToggleItem(evt.m_itemIndex) 296 + return wx.BitmapFromImage(wx_image.Scale(16, 16))
  297 +
  298 + def EditSurfaceTransparency(self, pubsub_evt):
  299 + """
  300 + Set actor transparency (oposite to opacity) according to given actor
  301 + index and value.
  302 + """
  303 + index, value = pubsub_evt.data
  304 + print "EditSurfaceTransparency", index, value
  305 + self.SetStringItem(index, 3, "%d%%"%(int(value*100)))
287 306
288 - def OnCheckItem(self, index, flag):  
289 - ps.Publisher().sendMessage('Show surface', (index, not flag)) 307 + def EditSurfaceColour(self, pubsub_evt):
  308 + """
  309 + """
  310 + index, colour = pubsub_evt.data
  311 + image = self.CreateColourBitmap(colour)
  312 + image_index = self.surface_list_index[index]
  313 + self.imagelist.Replace(image_index, image)
  314 + self.Refresh()
290 315
291 316
292 -  
293 class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): 317 class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
294 # TODO: Change edimixin to affect third column also 318 # TODO: Change edimixin to affect third column also
295 def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, 319 def __init__(self, parent, ID=-1, pos=wx.DefaultPosition,
invesalius/gui/frame.py
@@ -27,14 +27,15 @@ import default_tasks as tasks @@ -27,14 +27,15 @@ import default_tasks as tasks
27 import default_viewers as viewers 27 import default_viewers as viewers
28 28
29 29
30 -[ID_NEW, ID_OPEN, ID_FULLSCREEN] = [wx.NewId() for number in range(3)] 30 +
  31 +[ID_FILE_IMPORT, ID_FILE_LOAD_INTERNET, ID_FILE_SAVE, ID_FILE_PRINT] = [wx.NewId() for number in range(4)]
31 32
32 class Frame(wx.Frame): 33 class Frame(wx.Frame):
33 def __init__(self, prnt): 34 def __init__(self, prnt):
34 wx.Frame.__init__(self, id=-1, name='', parent=prnt, 35 wx.Frame.__init__(self, id=-1, name='', parent=prnt,
35 pos=wx.Point(0, 0), 36 pos=wx.Point(0, 0),
36 size=wx.Size(1024, 768), #size = wx.DisplaySize(), 37 size=wx.Size(1024, 768), #size = wx.DisplaySize(),
37 - style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3.0') 38 + style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3')
38 self.Center(wx.BOTH) 39 self.Center(wx.BOTH)
39 self.SetIcon(wx.Icon("../icons/invesalius.ico", wx.BITMAP_TYPE_ICO)) 40 self.SetIcon(wx.Icon("../icons/invesalius.ico", wx.BITMAP_TYPE_ICO))
40 41
@@ -84,17 +85,26 @@ class Frame(wx.Frame): @@ -84,17 +85,26 @@ class Frame(wx.Frame):
84 85
85 # Add toolbars to manager 86 # Add toolbars to manager
86 87
87 - aui_manager.AddPane(ObjectToolBar(self), wx.aui.AuiPaneInfo(). 88 + if sys.platform == 'win32':
  89 + t1 = ProjectToolBar(self)
  90 + t2 = LayoutToolBar(self)
  91 + t3 = ObjectToolBar(self)
  92 + else:
  93 + t3 = ProjectToolBar(self)
  94 + t2 = LayoutToolBar(self)
  95 + t1 = ObjectToolBar(self)
  96 +
  97 + aui_manager.AddPane(t1, wx.aui.AuiPaneInfo().
88 Name("General Features Toolbar"). 98 Name("General Features Toolbar").
89 ToolbarPane().Top().Floatable(False). 99 ToolbarPane().Top().Floatable(False).
90 LeftDockable(False).RightDockable(False)) 100 LeftDockable(False).RightDockable(False))
91 101
92 - #aui_manager.AddPane(LayoutToolBar(self), wx.aui.AuiPaneInfo().  
93 - # Name("Layout Toolbar").  
94 - # ToolbarPane().Top().Floatable(False).  
95 - # LeftDockable(False).RightDockable(False)) 102 + aui_manager.AddPane(t2, wx.aui.AuiPaneInfo().
  103 + Name("Layout Toolbar").
  104 + ToolbarPane().Top().Floatable(False).
  105 + LeftDockable(False).RightDockable(False))
96 106
97 - aui_manager.AddPane(ProjectToolBar(self), wx.aui.AuiPaneInfo(). 107 + aui_manager.AddPane(t3, wx.aui.AuiPaneInfo().
98 Name("Project Toolbar"). 108 Name("Project Toolbar").
99 ToolbarPane().Top().Floatable(False). 109 ToolbarPane().Top().Floatable(False).
100 LeftDockable(False).RightDockable(False)) 110 LeftDockable(False).RightDockable(False))
@@ -137,12 +147,11 @@ class MenuBar(wx.MenuBar): @@ -137,12 +147,11 @@ class MenuBar(wx.MenuBar):
137 def __init_items(self): 147 def __init_items(self):
138 148
139 file_menu = wx.Menu() 149 file_menu = wx.Menu()
140 - file_menu.Append(ID_NEW, "New")  
141 - file_menu.Append(ID_OPEN, "Open")  
142 - file_menu.Append(wx.ID_EXIT, "Exit") 150 + file_menu.Append(ID_FILE_IMPORT, "Import...")
  151 + file_menu.Append(101, "Exit")
143 152
144 view_menu = wx.Menu() 153 view_menu = wx.Menu()
145 - view_menu.Append(ID_FULLSCREEN, "Fullscreen") 154 + view_menu.Append(101, "Fullscreen")
146 155
147 tools_menu = wx.Menu() 156 tools_menu = wx.Menu()
148 157
@@ -169,8 +178,9 @@ class MenuBar(wx.MenuBar): @@ -169,8 +178,9 @@ class MenuBar(wx.MenuBar):
169 # events should be binded directly from wx.Menu / wx.MenuBar 178 # events should be binded directly from wx.Menu / wx.MenuBar
170 # message "Binding events of wx.MenuBar" on [wxpython-users] 179 # message "Binding events of wx.MenuBar" on [wxpython-users]
171 # mail list in Oct 20 2008 180 # mail list in Oct 20 2008
172 - self.parent.Bind(wx.EVT_MENU, self.OnNew, id=ID_NEW)  
173 - self.parent.Bind(wx.EVT_MENU, self.OnOpen, id=ID_OPEN) 181 + #self.parent.Bind(wx.EVT_MENU, self.OnNew, id=ID_NEW)
  182 + #self.parent.Bind(wx.EVT_MENU, self.OnOpen, id=ID_OPEN)
  183 + pass
174 184
175 def OnNew(self, event): 185 def OnNew(self, event):
176 print "New" 186 print "New"
@@ -215,7 +225,7 @@ class StatusBar(wx.StatusBar): @@ -215,7 +225,7 @@ class StatusBar(wx.StatusBar):
215 self.SetFieldsCount(3) 225 self.SetFieldsCount(3)
216 self.SetStatusWidths([-2,-2,-1]) 226 self.SetStatusWidths([-2,-2,-1])
217 self.SetStatusText("Ready", 0) 227 self.SetStatusText("Ready", 0)
218 - self.SetStatusText("Welcome to InVesalius 3.0", 1) 228 + self.SetStatusText("", 1)
219 self.SetStatusText("", 2) 229 self.SetStatusText("", 2)
220 230
221 self.progress_bar = ProgressBar(self) 231 self.progress_bar = ProgressBar(self)
@@ -257,35 +267,36 @@ class TaskBarIcon(wx.TaskBarIcon): @@ -257,35 +267,36 @@ class TaskBarIcon(wx.TaskBarIcon):
257 # ------------------------------------------------------------------------------ 267 # ------------------------------------------------------------------------------
258 268
259 class ProjectToolBar(wx.ToolBar): 269 class ProjectToolBar(wx.ToolBar):
260 - # TODO: what will appear in menubar?  
261 def __init__(self, parent): 270 def __init__(self, parent):
262 - wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER) 271 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition,
  272 + wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER)
263 if sys.platform == 'darwin': 273 if sys.platform == 'darwin':
264 - self._size = 25  
265 - else:  
266 - self._size = 16  
267 - self.SetToolBitmapSize(wx.Size(self._size,self._size)) 274 + self.SetToolBitmapSize(wx.Size(32,32))
268 self.parent = parent 275 self.parent = parent
269 self.__init_items() 276 self.__init_items()
270 self.__bind_events() 277 self.__bind_events()
271 278
272 def __init_items(self): 279 def __init_items(self):
273 280
274 - BMP_IMPORT = wx.Bitmap("../icons/file_import.png", wx.BITMAP_TYPE_PNG)  
275 - BMP_EXPORT = wx.Bitmap("../icons/file_export.png", wx.BITMAP_TYPE_PNG)  
276 - BMP_NET = wx.Bitmap("../icons/file_from_internet.png", wx.BITMAP_TYPE_PNG)  
277 - BMP_SAVE = wx.Bitmap("../icons/file_save.png", wx.BITMAP_TYPE_PNG)  
278 -  
279 - if sys.platform != 'darwin':  
280 - bmp_list = [BMP_IMPORT, BMP_EXPORT, BMP_NET, BMP_SAVE]  
281 - for bmp in bmp_list:  
282 - bmp.SetWidth(self._size)  
283 - bmp.SetHeight(self._size)  
284 281
285 - self.AddLabelTool(101, "Import medical image...", BMP_IMPORT)  
286 - self.AddLabelTool(101, "Export data.", BMP_EXPORT)  
287 - self.AddLabelTool(101, "Load medical image...", BMP_NET)  
288 - self.AddLabelTool(101, "Save InVesalius project", BMP_SAVE) 282 + if sys.platform == 'darwin':
  283 + BMP_IMPORT = wx.Bitmap("../icons/file_import_original.png", wx.BITMAP_TYPE_PNG)
  284 + BMP_NET = wx.Bitmap("../icons/file_from_internet_original.png", wx.BITMAP_TYPE_PNG)
  285 + BMP_SAVE = wx.Bitmap("../icons/file_save_original.png", wx.BITMAP_TYPE_PNG)
  286 + BMP_PRINT = wx.Bitmap("../icons/print_original.png", wx.BITMAP_TYPE_PNG)
  287 + BMP_PHOTO = wx.Bitmap("../icons/tool_photo_original.png", wx.BITMAP_TYPE_PNG)
  288 + else:
  289 + BMP_IMPORT = wx.Bitmap("../icons/file_import.png", wx.BITMAP_TYPE_PNG)
  290 + BMP_NET = wx.Bitmap("../icons/file_from_internet.png", wx.BITMAP_TYPE_PNG)
  291 + BMP_SAVE = wx.Bitmap("../icons/file_save.png", wx.BITMAP_TYPE_PNG)
  292 + BMP_PRINT = wx.Bitmap("../icons/print.png", wx.BITMAP_TYPE_PNG)
  293 + BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png", wx.BITMAP_TYPE_PNG)
  294 +
  295 + self.AddLabelTool(ID_FILE_IMPORT, "Import medical image...", BMP_IMPORT)
  296 + self.AddLabelTool(ID_FILE_LOAD_INTERNET, "Load medical image...", BMP_NET)
  297 + self.AddLabelTool(ID_FILE_SAVE, "Save InVesalius project", BMP_SAVE)
  298 + self.AddLabelTool(101, "Take photo of screen", BMP_PHOTO)
  299 + self.AddLabelTool(ID_FILE_PRINT, "Print medical image...", BMP_PRINT)
289 300
290 self.Realize() 301 self.Realize()
291 302
@@ -297,10 +308,7 @@ class ObjectToolBar(wx.ToolBar): @@ -297,10 +308,7 @@ class ObjectToolBar(wx.ToolBar):
297 def __init__(self, parent): 308 def __init__(self, parent):
298 wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER) 309 wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER)
299 if sys.platform == 'darwin': 310 if sys.platform == 'darwin':
300 - self._size = 25  
301 - else:  
302 - self._size = 16  
303 - self.SetToolBitmapSize(wx.Size(self._size,self._size)) 311 + self.SetToolBitmapSize(wx.Size(32,32))
304 312
305 self.parent = parent 313 self.parent = parent
306 self.__init_items() 314 self.__init_items()
@@ -308,24 +316,18 @@ class ObjectToolBar(wx.ToolBar): @@ -308,24 +316,18 @@ class ObjectToolBar(wx.ToolBar):
308 316
309 def __init_items(self): 317 def __init_items(self):
310 318
311 - #BMP_ROTATE = wx.Bitmap("../icons/tool_rotate.gif", wx.BITMAP_TYPE_GIF)  
312 - #BMP_TRANSLATE = wx.Bitmap("../icons/tool_translate.gif", wx.BITMAP_TYPE_GIF)  
313 - BMP_ZOOM = wx.Bitmap("../icons/tool_zoom.png", wx.BITMAP_TYPE_PNG)  
314 - BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png", wx.BITMAP_TYPE_PNG)  
315 - BMP_PRINT = wx.Bitmap("../icons/tool_print.png", wx.BITMAP_TYPE_PNG)  
316 -  
317 - if sys.platform != 'darwin':  
318 - bmp_list = [BMP_ZOOM, BMP_PHOTO, BMP_PRINT]  
319 - for bmp in bmp_list:  
320 - bmp.SetWidth(self._size)  
321 - bmp.SetHeight(self._size)  
322 -  
323 - #self.AddLabelTool(101, "Rotate image", BMP_ROTATE)  
324 - #self.AddLabelTool(101, "Translate image", BMP_TRANSLATE)  
325 - self.AddLabelTool(101, "Zoom image", BMP_ZOOM)  
326 - self.AddLabelTool(101, "Take photo of screen", BMP_PHOTO)  
327 - self.AddLabelTool(101, "Print screen", BMP_PRINT)  
328 319
  320 + if sys.platform == 'darwin':
  321 + BMP_ROTATE = wx.Bitmap("../icons/tool_rotate_original.gif", wx.BITMAP_TYPE_GIF)
  322 + BMP_TRANSLATE = wx.Bitmap("../icons/tool_translate_original.png", wx.BITMAP_TYPE_PNG)
  323 + BMP_ZOOM_IN = wx.Bitmap("../icons/tool_zoom_in_original.png", wx.BITMAP_TYPE_PNG)
  324 + BMP_ZOOM_OUT = wx.Bitmap("../icons/tool_zoom_out_original.png", wx.BITMAP_TYPE_PNG)
  325 +
  326 + self.AddLabelTool(101, "Zoom in image", BMP_ZOOM_IN)
  327 + self.AddLabelTool(101, "Zoom out image", BMP_ZOOM_OUT)
  328 + self.AddLabelTool(101, "Rotate image", BMP_ROTATE)
  329 + self.AddLabelTool(101, "Translate image", BMP_TRANSLATE)
  330 +
329 self.Realize() 331 self.Realize()
330 332
331 def __bind_events(self): 333 def __bind_events(self):
@@ -336,10 +338,7 @@ class LayoutToolBar(wx.ToolBar): @@ -336,10 +338,7 @@ class LayoutToolBar(wx.ToolBar):
336 def __init__(self, parent): 338 def __init__(self, parent):
337 wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER) 339 wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER)
338 if sys.platform == 'darwin': 340 if sys.platform == 'darwin':
339 - self._size = 25  
340 - else:  
341 - self._size = 16  
342 - self.SetToolBitmapSize(wx.Size(self._size,self._size)) 341 + self.SetToolBitmapSize(wx.Size(32,32))
343 342
344 self.parent = parent 343 self.parent = parent
345 self.__init_items() 344 self.__init_items()
@@ -347,14 +346,9 @@ class LayoutToolBar(wx.ToolBar): @@ -347,14 +346,9 @@ class LayoutToolBar(wx.ToolBar):
347 346
348 def __init_items(self): 347 def __init_items(self):
349 348
350 - BMP_ROTATE = wx.Bitmap("../icons/layout_data_only.png", wx.BITMAP_TYPE_PNG)  
351 - BMP_TRANSLATE = wx.Bitmap("../icons/layout_full.png", wx.BITMAP_TYPE_PNG) 349 + BMP_ROTATE = wx.Bitmap("../icons/layout_data_only_original.gif", wx.BITMAP_TYPE_GIF)
  350 + BMP_TRANSLATE = wx.Bitmap("../icons/layout_full_original.gif", wx.BITMAP_TYPE_GIF)
352 351
353 - if sys.platform != 'darwin':  
354 - bmp_list = [BMP_ROTATE, BMP_TRANSLATE]  
355 - for bmp in bmp_list:  
356 - bmp.SetWidth(self._size)  
357 - bmp.SetHeight(self._size)  
358 352
359 #BMP_ZOOM = wx.Bitmap("../icons/tool_zoom.png", wx.BITMAP_TYPE_PNG) 353 #BMP_ZOOM = wx.Bitmap("../icons/tool_zoom.png", wx.BITMAP_TYPE_PNG)
360 #BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png", wx.BITMAP_TYPE_PNG) 354 #BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png", wx.BITMAP_TYPE_PNG)
invesalius/gui/task_importer.py
@@ -58,8 +58,8 @@ class InnerTaskPanel(wx.Panel): @@ -58,8 +58,8 @@ class InnerTaskPanel(wx.Panel):
58 self.float_hyper_list = [] 58 self.float_hyper_list = []
59 59
60 # Fixed hyperlink items 60 # Fixed hyperlink items
61 - tooltip = wx.ToolTip("Select DICOM files to be reconstructed")  
62 - link_import_local = hl.HyperLinkCtrl(self, -1, "Open DICOM files...") 61 + tooltip = wx.ToolTip("Select DICOM or Analyze files to be reconstructed")
  62 + link_import_local = hl.HyperLinkCtrl(self, -1, "Import medical images...")
63 link_import_local.SetUnderlines(False, False, False) 63 link_import_local.SetUnderlines(False, False, False)
64 link_import_local.SetColours("BLACK", "BLACK", "BLACK") 64 link_import_local.SetColours("BLACK", "BLACK", "BLACK")
65 link_import_local.SetToolTip(tooltip) 65 link_import_local.SetToolTip(tooltip)
@@ -182,9 +182,9 @@ class InnerTaskPanel(wx.Panel): @@ -182,9 +182,9 @@ class InnerTaskPanel(wx.Panel):
182 self.OnLinkOpenProject() 182 self.OnLinkOpenProject()
183 183
184 def TestLoadProjects(self): 184 def TestLoadProjects(self):
185 - self.LoadProject("test1.inv")  
186 - self.LoadProject("test2.inv")  
187 - self.LoadProject("test3.inv") 185 + self.LoadProject("test1.iv3")
  186 + self.LoadProject("test2.iv3")
  187 + self.LoadProject("test3.iv3")
188 188
189 def LoadProject(self, proj_name="Unnamed"): 189 def LoadProject(self, proj_name="Unnamed"):
190 """ 190 """
invesalius/gui/task_slice.py
@@ -298,6 +298,7 @@ class MaskProperties(wx.Panel): @@ -298,6 +298,7 @@ class MaskProperties(wx.Panel):
298 index = pubsub_evt.data 298 index = pubsub_evt.data
299 self.combo_mask_name.SetSelection(index) 299 self.combo_mask_name.SetSelection(index)
300 300
  301 +
301 def ChangeMaskName(self, pubsub_evt): 302 def ChangeMaskName(self, pubsub_evt):
302 index, name = pubsub_evt.data 303 index, name = pubsub_evt.data
303 self.combo_mask_name.SetString(index, name) 304 self.combo_mask_name.SetString(index, name)
invesalius/gui/task_surface.py
@@ -311,14 +311,14 @@ class SurfaceProperties(wx.Panel): @@ -311,14 +311,14 @@ class SurfaceProperties(wx.Panel):
311 (slider_transparency, 1, flag_slider,4)]) 311 (slider_transparency, 1, flag_slider,4)])
312 312
313 # LINE 4 313 # LINE 4
314 - cb = wx.CheckBox(self, -1, "Fill largest surface holes")  
315 - cb.SetValue(True) 314 + #cb = wx.CheckBox(self, -1, "Fill largest surface holes")
  315 + #cb.SetValue(True)
316 316
317 # Add all lines into main sizer 317 # Add all lines into main sizer
318 sizer = wx.BoxSizer(wx.VERTICAL) 318 sizer = wx.BoxSizer(wx.VERTICAL)
319 sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) 319 sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
320 sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) 320 sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
321 - sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5) 321 + #sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5)
322 sizer.Fit(self) 322 sizer.Fit(self)
323 323
324 self.SetSizer(sizer) 324 self.SetSizer(sizer)
@@ -328,17 +328,21 @@ class SurfaceProperties(wx.Panel): @@ -328,17 +328,21 @@ class SurfaceProperties(wx.Panel):
328 self.__bind_events() 328 self.__bind_events()
329 329
330 def __bind_events(self): 330 def __bind_events(self):
331 - #ps.Publisher().sendMessage('Update surface info in GUI',  
332 - # (surface.name, surface.colour,  
333 - # surface.transparency))  
334 ps.Publisher().subscribe(self.InsertNewSurface, 331 ps.Publisher().subscribe(self.InsertNewSurface,
335 'Update surface info in GUI') 332 'Update surface info in GUI')
  333 + ps.Publisher().subscribe(self.ChangeMaskName,
  334 + 'Change surface name')
336 335
337 336
  337 + def ChangeMaskName(self, pubsub_evt):
  338 + index, name = pubsub_evt.data
  339 + self.combo_surface_name.SetString(index, name)
  340 + self.combo_surface_name.Refresh()
  341 +
338 def InsertNewSurface(self, pubsub_evt): 342 def InsertNewSurface(self, pubsub_evt):
339 name = pubsub_evt.data[1] 343 name = pubsub_evt.data[1]
340 colour = [value*255 for value in pubsub_evt.data[2]] 344 colour = [value*255 for value in pubsub_evt.data[2]]
341 - transparency = 100*pubsub_evt.data[3] 345 + transparency = 100*pubsub_evt.data[4]
342 index = self.combo_surface_name.Append(name) 346 index = self.combo_surface_name.Append(name)
343 self.combo_surface_name.SetSelection(index) 347 self.combo_surface_name.SetSelection(index)
344 self.button_colour.SetColour(colour) 348 self.button_colour.SetColour(colour)