Commit 6a3795bd0b791ab1bddce04e5855e24c2441a87f
1 parent
b7d73f1c
Exists in
master
and in
6 other branches
EHN: The RectangleCursor is centered in the mouse position
Showing
4 changed files
with
22 additions
and
22 deletions
Show diff stats
invesalius/control.py
@@ -7,7 +7,7 @@ import data.imagedata_utils as utils | @@ -7,7 +7,7 @@ import data.imagedata_utils as utils | ||
7 | import data.surface as surface | 7 | import data.surface as surface |
8 | import data.volume as volume | 8 | import data.volume as volume |
9 | import reader.dicom_reader as dicom | 9 | import reader.dicom_reader as dicom |
10 | -import reader.analyze_reader as analyze | 10 | +#import reader.analyze_reader as analyze |
11 | 11 | ||
12 | DEFAULT_THRESH_MODE = 0 | 12 | DEFAULT_THRESH_MODE = 0 |
13 | 13 |
invesalius/data/cursor_actors.py
@@ -56,9 +56,9 @@ class CursorCircle: | @@ -56,9 +56,9 @@ class CursorCircle: | ||
56 | Extracted equation. | 56 | Extracted equation. |
57 | http://www.mathopenref.com/chord.html | 57 | http://www.mathopenref.com/chord.html |
58 | """ | 58 | """ |
59 | - xc = 0 | ||
60 | - yc = 0 | ||
61 | - z = 0 | 59 | + xc = 0.0 |
60 | + yc = 0.0 | ||
61 | + z = 0.0 | ||
62 | xs, ys, zs = self.spacing | 62 | xs, ys, zs = self.spacing |
63 | orientation_based_spacing = {"AXIAL" : (xs, ys), | 63 | orientation_based_spacing = {"AXIAL" : (xs, ys), |
64 | "SAGITAL" : (ys, zs), | 64 | "SAGITAL" : (ys, zs), |
@@ -72,9 +72,9 @@ class CursorCircle: | @@ -72,9 +72,9 @@ class CursorCircle: | ||
72 | # line size | 72 | # line size |
73 | line = sqrt(radius**2 - d**2) * 2 | 73 | line = sqrt(radius**2 - d**2) * 2 |
74 | # line initial x | 74 | # line initial x |
75 | - xi = xc - line/2 | 75 | + xi = xc - line/2.0 |
76 | # line final | 76 | # line final |
77 | - xf = line/2 + xc | 77 | + xf = line/2.0 + xc |
78 | yi = i | 78 | yi = i |
79 | for k in utils.frange(xi,xf,xs): | 79 | for k in utils.frange(xi,xf,xs): |
80 | self.pixel_list.append((k, yi)) | 80 | self.pixel_list.append((k, yi)) |
@@ -190,11 +190,11 @@ class CursorRectangle: | @@ -190,11 +190,11 @@ class CursorRectangle: | ||
190 | seeds_xf.SetPoint1(0, 0, 0) | 190 | seeds_xf.SetPoint1(0, 0, 0) |
191 | seeds_xf.SetPoint2(self.x_length, 0, 0) | 191 | seeds_xf.SetPoint2(self.x_length, 0, 0) |
192 | 192 | ||
193 | - join_lines = self.join_lines | ||
194 | - join_lines.AddInput(seeds_yi.GetOutput()) | ||
195 | - join_lines.AddInput(seeds_yf.GetOutput()) | ||
196 | - join_lines.AddInput(seeds_xi.GetOutput()) | ||
197 | - join_lines.AddInput(seeds_xf.GetOutput()) | 193 | + #join_lines = self.join_lines |
194 | + #join_lines.AddInput(seeds_yi.GetOutput()) | ||
195 | + #join_lines.AddInput(seeds_yf.GetOutput()) | ||
196 | + #join_lines.AddInput(seeds_xi.GetOutput()) | ||
197 | + #join_lines.AddInput(seeds_xf.GetOutput()) | ||
198 | 198 | ||
199 | self.__calculate_area_pixels() | 199 | self.__calculate_area_pixels() |
200 | 200 | ||
@@ -215,8 +215,15 @@ class CursorRectangle: | @@ -215,8 +215,15 @@ class CursorRectangle: | ||
215 | self.actor.RotateY(90) | 215 | self.actor.RotateY(90) |
216 | 216 | ||
217 | def SetPosition(self, position): | 217 | def SetPosition(self, position): |
218 | - self.position = position | ||
219 | - self.actor.SetPosition(position) | 218 | + x,y,z = position |
219 | + x_half = self.x_length / 2.0 | ||
220 | + y_half = self.y_length / 2.0 | ||
221 | + orientation_position_based = {"AXIAL" : (x - x_half,y - y_half, z), | ||
222 | + "CORONAL" : (x - x_half, y, z - y_half), | ||
223 | + "SAGITAL" : (x, y - y_half, z + x_half)} | ||
224 | + xc,yc,zc = orientation_position_based[self.orientation] | ||
225 | + self.position = (xc,yc,zc) | ||
226 | + self.actor.SetPosition(xc,yc,zc) | ||
220 | 227 | ||
221 | def SetEditionPosition(self, position): | 228 | def SetEditionPosition(self, position): |
222 | self.edition_position = position | 229 | self.edition_position = position |
invesalius/data/viewer_slice.py
@@ -17,7 +17,6 @@ | @@ -17,7 +17,6 @@ | ||
17 | # detalhes. | 17 | # detalhes. |
18 | #-------------------------------------------------------------------------- | 18 | #-------------------------------------------------------------------------- |
19 | 19 | ||
20 | - | ||
21 | import vtk | 20 | import vtk |
22 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor | 21 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
23 | import wx | 22 | import wx |
@@ -121,8 +120,6 @@ class Viewer(wx.Panel): | @@ -121,8 +120,6 @@ class Viewer(wx.Panel): | ||
121 | style.AddObserver(event, | 120 | style.AddObserver(event, |
122 | action[mode][event]) | 121 | action[mode][event]) |
123 | 122 | ||
124 | - | ||
125 | - | ||
126 | def ChangeBrushSize(self, pubsub_evt): | 123 | def ChangeBrushSize(self, pubsub_evt): |
127 | size = pubsub_evt.data | 124 | size = pubsub_evt.data |
128 | self._brush_cursor_size = size | 125 | self._brush_cursor_size = size |
@@ -146,8 +143,6 @@ class Viewer(wx.Panel): | @@ -146,8 +143,6 @@ class Viewer(wx.Panel): | ||
146 | self.cursor.SetColour(colour_vtk) | 143 | self.cursor.SetColour(colour_vtk) |
147 | self.interactor.Render() | 144 | self.interactor.Render() |
148 | 145 | ||
149 | - | ||
150 | - | ||
151 | def ChangeBrushActor(self, pubsub_evt): | 146 | def ChangeBrushActor(self, pubsub_evt): |
152 | brush_type = pubsub_evt.data | 147 | brush_type = pubsub_evt.data |
153 | self._brush_cursor_type = brush_type | 148 | self._brush_cursor_type = brush_type |
@@ -208,7 +203,6 @@ class Viewer(wx.Panel): | @@ -208,7 +203,6 @@ class Viewer(wx.Panel): | ||
208 | self.cursor.SetPosition(coord) | 203 | self.cursor.SetPosition(coord) |
209 | self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) | 204 | self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) |
210 | self.__update_cursor_position(coord) | 205 | self.__update_cursor_position(coord) |
211 | - self.ren.Render() | ||
212 | 206 | ||
213 | if self._brush_cursor_op == 'Erase': | 207 | if self._brush_cursor_op == 'Erase': |
214 | evt_msg = 'Erase mask pixel' | 208 | evt_msg = 'Erase mask pixel' |
@@ -221,8 +215,7 @@ class Viewer(wx.Panel): | @@ -221,8 +215,7 @@ class Viewer(wx.Panel): | ||
221 | pixels = self.cursor.GetPixels() | 215 | pixels = self.cursor.GetPixels() |
222 | for coord in pixels: | 216 | for coord in pixels: |
223 | ps.Publisher().sendMessage(evt_msg, coord) | 217 | ps.Publisher().sendMessage(evt_msg, coord) |
224 | - self.interactor.Render() | ||
225 | - | 218 | + self.interactor.Render() |
226 | 219 | ||
227 | def OnCrossMove(self, obj, evt_vtk): | 220 | def OnCrossMove(self, obj, evt_vtk): |
228 | coord = self.GetCoordinate() | 221 | coord = self.GetCoordinate() |
invesalius/reader/dicom_reader.py
@@ -158,4 +158,4 @@ def GetDicomFiles(path, recursive = False): | @@ -158,4 +158,4 @@ def GetDicomFiles(path, recursive = False): | ||
158 | result.append(files[x]) | 158 | result.append(files[x]) |
159 | acquisition_modality = read_dicom.GetAcquisitionModality() | 159 | acquisition_modality = read_dicom.GetAcquisitionModality() |
160 | # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER | 160 | # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER |
161 | - return result, acquisition_modality | ||
162 | \ No newline at end of file | 161 | \ No newline at end of file |
162 | + return result, acquisition_modality |