Commit aa9c59d2c839081ec5ae0a7ce0280428037ced8a

Authored by Paulo Henrique Junqueira Amorim
1 parent a391e2fa

FIX: Bug in the Windows platebutton always selected

invesalius/gui/task_importer.py
... ... @@ -34,19 +34,19 @@ WILDCARD_OPEN = "InVesalius 1 project (*.promed)|*.promed|"\
34 34 class TaskPanel(wx.Panel):
35 35 def __init__(self, parent):
36 36 wx.Panel.__init__(self, parent)
37   -
  37 +
38 38 inner_panel = InnerTaskPanel(self)
39   -
  39 +
40 40 sizer = wx.BoxSizer(wx.HORIZONTAL)
41 41 sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT |
42 42 wx.LEFT, 7)
43 43 sizer.Fit(self)
44   -
  44 +
45 45 self.SetSizer(sizer)
46 46 self.Update()
47 47 self.SetAutoLayout(1)
48   -
49   -class InnerTaskPanel(wx.Panel):
  48 +
  49 +class InnerTaskPanel(wx.Panel):
50 50 def __init__(self, parent):
51 51 wx.Panel.__init__(self, parent)
52 52 self.SetBackgroundColour(wx.Colour(255,255,255))
... ... @@ -54,7 +54,7 @@ class InnerTaskPanel(wx.Panel):
54 54  
55 55 # Counter for projects loaded in current GUI
56 56 self.proj_count = 0
57   -
  57 +
58 58 # Floating items (to be inserted)
59 59 self.float_hyper_list = []
60 60  
... ... @@ -85,20 +85,20 @@ class InnerTaskPanel(wx.Panel):
85 85 link_open_proj.AutoBrowse(False)
86 86 link_open_proj.UpdateLink()
87 87 link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject)
88   -
  88 +
89 89 # Image(s) for buttons
90 90 BMP_IMPORT = wx.Bitmap("../icons/file_import.png", wx.BITMAP_TYPE_PNG)
91 91 BMP_NET = wx.Bitmap("../icons/file_from_internet.png", wx.BITMAP_TYPE_PNG)
92 92 BMP_NULL = wx.Bitmap("../icons/object_invisible.jpg", wx.BITMAP_TYPE_JPEG)
93   -
  93 +
94 94 bmp_list = [BMP_IMPORT, BMP_NET, BMP_NULL]
95 95 for bmp in bmp_list:
96 96 bmp.SetWidth(25)
97 97 bmp.SetHeight(25)
98   -
  98 +
99 99 # Buttons related to hyperlinks
100   - button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG
101   -
  100 + button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT
  101 +
102 102 button_import_local = pbtn.PlateButton(self, BTN_IMPORT_LOCAL, "",
103 103 BMP_IMPORT, style=button_style)
104 104 button_import_pacs = pbtn.PlateButton(self, BTN_IMPORT_PACS, "", BMP_NET,
... ... @@ -121,21 +121,21 @@ class InnerTaskPanel(wx.Panel):
121 121 (button_import_pacs, 0, flag_button),
122 122 (link_open_proj, 1, flag_link, 3),
123 123 (button_open_proj, 0, flag_button) ])
124   -
  124 +
125 125 # Add line sizers into main sizer
126 126 main_sizer = wx.BoxSizer(wx.VERTICAL)
127 127 main_sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND)
128   -
129   - # Update main sizer and panel layout
  128 +
  129 + # Update main sizer and panel layout
130 130 self.SetSizer(main_sizer)
131 131 self.Fit()
132 132 self.sizer = main_sizer
133   -
  133 +
134 134 # Test load and unload specific projects' links
135 135 self.TestLoadProjects()
136 136 #self.UnloadProjects()
137 137  
138   -
  138 +
