void showAllVisibleAnatomy() { AxisAlignedBox boundingBox = anatomyController.VisibleObjectsBoundingBox; SceneViewWindow activeWindow = sceneViewController.ActiveWindow; Vector3 center = boundingBox.Center; float nearPlane = activeWindow.Camera.getNearClipDistance(); float theta = activeWindow.Camera.getFOVy(); float aspectRatio = activeWindow.Camera.getAspectRatio(); if (aspectRatio < 1.0f) { theta *= aspectRatio; } Vector3 translation = center; Vector3 direction = (activeWindow.Translation - activeWindow.LookAt).normalized(); float diagonalDistance = boundingBox.DiagonalDistance; if (diagonalDistance > float.Epsilon) { translation += direction * diagonalDistance / (float)Math.Tan(theta); CameraPosition undoPosition = activeWindow.createCameraPosition(); activeWindow.setPosition(new CameraPosition() { Translation = translation, LookAt = center }, MedicalConfig.CameraTransitionTime); activeWindow.pushUndoState(undoPosition); } }
internal void centerAnatomy(AnatomyContextWindow requestingWindow) { AxisAlignedBox boundingBox = requestingWindow.Anatomy.WorldBoundingBox; SceneViewWindow window = sceneViewController.ActiveWindow; if (window != null) { CameraPosition undoPosition = window.createCameraPosition(); Vector3 center = boundingBox.Center; float nearPlane = window.Camera.getNearClipDistance(); float theta = window.Camera.getFOVy(); float aspectRatio = window.Camera.getAspectRatio(); if (aspectRatio < 1.0f) { theta *= aspectRatio; } Vector3 translation = center; Vector3 direction = (window.Translation - window.LookAt).normalized(); translation += direction * boundingBox.DiagonalDistance / (float)Math.Tan(theta); CameraPosition cameraPosition = new CameraPosition() { Translation = translation, LookAt = center }; window.setPosition(cameraPosition, MedicalConfig.CameraTransitionTime); window.pushUndoState(undoPosition); } }
public void applyCameraPosition(CameraPosition cameraPosition, float duration) { SceneViewWindow window = standaloneController.SceneViewController.ActiveWindow; if (window != null) { window.setPosition(cameraPosition, duration); } }
public void applyBookmark(Bookmark bookmark) { SceneViewWindow window = standaloneController.SceneViewController.ActiveWindow; LayerState undoLayers = LayerState.CreateAndCapture(); CameraPosition undoCameraPosition = window.createCameraPosition(); window.setPosition(bookmark.CameraPosition, MedicalConfig.CameraTransitionTime); bookmark.Layers.timedApply(MedicalConfig.CameraTransitionTime); standaloneController.LayerController.pushUndoState(undoLayers); window.pushUndoState(undoCameraPosition); }
public override void editing() { if (TimelineController != null) { SceneViewWindow window = TimelineController.SceneViewController.ActiveWindow; if (window != null) { CameraPosition undo = window.createCameraPosition(); window.setPosition(CameraPosition, MedicalConfig.CameraTransitionTime); window.pushUndoState(undo); } } }
public override void started(float timelineTime, Clock clock) { MDISceneViewWindow window = TimelineController.SceneViewController.findWindow(CameraName); if (window != null) { window.setPosition(CameraPosition, Duration); } else { SceneViewWindow sceneViewWindow = TimelineController.SceneViewController.ActiveWindow; if (sceneViewWindow != null) { sceneViewWindow.setPosition(CameraPosition, Duration); } } }
void setStraightAngleView(Vector3 lookAtMask, Vector3 translationMask) { SceneViewWindow activeWindow = sceneViewController.ActiveWindow; if (activeWindow != null) { Vector3 lookAt = activeWindow.LookAt; float length = (activeWindow.Translation - lookAt).length(); Vector3 newTrans = new Vector3(lookAt.x * lookAtMask.x + length * translationMask.x, lookAt.y * lookAtMask.y + length * translationMask.y, lookAt.z * lookAtMask.z + length * translationMask.z); CameraPosition undoPosition = activeWindow.createCameraPosition(); activeWindow.setPosition(new CameraPosition() { Translation = newTrans, LookAt = lookAt, }, MedicalConfig.CameraTransitionTime); activeWindow.pushUndoState(undoPosition); } }
void setTopBottomView(int direction) { SceneViewWindow activeWindow = sceneViewController.ActiveWindow; if (activeWindow != null) { Vector3 lookAt = activeWindow.LookAt; Vector3 transMinusLookAt = activeWindow.Translation - lookAt; float length = (transMinusLookAt).length(); transMinusLookAt.y = 0; //Compute the yaw. float localY = transMinusLookAt.y; transMinusLookAt.y = 0; float yaw = Vector3.Backward.angle(ref transMinusLookAt); if (!float.IsNaN(yaw)) { if (transMinusLookAt.x < 0) { yaw = -yaw; } Quaternion yawRot = new Quaternion(Vector3.Up, yaw); Quaternion pitchRot = new Quaternion(Vector3.Left, HALF_PI * direction); Quaternion rotation = yawRot * pitchRot; Vector3 normalDirection = Quaternion.quatRotate(ref rotation, ref Vector3.Backward); Vector3 newTrans = normalDirection * length + lookAt; CameraPosition undoPosition = activeWindow.createCameraPosition(); activeWindow.setPosition(new CameraPosition() { Translation = newTrans, LookAt = lookAt, }, MedicalConfig.CameraTransitionTime); activeWindow.pushUndoState(undoPosition); } } }
public CommonUICallback(StandaloneController standaloneController, EditorController editorController, PropEditController propEditController) { this.editorController = editorController; this.standaloneController = standaloneController; this.propEditController = propEditController; this.addOneWayCustomQuery(CameraPosition.CustomEditQueries.CaptureCameraPosition, delegate(CameraPosition camPos) { SceneViewWindow activeWindow = standaloneController.SceneViewController.ActiveWindow; if (activeWindow != null) { camPos.Translation = activeWindow.Translation; camPos.LookAt = activeWindow.LookAt; activeWindow.calculateIncludePoint(camPos); } }); this.addOneWayCustomQuery(CameraPosition.CustomEditQueries.PreviewCameraPosition, delegate(CameraPosition camPos) { SceneViewWindow activeWindow = standaloneController.SceneViewController.ActiveWindow; if (activeWindow != null) { CameraPosition undo = activeWindow.createCameraPosition(); activeWindow.setPosition(camPos, MedicalConfig.CameraTransitionTime); activeWindow.pushUndoState(undo); } }); this.addCustomQuery <PresetState>(ChangeMedicalStateCommand.CustomEditQueries.CapturePresetState, delegate(SendResult <PresetState> resultCallback) { PresetStateCaptureDialog stateCaptureDialog = new PresetStateCaptureDialog(resultCallback); stateCaptureDialog.SmoothShow = true; stateCaptureDialog.open(true); }); this.addOneWayCustomQuery(RmlView.CustomQueries.OpenFileInRmlViewer, delegate(String file) { editorController.openEditor(file); }); this.addCustomQuery <Browser>(ViewCollection.CustomQueries.CreateViewBrowser, delegate(SendResult <Browser> resultCallback) { Browser browser = new Browser("Views", "Choose View Type"); standaloneController.MvcCore.ViewHostFactory.createViewBrowser(browser); String errorPrompt = null; resultCallback(browser, ref errorPrompt); }); this.addCustomQuery <Browser>(ModelCollection.CustomQueries.CreateModelBrowser, delegate(SendResult <Browser> resultCallback) { Browser browser = new Browser("Models", "Choose Model Type"); browser.addNode(null, null, new BrowserNode("DataModel", typeof(DataModel), DataModel.DefaultName)); browser.addNode(null, null, new BrowserNode("Navigation", typeof(NavigationModel), NavigationModel.DefaultName)); browser.addNode(null, null, new BrowserNode("MedicalStateInfo", typeof(MedicalStateInfoModel), MedicalStateInfoModel.DefaultName)); browser.addNode(null, null, new BrowserNode("BackStack", typeof(BackStackModel), BackStackModel.DefaultName)); String error = null; resultCallback(browser, ref error); }); this.addCustomQuery <Type>(RunCommandsAction.CustomQueries.ShowCommandBrowser, delegate(SendResult <Type> resultCallback) { this.showBrowser(RunCommandsAction.CreateCommandBrowser(), resultCallback); }); this.addCustomQuery <Color>(ShowTextAction.CustomQueries.ChooseColor, queryDelegate => { ColorDialog colorDialog = new ColorDialog(); colorDialog.showModal((result, color) => { if (result == NativeDialogResult.OK) { String errorPrompt = null; queryDelegate.Invoke(color, ref errorPrompt); } }); }); this.addOneWayCustomQuery <ShowPropAction>(ShowPropAction.CustomQueries.KeepOpenToggle, showPropAction => { if (showPropAction.KeepOpen) { propEditController.removeOpenProp(showPropAction); } else { propEditController.addOpenProp(showPropAction); } }); this.addSyncCustomQuery <Browser, IEnumerable <String>, String>(FileBrowserEditableProperty.CustomQueries.BuildBrowser, (searchPattern, prompt) => { return(createFileBrowser(searchPattern, prompt)); }); this.addSyncCustomQuery <Browser>(AnatomyManager.CustomQueries.BuildBrowser, () => { return(AnatomyManager.buildBrowser()); }); this.addSyncCustomQuery <Browser>(PropBrowserEditableProperty.CustomQueries.BuildBrowser, () => { Browser browser = new Browser("Props", "Choose Prop"); foreach (var propDef in standaloneController.TimelineController.PropFactory.PropDefinitions) { if (standaloneController.LicenseManager.allowPropUse(propDef.PropLicenseId)) { browser.addNode(propDef.BrowserPath, new BrowserNode(propDef.PrettyName, propDef.Name)); } } return(browser); }); this.addSyncCustomQuery <Browser>(ElementNameEditableProperty.CustomQueries.BuildBrowser, () => { Browser browser = new Browser("Screen Location Name", "Choose Screen Location Name"); foreach (var elementName in standaloneController.GUIManager.NamedLinks) { browser.addNode(null, null, new BrowserNode(elementName.UniqueDerivedName, elementName)); } return(browser); }); addOneWayCustomQuery <String>(PlaySoundAction.CustomQueries.EditExternally, soundFile => { if (soundFile != null && editorController.ResourceProvider.exists(soundFile)) { String fullPath = editorController.ResourceProvider.getFullFilePath(soundFile); OtherProcessManager.openLocalURL(fullPath); } }); }