Skip to content

Commit 0ba7e81

Browse files
committed
iw3: desktop: Add TB and Anaglyph format
1 parent cc94327 commit 0ba7e81

2 files changed

Lines changed: 61 additions & 13 deletions

File tree

iw3/desktop/gui.py

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,31 @@ def initialize_component(self):
258258
self.lbl_stereo_format = wx.StaticText(self.grp_stereo, label=T("Stereo Format"))
259259
self.cbo_stereo_format = wx.ComboBox(
260260
self.grp_stereo,
261-
choices=["Half SBS", "Full SBS", "RGB-D", "Half RGB-D"],
261+
choices=[
262+
"Half SBS", "Full SBS",
263+
"Half TB", "Full TB",
264+
"Cross Eyed",
265+
"RGB-D", "Half RGB-D",
266+
"Anaglyph",
267+
],
262268
name="cbo_stereo_format")
263269
self.cbo_stereo_format.SetEditable(False)
264270
self.cbo_stereo_format.SetSelection(0)
271+
272+
self.lbl_anaglyph_method = wx.StaticText(self.grp_stereo, label=T("Anaglyph Method"))
273+
self.cbo_anaglyph_method = wx.ComboBox(
274+
self.grp_stereo,
275+
choices=["dubois", "dubois2",
276+
"color", "gray",
277+
"half-color",
278+
"wimmer", "wimmer2"],
279+
name="cbo_anaglyph_method")
280+
self.cbo_anaglyph_method.SetEditable(False)
281+
self.cbo_anaglyph_method.SetSelection(0)
282+
self.lbl_anaglyph_method.Hide()
283+
self.cbo_anaglyph_method.Hide()
284+
265285
self.lbl_format_device = wx.StaticText(self.grp_stereo, label=T(""))
266-
self.chk_cross_eyed = wx.CheckBox(self.grp_stereo, label=T("Cross Eyed"), name="chk_cross_eyed")
267-
self.chk_cross_eyed.SetToolTip(T("Swap left image and right image"))
268-
self.chk_cross_eyed.SetValue(False)
269-
self.chk_cross_eyed.Hide()
270286

