Commit 2cbdd0509190e3f8c5543c2755f75b66223aff36
1 parent
9b63f379
Exists in
master
and in
6 other branches
ADD: Brush in case's with different orientation. (TODO: FIX Bud in CursorCircle and CursorRectangle)
Showing
1 changed file
with
64 additions
and
16 deletions
Show diff stats
invesalius/data/cursor_actors.py
@@ -2,7 +2,8 @@ from math import * | @@ -2,7 +2,8 @@ from math import * | ||
2 | 2 | ||
3 | import vtk | 3 | import vtk |
4 | import wx.lib.pubsub as ps | 4 | import wx.lib.pubsub as ps |
5 | - | 5 | +from project import Project |
6 | +import constants as const | ||
6 | import utils | 7 | import utils |
7 | 8 | ||
8 | class CursorCircle: | 9 | class CursorCircle: |
@@ -59,9 +60,27 @@ class CursorCircle: | @@ -59,9 +60,27 @@ class CursorCircle: | ||
59 | yc = 0.0 | 60 | yc = 0.0 |
60 | z = 0.0 | 61 | z = 0.0 |
61 | xs, ys, zs = self.spacing | 62 | xs, ys, zs = self.spacing |
62 | - orientation_based_spacing = {"AXIAL" : (xs, ys), | ||
63 | - "SAGITAL" : (ys, zs), | ||
64 | - "CORONAL" : (xs, zs)} | 63 | + |
64 | + proj = Project() | ||
65 | + orig_orien = proj.original_orientation | ||
66 | + | ||
67 | + xy = (xs, ys) | ||
68 | + yz = (ys, zs) | ||
69 | + xz = (xs, zs) | ||
70 | + | ||
71 | + if (orig_orien == const.SAGITAL): | ||
72 | + orientation_based_spacing = {"SAGITAL" : xy, | ||
73 | + "AXIAL" : yz, | ||
74 | + "CORONAL" : xz} | ||
75 | + elif(orig_orien == const.CORONAL): | ||
76 | + orientation_based_spacing = {"CORONAL" : xy, | ||
77 | + "AXIAL" : xz, | ||
78 | + "SAGITAL" : yz} | ||
79 | + else: | ||
80 | + orientation_based_spacing = {"AXIAL" : xy, | ||
81 | + "SAGITAL" : yz, | ||
82 | + "CORONAL" : xz} | ||
83 | + | ||
65 | xs, ys = orientation_based_spacing[self.orientation] | 84 | xs, ys = orientation_based_spacing[self.orientation] |
66 | self.pixel_list = [] | 85 | self.pixel_list = [] |
67 | radius = self.radius | 86 | radius = self.radius |
@@ -90,12 +109,24 @@ class CursorCircle: | @@ -90,12 +109,24 @@ class CursorCircle: | ||
90 | 109 | ||
91 | def SetOrientation(self, orientation): | 110 | def SetOrientation(self, orientation): |
92 | self.orientation = orientation | 111 | self.orientation = orientation |
93 | - | ||
94 | - if orientation == "CORONAL": | ||
95 | - self.actor.RotateX(90) | ||
96 | - | ||
97 | - if orientation == "SAGITAL": | ||
98 | - self.actor.RotateY(90) | 112 | + proj = Project() |
113 | + | ||
114 | + orig_orien = proj.original_orientation | ||
115 | + if (orig_orien == const.SAGITAL): | ||
116 | + if orientation == "CORONAL": | ||
117 | + self.actor.RotateY(90) | ||
118 | + if orientation == "AXIAL": | ||
119 | + self.actor.RotateX(90) | ||
120 | + elif(orig_orien == const.CORONAL): | ||
121 | + if orientation == "AXIAL": | ||
122 | + self.actor.RotateX(270) | ||
123 | + if orientation == "SAGITAL": | ||
124 | + self.actor.RotateY(90) | ||
125 | + else: | ||
126 | + if orientation == "CORONAL": | ||
127 | + self.actor.RotateX(90) | ||
128 | + if orientation == "SAGITAL": | ||
129 | + self.actor.RotateY(90) | ||
99 | 130 | ||
100 | def SetPosition(self, position): | 131 | def SetPosition(self, position): |
101 | self.position = position | 132 | self.position = position |
@@ -112,12 +143,28 @@ class CursorCircle: | @@ -112,12 +143,28 @@ class CursorCircle: | ||
112 | px, py, pz = self.edition_position | 143 | px, py, pz = self.edition_position |
113 | orient = self.orientation | 144 | orient = self.orientation |
114 | xs, ys, zs = self.spacing | 145 | xs, ys, zs = self.spacing |
115 | - abs_pixel = {"AXIAL": lambda x,y: (px + x / xs, py+(y/ys), pz), | ||
116 | - "CORONAL": lambda x,y: (px+(x/xs), py, | ||
117 | - pz+(y/zs)), | ||
118 | - "SAGITAL": lambda x,y: (px, py+(x/ys), | ||
119 | - pz+(y/zs))} | 146 | + proj = Project() |
147 | + orig_orien = proj.original_orientation | ||
148 | + | ||
149 | + xy1 = lambda x,y: (px + x / xs, py+(y/ys), pz) | ||
150 | + xy2 = lambda x,y: (px+(x/xs), py, pz+(y/zs)) | ||
151 | + xy3 = lambda x,y: (px, py+(x/ys), pz+(y/zs)) | ||
152 | + | ||
153 | + if (orig_orien == const.SAGITAL): | ||
154 | + abs_pixel = {"SAGITAL": xy1, | ||
155 | + "AXIAL": xy2, | ||
156 | + "CORONAL": xy3} | ||
157 | + elif(orig_orien == const.CORONAL): | ||
158 | + abs_pixel = {"CORONAL": xy1, | ||
159 | + "SAGITAL": xy3, | ||
160 | + "AXIAL": xy2} | ||
161 | + else: | ||
162 | + abs_pixel = {"AXIAL": xy1, | ||
163 | + "CORONAL": xy2, | ||
164 | + "SAGITAL": xy3} | ||
165 | + | ||
120 | function_orientation = abs_pixel[orient] | 166 | function_orientation = abs_pixel[orient] |
167 | + | ||
121 | for pixel_0,pixel_1 in self.pixel_list: | 168 | for pixel_0,pixel_1 in self.pixel_list: |
122 | # The position of the pixels in this list is relative (based only on | 169 | # The position of the pixels in this list is relative (based only on |
123 | # the area, and not the cursor position). | 170 | # the area, and not the cursor position). |
@@ -131,7 +178,8 @@ class CursorCircle: | @@ -131,7 +178,8 @@ class CursorCircle: | ||
131 | #------------------------------------------------------------------------------- | 178 | #------------------------------------------------------------------------------- |
132 | #------------------------------------------------------------------------------- | 179 | #------------------------------------------------------------------------------- |
133 | #------------------------------------------------------------------------------- | 180 | #------------------------------------------------------------------------------- |
134 | -#-------------------------------------------------------------------------------#------------------------------------------------------------------------------- | 181 | +#------------------------------------------------------------------------------- |
182 | +#------------------------------------------------------------------------------- | ||
135 | #------------------------------------------------------------------------------- | 183 | #------------------------------------------------------------------------------- |
136 | #------------------------------------------------------------------------------- | 184 | #------------------------------------------------------------------------------- |
137 | #------------------------------------------------------------------------------- | 185 | #------------------------------------------------------------------------------- |