Commit a0f3adda58285a40e315f4b2330cb06d6661fbe3
1 parent
364c8cf6
Exists in
master
and in
6 other branches
ADD: Tool to Reposition Actor
Showing
4 changed files
with
78 additions
and
7 deletions
Show diff stats
invesalius/constants.py
@@ -15,7 +15,7 @@ CAM_POSITION = {"AXIAL":(0, 0, 1), "CORONAL":(0, -1, 0), "SAGITAL":(1, 0, 0)} | @@ -15,7 +15,7 @@ CAM_POSITION = {"AXIAL":(0, 0, 1), "CORONAL":(0, -1, 0), "SAGITAL":(1, 0, 0)} | ||
15 | CAM_VIEW_UP = {"AXIAL":(0, 1, 0), "CORONAL":(0, 0, 1), "SAGITAL":(0, 0, 1)} | 15 | CAM_VIEW_UP = {"AXIAL":(0, 1, 0), "CORONAL":(0, 0, 1), "SAGITAL":(0, 0, 1)} |
16 | 16 | ||
17 | # Camera according to volume's orientation | 17 | # Camera according to volume's orientation |
18 | -AXIAL_VOLUME_CAM_VIEW_UP = {"FRONT":(-1,0,1), "BACK":(0,0,1), "RIGHT":(0,0,1),\ | 18 | +AXIAL_VOLUME_CAM_VIEW_UP = {"FRONT":(0,0,1), "BACK":(0,0,1), "RIGHT":(0,0,1),\ |
19 | "LEFT":(0,0,1), "TOP":(0,1,0), "BOTTOM":(0,-1,0)} | 19 | "LEFT":(0,0,1), "TOP":(0,1,0), "BOTTOM":(0,-1,0)} |
20 | AXIAL_VOLUME_CAM_POSITION = {"FRONT":(0,-1,0), "BACK":(0,1,0), "RIGHT":(-1,0,0),\ | 20 | AXIAL_VOLUME_CAM_POSITION = {"FRONT":(0,-1,0), "BACK":(0,1,0), "RIGHT":(-1,0,0),\ |
21 | "LEFT":(1,0,0), "TOP":(0,0,1), "BOTTOM":(0,0,-1)} | 21 | "LEFT":(1,0,0), "TOP":(0,0,1), "BOTTOM":(0,0,-1)} |
invesalius/data/viewer_volume.py
@@ -22,8 +22,8 @@ import sys | @@ -22,8 +22,8 @@ import sys | ||
22 | import wx | 22 | import wx |
23 | import vtk | 23 | import vtk |
24 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor | 24 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
25 | - | ||
26 | import wx.lib.pubsub as ps | 25 | import wx.lib.pubsub as ps |
26 | +import constants as const | ||
27 | 27 | ||
28 | class Viewer(wx.Panel): | 28 | class Viewer(wx.Panel): |
29 | def __init__(self, parent): | 29 | def __init__(self, parent): |
@@ -67,6 +67,7 @@ class Viewer(wx.Panel): | @@ -67,6 +67,7 @@ class Viewer(wx.Panel): | ||
67 | ps.Publisher().subscribe(self.LoadVolume, 'Load volume into viewer') | 67 | ps.Publisher().subscribe(self.LoadVolume, 'Load volume into viewer') |
68 | ps.Publisher().subscribe(self.AppendActor,'AppendActor') | 68 | ps.Publisher().subscribe(self.AppendActor,'AppendActor') |
69 | ps.Publisher().subscribe(self.SetWidgetInteractor, 'Set Widget Interactor') | 69 | ps.Publisher().subscribe(self.SetWidgetInteractor, 'Set Widget Interactor') |
70 | + ps.Publisher().subscribe(self.RepositionActor, 'Reposition Actor') | ||
70 | 71 | ||
71 | 72 | ||
72 | def __bind_events_wx(self): | 73 | def __bind_events_wx(self): |
@@ -86,9 +87,7 @@ class Viewer(wx.Panel): | @@ -86,9 +87,7 @@ class Viewer(wx.Panel): | ||
86 | volume, colour = pubsub_evt.data | 87 | volume, colour = pubsub_evt.data |
87 | self.light = self.ren.GetLights().GetNextItem() | 88 | self.light = self.ren.GetLights().GetNextItem() |
88 | self.ren.AddVolume(volume) | 89 | self.ren.AddVolume(volume) |
89 | - #self.ren.SetBackground(colour) | ||
90 | - self.ren.ResetCamera() | ||
91 | - self.ren.ResetCameraClippingRange() | 90 | + self.RepositionActor() |
92 | self.UpdateRender() | 91 | self.UpdateRender() |
93 | 92 | ||
94 | def ChangeBackgroundColour(self, pubsub_evt): | 93 | def ChangeBackgroundColour(self, pubsub_evt): |
@@ -106,6 +105,26 @@ class Viewer(wx.Panel): | @@ -106,6 +105,26 @@ class Viewer(wx.Panel): | ||
106 | 105 | ||
107 | self.iren.Render() | 106 | self.iren.Render() |
108 | 107 | ||
108 | + def RepositionActor(self, evt_pubsub=None): | ||
109 | + | ||
110 | + if (evt_pubsub): | ||
111 | + position = evt_pubsub.data | ||
112 | + else: | ||
113 | + position = "FRONT" | ||
114 | + | ||
115 | + cam = self.ren.GetActiveCamera() | ||
116 | + cam.SetFocalPoint(0,0,0) | ||
117 | + | ||
118 | + xv,yv,zv = const.AXIAL_VOLUME_CAM_VIEW_UP[position] | ||
119 | + xp,yp,zp = const.AXIAL_VOLUME_CAM_POSITION[position] | ||
120 | + | ||
121 | + cam.SetViewUp(xv,yv,zv) | ||
122 | + cam.SetPosition(xp,yp,zp) | ||
123 | + | ||
124 | + self.ren.ResetCameraClippingRange() | ||
125 | + self.ren.ResetCamera() | ||
126 | + self.iren.Render() | ||
127 | + | ||
109 | def UpdateRender(self, evt_pubsub=None): | 128 | def UpdateRender(self, evt_pubsub=None): |
110 | self.iren.Render() | 129 | self.iren.Render() |
111 | 130 |
invesalius/gui/default_viewers.py
@@ -173,7 +173,7 @@ class VolumeViewerCover(wx.Panel): | @@ -173,7 +173,7 @@ class VolumeViewerCover(wx.Panel): | ||
173 | self.SetSizer(sizer) | 173 | self.SetSizer(sizer) |
174 | sizer.Fit(self) | 174 | sizer.Fit(self) |
175 | 175 | ||
176 | -#import wx.lib.platebtn as pbtn | 176 | +import wx.lib.platebtn as pbtn |
177 | import wx.lib.buttons as btn | 177 | import wx.lib.buttons as btn |
178 | import wx.lib.pubsub as ps | 178 | import wx.lib.pubsub as ps |
179 | import wx.lib.colourselect as csel | 179 | import wx.lib.colourselect as csel |
@@ -186,10 +186,55 @@ class VolumeToolPanel(wx.Panel): | @@ -186,10 +186,55 @@ class VolumeToolPanel(wx.Panel): | ||
186 | BMP_RAYCASTING.SetWidth(22) | 186 | BMP_RAYCASTING.SetWidth(22) |
187 | BMP_RAYCASTING.SetHeight(22) | 187 | BMP_RAYCASTING.SetHeight(22) |
188 | 188 | ||
189 | + BMP_POSITION = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
190 | + BMP_POSITION.SetWidth(22) | ||
191 | + BMP_POSITION.SetHeight(22) | ||
192 | + | ||
189 | button_raycasting=btn.GenBitmapToggleButton(self, 1, BMP_RAYCASTING, size=(24,24)) | 193 | button_raycasting=btn.GenBitmapToggleButton(self, 1, BMP_RAYCASTING, size=(24,24)) |
190 | button_raycasting.Bind(wx.EVT_BUTTON, self.OnToggleRaycasting) | 194 | button_raycasting.Bind(wx.EVT_BUTTON, self.OnToggleRaycasting) |
191 | self.button_raycasting = button_raycasting | 195 | self.button_raycasting = button_raycasting |
192 | 196 | ||
197 | + menu = wx.Menu() | ||
198 | + | ||
199 | + FRONT_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) | ||
200 | + item = wx.MenuItem(menu, 0, "Front") | ||
201 | + item.SetBitmap(FRONT_BMP) | ||
202 | + | ||
203 | + BACK_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
204 | + item2 = wx.MenuItem(menu, 1, "Back") | ||
205 | + item2.SetBitmap(BACK_BMP) | ||
206 | + | ||
207 | + TOP_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
208 | + item3 = wx.MenuItem(menu, 2, "Top") | ||
209 | + item3.SetBitmap(TOP_BMP) | ||
210 | + | ||
211 | + BOTTOM_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
212 | + item4 = wx.MenuItem(menu, 3, "Bottom") | ||
213 | + item4.SetBitmap(BOTTOM_BMP) | ||
214 | + | ||
215 | + RIGHT_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
216 | + item5 = wx.MenuItem(menu, 4, "Right") | ||
217 | + item5.SetBitmap(RIGHT_BMP) | ||
218 | + | ||
219 | + LEFT_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | ||
220 | + item6 = wx.MenuItem(menu, 5, "Left") | ||
221 | + item6.SetBitmap(LEFT_BMP) | ||
222 | + | ||
223 | + self.Bind(wx.EVT_MENU, self.OnMenu) | ||
224 | + | ||
225 | + menu.AppendItem(item) | ||
226 | + menu.AppendItem(item2) | ||
227 | + menu.AppendItem(item3) | ||
228 | + menu.AppendItem(item4) | ||
229 | + menu.AppendItem(item5) | ||
230 | + menu.AppendItem(item6) | ||
231 | + | ||
232 | + button_position = pbtn.PlateButton(self, wx.ID_ANY,"", BMP_POSITION, | ||
233 | + style=pbtn.PB_STYLE_SQUARE, size=(24,24)) | ||
234 | + | ||
235 | + button_position.SetMenu(menu) | ||
236 | + self.button_position = button_position | ||
237 | + | ||
193 | button_colour= csel.ColourSelect(self, 111,colour=(0,0,0),size=(24,24)) | 238 | button_colour= csel.ColourSelect(self, 111,colour=(0,0,0),size=(24,24)) |
194 | button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) | 239 | button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) |
195 | self.button_colour = button_colour | 240 | self.button_colour = button_colour |
@@ -197,8 +242,15 @@ class VolumeToolPanel(wx.Panel): | @@ -197,8 +242,15 @@ class VolumeToolPanel(wx.Panel): | ||
197 | sizer = wx.BoxSizer(wx.VERTICAL) | 242 | sizer = wx.BoxSizer(wx.VERTICAL) |
198 | sizer.Add(button_colour, 0, wx.ALL, 1) | 243 | sizer.Add(button_colour, 0, wx.ALL, 1) |
199 | sizer.Add(button_raycasting, 0, wx.ALL, 1) | 244 | sizer.Add(button_raycasting, 0, wx.ALL, 1) |
245 | + sizer.Add(button_position, 0, wx.ALL, 1) | ||
200 | self.SetSizer(sizer) | 246 | self.SetSizer(sizer) |
201 | sizer.Fit(self) | 247 | sizer.Fit(self) |
248 | + | ||
249 | + def OnMenu(self, evt): | ||
250 | + values = {0:"FRONT", 1:"BACK", 2:"TOP",\ | ||
251 | + 3:"BOTTOM", 4:"RIGHT", 5:"LEFT"} | ||
252 | + ps.Publisher().sendMessage('Reposition Actor',\ | ||
253 | + values[evt.GetId()]) | ||
202 | 254 | ||
203 | def OnSelectColour(self, evt): | 255 | def OnSelectColour(self, evt): |
204 | colour = c = [i/255.0 for i in evt.GetValue()] | 256 | colour = c = [i/255.0 for i in evt.GetValue()] |
invesalius/reader/dicom_reader.py
@@ -109,7 +109,7 @@ def LoadImages(dir_): | @@ -109,7 +109,7 @@ def LoadImages(dir_): | ||
109 | read.Update() | 109 | read.Update() |
110 | 110 | ||
111 | #Resample image in x,y dimension | 111 | #Resample image in x,y dimension |
112 | - img = ResampleImage2D(read.GetOutput(), 256) | 112 | + img = ResampleImage2D(read.GetOutput(), 200) |
113 | 113 | ||
114 | #Stack images in Z axes | 114 | #Stack images in Z axes |
115 | img_app.AddInput(img) | 115 | img_app.AddInput(img) |