private void LoadSegmentation() { if (Engine.TileManager.ChangesMade) { var mbresult = MessageBox.Show("Changes were made to this segmentation. Do you want to save the changes?", "Save Changes?", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); switch (mbresult) { case MessageBoxResult.Yes: Engine.TileManager.SaveSegmentation(); break; case MessageBoxResult.No: Engine.TileManager.DiscardChanges(); break; default: return; } } var initialPath = Settings.Default.LoadSegmentationPath; if (string.IsNullOrEmpty(initialPath) || !Directory.Exists(initialPath)) { initialPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } var folderBrowserDialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog { Description = "Select Mojo Segmentation Folder (the folder you select should be called \"" + Constants.DATASET_ROOT_DIRECTORY_NAME + "\")", UseDescriptionForTitle = true, ShowNewFolderButton = false, SelectedPath = initialPath }; var result = folderBrowserDialog.ShowDialog(); if (result != null && result == true) { Settings.Default.LoadSegmentationPath = folderBrowserDialog.SelectedPath; Settings.Default.Save(); try { // // Load the segmentation and show (approximate) progress // TileManagerDataContext.Progress = 10; Engine.TileManager.LoadSegmentation(folderBrowserDialog.SelectedPath); TileManagerDataContext.Progress = 70; if (Engine.TileManager.SegmentationLoaded) { // // Set the initial view // Engine.CurrentToolMode = ToolMode.SplitSegmentation; Engine.TileManager.SegmentationVisibilityRatio = 0.5f; // // Load segment info list // TileManagerDataContext.SortSegmentListBy("Size", true); } TileManagerDataContext.Progress = 100; } catch (Exception e) { String errorMessage = "Error loading segmentation from:\n" + folderBrowserDialog.SelectedPath + "\n\n" + e.Message + "\n\nPlease check the path and try again."; MessageBox.Show(errorMessage, "Load Error", MessageBoxButton.OK, MessageBoxImage.Error); Console.WriteLine(errorMessage); } } }
private void LoadDataset() { if (Engine.TileManager.ChangesMade) { var mbresult = MessageBox.Show("Changes were made to this segmentation. Do you want to save the changes?", "Save Changes?", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); switch (mbresult) { case MessageBoxResult.Yes: Engine.TileManager.SaveSegmentation(); break; case MessageBoxResult.No: Engine.TileManager.DiscardChanges(); break; default: return; } } var initialPath = Settings.Default.LoadDatasetPath; if (string.IsNullOrEmpty(initialPath) || !Directory.Exists(initialPath)) { initialPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } var folderBrowserDialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog { Description = "Select Mojo Dataset Folder (the folder you select should be called \"" + Constants.DATASET_ROOT_DIRECTORY_NAME + "\")", UseDescriptionForTitle = true, ShowNewFolderButton = false, SelectedPath = initialPath }; var result = folderBrowserDialog.ShowDialog(); if (result != null && result == true) { Settings.Default.LoadDatasetPath = folderBrowserDialog.SelectedPath; Settings.Default.Save(); try { // // Load the dataset and show (approximate) progress // TileManagerDataContext.Progress = 10; Engine.TileManager.LoadTiledDataset(folderBrowserDialog.SelectedPath); TileManagerDataContext.Progress = 70; if (Engine.TileManager.TiledDatasetLoaded) { // // Set the initial view // var viewportDataSpaceX = Engine.Viewers.Internal[ViewerMode.TileManager2D].D3D11RenderingPane.Viewport.Width / Engine.TileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumVoxelsPerTileX; var viewportDataSpaceY = Engine.Viewers.Internal[ViewerMode.TileManager2D].D3D11RenderingPane.Viewport.Height / Engine.TileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumVoxelsPerTileY; var maxExtentDataSpaceX = Engine.TileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumTilesX *Constants.ConstParameters.GetInt("TILE_SIZE_X"); var maxExtentDataSpaceY = Engine.TileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumTilesY *Constants.ConstParameters.GetInt("TILE_SIZE_Y"); var zoomLevel = Math.Min(viewportDataSpaceX / maxExtentDataSpaceX, viewportDataSpaceY / maxExtentDataSpaceY); Engine.TileManager.TiledDatasetView.CenterDataSpace = new Vector3(maxExtentDataSpaceX / 2f, maxExtentDataSpaceY / 2f, 0f); Engine.TileManager.TiledDatasetView.ExtentDataSpace = new Vector3(viewportDataSpaceX / zoomLevel, viewportDataSpaceY / zoomLevel, 0f); Engine.CurrentToolMode = ToolMode.SplitSegmentation; Engine.TileManager.UpdateXYZ(); } TileManagerDataContext.Progress = 90; // // Reset the segment info list // TileManagerDataContext.SortSegmentListBy("Size", true); TileManagerDataContext.Progress = 100; } catch (Exception e) { String errorMessage = "Error loading images from:\n" + folderBrowserDialog.SelectedPath + "\n\n" + e.Message + "\n\nPlease check the path and try again."; MessageBox.Show(errorMessage, "Load Error", MessageBoxButton.OK, MessageBoxImage.Error); Console.WriteLine(errorMessage); } } }