Commit b801673a42ddf71dc07161aa2bf8d8cba70103b9
1 parent
dcd9eb40
Exists in
master
ENH: Add reset button
Showing
2 changed files
with
49 additions
and
31 deletions
Show diff stats
invesalius/gui/dialogs.py
... | ... | @@ -1170,7 +1170,7 @@ def ShowAboutDialog(parent): |
1170 | 1170 | |
1171 | 1171 | info.SetWebSite("https://www.cti.gov.br/invesalius") |
1172 | 1172 | info.SetIcon(icon) |
1173 | - | |
1173 | + | |
1174 | 1174 | info.License = _("GNU GPL (General Public License) version 2") |
1175 | 1175 | |
1176 | 1176 | info.Developers = [u"Paulo Henrique Junqueira Amorim", |
... | ... | @@ -1358,7 +1358,7 @@ class NewSurfaceDialog(wx.Dialog): |
1358 | 1358 | def ExportPicture(type_=""): |
1359 | 1359 | import invesalius.constants as const |
1360 | 1360 | import invesalius.project as proj |
1361 | - | |
1361 | + | |
1362 | 1362 | INDEX_TO_EXTENSION = {0: "bmp", 1: "jpg", 2: "png", 3: "ps", 4:"povray", 5:"tiff"} |
1363 | 1363 | WILDCARD_SAVE_PICTURE = _("BMP image")+" (*.bmp)|*.bmp|"+\ |
1364 | 1364 | _("JPG image")+" (*.jpg)|*.jpg|"+\ |
... | ... | @@ -1528,7 +1528,7 @@ class SurfaceCreationOptionsPanel(wx.Panel): |
1528 | 1528 | project = prj.Project() |
1529 | 1529 | index_list = project.mask_dict.keys() |
1530 | 1530 | self.mask_list = [project.mask_dict[index].name for index in sorted(index_list)] |
1531 | - | |
1531 | + | |
1532 | 1532 | active_mask = slc.Slice().current_mask.index |
1533 | 1533 | #active_mask = len(self.mask_list)-1 |
1534 | 1534 | |
... | ... | @@ -2108,17 +2108,17 @@ class ImportBitmapParameters(wx.Dialog): |
2108 | 2108 | |
2109 | 2109 | |
2110 | 2110 | def _init_gui(self): |
2111 | - | |
2111 | + | |
2112 | 2112 | import invesalius.project as prj |
2113 | - | |
2113 | + | |
2114 | 2114 | p = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL |
2115 | 2115 | | wx.CLIP_CHILDREN |
2116 | 2116 | | wx.FULL_REPAINT_ON_RESIZE) |
2117 | - | |
2117 | + | |
2118 | 2118 | gbs_principal = self.gbs = wx.GridBagSizer(4,1) |
2119 | 2119 | |
2120 | 2120 | gbs = self.gbs = wx.GridBagSizer(5, 2) |
2121 | - | |
2121 | + | |
2122 | 2122 | flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL |
2123 | 2123 | |
2124 | 2124 | stx_name = wx.StaticText(p, -1, _(u"Project name:")) |
... | ... | @@ -2149,7 +2149,7 @@ class ImportBitmapParameters(wx.Dialog): |
2149 | 2149 | |
2150 | 2150 | #--- spacing -------------- |
2151 | 2151 | gbs_spacing = wx.GridBagSizer(2, 6) |
2152 | - | |
2152 | + | |
2153 | 2153 | stx_spacing_x = stx_spacing_x = wx.StaticText(p, -1, _(u"X:")) |
2154 | 2154 | fsp_spacing_x = self.fsp_spacing_x = InvFloatSpinCtrl(p, -1, min_value=0, max_value=1000000000, |
2155 | 2155 | increment=0.25, value=1.0, digits=8) |
... | ... | @@ -2166,7 +2166,7 @@ class ImportBitmapParameters(wx.Dialog): |
2166 | 2166 | |
2167 | 2167 | try: |
2168 | 2168 | proj = prj.Project() |
2169 | - | |
2169 | + | |
2170 | 2170 | sx = proj.spacing[0] |
2171 | 2171 | sy = proj.spacing[1] |
2172 | 2172 | sz = proj.spacing[2] |
... | ... | @@ -2189,7 +2189,7 @@ class ImportBitmapParameters(wx.Dialog): |
2189 | 2189 | |
2190 | 2190 | #----- buttons ------------------------ |
2191 | 2191 | gbs_button = wx.GridBagSizer(2, 4) |
2192 | - | |
2192 | + | |
2193 | 2193 | btn_ok = self.btn_ok= wx.Button(p, wx.ID_OK) |
2194 | 2194 | btn_ok.SetDefault() |
2195 | 2195 | |
... | ... | @@ -2212,14 +2212,14 @@ class ImportBitmapParameters(wx.Dialog): |
2212 | 2212 | |
2213 | 2213 | box = wx.BoxSizer() |
2214 | 2214 | box.Add(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) |
2215 | - | |
2215 | + | |
2216 | 2216 | p.SetSizer(box) |
2217 | 2217 | box.Fit(self) |
2218 | 2218 | self.Layout() |
2219 | 2219 | |
2220 | 2220 | def bind_evts(self): |
2221 | 2221 | self.btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) |
2222 | - | |
2222 | + | |
2223 | 2223 | def SetInterval(self, v): |
2224 | 2224 | self.interval = v |
2225 | 2225 | |
... | ... | @@ -2243,10 +2243,10 @@ class ImportBitmapParameters(wx.Dialog): |
2243 | 2243 | |
2244 | 2244 | |
2245 | 2245 | def BitmapNotSameSize(): |
2246 | - | |
2246 | + | |
2247 | 2247 | dlg = wx.MessageDialog(None,_("All bitmaps files must be the same \n width and height size."), 'Error',\ |
2248 | 2248 | wx.OK | wx.ICON_ERROR) |
2249 | - | |
2249 | + | |
2250 | 2250 | dlg.ShowModal() |
2251 | 2251 | dlg.Destroy() |
2252 | 2252 | |
... | ... | @@ -2923,7 +2923,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
2923 | 2923 | |
2924 | 2924 | |
2925 | 2925 | class CropOptionsDialog(wx.Dialog): |
2926 | - | |
2926 | + | |
2927 | 2927 | def __init__(self, config, ID=-1, title=_(u"Crop mask"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): |
2928 | 2928 | self.config = config |
2929 | 2929 | wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style) |
... | ... | @@ -3552,7 +3552,7 @@ class ICPCorregistrationDialog(wx.Dialog): |
3552 | 3552 | |
3553 | 3553 | txt_surface = wx.StaticText(self, -1, _('Select the surface:')) |
3554 | 3554 | |
3555 | - combo_surface_name = wx.ComboBox(self, -1, | |
3555 | + combo_surface_name = wx.ComboBox(self, -1, size=(330,23), | |
3556 | 3556 | style=wx.CB_DROPDOWN | wx.CB_READONLY) |
3557 | 3557 | # combo_surface_name.SetSelection(0) |
3558 | 3558 | if sys.platform != 'win32': |
... | ... | @@ -3578,6 +3578,9 @@ class ICPCorregistrationDialog(wx.Dialog): |
3578 | 3578 | self.timer = wx.Timer(self) |
3579 | 3579 | self.Bind(wx.EVT_TIMER, self.OnUpdate, self.timer) |
3580 | 3580 | |
3581 | + btn_reset = wx.Button(self, -1, label=_('Reset the points'), size=(100, 23)) | |
3582 | + btn_reset.Bind(wx.EVT_BUTTON, self.OnReset) | |
3583 | + | |
3581 | 3584 | btn_acqui_sizer = wx.FlexGridSizer(rows=1, cols=2, hgap=5, vgap=5) |
3582 | 3585 | btn_acqui_sizer.AddMany([(create_point, wx.LEFT), |
3583 | 3586 | (cont_point, wx.RIGHT)]) |
... | ... | @@ -3596,6 +3599,13 @@ class ICPCorregistrationDialog(wx.Dialog): |
3596 | 3599 | btn_icp_sizer.AddMany([(choice_icp_method, wx.LEFT), |
3597 | 3600 | (icp, wx.RIGHT)]) |
3598 | 3601 | |
3602 | + surface_resetsizer = wx.FlexGridSizer(rows=1, cols=2, hgap=5, vgap=5) | |
3603 | + surface_resetsizer.AddMany([combo_surface_name, | |
3604 | + btn_reset]) | |
3605 | + | |
3606 | + top_sizer = wx.FlexGridSizer(rows=2, cols=1, hgap=50, vgap=5) | |
3607 | + top_sizer.AddMany([txt_surface, | |
3608 | + surface_resetsizer]) | |
3599 | 3609 | |
3600 | 3610 | # Buttons to finish or cancel object registration |
3601 | 3611 | tooltip = wx.ToolTip(_(u"ICP done")) |
... | ... | @@ -3609,11 +3619,6 @@ class ICPCorregistrationDialog(wx.Dialog): |
3609 | 3619 | btnsizer.AddMany([(btn_ok, wx.LEFT), |
3610 | 3620 | (btn_cancel, wx.RIGHT)]) |
3611 | 3621 | |
3612 | - | |
3613 | - top_sizer = wx.FlexGridSizer(rows=2, cols=1, hgap=50, vgap=5) | |
3614 | - top_sizer.AddMany([txt_surface, | |
3615 | - combo_surface_name]) | |
3616 | - | |
3617 | 3622 | extra_sizer = wx.FlexGridSizer(rows=3, cols=1, hgap=50, vgap=10) |
3618 | 3623 | extra_sizer.AddMany([btn_acqui_sizer, |
3619 | 3624 | btn_icp_sizer, |
... | ... | @@ -3622,7 +3627,7 @@ class ICPCorregistrationDialog(wx.Dialog): |
3622 | 3627 | self.progress = wx.Gauge(self, -1) |
3623 | 3628 | |
3624 | 3629 | main_sizer = wx.BoxSizer(wx.VERTICAL) |
3625 | - main_sizer.Add(top_sizer, 0, wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP|wx.RIGHT|wx.BOTTOM, 10) | |
3630 | + main_sizer.Add(top_sizer, 0, wx.LEFT|wx.TOP|wx.RIGHT|wx.BOTTOM, 10) | |
3626 | 3631 | main_sizer.Add(self.interactor, 0, wx.EXPAND) |
3627 | 3632 | main_sizer.Add(extra_sizer, 0, |
3628 | 3633 | wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP|wx.RIGHT|wx.BOTTOM, 10) |
... | ... | @@ -3657,6 +3662,9 @@ class ICPCorregistrationDialog(wx.Dialog): |
3657 | 3662 | #self.ren.RemoveActor(self.obj_actor) |
3658 | 3663 | self.ren.RemoveAllViewProps() |
3659 | 3664 | self.point_coord = [] |
3665 | + self.transformed_points = [] | |
3666 | + self.m_icp = None | |
3667 | + self.SetProgress(0) | |
3660 | 3668 | self.ren.ResetCamera() |
3661 | 3669 | self.interactor.Render() |
3662 | 3670 | |
... | ... | @@ -3806,7 +3814,7 @@ class ICPCorregistrationDialog(wx.Dialog): |
3806 | 3814 | else: |
3807 | 3815 | self.timer.Stop() |
3808 | 3816 | |
3809 | - def OnUpdate(self, event): | |
3817 | + def OnUpdate(self, evt): | |
3810 | 3818 | self.AddMarker(3, (1, 0, 0), self.current_coord[:3]) |
3811 | 3819 | self.SetCameraVolume(self.current_coord[:3]) |
3812 | 3820 | |
... | ... | @@ -3814,6 +3822,10 @@ class ICPCorregistrationDialog(wx.Dialog): |
3814 | 3822 | self.AddMarker(3,(1,0,0),self.current_coord[:3]) |
3815 | 3823 | self.SetCameraVolume(self.current_coord[:3]) |
3816 | 3824 | |
3825 | + def OnReset(self, evt): | |
3826 | + self.RemoveActor() | |
3827 | + self.LoadActor() | |
3828 | + | |
3817 | 3829 | def GetValue(self): |
3818 | 3830 | return self.m_icp, self.point_coord, self.transformed_points |
3819 | 3831 | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -312,6 +312,7 @@ class NeuronavigationPanel(wx.Panel): |
312 | 312 | self.m_icp = None |
313 | 313 | self.fre = None |
314 | 314 | self.icp_fre = None |
315 | + self.icp = False | |
315 | 316 | self.event = threading.Event() |
316 | 317 | |
317 | 318 | self.coord_queue = QueueCustom(maxsize=1) |
... | ... | @@ -682,14 +683,19 @@ class NeuronavigationPanel(wx.Panel): |
682 | 683 | if dialog.ShowModal() == wx.ID_OK: |
683 | 684 | self.m_icp, point_coord, transformed_points = dialog.GetValue() |
684 | 685 | #create markers |
685 | - for i in range(len(point_coord)): | |
686 | - img_coord = point_coord[i][0],-point_coord[i][1],point_coord[i][2], 0, 0, 0 | |
687 | - transf_coord = transformed_points[i][0],-transformed_points[i][1],transformed_points[i][2], 0, 0, 0 | |
688 | - Publisher.sendMessage('Create marker', coord=img_coord, marker_id=None, colour=(1,0,0)) | |
689 | - Publisher.sendMessage('Create marker', coord=transf_coord, marker_id=None, colour=(0,0,1)) | |
690 | - self.checkicp.Enable(True) | |
691 | - self.checkicp.SetValue(True) | |
692 | - self.icp = True | |
686 | + # for i in range(len(point_coord)): | |
687 | + # img_coord = point_coord[i][0],-point_coord[i][1],point_coord[i][2], 0, 0, 0 | |
688 | + # transf_coord = transformed_points[i][0],-transformed_points[i][1],transformed_points[i][2], 0, 0, 0 | |
689 | + # Publisher.sendMessage('Create marker', coord=img_coord, marker_id=None, colour=(1,0,0)) | |
690 | + # Publisher.sendMessage('Create marker', coord=transf_coord, marker_id=None, colour=(0,0,1)) | |
691 | + if self.m_icp is not None: | |
692 | + self.checkicp.Enable(True) | |
693 | + self.checkicp.SetValue(True) | |
694 | + self.icp = True | |
695 | + else: | |
696 | + self.checkicp.Enable(False) | |
697 | + self.checkicp.SetValue(False) | |
698 | + self.icp = False | |
693 | 699 | |
694 | 700 | return self.m_icp |
695 | 701 | ... | ... |