271287
layout = wx.GridBagSizer(vgap=4, hgap=4)
272288
layout.SetEmptyCellSize((0, 0))
@@ -297,8 +313,9 @@ def initialize_component(self):
297313
layout.Add(self.chk_preserve_screen_border, (i := i + 1, 0), (0, 1), flag=wx.ALIGN_CENTER_VERTICAL)
298314
layout.Add(self.lbl_stereo_format, (i := i + 1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
299315
layout.Add(self.cbo_stereo_format, (i, 1), (1, 2), flag=wx.EXPAND)
300-
layout.Add(self.chk_cross_eyed, (i := i + 1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
301-
layout.Add(self.lbl_format_device, (i, 1), (1, 2), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
316+
layout.Add(self.lbl_anaglyph_method, (i := i + 1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
317+
layout.Add(self.cbo_anaglyph_method, (i, 1), (1, 2), flag=wx.EXPAND)
318+
layout.Add(self.lbl_format_device, (i := i + 1, 1), (1, 2), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
302319

303320
sizer_stereo = wx.StaticBoxSizer(self.grp_stereo, wx.VERTICAL)
304321
sizer_stereo.Add(layout, 1, wx.ALL | wx.EXPAND, 4)
@@ -676,6 +693,8 @@ def initialize_component(self):
676693
self.update_compile()
677694

678695
self.grp_adjustment.Hide()
696+
697+
self.btn_start.SetFocus()
679698
self.Fit()
680699

681700
def get_depth_models(self, small_only):
@@ -736,6 +755,13 @@ def get_editable_comboboxes(self):
736755
]
737756
return editable_comboboxes
738757

758+
def get_anaglyph_method(self):
759+
if self.cbo_stereo_format.GetValue() == "Anaglyph":
760+
anaglyph = self.cbo_anaglyph_method.GetValue()
761+
else:
762+
anaglyph = None
763+
return anaglyph
764+
739765
def on_close(self, event):
740766
self.save_preset()
741767
event.Skip()
@@ -852,14 +878,13 @@ def update_auth_state(self, *args, **kwargs):
852878

853879
def update_stereo_format(self, *args, **kwargs):
854880
stereo_format = self.cbo_stereo_format.GetValue()
855-
self.chk_cross_eyed.Show()
856-
if stereo_format == "Half SBS":
881+
if stereo_format in {"Half SBS", "Half TB"}:
857882
self.lbl_format_device.SetLabel("Meta Quest 2/3")
858-
elif stereo_format == "Full SBS":
883+
elif stereo_format in {"Full SBS", "Full TB"}:
859884
self.lbl_format_device.SetLabel("PICO 4")
860885
else:
861886
self.lbl_format_device.SetLabel("")
862-
self.chk_cross_eyed.Hide()
887+
self.update_anaglyph_state()
863888

864889
def update_edge_dilation(self):
865890
if self.cbo_edge_dilation_y.GetValue():
@@ -881,6 +906,15 @@ def on_selected_index_changed_cbo_method(self, event):
881906
self.update_divergence_warning()
882907
self.update_preserve_screen_border()
883908

909+
def update_anaglyph_state(self):
910+
if self.cbo_stereo_format.GetValue() == "Anaglyph":
911+
self.lbl_anaglyph_method.Show()
912+
self.cbo_anaglyph_method.Show()
913+
else:
914+
self.lbl_anaglyph_method.Hide()
915+
self.cbo_anaglyph_method.Hide()
916+
self.GetSizer().Layout()
917+
884918
def update_ema_normalize(self):
885919
if self.chk_ema_normalize.IsChecked():
886920
self.cbo_ema_decay.Enable()
@@ -958,9 +992,15 @@ def parse_args(self):
958992
resolution = int(resolution)
959993

960994
parser = create_parser()
995+
961996
full_sbs = self.cbo_stereo_format.GetValue() == "Full SBS"
997+
tb = self.cbo_stereo_format.GetValue() == "Full TB"
998+
half_tb = self.cbo_stereo_format.GetValue() == "Half TB"
999+
cross_eyed = self.cbo_stereo_format.GetValue() == "Cross Eyed"
9621000
rgbd = self.cbo_stereo_format.GetValue() == "RGB-D"
9631001
half_rgbd = self.cbo_stereo_format.GetValue() == "Half RGB-D"
1002+
anaglyph = self.get_anaglyph_method()
1003+
9641004
device_id = int(self.cbo_device.GetClientData(self.cbo_device.GetSelection()))
9651005
device_id = [device_id]
9661006

@@ -1030,17 +1070,24 @@ def parse_args(self):
10301070
resolution=resolution,
10311071
autocrop=self.cbo_autocrop.GetValue() if self.cbo_autocrop.GetValue() else None,
10321072
compile=self.chk_compile.IsEnabled() and self.chk_compile.IsChecked(),
1033-
cross_eyed=self.chk_cross_eyed.IsChecked(),
1073+
10341074
screenshot=self.cbo_screenshot.GetValue(),
10351075
monitor_index=monitor_index,
10361076
window_name=window_name,
10371077
crop_top=crop_top,
10381078
crop_left=crop_left,
10391079
crop_right=crop_right,
10401080
crop_bottom=crop_bottom,
1081+
1082+
# in iw3.desktop, half_sbs by default
10411083
full_sbs=full_sbs,
1084+
tb=tb,
1085+
half_tb=half_tb,
1086+
cross_eyed=cross_eyed,
10421087
rgbd=rgbd,
10431088
half_rgbd=half_rgbd,
1089+
anaglyph=anaglyph,
1090+
10441091
pad_mode=pad_mode,
10451092

10461093
**viewer_kwargs,

iw3/desktop/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ def try_switch_mlbw_model(old_divergence, new_divergence, old_side_model, args):
218218
def iw3_desktop_main(args, init_wxapp=True):
219219
init_num_threads(args.gpu[0])
220220

221-
if not (args.full_sbs or args.rgbd or args.half_rgbd):
221+
if not any([args.full_sbs, args.tb, args.half_tb,
222+
args.cross_eyed, args.rgbd, args.half_rgbd, args.anaglyph]):
222223
args.half_sbs = True
223224

224225
if args.user or args.password:

0 commit comments

Comments
 (0)