139 139 def OnLinkImport(self, evt=None):
140 140 dlg = wx.DirDialog(self, "Choose a directory:", "",
141 141 style=wx.DD_DEFAULT_STYLE
... ... @@ -145,29 +145,29 @@ class InnerTaskPanel(wx.Panel):
145 145 if dlg.ShowModal() == wx.ID_OK:
146 146 path = dlg.GetPath()
147 147 ps.Publisher().sendMessage("Show import panel", path)
148   -
  148 +
149 149 # Only destroy a dialog after you're done with it.
150 150 dlg.Destroy()
151   -
  151 +
152 152 if evt:
153 153 evt.Skip()
154   -
  154 +
155 155 def OnLinkImportPACS(self, evt=None):
156 156 print "TODO: Send Signal - Import DICOM files from PACS"
157 157 if evt:
158 158 evt.Skip()
159   -
  159 +
160 160 def OnLinkOpenProject(self, evt=None, proj_name=""):
161 161 if proj_name:
162 162 print "TODO: Send Signal - Open project "+ proj_name
163 163 else:
164 164 dlg = wx.FileDialog(self, message="Open project...",
165   - defaultDir=os.getcwd(),
  165 + defaultDir=os.getcwd(),
166 166 defaultFile="", wildcard=WILDCARD_OPEN,
167 167 style=wx.OPEN|wx.CHANGE_DIR)
168 168 dlg.SetFilterIndex(3)
169   -
170   - # Show the dialog and retrieve the user response. If it is the OK response,
  169 +
  170 + # Show the dialog and retrieve the user response. If it is the OK response,
171 171 # process the data.
172 172 if dlg.ShowModal() == wx.ID_OK:
173 173 # This returns a Python list of files that were selected.
... ... @@ -175,29 +175,29 @@ class InnerTaskPanel(wx.Panel):
175 175 proj_name = dlg.GetFilename()
176 176 print "TODO: Send Signal - Open project "+ proj_path
177 177 print "TODO: Send Signal - Change frame title "+ proj_name
178   -
  178 +
179 179 # Destroy the dialog. Don't do this until you are done with it!
180 180 # BAD things can happen otherwise!
181 181 dlg.Destroy()
182   -
  182 +
183 183 if evt:
184 184 evt.Skip()
185   -
  185 +
186 186 def OnButton(self, evt):
187 187 id = evt.GetId()
188   -
  188 +
189 189 if id == BTN_IMPORT_LOCAL:
190 190 self.OnLinkImport()
191 191 elif id == BTN_IMPORT_PACS:
192 192 self.OnLinkImportPACS()
193 193 else: #elif id == BTN_OPEN_PROJECT:
194 194 self.OnLinkOpenProject()
195   -
  195 +
196 196 def TestLoadProjects(self):
197 197 self.LoadProject("test1.iv3")
198 198 self.LoadProject("test2.iv3")
199 199 self.LoadProject("test3.iv3")
200   -
  200 +
201 201 def LoadProject(self, proj_name="Unnamed"):
202 202 """
203 203 Load into user interface name of project into import task panel.
... ... @@ -206,13 +206,13 @@ class InnerTaskPanel(wx.Panel):
206 206 """
207 207 # TODO: What todo when it is called more than 3 times?
208 208 # TODO: Load from config file last 3 recent projects
209   -
  209 +
210 210 if (self.proj_count < 3):
211 211 self.proj_count += 1
212   -
  212 +
213 213 # Create name to be plot on GUI
214 214 label = " "+str(self.proj_count)+". "+proj_name
215   -
  215 +
216 216 # Create corresponding hyperlink
217 217 proj_link = hl.HyperLinkCtrl(self, -1, label)
218 218 proj_link.SetUnderlines(False, False, False)
... ... @@ -221,34 +221,33 @@ class InnerTaskPanel(wx.Panel):
221 221 proj_link.UpdateLink()
222 222 proj_link.Bind(hl.EVT_HYPERLINK_LEFT,
223 223 lambda e: self.OnLinkOpenProject(e, proj_name))
224   -
  224 +
225 225 # Add to existing frame
226 226 self.sizer.Add(proj_link, 1, wx.GROW | wx.EXPAND | wx.ALL, 2)
227 227 self.Update()
228 228  
229 229 # Add hyperlink to floating hyperlinks list
230   - self.float_hyper_list.append(proj_link)
231   -
  230 + self.float_hyper_list.append(proj_link)
  231 +
232 232 def UnloadProjects(self):
233 233 """
234 234 Unload all projects from interface into import task panel.
235 235 This will be called when the current project is closed.
236 236 """
237   -
  237 +
238 238 # Remove each project from sizer
239 239 for i in xrange(0, self.proj_count):
240 240 self.sizer.Remove(self.float_hyper_list[i])
241   -
  241 +
242 242 # Delete hyperlinks
243 243 for hyper in self.float_hyper_list:
244 244 hyper.Destroy()
245 245 del(hyper)
246   -
  246 +
247 247 # Update GUI
248 248 self.sizer.Layout()
249 249 self.Update()
250   -
  250 +
251 251 # Now we set projects loaded to 0
252 252 self.proj_count = 0
253 253 self.float_hyper_list = []
254   -
255 254 \ No newline at end of file
... ...
invesalius/gui/task_slice.py
... ... @@ -44,20 +44,20 @@ MASK_LIST = []
44 44 class TaskPanel(wx.Panel):
45 45 def __init__(self, parent):
46 46 wx.Panel.__init__(self, parent)
47   -
  47 +
48 48 inner_panel = InnerTaskPanel(self)
49 49  
50 50 sizer = wx.BoxSizer(wx.HORIZONTAL)
51 51 sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT |
52 52 wx.LEFT, 7)
53 53 sizer.Fit(self)
54   -
55   -
  54 +
  55 +
56 56 self.SetSizer(sizer)
57 57 self.Update()
58 58 self.SetAutoLayout(1)
59 59  
60   -class InnerTaskPanel(wx.Panel):
  60 +class InnerTaskPanel(wx.Panel):
61 61 def __init__(self, parent):
62 62 wx.Panel.__init__(self, parent)
63 63 default_colour = self.GetBackgroundColour()
... ... @@ -68,10 +68,10 @@ class InnerTaskPanel(wx.Panel):
68 68 BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG)
69 69 BMP_ADD.SetWidth(25)
70 70 BMP_ADD.SetHeight(25)
71   -
  71 +
72 72 # Button for creating new surface
73 73 button_new_mask = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\
74   - pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG)
  74 + pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT)
75 75 self.Bind(wx.EVT_BUTTON, self.OnButton)
76 76  
77 77  
... ... @@ -100,7 +100,7 @@ class InnerTaskPanel(wx.Panel):
100 100 button_next = wx.Button(self, -1, "Create 3D surface")
101 101 button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
102 102 button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask)
103   -
  103 +
104 104 # Add line sizers into main sizer
105 105 main_sizer = wx.BoxSizer(wx.VERTICAL)
106 106 main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
... ... @@ -108,66 +108,66 @@ class InnerTaskPanel(wx.Panel):
108 108 main_sizer.Add(button_next, 0,
109 109 wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT|wx.BOTTOM, 5)
110 110 main_sizer.Fit(self)
111   -
  111 +
112 112 self.SetSizer(main_sizer)
113 113 self.Update()
114 114 self.SetAutoLayout(1)
115 115  
116 116 self.sizer = main_sizer
117   -
  117 +
