public void Initialize(Cockpit cockpit) { cockpit.Name = "modelCockpit"; // Configure how the cockpit moves //cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) //cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; var tracker = SmoothCockpitTracker.Enable(cockpit); //cockpit.TiltAngle = 10.0f; cockpit.TiltAngle = 0.0f; tracker.ShowIndicator = false; FScene Scene = cockpit.Scene; //ISurfaceBoxRegion region = new CylinderBoxRegion() { Radius = 1.0f, MinHeight = -1.0f, MaxHeight = 0.3f, HorzDegreeLeft = 50, HorzDegreeRight = 50 }; ISurfaceBoxRegion region = new SphereBoxRegion() { Radius = 1.0f, VertDegreeBottom = 30, VertDegreeTop = 10, HorzDegreeLeft = 55, HorzDegreeRight = 55 }; //Frame3f f = new Frame3f(new Vector3f(0, 0, 1), Vector3f.AxisZ); //f.RotateAround(Vector3f.Zero, Quaternionf.AxisAngleD(Vector3f.AxisX, 10)); //f.RotateAround(Vector3f.Zero, Quaternionf.AxisAngleD(Vector3f.AxisY, -50)); //ISurfaceBoxRegion region = new PlaneBoxRegion() { // Frame = f, Dimensions = new AxisAlignedBox2f(-0.15f, -0.5f, 0.5f, 0.2f) //}; BoxContainer leftPanelContainer = new BoxContainer(new BoxRegionContainerProvider(cockpit, region)); PinnedBoxes3DLayoutSolver leftPanelLayout = new PinnedBoxes3DLayoutSolver(leftPanelContainer, region); PinnedBoxesLayout layout = new PinnedBoxesLayout(cockpit, leftPanelLayout) { StandardDepth = 0.0f }; cockpit.AddLayout(layout, "3D", true); ISurfaceBoxRegion cylregion = new CylinderBoxRegion() { Radius = 1.0f, MinHeight = -1.0f, MaxHeight = 0.2f, HorzDegreeLeft = 55, HorzDegreeRight = 50 }; BoxContainer cylPanelContainer = new BoxContainer(new BoxRegionContainerProvider(cockpit, cylregion)); PinnedBoxes3DLayoutSolver cylPanelLayout = new PinnedBoxes3DLayoutSolver(cylPanelContainer, cylregion); PinnedBoxesLayout cyl_layout = new PinnedBoxesLayout(cockpit, cylPanelLayout) { StandardDepth = 0.0f }; cockpit.AddLayout(cyl_layout, "cylinder", true); float button_width = 0.32f; float button_height = 0.075f; float button_spacing = 0.015f; float text_height = button_height * 0.6f; float row_y_shift = button_height + button_spacing; Func <string, float, HUDLabel> MakeButtonF = (label, buttonW) => { HUDLabel button = new HUDLabel() { Shape = OrthogenUI.MakeMenuButtonRect(buttonW, button_height), TextHeight = text_height, AlignmentHorz = HorizontalAlignment.Center, BackgroundColor = OrthogenUI.ButtonBGColor, TextColor = OrthogenUI.ButtonTextColor, DisabledTextColor = OrthogenUI.DisabledButtonTextColor, Text = label, EnableBorder = false, BorderWidth = OrthogenUI.StandardButtonBorderWidth, BorderColor = OrthogenUI.ButtonTextColor }; button.Create(); button.Name = label; button.Enabled = true; return(button); }; /* * Scan UI */ HUDElementList scan_buttons_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Vertical }; HUDLabel trim_scan_button = MakeButtonF("Trim Scan", button_width); trim_scan_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.TrimScanStartT); }; scan_buttons_list.AddListItem(trim_scan_button); HUDLabel align_scan_button = MakeButtonF("Align Scan", button_width); align_scan_button.OnClicked += (sender, e) => { OG.Transition(OGVRWorkflow.VRAlignScanStartT); }; scan_buttons_list.AddListItem(align_scan_button); HUDLabel accept_scan_button = MakeButtonF("Done Scan", button_width); accept_scan_button.OnClicked += (sender, e) => { OG.TransitionToState(RectifyState.Identifier); }; scan_buttons_list.AddListItem(accept_scan_button); scan_buttons_list.Create(); scan_buttons_list.Name = "scan_buttons_list"; cyl_layout.Add(scan_buttons_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(scan_buttons_list, BoxPosition.CenterTop), PinTargetPoint2D = LayoutUtil.BoxPointF(cylPanelContainer, BoxPosition.TopLeft) }); /* * Model UI UI */ HUDElementList model_buttons_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Vertical }; HUDLabel draw_offset_area_button = MakeButtonF("Offset Area", button_width); draw_offset_area_button.OnClicked += (sender, e) => { OGActions.CurrentLegDeformType = LegModel.LegDeformationTypes.Offset; OG.Transition(OGWorkflow.DrawAreaStartT); }; model_buttons_list.AddListItem(draw_offset_area_button); HUDLabel draw_smooth_area_button = MakeButtonF("Smooth Area", button_width); draw_smooth_area_button.OnClicked += (sender, e) => { OGActions.CurrentLegDeformType = LegModel.LegDeformationTypes.Smooth; OG.Transition(OGWorkflow.DrawAreaStartT); }; model_buttons_list.AddListItem(draw_smooth_area_button); HUDLabel add_plane_button = MakeButtonF("Add Plane", button_width); add_plane_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.AddDeformRingStartT); }; model_buttons_list.AddListItem(add_plane_button); HUDLabel add_lengthen_button = MakeButtonF("Add Lengthen", button_width); add_lengthen_button.OnClicked += (sender, e) => { if (OGActions.CanAddLengthenOp()) { OGActions.AddLengthenOp(); } }; model_buttons_list.AddListItem(add_lengthen_button); HUDLabel sculpt_curve_model_button = MakeButtonF("Sculpt Curve", button_width); WorkflowRouter sculpt_router = WorkflowRouter.Build(new[] { OGWorkflow.RectifyState, OGWorkflow.SculptAreaStartT, OGWorkflow.SocketState, OGWorkflow.SculptTrimlineStartT }); sculpt_curve_model_button.OnClicked += (sender, e) => { sculpt_router.Apply(OG.Model.Workflow); }; model_buttons_list.AddListItem(sculpt_curve_model_button); HUDLabel accept_rectify_button = MakeButtonF("Begin Socket", button_width); accept_rectify_button.OnClicked += (sender, e) => { OG.TransitionToState(SocketDesignState.Identifier); OG.Leg.SetOpWidgetVisibility(false); }; model_buttons_list.AddListItem(accept_rectify_button); model_buttons_list.Create(); model_buttons_list.Name = "model_buttons_list"; cyl_layout.Add(model_buttons_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(model_buttons_list, BoxPosition.CenterTop), PinTargetPoint2D = LayoutUtil.BoxPointF(cylPanelContainer, BoxPosition.TopLeft) }); /* * Model UI UI */ HUDElementList socket_buttons_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Vertical }; HUDLabel draw_trim_line_button = MakeButtonF("Draw Trimline", button_width); draw_trim_line_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.DrawTrimlineStartT); }; socket_buttons_list.AddListItem(draw_trim_line_button); HUDLabel plane_trim_line_button = MakeButtonF("Plane Trimline", button_width); plane_trim_line_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.PlaneTrimlineStartT); }; socket_buttons_list.AddListItem(plane_trim_line_button); HUDLabel sculpt_trimline_button = MakeButtonF("Sculpt Trimline", button_width); sculpt_trimline_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.SculptTrimlineStartT); }; socket_buttons_list.AddListItem(sculpt_trimline_button); HUDLabel add_socket_button = MakeButtonF("Add Socket", button_width); add_socket_button.OnClicked += (sender, e) => { if (OGActions.CanAddSocket()) { OGActions.AddSocket(); } }; socket_buttons_list.AddListItem(add_socket_button); HUDLabel export_socket_button = MakeButtonF("Export", button_width); export_socket_button.OnClicked += (sender, e) => { if (OGActions.CanExportSocket()) { OGActions.ExportSocket(); } }; socket_buttons_list.AddListItem(export_socket_button); // align button list top top-left of ui socket_buttons_list.Create(); socket_buttons_list.Name = "socket_buttons"; cyl_layout.Add(socket_buttons_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(socket_buttons_list, BoxPosition.CenterTop), PinTargetPoint2D = LayoutUtil.BoxPointF(cylPanelContainer, BoxPosition.TopLeft) }); HUDElementList ok_cancel_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Horizontal }; HUDLabel accept_button = MakeButtonF("Accept", button_width * 0.75f); accept_button.OnClicked += (sender, e) => { OGActions.AcceptCurrentTool(); }; HUDLabel cancel_button = MakeButtonF("Cancel", button_width * 0.75f); cancel_button.OnClicked += (sender, e) => { OGActions.CancelCurrentTool(); }; ok_cancel_list.AddListItem(accept_button); ok_cancel_list.AddListItem(cancel_button); // align button list top top-left of ui ok_cancel_list.Create(); ok_cancel_list.Name = "ok_cancel_list"; layout.Add(ok_cancel_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(ok_cancel_list, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(leftPanelContainer, BoxPosition.BottomLeft) }); HUDElementList size_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Horizontal }; HUDLabel size_1to1 = MakeButtonF("Real Size", button_width * 0.75f); size_1to1.OnClicked += (sender, e) => { OGActions.SetSizeMode(OGActions.SizeModes.RealSize); OGActions.RecenterVRView(false); }; HUDLabel size_medium = MakeButtonF("Zoom Size", button_width * 0.75f); size_medium.OnClicked += (sender, e) => { OGActions.SetSizeMode(OGActions.SizeModes.DemoSize); OGActions.RecenterVRView(false); }; size_list.AddListItem(size_1to1); size_list.AddListItem(size_medium); size_list.Create(); size_list.Name = "size_list"; layout.Add(size_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(size_list, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(leftPanelContainer, BoxPosition.BottomLeft), FrameAxesShift = new Vector3f(0, -row_y_shift, 0) }); HUDElementList view_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Horizontal }; HUDLabel recenter_button = MakeButtonF("Recenter", 2 * button_width * 0.75f); recenter_button.OnClicked += (sender, e) => { OGActions.RecenterVRView(true); }; view_list.AddListItem(recenter_button); view_list.Create(); view_list.Name = "view_list"; layout.Add(view_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(view_list, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(leftPanelContainer, BoxPosition.BottomLeft), FrameAxesShift = new Vector3f(0, -2 * row_y_shift, 0) }); HUDElementList capture_list = new HUDElementList() { Width = button_width, Height = button_height, Spacing = button_spacing, SizeMode = HUDElementList.SizeModes.AutoSizeToFit, Direction = HUDElementList.ListDirection.Horizontal }; HUDLabel capture_button = MakeButtonF("Capture", button_width * 0.75f); capture_button.OnClicked += (sender, e) => { if (FBCapture.CaptureOption.Active != null) { if (capture_button.Text == "Capture") { DebugUtil.Log("Starting 2D Capture..."); FBCapture.CaptureOption.Active.doSurroundCaptureOption = false; cockpit.Context.RegisterNextFrameAction(() => { //FBCapture.CaptureOption.Active.videoWidth = 4096; //FBCapture.CaptureOption.Active.videoHeight = 2048; FBCapture.CaptureOption.Active.StartCaptureVideo(); capture_button.Text = "Stop"; }); } else { FBCapture.CaptureOption.Active.StopCaptureVideo(); capture_button.Text = "Capture"; } } }; HUDLabel vrcapture_button = MakeButtonF("VRCapture", button_width * 0.75f); vrcapture_button.OnClicked += (sender, e) => { if (FBCapture.CaptureOption.Active != null) { if (vrcapture_button.Text == "VRCapture") { // [RMS] when we set this flag, we need to give CaptureOption.Update() a chance to see // it, which means we need to wait up to 2 frames FBCapture.CaptureOption.Active.doSurroundCaptureOption = true; cockpit.Context.RegisterNextFrameAction(() => { cockpit.Context.RegisterNextFrameAction(() => { GameObject encoderObj = GameObject.Find("EncoderObject"); encoderObj.transform.position = Camera.main.transform.position; encoderObj.transform.rotation = Quaternionf.Identity; GameObject head = UnityUtil.FindGameObjectByName("VRHead"); head.SetVisible(false); FBCapture.CaptureOption.Active.StartCaptureVideo(); vrcapture_button.Text = "Stop"; }); }); } else { FBCapture.CaptureOption.Active.StopCaptureVideo(); vrcapture_button.Text = "VRCapture"; } } }; capture_list.AddListItem(capture_button); capture_list.AddListItem(vrcapture_button); // align button list top top-left of ui capture_list.Create(); capture_list.Name = "capture_list"; layout.Add(capture_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.LocalBoxPointF(capture_list, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(leftPanelContainer, BoxPosition.BottomLeft), FrameAxesShift = new Vector3f(0, -3 * row_y_shift, 0) }); leftPanelLayout.RecomputeLayout(); leftPanelLayout.RecomputeLayout(); leftPanelLayout.RecomputeLayout(); leftPanelLayout.RecomputeLayout(); leftPanelLayout.RecomputeLayout(); cylPanelLayout.RecomputeLayout(); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new OrthoVRKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) if (cockpit.Context.Use2DCockpit) { cockpit.InputBehaviors.Add(new Mouse2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); } cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 1 }); cockpit.InputBehaviors.Add(new SpatialDeviceGrabViewBehavior(cockpit) { Priority = 2 }); //cockpit.InputBehaviors.Add(new TwoHandViewManipBehavior(cockpit) { Priority = 1 }); //cockpit.InputBehaviors.Add(new SpatialDeviceViewManipBehavior(cockpit) { Priority = 2 }); // selection / multi-selection behaviors cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new SpatialDeviceMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new MouseDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new SpatialDeviceDeselectBehavior(cockpit.Context) { Priority = 999 }); // update buttons enable/disable on state transitions, selection changes string main_state = ""; Action updateStateChangeButtons = () => { if (OG.IsInState(OGWorkflow.ScanState)) { main_state = OGWorkflow.ScanState; } else if (OG.IsInState(OGWorkflow.RectifyState)) { main_state = OGWorkflow.RectifyState; } else if (OG.IsInState(OGWorkflow.SocketState)) { main_state = OGWorkflow.SocketState; } scan_buttons_list.IsVisible = (main_state == OGWorkflow.ScanState); model_buttons_list.IsVisible = (main_state == OGWorkflow.RectifyState); socket_buttons_list.IsVisible = (main_state == OGWorkflow.SocketState); trim_scan_button.Enabled = OG.CanTransition(OGWorkflow.TrimScanStartT); align_scan_button.Enabled = OG.CanTransition(OGVRWorkflow.VRAlignScanStartT); accept_scan_button.Enabled = OG.IsInState(ScanState.Identifier) && OG.CanTransitionToState(RectifyState.Identifier); draw_offset_area_button.Enabled = OG.CanTransition(OGWorkflow.DrawAreaStartT); draw_smooth_area_button.Enabled = OG.CanTransition(OGWorkflow.DrawAreaStartT); add_plane_button.Enabled = OG.CanTransition(OGWorkflow.AddDeformRingStartT); add_lengthen_button.Enabled = OGActions.CanAddLengthenOp(); accept_rectify_button.Enabled = OG.IsInState(RectifyState.Identifier) && OG.CanTransitionToState(SocketDesignState.Identifier); draw_trim_line_button.Enabled = OG.CanTransition(OGWorkflow.DrawTrimlineStartT); plane_trim_line_button.Enabled = OG.CanTransition(OGWorkflow.PlaneTrimlineStartT); add_socket_button.Enabled = OGActions.CanAddSocket(); export_socket_button.Enabled = OGActions.CanExportSocket(); sculpt_curve_model_button.Enabled = sculpt_router.CanApply(OG.Model.Workflow); sculpt_trimline_button.Enabled = OG.CanTransition(OGWorkflow.SculptTrimlineStartT); }; OG.OnWorfklowInitialized += (o, e) => { updateStateChangeButtons(); }; OG.OnStateTransition += (from, to) => { updateStateChangeButtons(); }; OG.OnDataModelModified += (from, to) => { updateStateChangeButtons(); }; cockpit.Scene.SelectionChangedEvent += (o, e) => { if (OG.WorkflowInitialized) { updateStateChangeButtons(); } }; cockpit.Scene.ChangedEvent += (scene, so, type) => { if (OG.WorkflowInitialized) { updateStateChangeButtons(); } }; // accept/cancel buttons need to be checked every frame because the CanApply state // could change at any time, and there is no event about it cockpit.Context.RegisterEveryFrameAction("update_buttons", () => { if (cockpit.Context.ToolManager.ActiveRightTool != null) { cancel_button.Enabled = true; accept_button.Enabled = cockpit.Context.ToolManager.ActiveRightTool.CanApply; } else { cancel_button.Enabled = accept_button.Enabled = false; } // [RMS] currently this state changes outside workflow state changes... add_socket_button.Enabled = OGActions.CanAddSocket(); }); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "modelCockpit"; // Configure how the cockpit moves cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) //cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; FScene Scene = cockpit.Scene; BoxContainer screenContainer = new BoxContainer(new Cockpit2DContainerProvider(cockpit)); PinnedBoxes2DLayoutSolver screenLayout = new PinnedBoxes2DLayoutSolver(screenContainer); PinnedBoxesLayout layout = new PinnedBoxesLayout(cockpit, screenLayout) { StandardDepth = 1.5f }; cockpit.AddLayout(layout, "2D", true); Func <string, float, HUDLabel> MakeButtonF = (label, buttonW) => { HUDLabel button = new HUDLabel() { Shape = OrthogenUI.MakeMenuButtonRect(buttonW, OrthogenUI.MenuButtonHeight), TextHeight = OrthogenUI.MenuButtonTextHeight, AlignmentHorz = HorizontalAlignment.Center, BackgroundColor = OrthogenUI.ButtonBGColor, TextColor = OrthogenUI.ButtonTextColor, DisabledTextColor = OrthogenUI.DisabledButtonTextColor, Text = label, EnableBorder = true, BorderWidth = OrthogenUI.StandardButtonBorderWidth, BorderColor = OrthogenUI.ButtonTextColor }; button.Create(); button.Name = label; button.Enabled = true; return(button); }; Func <string, float, float, HUDSpacer> MakeSpacerF = (label, spacerw, spacerh) => { HUDSpacer spacer = new HUDSpacer() { Shape = new HUDShape(HUDShapeType.Rectangle, spacerw, spacerh) }; spacer.Create(); spacer.Name = label; return(spacer); }; HUDElementList button_list = new HUDElementList() { Width = OrthogenUI.MenuButtonWidth, Height = 5 * OrthogenUI.MenuButtonHeight, Spacing = 10 * OrthogenUI.PixelScale, Direction = HUDElementList.ListDirection.Vertical }; HUDLabel trim_scan_button = MakeButtonF("Trim Scan", OrthogenUI.MenuButtonWidth); trim_scan_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.TrimScanStartT); }; button_list.AddListItem(trim_scan_button); HUDLabel align_scan_button = MakeButtonF("Align Scan", OrthogenUI.MenuButtonWidth); align_scan_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.AlignScanStartT); }; button_list.AddListItem(align_scan_button); HUDLabel accept_scan_button = MakeButtonF("Done Scan", OrthogenUI.MenuButtonWidth); accept_scan_button.OnClicked += (sender, e) => { OG.TransitionToState(RectifyState.Identifier); }; button_list.AddListItem(accept_scan_button); button_list.AddListItem(MakeSpacerF("space", OrthogenUI.MenuButtonWidth, 0.5f * OrthogenUI.MenuButtonHeight)); HUDLabel draw_offset_area_button = MakeButtonF("Offset Area", OrthogenUI.MenuButtonWidth); draw_offset_area_button.OnClicked += (sender, e) => { OGActions.CurrentLegDeformType = LegModel.LegDeformationTypes.Offset; OG.Transition(OGWorkflow.DrawAreaStartT); }; button_list.AddListItem(draw_offset_area_button); HUDLabel draw_smooth_area_button = MakeButtonF("Smooth Area", OrthogenUI.MenuButtonWidth); draw_smooth_area_button.OnClicked += (sender, e) => { OGActions.CurrentLegDeformType = LegModel.LegDeformationTypes.Smooth; OG.Transition(OGWorkflow.DrawAreaStartT); }; button_list.AddListItem(draw_smooth_area_button); HUDLabel add_plane_button = MakeButtonF("Add Plane", OrthogenUI.MenuButtonWidth); add_plane_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.AddDeformRingStartT); }; button_list.AddListItem(add_plane_button); HUDLabel add_lengthen_button = MakeButtonF("Add Lengthen", OrthogenUI.MenuButtonWidth); add_lengthen_button.OnClicked += (sender, e) => { if (OGActions.CanAddLengthenOp()) { OGActions.AddLengthenOp(); } }; button_list.AddListItem(add_lengthen_button); HUDLabel sculpt_curve_button = MakeButtonF("Sculpt Curve", OrthogenUI.MenuButtonWidth); WorkflowRouter sculpt_router = WorkflowRouter.Build(new[] { OGWorkflow.RectifyState, OGWorkflow.SculptAreaStartT, OGWorkflow.SocketState, OGWorkflow.SculptTrimlineStartT }); sculpt_curve_button.OnClicked += (sender, e) => { sculpt_router.Apply(OG.Model.Workflow); }; button_list.AddListItem(sculpt_curve_button); HUDLabel accept_rectify_button = MakeButtonF("Begin Socket", OrthogenUI.MenuButtonWidth); accept_rectify_button.OnClicked += (sender, e) => { OG.Leg.SetOpWidgetVisibility(false); OG.TransitionToState(SocketDesignState.Identifier); }; button_list.AddListItem(accept_rectify_button); button_list.AddListItem(MakeSpacerF("space", OrthogenUI.MenuButtonWidth, 0.5f * OrthogenUI.MenuButtonHeight)); HUDLabel draw_trim_line_button = MakeButtonF("Draw Trimline", OrthogenUI.MenuButtonWidth); draw_trim_line_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.DrawTrimlineStartT); }; button_list.AddListItem(draw_trim_line_button); HUDLabel plane_trim_line_button = MakeButtonF("Plane Trimline", OrthogenUI.MenuButtonWidth); plane_trim_line_button.OnClicked += (sender, e) => { OG.Transition(OGWorkflow.PlaneTrimlineStartT); }; button_list.AddListItem(plane_trim_line_button); HUDLabel add_socket_button = MakeButtonF("Add Socket", OrthogenUI.MenuButtonWidth); add_socket_button.OnClicked += (sender, e) => { if (OGActions.CanAddSocket()) { OGActions.AddSocket(); } }; button_list.AddListItem(add_socket_button); HUDLabel export_socket_button = MakeButtonF("Export", OrthogenUI.MenuButtonWidth); export_socket_button.OnClicked += (sender, e) => { if (OGActions.CanExportSocket()) { OGActions.ExportSocket(); } }; button_list.AddListItem(export_socket_button); button_list.AddListItem(MakeSpacerF("space", OrthogenUI.MenuButtonWidth, 1.0f * OrthogenUI.MenuButtonHeight)); HUDLabel accept_button = MakeButtonF("Accept", OrthogenUI.MenuButtonWidth); accept_button.OnClicked += (sender, e) => { OGActions.AcceptCurrentTool(); }; HUDLabel cancel_button = MakeButtonF("Cancel", OrthogenUI.MenuButtonWidth); cancel_button.OnClicked += (sender, e) => { OGActions.CancelCurrentTool(); }; button_list.AddListItem(accept_button); button_list.AddListItem(cancel_button); button_list.Create(); button_list.Name = "button_bar"; // align button list to center of timeline layout.Add(button_list, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.BoxPointF(button_list, BoxPosition.TopLeft), PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.TopLeft, 10 * OrthogenUI.PixelScale * (Vector2f.AxisX - Vector2f.AxisY)) }); screenLayout.RecomputeLayout(); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new OrthoGenKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) cockpit.InputBehaviors.Add(new Mouse2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 1 }); // selection / multi-selection behaviors // Note: this custom behavior implements some selection redirects that we use in various parts of Archform cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); // left click-drag to tumble, and left click-release to de-select cockpit.InputBehaviors.Add(new MouseClickDragSuperBehavior() { Priority = 100, DragBehavior = new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f }, ClickBehavior = new MouseDeselectBehavior(cockpit.Context) { Priority = 999 } }); // also right-click-drag to tumble cockpit.InputBehaviors.Add(new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f, ActivateF = MouseBehaviors.RightButtonPressedF, ContinueF = MouseBehaviors.RightButtonDownF }); // middle-click-drag to pan cockpit.InputBehaviors.Add(new MouseViewPanBehavior(cockpit.Context) { Priority = 100, PanSpeed = 10.0f, ActivateF = MouseBehaviors.MiddleButtonPressedF, ContinueF = MouseBehaviors.MiddleButtonDownF }); cockpit.OverrideBehaviors.Add(new MouseWheelZoomBehavior(cockpit) { Priority = 100, ZoomScale = 100.0f }); // touch input cockpit.InputBehaviors.Add(new TouchUIBehavior(cockpit.Context) { Priority = 1 }); cockpit.InputBehaviors.Add(new Touch2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new TouchViewManipBehavior(cockpit.Context) { Priority = 999, TouchZoomSpeed = 1.0f, TouchPanSpeed = 0.3f }); // update buttons enable/disable on state transitions, selection changes Action updateStateChangeButtons = () => { trim_scan_button.Enabled = OG.CanTransition(OGWorkflow.TrimScanStartT); align_scan_button.Enabled = OG.CanTransition(OGWorkflow.AlignScanStartT); accept_scan_button.Enabled = OG.IsInState(ScanState.Identifier) && OG.CanTransitionToState(RectifyState.Identifier); draw_offset_area_button.Enabled = OG.CanTransition(OGWorkflow.DrawAreaStartT); draw_smooth_area_button.Enabled = OG.CanTransition(OGWorkflow.DrawAreaStartT); add_plane_button.Enabled = OG.CanTransition(OGWorkflow.AddDeformRingStartT); add_lengthen_button.Enabled = OGActions.CanAddLengthenOp(); accept_rectify_button.Enabled = OG.IsInState(RectifyState.Identifier) && OG.CanTransitionToState(SocketDesignState.Identifier); draw_trim_line_button.Enabled = OG.CanTransition(OGWorkflow.DrawTrimlineStartT); plane_trim_line_button.Enabled = OG.CanTransition(OGWorkflow.PlaneTrimlineStartT); add_socket_button.Enabled = OGActions.CanAddSocket(); export_socket_button.Enabled = OGActions.CanExportSocket(); sculpt_curve_button.Enabled = sculpt_router.CanApply(OG.Model.Workflow); }; OG.OnWorfklowInitialized += (o, e) => { updateStateChangeButtons(); }; OG.OnStateTransition += (from, to) => { updateStateChangeButtons(); }; OG.OnDataModelModified += (from, to) => { updateStateChangeButtons(); }; cockpit.Scene.SelectionChangedEvent += (o, e) => { if (OG.WorkflowInitialized) { updateStateChangeButtons(); } }; cockpit.Scene.ChangedEvent += (scene, so, type) => { if (OG.WorkflowInitialized) { updateStateChangeButtons(); } }; // accept/cancel buttons need to be checked every frame because the CanApply state // could change at any time, and there is no event about it cockpit.Context.RegisterEveryFrameAction("update_buttons", () => { if (cockpit.Context.ToolManager.ActiveRightTool != null) { cancel_button.Enabled = true; accept_button.Enabled = cockpit.Context.ToolManager.ActiveRightTool.CanApply; } else { cancel_button.Enabled = accept_button.Enabled = false; } // [RMS] currently this state changes outside workflow state changes... add_socket_button.Enabled = OGActions.CanAddSocket(); }); }