Commit 5de709ee1731a30b619e071f616a231b75b5ac22
1 parent
01a03174
Exists in
master
and in
68 other branches
ENH: Using wx events instead of pubsub messages in clut_raycasting. FIX: fix a e…
…rror when altering color in clut_raycasting
Showing
4 changed files
with
19 additions
and
9 deletions
Show diff stats
invesalius/data/viewer_volume.py
invesalius/data/volume.py
... | ... | @@ -125,7 +125,7 @@ class Volume(): |
125 | 125 | if self.exist: |
126 | 126 | self.__load_preset() |
127 | 127 | self.volume.SetVisibility(1) |
128 | - ps.Publisher().sendMessage('Render volume viewer') | |
128 | + #ps.Publisher().sendMessage('Render volume viewer') | |
129 | 129 | else: |
130 | 130 | self.LoadVolume() |
131 | 131 | self.exist = 1 |
... | ... | @@ -140,10 +140,16 @@ class Volume(): |
140 | 140 | if self.config['advancedCLUT']: |
141 | 141 | self.Create16bColorTable(self.scale) |
142 | 142 | self.CreateOpacityTable(self.scale) |
143 | + self.CalculateWWWL() | |
144 | + ww = self.ww | |
145 | + wl = self.wl | |
146 | + ps.Publisher().sendMessage('Set volume window and level text', | |
147 | + (ww, wl)) | |
143 | 148 | else: |
144 | 149 | self.Create8bColorTable(self.scale) |
145 | 150 | self.Create8bOpacityTable(self.scale) |
146 | 151 | |
152 | + | |
147 | 153 | def __load_preset(self): |
148 | 154 | # Update colour table |
149 | 155 | self.__update_colour_table() |
... | ... | @@ -185,7 +191,11 @@ class Volume(): |
185 | 191 | def SetWWWL(self, ww, wl): |
186 | 192 | |
187 | 193 | if self.config['advancedCLUT']: |
188 | - curve = self.config['16bitClutCurves'][self.curve] | |
194 | + try: | |
195 | + curve = self.config['16bitClutCurves'][self.curve] | |
196 | + except IndexError: | |
197 | + self.curve = 0 | |
198 | + curve = self.config['16bitClutCurves'][self.curve] | |
189 | 199 | |
190 | 200 | p1 = curve[0] |
191 | 201 | p2 = curve[-1] |
... | ... | @@ -210,7 +220,6 @@ class Volume(): |
210 | 220 | self.config['ww'] = ww |
211 | 221 | |
212 | 222 | self.__update_colour_table() |
213 | - ps.Publisher().sendMessage('Render volume viewer') | |
214 | 223 | |
215 | 224 | def CalculateWWWL(self): |
216 | 225 | """ |
... | ... | @@ -220,7 +229,7 @@ class Volume(): |
220 | 229 | first_point = curve[0]['x'] |
221 | 230 | last_point = curve[-1]['x'] |
222 | 231 | self.ww = last_point - first_point |
223 | - self.wl = first_point + self.ww | |
232 | + self.wl = first_point + self.ww / 2.0 | |
224 | 233 | |
225 | 234 | def Refresh(self, pubsub_evt): |
226 | 235 | self.__update_colour_table() |
... | ... | @@ -457,8 +466,8 @@ class Volume(): |
457 | 466 | self.volume_mapper = volume_mapper |
458 | 467 | |
459 | 468 | # TODO: Look to this |
460 | - #volume_mapper = vtk.vtkVolumeTextureMapper2D() | |
461 | - #volume_mapper.SetInput(image2.GetOutput()) | |
469 | + #volume_mapper_hw = vtk.vtkVolumeTextureMapper3D() | |
470 | + #volume_mapper_hw.SetInput(image2) | |
462 | 471 | |
463 | 472 | #Cut Plane |
464 | 473 | #CutPlane(image2, volume_mapper) |
... | ... | @@ -495,7 +504,7 @@ class Volume(): |
495 | 504 | volume.SetMapper(volume_mapper) |
496 | 505 | volume.SetProperty(volume_properties) |
497 | 506 | volume.AddObserver("ProgressEvent", lambda obj,evt: |
498 | - update_progress(volume, "Volume ...")) | |
507 | + update_progress(volume, "Volume ...")) | |
499 | 508 | self.volume = volume |
500 | 509 | |
501 | 510 | colour = self.GetBackgroundColour() | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -255,6 +255,7 @@ class VolumeInteraction(wx.Panel): |
255 | 255 | |
256 | 256 | def OnPointChanged(self, evt): |
257 | 257 | ps.Publisher.sendMessage('Set raycasting refresh', None) |
258 | + ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | |
258 | 259 | ps.Publisher().sendMessage('Render volume viewer', None) |
259 | 260 | |
260 | 261 | def OnCurveSelected(self, evt): | ... | ... |
invesalius/gui/widgets/clut_raycasting.py
... | ... | @@ -150,7 +150,7 @@ class CLUTRaycastingWidget(wx.Panel): |
150 | 150 | if point: |
151 | 151 | colour = wx.GetColourFromUser(self) |
152 | 152 | if colour.IsOk(): |
153 | - i,j = self.point_dragged | |
153 | + i,j = point | |
154 | 154 | r, g, b = [x/255.0 for x in colour.Get()] |
155 | 155 | self.colours[i][j]['red'] = r |
156 | 156 | self.colours[i][j]['green'] = g | ... | ... |