118 118 def OnButton(self, evt):
119 119 id = evt.GetId()
120 120 if id == BTN_NEW:
121 121 self.OnLinkNewMask()
122   -
  122 +
123 123 def OnButtonNextTask(self, evt):
124   - ps.Publisher().sendMessage('Create surface from index',
  124 + ps.Publisher().sendMessage('Create surface from index',
125 125 self.GetMaskSelected())
126   -
  126 +
127 127 def OnLinkNewMask(self, evt=None):
128 128 dlg = wx.TextEntryDialog(self, 'Name of new mask:',
129 129 'InVesalius 3.0 - New mask')
130 130 dlg.CenterOnScreen()
131 131 default_mask_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2)
132 132 dlg.SetValue(default_mask_name)
133   -
  133 +
134 134 if dlg.ShowModal() == wx.ID_OK:
135 135 print "TODO: Send Signal - New mask"
136 136 mask_name = dlg.GetValue()
137 137 ps.Publisher().sendMessage('Create new mask', mask_name)
138 138 if evt:
139 139 evt.Skip()
140   -
  140 +
141 141 def GetMaskSelected(self):
142 142 return self.fold_panel.GetMaskSelected()
143   -
  143 +
144 144 class FoldPanel(wx.Panel):
145 145 def __init__(self, parent):
146 146 wx.Panel.__init__(self, parent, size=(50,50))
147 147 self.SetBackgroundColour(wx.Colour(0,255,0))
148   -
  148 +
149 149 inner_panel = InnerFoldPanel(self)
150   -
151   - sizer = wx.BoxSizer(wx.VERTICAL)
  150 +
  151 + sizer = wx.BoxSizer(wx.VERTICAL)
152 152 sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2)
153 153 sizer.Fit(self)
154   -
  154 +
155 155 self.SetSizer(sizer)
156 156 self.Update()
157 157 self.SetAutoLayout(1)
158   -
  158 +
159 159 self.inner_panel = inner_panel
160   -
  160 +
161 161 def GetMaskSelected(self):
162 162 x = self.inner_panel.GetMaskSelected()
163 163 return self.inner_panel.GetMaskSelected()
164   -
  164 +
165 165 class InnerFoldPanel(wx.Panel):
166 166 def __init__(self, parent):
167 167 wx.Panel.__init__(self, parent)
168 168 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
169 169 #self.SetBackgroundColour(wx.Colour(0,0,0))
170   -
  170 +
171 171 # Fold panel and its style settings
172 172 # FIXME: If we dont insert a value in size or if we set wx.DefaultSize,
173 173 # the fold_panel doesnt show. This means that, for some reason, Sizer
... ... @@ -189,7 +189,7 @@ class InnerFoldPanel(wx.Panel):
189 189 fold_panel.AddFoldPanelWindow(item, self.mask_prop_panel, Spacing= 0,
190 190 leftSpacing=0, rightSpacing=0)
191 191 fold_panel.Expand(fold_panel.GetFoldPanel(0))
192   -
  192 +
193 193 # Fold 2 - Advanced edition tools
194 194 item = fold_panel.AddFoldPanel("Advanced edition tools", collapsed=True)
195 195 fold_panel.ApplyCaptionStyle(item, style)
... ... @@ -200,11 +200,11 @@ class InnerFoldPanel(wx.Panel):
200 200 # Panel sizer to expand fold panel
201 201 sizer = wx.BoxSizer(wx.VERTICAL)
202 202 sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND)
203   - sizer.Fit(self)
  203 + sizer.Fit(self)
204 204 self.SetSizer(sizer)
205 205 self.Update()
206 206 self.SetAutoLayout(1)
207   -
  207 +
208 208 def GetMaskSelected(self):
209 209 x= self.mask_prop_panel.GetMaskSelected()
210 210 return self.mask_prop_panel.GetMaskSelected()
... ... @@ -213,7 +213,7 @@ class MaskProperties(wx.Panel):
213 213 def __init__(self, parent):
214 214 wx.Panel.__init__(self, parent, size=(50,240))
215 215 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
216   -
  216 +
217 217 ## LINE 1
218 218  
219 219 # Combo related to mask naem
... ... @@ -222,16 +222,16 @@ class MaskProperties(wx.Panel):
222 222 combo_mask_name.SetSelection(0) # wx.CB_SORT
223 223 combo_mask_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
224 224 self.combo_mask_name = combo_mask_name
225   -
  225 +
226 226 # Mask colour
227 227 button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(-1,22))
228 228 self.button_colour = button_colour
229   -
  229 +
230 230 # Sizer which represents the first line
231 231 line1 = wx.BoxSizer(wx.HORIZONTAL)
232 232 line1.Add(combo_mask_name, 1, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 2)
233   - line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2)
234   -
  233 + line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2)
  234 +
