Commit 1560ae566744f339e044971dc23bd06f9a90fd08
Committed by
GitHub
1 parent
4fa55237
Exists in
master
Add dialog window for inputing optitrack directory files (#322)
Showing
3 changed files
with
85 additions
and
9 deletions
Show diff stats
invesalius/data/trackers.py
@@ -78,16 +78,23 @@ def OptitrackTracker(tracker_id): | @@ -78,16 +78,23 @@ def OptitrackTracker(tracker_id): | ||
78 | ------- | 78 | ------- |
79 | trck_init : local name for Optitrack module | 79 | trck_init : local name for Optitrack module |
80 | """ | 80 | """ |
81 | + from wx import ID_OK | ||
81 | trck_init = None | 82 | trck_init = None |
82 | - try: | ||
83 | - import optitrack | ||
84 | - trck_init = optitrack.optr() | ||
85 | - if trck_init.Initialize()==0: | ||
86 | - trck_init.Run() #Runs once Run function, to update cameras. | ||
87 | - else: | ||
88 | - trck_init = None | ||
89 | - except ImportError: | ||
90 | - print('Error') | 83 | + dlg_port = dlg.SetOptitrackconfigs() |
84 | + if dlg_port.ShowModal() == ID_OK: | ||
85 | + Cal_optitrack, User_profile_optitrack = dlg_port.GetValue() | ||
86 | + try: | ||
87 | + import optitrack | ||
88 | + trck_init = optitrack.optr() | ||
89 | + | ||
90 | + if trck_init.Initialize(Cal_optitrack, User_profile_optitrack)==0: | ||
91 | + trck_init.Run() #Runs once Run function, to update cameras. | ||
92 | + else: | ||
93 | + trck_init = None | ||
94 | + except ImportError: | ||
95 | + print('Error') | ||
96 | + else: | ||
97 | + print('#####') | ||
91 | return trck_init, 'wrapper' | 98 | return trck_init, 'wrapper' |
92 | 99 | ||
93 | def PolarisTracker(tracker_id): | 100 | def PolarisTracker(tracker_id): |
invesalius/gui/dialogs.py
@@ -4134,6 +4134,73 @@ class GoToDialogScannerCoord(wx.Dialog): | @@ -4134,6 +4134,73 @@ class GoToDialogScannerCoord(wx.Dialog): | ||
4134 | wx.Dialog.Close(self) | 4134 | wx.Dialog.Close(self) |
4135 | self.Destroy() | 4135 | self.Destroy() |
4136 | 4136 | ||
4137 | +class SetOptitrackconfigs(wx.Dialog): | ||
4138 | + def __init__(self, title=_("Setting Optitrack configs:")): | ||
4139 | + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, size=wx.Size(1000, 200), | ||
4140 | + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP|wx.RESIZE_BORDER) | ||
4141 | + self._init_gui() | ||
4142 | + | ||
4143 | + def _init_gui(self): | ||
4144 | + session = ses.Session() | ||
4145 | + last_optitrack_cal_dir = session.get('paths', 'last_optitrack_cal_dir', '') | ||
4146 | + last_optitrack_User_Profile_dir = session.get('paths', 'last_optitrack_User_Profile_dir', '') | ||
4147 | + | ||
4148 | + if not last_optitrack_cal_dir: | ||
4149 | + last_optitrack_cal_dir = inv_paths.OPTITRACK_CAL_DIR | ||
4150 | + if not last_optitrack_User_Profile_dir: | ||
4151 | + last_optitrack_User_Profile_dir = inv_paths.OPTITRACK_USERPROFILE_DIR | ||
4152 | + | ||
4153 | + self.dir_cal = wx.FilePickerCtrl(self, path=last_optitrack_cal_dir, style=wx.FLP_USE_TEXTCTRL | wx.FLP_SMALL, | ||
4154 | + wildcard="Cal files (*.cal)|*.cal", message="Select Calibration file") | ||
4155 | + row_cal = wx.BoxSizer(wx.VERTICAL) | ||
4156 | + row_cal.Add(wx.StaticText(self, wx.ID_ANY, "Select Calibration file"), 0, wx.TOP | wx.RIGHT, 5) | ||
4157 | + row_cal.Add(self.dir_cal, 0, wx.ALL | wx.CENTER | wx.EXPAND) | ||
4158 | + | ||
4159 | + self.dir_UserProfile = wx.FilePickerCtrl(self, path=last_optitrack_User_Profile_dir, style=wx.FLP_USE_TEXTCTRL | wx.FLP_SMALL, | ||
4160 | + wildcard="User Profile files (*.motive)|*.motive", message="Select User Profile file") | ||
4161 | + | ||
4162 | + row_userprofile = wx.BoxSizer(wx.VERTICAL) | ||
4163 | + row_userprofile.Add(wx.StaticText(self, wx.ID_ANY, "Select User Profile file"), 0, wx.TOP | wx.RIGHT, 5) | ||
4164 | + row_userprofile.Add(self.dir_UserProfile, 0, wx.ALL | wx.CENTER | wx.EXPAND) | ||
4165 | + | ||
4166 | + btn_ok = wx.Button(self, wx.ID_OK) | ||
4167 | + btn_ok.SetHelpText("") | ||
4168 | + btn_ok.SetDefault() | ||
4169 | + | ||
4170 | + btn_cancel = wx.Button(self, wx.ID_CANCEL) | ||
4171 | + btn_cancel.SetHelpText("") | ||
4172 | + | ||
4173 | + btnsizer = wx.StdDialogButtonSizer() | ||
4174 | + btnsizer.AddButton(btn_ok) | ||
4175 | + btnsizer.AddButton(btn_cancel) | ||
4176 | + btnsizer.Realize() | ||
4177 | + | ||
4178 | + main_sizer = wx.BoxSizer(wx.VERTICAL) | ||
4179 | + | ||
4180 | + main_sizer.Add((5, 5)) | ||
4181 | + main_sizer.Add(row_cal, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5) | ||
4182 | + main_sizer.Add((5, 5)) | ||
4183 | + main_sizer.Add(row_userprofile, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5) | ||
4184 | + main_sizer.Add((15, 15)) | ||
4185 | + main_sizer.Add(btnsizer, 0, wx.EXPAND) | ||
4186 | + main_sizer.Add((5, 5)) | ||
4187 | + | ||
4188 | + self.SetSizer(main_sizer) | ||
4189 | + main_sizer.Fit(self) | ||
4190 | + | ||
4191 | + self.CenterOnParent() | ||
4192 | + | ||
4193 | + def GetValue(self): | ||
4194 | + fn_cal = self.dir_cal.GetPath() | ||
4195 | + fn_userprofile = self.dir_UserProfile.GetPath() | ||
4196 | + | ||
4197 | + if fn_cal and fn_userprofile: | ||
4198 | + session = ses.Session() | ||
4199 | + session['paths']['last_optitrack_cal_dir'] = self.dir_cal.GetPath() | ||
4200 | + session['paths']['last_optitrack_User_Profile_dir'] = self.dir_UserProfile.GetPath() | ||
4201 | + session.WriteSessionFile() | ||
4202 | + | ||
4203 | + return fn_cal, fn_userprofile | ||
4137 | 4204 | ||
4138 | class SetNDIconfigs(wx.Dialog): | 4205 | class SetNDIconfigs(wx.Dialog): |
4139 | def __init__(self, title=_("Setting NDI polaris configs:")): | 4206 | def __init__(self, title=_("Setting NDI polaris configs:")): |
invesalius/inv_paths.py
@@ -84,6 +84,8 @@ NDI_MAR_DIR_PROBE = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers | @@ -84,6 +84,8 @@ NDI_MAR_DIR_PROBE = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers | ||
84 | NDI_MAR_DIR_REF = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers", "8700339.rom")) | 84 | NDI_MAR_DIR_REF = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers", "8700339.rom")) |
85 | NDI_MAR_DIR_OBJ = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers", "8700338.rom")) | 85 | NDI_MAR_DIR_OBJ = str(INV_TOP_DIR.joinpath("navigation", "ndi_files", "Markers", "8700338.rom")) |
86 | 86 | ||
87 | +OPTITRACK_CAL_DIR = str(INV_TOP_DIR.joinpath("navigation", "optitrack_files", "Calibration.cal")) | ||
88 | +OPTITRACK_USERPROFILE_DIR = str(INV_TOP_DIR.joinpath("navigation", "optitrack_files", "UserProfile.motive")) | ||
87 | # MAC App | 89 | # MAC App |
88 | if not os.path.exists(ICON_DIR): | 90 | if not os.path.exists(ICON_DIR): |
89 | ICON_DIR = INV_TOP_DIR.parent.parent.joinpath("icons").resolve() | 91 | ICON_DIR = INV_TOP_DIR.parent.parent.joinpath("icons").resolve() |