Inheritance: TUM.CMS.VplControl.Core.Node
Ejemplo n.º 1
0
        /// <summary>
        ///     OnElementMouseDown: Click Event for each geometric element
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="watch3DNode"></param>
        protected void OnElementMouseDown(object sender, MouseButtonEventArgs e, Watch3DNode watch3DNode)
        {
            // Check null expression
            // if (e == null) throw new ArgumentNullException(nameof(e));

            // 1-CLick event
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            // Get sender
            var element = sender as ModelUIElement3D;

            // Check Type
            if (element != null)
            {
                var geometryModel3D = element.Model as GeometryModel3D;
                if (geometryModel3D == null)
                {
                    return;
                }

                // If it is already selected ... Deselect
                if (SelectedModels.Contains(geometryModel3D))
                {
                    geometryModel3D.Material = geometryModel3D.BackMaterial;
                    SelectedModels.Remove(geometryModel3D);
                }
                // If not ... Select!
                else
                {
                    SelectedModels.Add(geometryModel3D);
                    geometryModel3D.Material = _selectionMaterial;
                }
            }

            // Set selected models to Output ...
            if (SelectedModels != null && SelectedModels.Count != 0)
            {
                var container = new ContainerUIElement3D();
                foreach (var geom in SelectedModels)
                {
                    container.Children.Add(new ModelUIElement3D {
                        Model = geom
                    });
                }

                OutputPorts[0].Data = container;
            }

            e.Handled = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     OnElementMouseDown: Click Event for each geometric element
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="watch3DNode"></param>
        protected void OnElementMouseDown(object sender, MouseButtonEventArgs e, Watch3DNode watch3DNode)
        {
            // Check null expression
            // if (e == null) throw new ArgumentNullException(nameof(e));

            // 1-CLick event
            if (e.LeftButton != MouseButtonState.Pressed)
                return;

            // Get sender
            var element = sender as ModelUIElement3D;

            // Check Type
            if (element != null)
            {
                var geometryModel3D = element.Model as GeometryModel3D;
                if (geometryModel3D == null)
                    return;

                // If it is already selected ... Deselect
                if (SelectedModels.Contains(geometryModel3D))
                {
                    geometryModel3D.Material = geometryModel3D.BackMaterial;
                    SelectedModels.Remove(geometryModel3D);
                }
                // If not ... Select!
                else
                {
                    SelectedModels.Add(geometryModel3D);
                    geometryModel3D.Material = _selectionMaterial;
                }
            }

            // Set selected models to Output ...  
            if (SelectedModels != null && SelectedModels.Count != 0)
            {
                var container = new ContainerUIElement3D();
                foreach (var geom in SelectedModels)
                    container.Children.Add(new ModelUIElement3D {Model = geom});

                OutputPorts[0].Data = container;
            }

            e.Handled = true;
        }
        /// <summary>
        ///     OnElementMouseDown: Click Event for each geometric element
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="watch3DNode"></param>
        private void OnElementMouseDown(object sender, MouseButtonEventArgs e, Watch3DNode watch3DNode)
        {
            // 1-CLick event
            if (e.LeftButton != MouseButtonState.Pressed)
                return;

            // Get sender
            var element = sender as ModelUIElement3D;
            var geometryModel3D = element?.Model as GeometryModel3D;
            if (geometryModel3D == null)
                return;

            // Check Type
            // If it is already selected ... Deselect
            if (SelectedModels.Contains(geometryModel3D))
            {
                // var geo = geometryModel3D.Clone();
                // geo.Material = geometryModel3D.BackMaterial;
                geometryModel3D.Material = geometryModel3D.BackMaterial;
                SelectedModels.Remove(geometryModel3D);
            }
            // If not ... Select!
            else
            {
                SelectedModels.Add(geometryModel3D);
                // var geo = geometryModel3D.Clone();
                // geo.Material = _selectionMaterial;
                geometryModel3D.Material = _selectionMaterial;
            }

            // Get the id of the selected model
            var reslist = new List<Guid>();
            
            if (SelectedModels != null && SelectedModels.Count > 0)
            {
                foreach (var item in _fallBackGeometry)
                {
                    foreach (var item_2 in SelectedModels)
                    {
                        if (Equals(item_2.Geometry, item.Model3D.Geometry))
                            reslist.Add(item.Id);
                    }
                }
            }

            string modelId = null;
            string projectId = null;

            if (InputPorts[0].Data.GetType() == typeof(ModelInfo))
            {
                var input = InputPorts[0].Data as ModelInfo;
                if (input != null)
                {
                    modelId = input.ModelId;
                    projectId = input.ProjectId;
                }
            }
            else if (InputPorts[0].Data.GetType() == typeof(BaseRelation))
            {
                var input = InputPorts[0].Data as BaseRelation;
                if (input != null)
                {
                    modelId = input.ModelId.ToString();
                    projectId = input.ProjectId.ToString();
                }
            }
            else
            {
                return;
            }

            var res = new ModelInfo(projectId, modelId, reslist, ModelType.BimPlusModel);

            OutputPorts[0].Data = res;
            // Set selected models to Output ...  
            
            e.Handled = true;
        }