235 235 ## LINE 2
236 236 text_thresh = wx.StaticText(self, -1,
237 237 "Set predefined or manual threshold:")
... ... @@ -245,10 +245,10 @@ class MaskProperties(wx.Panel):
245 245 self.combo_thresh = combo_thresh
246 246  
247 247 ## LINE 4
248   - gradient = grad.GradientSlider(self, -1, -5000, 5000, 0, 5000,
  248 + gradient = grad.GradientSlider(self, -1, -5000, 5000, 0, 5000,
249 249 (0, 255, 0, 100))
250 250 self.gradient = gradient
251   -
  251 +
252 252 # Add all lines into main sizer
253 253 sizer = wx.BoxSizer(wx.VERTICAL)
254 254 sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
... ... @@ -256,13 +256,13 @@ class MaskProperties(wx.Panel):
256 256 sizer.Add(combo_thresh, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
257 257 sizer.Add(gradient, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT|wx.BOTTOM, 6)
258 258 sizer.Fit(self)
259   -
  259 +
260 260 self.SetSizer(sizer)
261 261 self.Update()
262 262 self.SetAutoLayout(1)
263   -
  263 +
264 264 # Non GUI stuff
265   -
  265 +
266 266 proj = Project()
267 267 self.threshold_modes = proj.threshold_modes
268 268 self.bind_evt_gradient = True
... ... @@ -280,7 +280,7 @@ class MaskProperties(wx.Panel):
280 280 'Set threshold values in gradient')
281 281 ps.Publisher().subscribe(self.SelectMaskName, 'Select mask name in combo')
282 282 ps.Publisher().subscribe(self.ChangeMaskName, 'Change mask name')
283   -
  283 +
284 284 def __bind_events_wx(self):
285 285 self.Bind(grad.EVT_THRESHOLD_CHANGE, self.OnSlideChanged, self.gradient)
286 286 self.combo_thresh.Bind(wx.EVT_COMBOBOX, self.OnComboThresh)
... ... @@ -290,7 +290,7 @@ class MaskProperties(wx.Panel):
290 290 def SelectMaskName(self, pubsub_evt):
291 291 index = pubsub_evt.data
292 292 self.combo_mask_name.SetSelection(index)
293   -
  293 +
294 294 def ChangeMaskName(self, pubsub_evt):
295 295 index, name = pubsub_evt.data
296 296 self.combo_mask_name.SetString(index, name)
... ... @@ -302,7 +302,7 @@ class MaskProperties(wx.Panel):
302 302 self.gradient.SetMinValue(thresh_min)
303 303 self.gradient.SetMaxValue(thresh_max)
304 304 self.bind_evt_gradient = True
305   -
  305 +
306 306 def SetItemsColour(self, evt_pubsub):
307 307 colour = evt_pubsub.data
308 308 self.gradient.SetColour(colour)
... ... @@ -329,7 +329,7 @@ class MaskProperties(wx.Panel):
329 329 (thresh_min, thresh_max) = self.threshold_modes[thresh_modes_names[default_thresh]]
330 330 self.gradient.SetMinValue(thresh_min)
331 331 self.gradient.SetMaxValue(thresh_max)
332   -
  332 +
333 333 def SetThresholdBounds(self, pubsub_evt):
334 334 thresh_min = pubsub_evt.data[0]
335 335 thresh_max = pubsub_evt.data[1]
... ... @@ -362,13 +362,13 @@ class EditionTools(wx.Panel):
362 362 def __init__(self, parent):
363 363 wx.Panel.__init__(self, parent, size=(50,240))
364 364 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
365   -
  365 +
366 366 ## LINE 1
367 367 text1 = wx.StaticText(self, -1, "Choose brush type, size or operation:")
368   -
  368 +
369 369 ## LINE 2
370 370 menu = wx.Menu()
371   -
  371 +
372 372 CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG)
373 373 item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, "Circle")
374 374 item.SetBitmap(CIRCLE_BMP)
... ... @@ -378,12 +378,12 @@ class EditionTools(wx.Panel):
378 378 item2.SetBitmap(SQUARE_BMP)
379 379  
380 380 menu.AppendItem(item)
381   - menu.AppendItem(item2)
382   -
  381 + menu.AppendItem(item2)
  382 +
383 383 bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP,
384 384 const.BRUSH_SQUARE: SQUARE_BMP}
385 385 selected_bmp = bmp_brush_format[const.DEFAULT_BRUSH_FORMAT]
386   -
  386 +
