public void CustomizeView(Watch3D model, NodeView nodeView) { model.ViewModel = nodeView.ViewModel.DynamoViewModel; this.watch3dModel = model; View = new Watch3DView(model.GUID, watch3dModel) { Width = model.WatchWidth, Height = model.WatchHeight }; View.View.Camera.Position = model.CameraPosition; View.View.Camera.LookDirection = model.LookDirection; // When user sizes a watch node, only view gets resized. The actual // NodeModel does not get updated. This is where the view updates the // model whenever its size is updated. View.SizeChanged += (sender, args) => model.SetSize(args.NewSize.Width, args.NewSize.Height); model.RequestUpdateLatestCameraPosition += this.UpdateLatestCameraPosition; var mi = new MenuItem { Header = "Zoom to Fit" }; mi.Click += mi_Click; nodeView.MainContextMenu.Items.Add(mi); var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeView.PresentationGrid.Children.Add(backgroundRect); nodeView.PresentationGrid.Children.Add(View); nodeView.PresentationGrid.Visibility = Visibility.Visible; DataBridge.Instance.RegisterCallback( model.GUID.ToString(), obj => nodeView.Dispatcher.Invoke( new Action <object>(RenderData), DispatcherPriority.Render, obj)); }
public void SetupCustomUIElements(dynNodeView nodeUI) { this.ViewModel = nodeUI.ViewModel.DynamoViewModel; VisualizationManager = ViewModel.VisualizationManager; var mi = new MenuItem { Header = "Zoom to Fit" }; mi.Click += mi_Click; nodeUI.MainContextMenu.Items.Add(mi); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation //_watchView = new WatchView(); View = new Watch3DView(GUID) { DataContext = this, Width = _watchWidth, Height = _watchHeight }; View.View.Camera.Position = _camPosition; View.View.Camera.LookDirection = _lookDirection; var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeUI.PresentationGrid.Children.Add(backgroundRect); nodeUI.PresentationGrid.Children.Add(View); nodeUI.PresentationGrid.Visibility = Visibility.Visible; DataBridge.Instance.RegisterCallback( GUID.ToString(), obj => nodeUI.Dispatcher.Invoke( new Action <object>(RenderData), DispatcherPriority.Render, obj)); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; MenuItem mi = new MenuItem(); mi.Header = "Zoom to Fit"; mi.Click += new RoutedEventHandler(mi_Click); nodeUI.MainContextMenu.Items.Add(mi); //take out the left and right margins and make this so it's not so wide //NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation //_watchView = new WatchView(); _watchView = new Watch3DView(GUID.ToString()); _watchView.DataContext = this; _watchView.Width = _watchWidth; _watchView.Height = _watchHeight; _watchView.View.Camera.Position = _camPosition; _watchView.View.Camera.LookDirection = _lookDirection; System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle(); backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; backgroundRect.IsHitTestVisible = false; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeUI.grid.Children.Add(backgroundRect); nodeUI.grid.Children.Add(_watchView); backgroundRect.SetValue(Grid.RowProperty, 2); backgroundRect.SetValue(Grid.ColumnSpanProperty, 3); _watchView.SetValue(Grid.RowProperty, 2); _watchView.SetValue(Grid.ColumnSpanProperty, 3); _watchView.Margin = new Thickness(5, 0, 5, 5); backgroundRect.Margin = new Thickness(5, 0, 5, 5); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); }
public void SetupCustomUIElements(dynNodeView nodeUI) { var mi = new MenuItem { Header = "Zoom to Fit" }; mi.Click += mi_Click; nodeUI.MainContextMenu.Items.Add(mi); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation //_watchView = new WatchView(); View = new Watch3DView(GUID.ToString()) { DataContext = this, Width = _watchWidth, Height = _watchHeight }; View.View.Camera.Position = _camPosition; View.View.Camera.LookDirection = _lookDirection; var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeUI.PresentationGrid.Children.Add(backgroundRect); nodeUI.PresentationGrid.Children.Add(View); }
public void CustomizeView(Watch3D model, NodeView nodeView) { var dynamoViewModel = nodeView.ViewModel.DynamoViewModel; watch3dModel = model; var renderingTier = (RenderCapability.Tier >> 16); if (renderingTier < 2) { return; } var dynamoModel = dynamoViewModel.Model; var vmParams = new Watch3DViewModelStartupParams(dynamoModel); watch3DViewModel = new HelixWatch3DNodeViewModel(watch3dModel, vmParams); watch3DViewModel.Setup(dynamoViewModel, dynamoViewModel.RenderPackageFactoryViewModel.Factory); if (model.initialCameraData != null) { try { // The deserialization logic is unified between the view model and this node model. // For the node model, we need to supply the deserialization method with the camera node. var cameraNode = model.initialCameraData.ChildNodes.Cast <XmlNode>().FirstOrDefault(innerNode => innerNode.Name.Equals("camera", StringComparison.OrdinalIgnoreCase)); var cameraData = watch3DViewModel.DeserializeCamera(cameraNode); watch3DViewModel.SetCameraData(cameraData); } catch { watch3DViewModel.SetCameraData(new CameraData()); } } model.Serialized += model_Serialized; watch3DViewModel.ViewCameraChanged += (s, args) => { var camera = watch3DViewModel.GetCameraInformation(); watch3dModel.Camera.Name = camera.Name; watch3dModel.Camera.EyeX = camera.EyePosition.X; watch3dModel.Camera.EyeY = camera.EyePosition.Y; watch3dModel.Camera.EyeZ = camera.EyePosition.Z; watch3dModel.Camera.LookX = camera.LookDirection.X; watch3dModel.Camera.LookY = camera.LookDirection.Y; watch3dModel.Camera.LookZ = camera.LookDirection.Z; watch3dModel.Camera.UpX = camera.UpDirection.X; watch3dModel.Camera.UpY = camera.UpDirection.Y; watch3dModel.Camera.UpZ = camera.UpDirection.Z; }; watch3DView = new Watch3DView() { Width = model.WatchWidth, Height = model.WatchHeight, DataContext = watch3DViewModel }; // When user sizes a watch node, only view gets resized. The actual // NodeModel does not get updated. This is where the view updates the // model whenever its size is updated. // Updated from (Watch3d)View.SizeChanged to nodeView.SizeChanged - height // and width should correspond to node model and not watch3Dview nodeView.SizeChanged += (sender, args) => model.SetSize(args.NewSize.Width, args.NewSize.Height); // set WatchSize in model watch3DView.View.SizeChanged += (sender, args) => model.SetWatchSize(args.NewSize.Width, args.NewSize.Height); var mi = new MenuItem { Header = Resources.ZoomToFit }; mi.Click += mi_Click; nodeView.MainContextMenu.Items.Add(mi); var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false, }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeView.PresentationGrid.Children.Add(backgroundRect); nodeView.PresentationGrid.Children.Add(watch3DView); nodeView.PresentationGrid.Visibility = Visibility.Visible; DataBridge.Instance.RegisterCallback( model.GUID.ToString(), obj => nodeView.Dispatcher.Invoke( new Action <object>(RenderData), DispatcherPriority.Render, obj)); }
public static bool HasNumberOfLines(this Watch3DView view, int numberOfLines) { return(view.Lines.Positions.Count == numberOfLines * 2); }
public static bool HasNumberOfMeshVertices(this Watch3DView view, int numberOfVertices) { return(view.Mesh.Positions.Count == numberOfVertices); }
public static bool HasMeshes(this Watch3DView view) { return(view.Mesh.Positions.Count > 0); }
public static bool HasNumberOfTextObjects(this Watch3DView view, int numberOfTextObjects) { return(view.Text.TextInfo.Count == numberOfTextObjects); }
public static bool HasNumberOfPointVertices(this Watch3DView view, int numberOfPoints) { return(view.Points.Positions.Count == numberOfPoints); }
public static bool HasNumberOfLinesOfColor(this Watch3DView view, int lineCount, Color4 color) { var ptsOfColor = view.Lines.Colors.Where(c => c == color); return(ptsOfColor.Count() == lineCount * 2); }
public void CustomizeView(Watch3D model, NodeView nodeView) { model.ViewModel = nodeView.ViewModel.DynamoViewModel; this.watch3dModel = model; var renderingTier = (RenderCapability.Tier >> 16); if (renderingTier < 2) { return; } View = new Watch3DView(model.GUID, watch3dModel) { Width = model.WatchWidth, Height = model.WatchHeight }; var pos = model.CameraPosition; var viewDir = model.LookDirection; View.View.Camera.Position = new Point3D(pos.X, pos.Z, -pos.Y); View.View.Camera.LookDirection = new Vector3D(viewDir.X, viewDir.Z, -viewDir.Y); // When user sizes a watch node, only view gets resized. The actual // NodeModel does not get updated. This is where the view updates the // model whenever its size is updated. //Updated from (Watch3d)View.SizeChanged to nodeView.SizeChanged - height // and width should correspond to node model and not watch3Dview nodeView.SizeChanged += (sender, args) => model.SetSize(args.NewSize.Width, args.NewSize.Height); model.RequestUpdateLatestCameraPosition += this.UpdateLatestCameraPosition; var mi = new MenuItem { Header = DynamoWatch3D.Properties.Resources.ZoomToFit }; mi.Click += mi_Click; nodeView.MainContextMenu.Items.Add(mi); var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeView.PresentationGrid.Children.Add(backgroundRect); nodeView.PresentationGrid.Children.Add(View); nodeView.PresentationGrid.Visibility = Visibility.Visible; DataBridge.Instance.RegisterCallback( model.GUID.ToString(), obj => nodeView.Dispatcher.Invoke( new Action <object>(RenderData), DispatcherPriority.Render, obj)); View.Loaded += View_Loaded; }