Commit 4ed57aabd87a640a2ad7741b67b576aec7263e6f
1 parent
fd9af976
Exists in
master
and in
68 other branches
ENH: In the process of adjusting raycasting plane
Showing
3 changed files
with
36 additions
and
8 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -160,5 +160,5 @@ RAYCASTING_TYPES = [filename.split(".")[0] for filename in |
160 | 160 | RAYCASTING_TYPES.append(' Off') |
161 | 161 | RAYCASTING_TYPES.sort() |
162 | 162 | RAYCASTING_OFF_LABEL = ' Off' |
163 | -RAYCASTING_TOOLS = ["Plane cutter"] | |
163 | +RAYCASTING_TOOLS = ["Cut plane"] | |
164 | 164 | ... | ... |
invesalius/data/volume.py
... | ... | @@ -92,6 +92,8 @@ class Volume(): |
92 | 92 | 'Set raycasting refresh') |
93 | 93 | ps.Publisher().subscribe(self.OnSetRelativeWindowLevel, |
94 | 94 | 'Set raycasting relative window and level') |
95 | + ps.Publisher().subscribe(self.OnEnableTool, | |
96 | + 'Enable raycasting tool') | |
95 | 97 | |
96 | 98 | def OnLoadVolume(self, pubsub_evt): |
97 | 99 | label = pubsub_evt.data |
... | ... | @@ -386,6 +388,7 @@ class Volume(): |
386 | 388 | self.Create8bOpacityTable(scale) |
387 | 389 | |
388 | 390 | image2 = self.ApplyConvolution(image2.GetOutput()) |
391 | + self.final_imagedata = image2 | |
389 | 392 | |
390 | 393 | composite_function = vtk.vtkVolumeRayCastCompositeFunction() |
391 | 394 | composite_function.SetCompositeMethodToInterpolateFirst() |
... | ... | @@ -454,6 +457,11 @@ class Volume(): |
454 | 457 | colour = self.GetBackgroundColour() |
455 | 458 | ps.Publisher().sendMessage('Load volume into viewer', (volume, colour)) |
456 | 459 | |
460 | + def OnEnableTool(self, pubsub_evt): | |
461 | + tool_name = pubsub_evt.data | |
462 | + if tool_name == "Cut plane": | |
463 | + plane = CutPlane(self.final_imagedata, self.volume_mapper) | |
464 | + | |
457 | 465 | def TranslateScale(self, scale, value): |
458 | 466 | #if value < 0: |
459 | 467 | # valor = 2**16 - abs(value) | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -176,7 +176,7 @@ import wx.lib.colourselect as csel |
176 | 176 | import constants as const |
177 | 177 | |
178 | 178 | [BUTTON_RAYCASTING, BUTTON_VIEW] = [wx.NewId() for num in xrange(2)] |
179 | - | |
179 | +RAYCASTING_TOOLS = wx.NewId() | |
180 | 180 | |
181 | 181 | ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], |
182 | 182 | const.VOL_BACK: ["Back", "../icons/view_back.png"], |
... | ... | @@ -189,6 +189,7 @@ ID_TO_BMP = {const.VOL_FRONT: ["Front", "../icons/view_front.png"], |
189 | 189 | |
190 | 190 | ID_TO_NAME = {} |
191 | 191 | ID_TO_TOOL = {} |
192 | +ID_TO_TOOL_ITEM = {} | |
192 | 193 | |
193 | 194 | class VolumeViewerCover(wx.Panel): |
194 | 195 | def __init__(self, parent): |
... | ... | @@ -208,6 +209,7 @@ class VolumeToolPanel(wx.Panel): |
208 | 209 | BMP_RAYCASTING = wx.Bitmap("../icons/volume_raycasting.png", |
209 | 210 | wx.BITMAP_TYPE_PNG) |
210 | 211 | |
212 | + # MENU RELATED TO RAYCASTING TYPES | |
211 | 213 | menu = wx.Menu() |
212 | 214 | for name in const.RAYCASTING_TYPES: |
213 | 215 | id = wx.NewId() |
... | ... | @@ -218,22 +220,25 @@ class VolumeToolPanel(wx.Panel): |
218 | 220 | ID_TO_NAME[id] = name |
219 | 221 | |
220 | 222 | menu.AppendSeparator() |
223 | + # MENU RELATED TO RAYCASTING TOOLS | |
221 | 224 | submenu = wx.Menu() |
222 | - for tool in const.RAYCASTING_TOOLS: | |
225 | + for name in const.RAYCASTING_TOOLS: | |
223 | 226 | id = wx.NewId() |
224 | 227 | item = wx.MenuItem(submenu, id, name, kind=wx.ITEM_CHECK) |
225 | 228 | submenu.AppendItem(item) |
226 | 229 | ID_TO_TOOL[id] = name |
230 | + ID_TO_TOOL_ITEM[id] = item | |
231 | + #submenu.Enable(0) | |
232 | + self.submenu_raycasting_tools = submenu | |
233 | + menu.AppendMenu(RAYCASTING_TOOLS, "Tools", submenu) | |
234 | + menu.Enable(RAYCASTING_TOOLS, 0) | |
227 | 235 | |
228 | 236 | self.menu_raycasting = menu |
229 | 237 | menu.Bind(wx.EVT_MENU, self.OnMenuRaycasting) |
230 | 238 | |
231 | - #button_raycasting=btn.GenBitmapToggleButton(self, 1, BMP_RAYCASTING, size=(24,24)) | |
232 | - #self.button_raycasting_toggle = 0 | |
233 | 239 | button_raycasting = pbtn.PlateButton(self, BUTTON_RAYCASTING,"", |
234 | 240 | BMP_RAYCASTING, style=pbtn.PB_STYLE_SQUARE, |
235 | 241 | size=(24,24)) |
236 | - #self.Bind(wx.EVT_BUTTON, self.OnToggleRaycasting) | |
237 | 242 | button_raycasting.SetMenu(menu) |
238 | 243 | |
239 | 244 | self.button_raycasting = button_raycasting |
... | ... | @@ -274,11 +279,26 @@ class VolumeToolPanel(wx.Panel): |
274 | 279 | """Events from raycasting menu.""" |
275 | 280 | id = evt.GetId() |
276 | 281 | if id in ID_TO_NAME.keys(): |
282 | + name = ID_TO_NAME[evt.GetId()] | |
277 | 283 | ps.Publisher().sendMessage('Load raycasting preset', |
278 | 284 | ID_TO_NAME[evt.GetId()]) |
285 | + if name != const.RAYCASTING_OFF_LABEL: | |
286 | + self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) | |
287 | + else: | |
288 | + self.menu_raycasting.Enable(RAYCASTING_TOOLS, 0) | |
279 | 289 | else: |
280 | - ps.Publisher().sendMessage('Enable raycasting tool', | |
281 | - ID_TO_TOOL(evt.GetId()) | |
290 | + item = ID_TO_TOOL_ITEM[evt.GetId()] | |
291 | + if not item.IsChecked(): | |
292 | + for i in ID_TO_TOOL_ITEM.values(): | |
293 | + if i is not item: | |
294 | + i.Check(0) | |
295 | + | |
296 | + ps.Publisher().sendMessage('Enable raycasting tool', | |
297 | + [ID_TO_TOOL[evt.GetId()],1]) | |
298 | + else: | |
299 | + ps.Publisher().sendMessage('Enable raycasting tool', | |
300 | + [ID_TO_TOOL[evt.GetId()],0]) | |
301 | + | |
282 | 302 | |
283 | 303 | def OnMenuView(self, evt): |
284 | 304 | """Events from button menus.""" | ... | ... |