387 387 btn_brush_format = pbtn.PlateButton(self, wx.ID_ANY,"", selected_bmp,
388 388 style=pbtn.PB_STYLE_SQUARE)
389 389 btn_brush_format.SetMenu(menu)
... ... @@ -412,7 +412,7 @@ class EditionTools(wx.Panel):
412 412 text_thresh = wx.StaticText(self, -1, "Brush threshold range:")
413 413  
414 414 ## LINE 4
415   - gradient_thresh = grad.GradientSlider(self, -1, 0, 5000, 0, 5000,
  415 + gradient_thresh = grad.GradientSlider(self, -1, 0, 5000, 0, 5000,
416 416 (0, 0, 255, 100))
417 417 self.gradient_thresh = gradient_thresh
418 418 self.bind_evt_gradient = True
... ... @@ -425,12 +425,12 @@ class EditionTools(wx.Panel):
425 425 sizer.Add(gradient_thresh, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT|
426 426 wx.BOTTOM, 6)
427 427 sizer.Fit(self)
428   -
  428 +
429 429 self.SetSizer(sizer)
430 430 self.Update()
431 431 self.SetAutoLayout(1)
432 432  
433   - self.__bind_events()
  433 + self.__bind_events()
434 434 self.__bind_events_wx()
435 435  
436 436  
... ... @@ -439,7 +439,7 @@ class EditionTools(wx.Panel):
439 439 self.Bind(grad.EVT_THRESHOLD_CHANGE, self.OnGradientChanged,
440 440 self.gradient_thresh)
441 441 self.combo_brush_op.Bind(wx.EVT_COMBOBOX, self.OnComboBrushOp)
442   -
  442 +
443 443 def __bind_events(self):
444 444 ps.Publisher().subscribe(self.SetThresholdBounds,
445 445 'Update threshold limits')
... ... @@ -449,19 +449,19 @@ class EditionTools(wx.Panel):
449 449 def ChangeMaskColour(self, pubsub_evt):
450 450 colour = pubsub_evt.data
451 451 self.gradient_thresh.SetColour(colour)
452   -
  452 +
453 453 def SetGradientColour(self, pubsub_evt):
454 454 vtk_colour = pubsub_evt.data[3]
455 455 wx_colour = [c*255 for c in vtk_colour]
456 456 self.gradient_thresh.SetColour(wx_colour)
457   -
  457 +
458 458 def SetThresholdValues(self, pubsub_evt):
459 459 thresh_min, thresh_max = pubsub_evt.data
460 460 self.bind_evt_gradient = False
461 461 self.gradient_thresh.SetMinValue(thresh_min)
462 462 self.gradient_thresh.SetMaxValue(thresh_max)
463 463 self.bind_evt_gradient = True
464   -
  464 +
465 465 def SetThresholdBounds(self, pubsub_evt):
466 466 thresh_min = pubsub_evt.data[0]
467 467 thresh_max = pubsub_evt.data[1]
... ... @@ -469,14 +469,14 @@ class EditionTools(wx.Panel):
469 469 self.gradient_thresh.SetMaxRange(thresh_max)
470 470 self.gradient_thresh.SetMinValue(thresh_min)
471 471 self.gradient_thresh.SetMaxValue(thresh_max)
472   -
  472 +
473 473 def OnGradientChanged(self, evt):
474 474 thresh_min = self.gradient_thresh.GetMinValue()
475 475 thresh_max = self.gradient_thresh.GetMaxValue()
476 476 if self.bind_evt_gradient:
477 477 ps.Publisher().sendMessage('Set edition threshold values',
478 478 (thresh_min, thresh_max))
479   -
  479 +
480 480 def OnMenu(self, evt):
481 481 SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG)
482 482 CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG)
... ... @@ -487,7 +487,7 @@ class EditionTools(wx.Panel):
487 487 MENU_BRUSH_SQUARE: SQUARE_BMP}
488 488  
489 489 self.btn_brush_format.SetBitmap(bitmap[evt.GetId()])
490   -
  490 +
491 491 ps.Publisher().sendMessage('Set brush format', brush[evt.GetId()])
492 492  
493 493 def OnBrushSize(self, evt):
... ... @@ -496,9 +496,9 @@ class EditionTools(wx.Panel):
496 496 # in the text ctrl - so we are capturing only changes on text
497 497 # Strangelly this is being called twice
498 498 ps.Publisher().sendMessage('Set edition brush size',self.spin.GetValue())
499   -
  499 +
500 500 def OnComboBrushOp(self, evt):
501 501 brush_op_id = evt.GetSelection()
502 502 ps.Publisher().sendMessage('Set edition operation', brush_op_id)
503   -
  503 +
504 504  
... ...
invesalius/gui/task_surface.py
... ... @@ -42,14 +42,14 @@ OP_LIST = [&quot;Draw&quot;, &quot;Erase&quot;, &quot;Threshold&quot;]
42 42 class TaskPanel(wx.Panel):
43 43 def __init__(self, parent):
44 44 wx.Panel.__init__(self, parent)
45   -
  45 +
46 46 inner_panel = InnerTaskPanel(self)
47 47  
48 48 sizer = wx.BoxSizer(wx.HORIZONTAL)
49 49 sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT |
50 50 wx.LEFT, 7)
51 51 sizer.Fit(self)
52   -
  52 +
53 53 self.SetSizer(sizer)
54 54 self.Update()
55 55 self.SetAutoLayout(1)
... ... @@ -60,7 +60,7 @@ class TaskPanel(wx.Panel):
60 60 # Contour - slider
61 61 # enable / disable Fill holes
62 62  
63   -class InnerTaskPanel(wx.Panel):
  63 +class InnerTaskPanel(wx.Panel):
64 64 def __init__(self, parent):
65 65 wx.Panel.__init__(self, parent)
66 66 default_colour = self.GetBackgroundColour()
... ... @@ -71,10 +71,10 @@ class InnerTaskPanel(wx.Panel):
71 71 BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG)
72 72 BMP_ADD.SetWidth(25)
73 73 BMP_ADD.SetHeight(25)
74   -
  74 +
75 75 # Button for creating new surface
76 76 button_new_surface = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\
77   - pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG)
  77 + pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT)
78 78 self.Bind(wx.EVT_BUTTON, self.OnButton)
79 79  
80 80 # Fixed hyperlink items
... ... @@ -100,20 +100,20 @@ class InnerTaskPanel(wx.Panel):
100 100 button_next = wx.Button(self, -1, "Next step")
101 101 button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
102 102 #button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask)
103   -
  103 +
104 104 # Add line sizers into main sizer
105 105 main_sizer = wx.BoxSizer(wx.VERTICAL)
106 106 main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
107 107 main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5)
108 108 main_sizer.Add(button_next, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.BOTTOM, 5)
109 109 main_sizer.Fit(self)
110   -
  110 +
111 111 self.SetSizer(main_sizer)
112 112 self.Update()
113 113 self.SetAutoLayout(1)
114 114  
115 115 self.sizer = main_sizer
116   -
  116 +
117 117 def OnButton(self, evt):
118 118 id = evt.GetId()
119 119 if id == BTN_NEW:
... ... @@ -123,7 +123,7 @@ class InnerTaskPanel(wx.Panel):
123 123 self.OnLinkNewSurface()
124 124 if evt:
125 125 evt.Skip()
126   -
  126 +
