Commit 233d55c0d8981d6105b53090e691b6c7ed9f5777
1 parent
e64f9318
Exists in
master
and in
68 other branches
FIX: Raycasting startup (show WW/WL, bkg colour)
Showing
3 changed files
with
44 additions
and
18 deletions
Show diff stats
invesalius/data/viewer_volume.py
| ... | ... | @@ -60,15 +60,20 @@ class Viewer(wx.Panel): |
| 60 | 60 | self.interactor = interactor |
| 61 | 61 | self.ren = ren |
| 62 | 62 | |
| 63 | + self.raycasting_volume = False | |
| 64 | + | |
| 63 | 65 | self.onclick = False |
| 64 | 66 | |
| 67 | + self.text = vtku.Text() | |
| 68 | + | |
| 69 | + self.view_angle = None | |
| 70 | + | |
| 65 | 71 | self.__bind_events() |
| 66 | 72 | self.__bind_events_wx() |
| 67 | 73 | |
| 68 | - self.view_angle = None | |
| 69 | - | |
| 74 | + | |
| 70 | 75 | def OnMove(self, obj, evt): |
| 71 | - if self.onclick: | |
| 76 | + if self.onclick and self.raycasting_volume: | |
| 72 | 77 | mouse_x, mouse_y = self.interactor.GetEventPosition() |
| 73 | 78 | diff_x = mouse_x - self.last_x |
| 74 | 79 | diff_y = mouse_y - self.last_y |
| ... | ... | @@ -92,15 +97,22 @@ class Viewer(wx.Panel): |
| 92 | 97 | 'Render volume viewer') |
| 93 | 98 | ps.Publisher().subscribe(self.ChangeBackgroundColour, |
| 94 | 99 | 'Change volume viewer background colour') |
| 100 | + # Raycating - related | |
| 95 | 101 | ps.Publisher().subscribe(self.LoadVolume, |
| 96 | 102 | 'Load volume into viewer') |
| 103 | + ps.Publisher().subscribe(self.OnSetWindowLevelText, | |
| 104 | + 'Set volume window and level text') | |
| 105 | + ps.Publisher().subscribe(self.OnHideRaycasting, | |
| 106 | + 'Hide raycasting volume') | |
| 107 | + ps.Publisher().subscribe(self.OnShowRaycasting, | |
| 108 | + 'Update raycasting preset') | |
| 109 | + ### | |
| 97 | 110 | ps.Publisher().subscribe(self.AppendActor,'AppendActor') |
| 98 | 111 | ps.Publisher().subscribe(self.SetWidgetInteractor, |
| 99 | 112 | 'Set Widget Interactor') |
| 100 | 113 | ps.Publisher().subscribe(self.OnSetViewAngle, |
| 101 | 114 | 'Set volume view angle') |
| 102 | - ps.Publisher().subscribe(self.OnSetWindowLevelText, | |
| 103 | - 'Set volume window and level text') | |
| 115 | + | |
| 104 | 116 | ps.Publisher().subscribe(self.OnEnableBrightContrast, |
| 105 | 117 | ('Set interaction mode', const.MODE_WW_WL)) |
| 106 | 118 | ps.Publisher().subscribe(self.OnDisableBrightContrast, |
| ... | ... | @@ -133,19 +145,33 @@ class Viewer(wx.Panel): |
| 133 | 145 | evt.Skip() |
| 134 | 146 | |
| 135 | 147 | def OnSetWindowLevelText(self, pubsub_evt): |
| 136 | - ww, wl = pubsub_evt.data | |
| 137 | - self.text.SetValue("WL: %d WW: %d"%(wl, ww)) | |
| 148 | + if self.raycasting_volume: | |
| 149 | + ww, wl = pubsub_evt.data | |
| 150 | + self.text.SetValue("WL: %d WW: %d"%(wl, ww)) | |
| 151 | + | |
| 152 | + def OnShowRaycasting(self, pubsub_evt): | |
| 153 | + self.raycasting_volume = True | |
| 154 | + self.text.Show() | |
| 155 | + | |
| 156 | + def OnHideRaycasting(self, pubsub_evt): | |
| 157 | + self.raycasting_volume = False | |
| 158 | + self.text.Hide() | |
| 138 | 159 | |
| 139 | 160 | def LoadVolume(self, pubsub_evt): |
| 161 | + self.raycasting_volume = True | |
| 162 | + | |
| 140 | 163 | volume = pubsub_evt.data[0] |
| 164 | + colour = pubsub_evt.data[1] | |
| 165 | + ww, wl = pubsub_evt.data[2] | |
| 166 | + | |
| 141 | 167 | self.light = self.ren.GetLights().GetNextItem() |
| 142 | 168 | |
| 143 | - text = vtku.Text() | |
| 144 | - self.text = text | |
| 145 | - | |
| 146 | 169 | self.ren.AddVolume(volume) |
| 147 | - self.ren.AddActor(text.actor) | |
| 148 | - | |
| 170 | + self.text.SetValue("WL: %d WW: %d"%(wl, ww)) | |
| 171 | + self.ren.AddActor(self.text.actor) | |
| 172 | + self.ren.SetBackground(colour) | |
| 173 | + | |
| 174 | + | |
| 149 | 175 | if not (self.view_angle): |
| 150 | 176 | self.SetViewAngle(const.VOL_FRONT) |
| 151 | 177 | else: | ... | ... |
invesalius/data/volume.py
| ... | ... | @@ -100,10 +100,8 @@ class Volume(): |
| 100 | 100 | self.LoadVolume() |
| 101 | 101 | |
| 102 | 102 | def OnHideVolume(self, pubsub_evt): |
| 103 | - print "Hide", self.plane, self.plane_on | |
| 104 | 103 | self.volume.SetVisibility(0) |
| 105 | 104 | if (self.plane and self.plane_on): |
| 106 | - print "--- Hide Plane" | |
| 107 | 105 | self.plane.Disable() |
| 108 | 106 | ps.Publisher().sendMessage('Render volume viewer') |
| 109 | 107 | |
| ... | ... | @@ -111,7 +109,6 @@ class Volume(): |
| 111 | 109 | if self.exist: |
| 112 | 110 | self.volume.SetVisibility(1) |
| 113 | 111 | if (self.plane and self.plane_on): |
| 114 | - print "----- Show Plane" | |
| 115 | 112 | self.plane.Enable() |
| 116 | 113 | ps.Publisher().sendMessage('Render volume viewer') |
| 117 | 114 | else: |
| ... | ... | @@ -162,7 +159,6 @@ class Volume(): |
| 162 | 159 | |
| 163 | 160 | def OnSetRelativeWindowLevel(self, pubsub_evt): |
| 164 | 161 | diff_ww, diff_wl = pubsub_evt.data |
| 165 | - print diff_ww | |
| 166 | 162 | ww = self.ww + diff_ww |
| 167 | 163 | wl = self.wl + diff_wl |
| 168 | 164 | ps.Publisher().sendMessage('Set volume window and level text', |
| ... | ... | @@ -365,7 +361,6 @@ class Volume(): |
| 365 | 361 | def ApplyConvolution(self, imagedata): |
| 366 | 362 | number_filters = len(self.config['convolutionFilters']) |
| 367 | 363 | for filter in self.config['convolutionFilters']: |
| 368 | - print "convolving", filter | |
| 369 | 364 | convolve = vtk.vtkImageConvolve() |
| 370 | 365 | convolve.SetInput(imagedata) |
| 371 | 366 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) |
| ... | ... | @@ -471,7 +466,9 @@ class Volume(): |
| 471 | 466 | self.volume = volume |
| 472 | 467 | |
| 473 | 468 | colour = self.GetBackgroundColour() |
| 474 | - ps.Publisher().sendMessage('Load volume into viewer', (volume, colour)) | |
| 469 | + | |
| 470 | + ps.Publisher().sendMessage('Load volume into viewer', | |
| 471 | + (volume, colour, (self.ww, self.wl))) | |
| 475 | 472 | |
| 476 | 473 | def OnEnableTool(self, pubsub_evt): |
| 477 | 474 | tool_name, enable = pubsub_evt.data | ... | ... |