127 127 def OnLinkNewSurface(self, evt=None):
128 128 dlg = NewSurfaceDialog(self, -1, 'InVesalius 3.0 - New surface')
129 129 if dlg.ShowModal() == wx.ID_OK:
... ... @@ -131,10 +131,10 @@ class InnerTaskPanel(wx.Panel):
131 131 dlg.Destroy()
132 132 if evt:
133 133 evt.Skip()
134   -
  134 +
135 135 class NewSurfaceDialog(wx.Dialog):
136 136 def __init__(self, parent, ID, title, size=wx.DefaultSize,
137   - pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE,
  137 + pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE,
138 138 useMetal=False):
139 139  
140 140 # Instead of calling wx.Dialog.__init__ we precreate the dialog
... ... @@ -158,7 +158,7 @@ class NewSurfaceDialog(wx.Dialog):
158 158  
159 159 # Now continue with the normal construction of the dialog
160 160 # contents
161   -
  161 +
162 162 # Label related to mask name
163 163 label_mask = wx.StaticText(self, -1, "Select mask to be used for creating 3D surface:")
164 164  
... ... @@ -176,7 +176,7 @@ class NewSurfaceDialog(wx.Dialog):
176 176 text.SetHelpText("Name the new surface to be created")
177 177 text.SetValue("Default 3D")
178 178 self.text = text
179   -
  179 +
180 180 sizer = wx.BoxSizer(wx.VERTICAL)
181 181 sizer.Add(label_mask, 0, wx.ALL|wx.GROW|wx.EXPAND, 5)
182 182 sizer.Add(combo_surface_name, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
... ... @@ -184,11 +184,11 @@ class NewSurfaceDialog(wx.Dialog):
184 184 sizer.Add(text, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT, 10)
185 185  
186 186 btnsizer = wx.StdDialogButtonSizer()
187   -
  187 +
188 188 #if wx.Platform != "__WXMSW__":
189 189 # btn = wx.ContextHelpButton(self)
190 190 # btnsizer.AddButton(btn)
191   -
  191 +
192 192 btn = wx.Button(self, wx.ID_OK)
193 193 btn.SetDefault()
194 194 btnsizer.AddButton(btn)
... ... @@ -204,28 +204,28 @@ class NewSurfaceDialog(wx.Dialog):
204 204  
205 205 def GetValue(self):
206 206 return self.text.GetValue() +"| mask: "+ MASK_LIST[self.combo_surface_name.GetSelection()]
207   -
  207 +
208 208 class FoldPanel(wx.Panel):
209 209 def __init__(self, parent):
210 210 wx.Panel.__init__(self, parent, size=(50,50))
211 211 self.SetBackgroundColour(wx.Colour(0,255,0))
212   -
  212 +
213 213 inner_panel = InnerFoldPanel(self)
214   -
215   - sizer = wx.BoxSizer(wx.VERTICAL)
  214 +
  215 + sizer = wx.BoxSizer(wx.VERTICAL)
216 216 sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2)
217 217 sizer.Fit(self)
218   -
  218 +
219 219 self.SetSizer(sizer)
220 220 self.Update()
221 221 self.SetAutoLayout(1)
222   -
  222 +
223 223 class InnerFoldPanel(wx.Panel):
224 224 def __init__(self, parent):
225 225 wx.Panel.__init__(self, parent)
226 226 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
227 227 #self.SetBackgroundColour(wx.Colour(0,0,0))
228   -
  228 +
229 229 # Fold panel and its style settings
230 230 # FIXME: If we dont insert a value in size or if we set wx.DefaultSize,
231 231 # the fold_panel doesnt show. This means that, for some reason, Sizer
... ... @@ -246,7 +246,7 @@ class InnerFoldPanel(wx.Panel):
246 246 fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), Spacing= 0,
247 247 leftSpacing=0, rightSpacing=0)
248 248 fold_panel.Expand(fold_panel.GetFoldPanel(0))
249   -
  249 +
250 250 # Fold 2 - Surface quality
251 251 item = fold_panel.AddFoldPanel("Surface quality", collapsed=True)
252 252 fold_panel.ApplyCaptionStyle(item, style)
... ... @@ -258,7 +258,7 @@ class InnerFoldPanel(wx.Panel):
258 258 sizer = wx.BoxSizer(wx.VERTICAL)
259 259 sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND)
260 260 sizer.Fit(self)
261   -
  261 +
262 262 self.SetSizer(sizer)
263 263 self.Update()
264 264 self.SetAutoLayout(1)
... ... @@ -267,9 +267,9 @@ class SurfaceProperties(wx.Panel):
267 267 def __init__(self, parent):
268 268 wx.Panel.__init__(self, parent, size=(50,240))
269 269 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
270   -
  270 +
271 271 ## LINE 1
272   -
  272 +
273 273 # Combo related to mask naem
274 274 combo_surface_name = wx.ComboBox(self, -1, "", choices= SURFACE_LIST,
275 275 style=wx.CB_DROPDOWN|wx.CB_READONLY)
... ... @@ -277,56 +277,56 @@ class SurfaceProperties(wx.Panel):
277 277 combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
278 278 combo_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboName)
279 279 self.combo_surface_name = combo_surface_name
280   -
  280 +
281 281 # Mask colour
282 282 button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(-1,22))
283 283 button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
284 284 self.button_colour = button_colour
285   -
  285 +
286 286 # Sizer which represents the first line
287 287 line1 = wx.BoxSizer(wx.HORIZONTAL)
288 288 line1.Add(combo_surface_name, 1, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 2)
289   - line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2)
290   -
291   -
  289 + line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2)
  290 +
  291 +
292 292 ## LINE 2
293   -
  293 +
294 294 text_transparency = wx.StaticText(self, -1, "Transparency:")
295   -
  295 +
296 296 slider_transparency = wx.Slider(self, -1, 0, MIN_TRANSPARENCY,
297   - MAX_TRANSPARENCY,
  297 + MAX_TRANSPARENCY,
298 298 style=wx.SL_HORIZONTAL)#|wx.SL_AUTOTICKS)
299 299 slider_transparency.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
300 300 slider_transparency.Bind(wx.EVT_SLIDER, self.OnTransparency)
301 301 self.slider_transparency = slider_transparency
302   -
303   -
  302 +
  303 +
304 304 ## MIX LINE 2 AND 3
305 305 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT
306 306 flag_slider = wx.EXPAND | wx.GROW| wx.LEFT|wx.TOP
307 307 flag_combo = wx.EXPAND | wx.GROW| wx.LEFT
308   -
  308 +
309 309 fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=2, vgap=4)
310 310 fixed_sizer.AddMany([ (text_transparency, 0, flag_link, 0),
311 311 (slider_transparency, 1, flag_slider,4)])
312   -
  312 +
313 313 # LINE 4
314 314 #cb = wx.CheckBox(self, -1, "Fill largest surface holes")
315 315 #cb.SetValue(True)
316   -
  316 +
317 317 # Add all lines into main sizer
318 318 sizer = wx.BoxSizer(wx.VERTICAL)
319 319 sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
320 320 sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
321 321 #sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5)
322 322 sizer.Fit(self)
323   -
  323 +
324 324 self.SetSizer(sizer)
325 325 self.Update()
326 326 self.SetAutoLayout(1)
327   -
  327 +
328 328 self.__bind_events()
329   -
  329 +
330 330 def __bind_events(self):
331 331 ps.Publisher().subscribe(self.InsertNewSurface,
332 332 'Update surface info in GUI')
... ... @@ -344,10 +344,10 @@ class SurfaceProperties(wx.Panel):
344 344 colour = [value*255 for value in pubsub_evt.data[2]]
345 345 transparency = 100*pubsub_evt.data[4]
346 346 index = self.combo_surface_name.Append(name)
347   - self.combo_surface_name.SetSelection(index)
  347 + self.combo_surface_name.SetSelection(index)
348 348 self.button_colour.SetColour(colour)
349 349 self.slider_transparency.SetValue(transparency)
350   -
  350 +
351 351 def OnComboName(self, evt):
352 352 print "TODO: Send Signal - Change 3D surface selected: %s" % (evt.GetString())
353 353  
... ... @@ -373,19 +373,19 @@ class QualityAdjustment(wx.Panel):
373 373 def __init__(self, parent):
374 374 wx.Panel.__init__(self, parent, size=(50,240))
375 375 self.SetBackgroundColour(wx.Colour(221, 221, 221, 255))
376   -
  376 +
377 377 # LINE 1
378 378 combo_quality = wx.ComboBox(self, -1, "", choices= QUALITY_LIST,
379 379 style=wx.CB_DROPDOWN|wx.CB_READONLY)
380 380 combo_quality.SetSelection(3)
381 381 combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
382   - #combo_quality.Bind(wx.EVT_COMBOBOX, self.OnComboQuality)
383   -
  382 + #combo_quality.Bind(wx.EVT_COMBOBOX, self.OnComboQuality)
  383 +
384 384 # LINE 2
385 385 check_decimate = wx.CheckBox(self, -1, "")
386   -
  386 +
387 387 text_decimate = wx.StaticText(self, -1, "Decimate resolution:")
388   -
  388 +
389 389 spin_decimate = wx.SpinCtrl(self, -1, "", (30, 50))
390 390 spin_decimate.SetRange(1,100)
391 391 spin_decimate.SetValue(30)
... ... @@ -393,18 +393,18 @@ class QualityAdjustment(wx.Panel):
393 393  
394 394 # LINE 3
395 395 check_smooth = wx.CheckBox(self, -1, "")
396   -
  396 +
397 397 text_smooth = wx.StaticText(self, -1, "Smooth iterations:")
398   -
  398 +
399 399 spin_smooth = wx.SpinCtrl(self, -1, "", (30, 50))
400 400 spin_smooth.SetRange(1,100)
401 401 spin_smooth.SetValue(0)
402   -
  402 +
403 403 # MIXED LINE 2 AND 3
404 404 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT|wx.LEFT
405 405 flag_slider = wx.EXPAND | wx.GROW| wx.LEFT|wx.TOP
406 406 flag_combo = wx.EXPAND | wx.GROW| wx.LEFT
407   -
  407 +
408 408 fixed_sizer = wx.FlexGridSizer(rows=2, cols=3, hgap=2, vgap=0)
409 409 fixed_sizer.AddMany([ (check_decimate, 0, flag_combo, 2),
410 410 (text_decimate, 0, flag_slider, 7),
... ... @@ -413,19 +413,18 @@ class QualityAdjustment(wx.Panel):
413 413 (text_smooth, 0, flag_slider, 7),
414 414 (spin_smooth, 1, flag_link, 14)])
415 415 fixed_sizer.AddGrowableCol(2)
416   -
  416 +
417 417 sizer = wx.BoxSizer(wx.VERTICAL)
418 418 sizer.Add(combo_quality, 1, wx.EXPAND|wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP, 5)
419 419 sizer.Add(fixed_sizer, 0, wx.LEFT|wx.RIGHT, 5)
420 420 sizer.Fit(self)
421   -
  421 +
422 422 self.SetSizer(sizer)
423 423 self.Update()
424 424 self.SetAutoLayout(1)
425   -
  425 +
426 426 def OnComboQuality(self, evt):
427 427 print "TODO: Send Signal - Change surface quality: %s" % (evt.GetString())
428   -
  428 +
429 429 def OnDecimate(self, evt):
430 430 print "TODO: Send Signal - Decimate: %s" % float(self.spin.GetValue())/100
431   -
432 431 \ No newline at end of file
... ...
invesalius/gui/task_tools.py
... ... @@ -29,19 +29,19 @@ ID_BTN_ANNOTATION = wx.NewId()
29 29 class TaskPanel(wx.Panel):
30 30 def __init__(self, parent):
31 31 wx.Panel.__init__(self, parent)
32   -
  32 +
33 33 inner_panel = InnerTaskPanel(self)
34   -
  34 +
35 35 sizer = wx.BoxSizer(wx.HORIZONTAL)
36 36 sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT |
37 37 wx.LEFT, 7)
38 38 sizer.Fit(self)
39   -
  39 +
40 40 self.SetSizer(sizer)
41 41 self.Update()
42 42 self.SetAutoLayout(1)
43   -
44   -class InnerTaskPanel(wx.Panel):
  43 +
  44 +class InnerTaskPanel(wx.Panel):
45 45 def __init__(self, parent):
46 46 wx.Panel.__init__(self, parent)
47 47 self.SetBackgroundColour(wx.Colour(255,255,255))
... ... @@ -49,7 +49,7 @@ class InnerTaskPanel(wx.Panel):
49 49  
50 50 # Counter for projects loaded in current GUI
51 51 self.proj_count = 0
52   -
  52 +
53 53 # Floating items (to be inserted)
54 54 self.float_hyper_list = []
55 55  
... ... @@ -66,7 +66,7 @@ class InnerTaskPanel(wx.Panel):
66 66 txt_annotation.AutoBrowse(False)
67 67 txt_annotation.UpdateLink()
68 68 txt_annotation.Bind(hl.EVT_HYPERLINK_LEFT, self.OnTextAnnotation)
69   -
  69 +
70 70 # Image(s) for buttons
71 71 BMP_ANNOTATE = wx.Bitmap("../icons/annotation.png", wx.BITMAP_TYPE_PNG)
72 72 BMP_ANGLE = wx.Bitmap("../icons/measure_angle.jpg", wx.BITMAP_TYPE_JPEG)
... ... @@ -77,16 +77,16 @@ class InnerTaskPanel(wx.Panel):
77 77 BMP_ANGLE.SetHeight(25)
78 78 BMP_DISTANCE.SetWidth(25)
79 79 BMP_DISTANCE.SetHeight(25)
80   -
  80 +
81 81 # Buttons related to hyperlinks
82   - button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_NOBG
83   -
  82 + button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT
  83 +
84 84 button_measure_linear = pbtn.PlateButton(self, ID_BTN_MEASURE_LINEAR, "",
85 85 BMP_DISTANCE, style=button_style)
86   - button_measure_angular = pbtn.PlateButton(self, ID_BTN_MEASURE_ANGULAR, "",
  86 + button_measure_angular = pbtn.PlateButton(self, ID_BTN_MEASURE_ANGULAR, "",
87 87 BMP_ANGLE, style=button_style)
88 88  
89   - button_annotation = pbtn.PlateButton(self, ID_BTN_ANNOTATION, "",
  89 + button_annotation = pbtn.PlateButton(self, ID_BTN_ANNOTATION, "",
90 90 BMP_ANNOTATE, style=button_style)
91 91  
92 92 # When using PlaneButton, it is necessary to bind events from parent win
... ... @@ -103,35 +103,34 @@ class InnerTaskPanel(wx.Panel):
103 103 sizer.Add(txt_annotation, pos=(1,0),flag=wx.GROW|wx.EXPAND)
104 104 sizer.Add(button_annotation, pos=(1,2),span=(2,1), flag=wx.GROW|wx.EXPAND)
105 105 sizer.AddGrowableCol(0)
106   -
  106 +
107 107 # Add line sizers into main sizer
108 108 main_sizer = wx.BoxSizer(wx.VERTICAL)
109 109 main_sizer.Add(sizer, 0, wx.GROW|wx.EXPAND)
110 110 main_sizer.Fit(self)
111   -
112   - # Update main sizer and panel layout
  111 +
  112 + # Update main sizer and panel layout
113 113 self.SetSizer(sizer)
114 114 self.Fit()
115 115 self.sizer = main_sizer
116 116  
117 117 def OnTextAnnotation(self, evt=None):
118 118 print "TODO: Send Signal - Add text annotation (both 2d and 3d)"
119   -
  119 +
120 120 def OnLinkLinearMeasure(self):
121 121 print "TODO: Send Signal - Add linear measure (both 2d and 3d)"
122 122  
123 123 def OnLinkAngularMeasure(self):
124 124 print "TODO: Send Signal - Add angular measure (both 2d and 3d)"
125   -
  125 +
126 126 def OnButton(self, evt):
127 127 id = evt.GetId()
128   -
  128 +
129 129 if id == ID_BTN_MEASURE_LINEAR:
130 130 self.OnLinkLinearMeasure()
131 131 elif id == ID_BTN_MEASURE_ANGULAR:
132 132 self.OnLinkAngularMeasure()
133 133 else: # elif id == ID_BTN_ANNOTATION:
134 134 self.OnTextAnnotation()
135   -
136 135  
137   -
138 136 \ No newline at end of file
  137 +
... ...