Beispiel #1
0
        private TreeNode FindTreeNode(PlaneStructure structure)
        {
            //polygons
            foreach (GeometricNode node in treeView.Nodes)
            {
                if (node.Structure == structure)
                {
                    return(node);
                }

                //edges
                foreach (GeometricNode edgeNode in node.Nodes[0].Nodes)
                {
                    if (edgeNode.Structure == structure)
                    {
                        return(edgeNode);
                    }
                }

                //vertices
                foreach (GeometricNode vertexNode in node.Nodes[1].Nodes)
                {
                    if (vertexNode.Structure == structure)
                    {
                        return(vertexNode);
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        public void DeleteStructure(PlaneStructure structure)
        {
            if (structure is Polygon)
            {
                polygons.Remove(structure as Polygon);
                return;
            }

            var polygon = structure.UnderlyingPolygon;

            if (polygon == null)
            {
                return;
            }

            if (structure is Edge)
            {
                polygon.DeleteEdge(structure as Edge);
            }
            else if (structure is Vertex)
            {
                polygon.DeleteVertex(structure as Vertex);
            }

            if (polygon.GetEdges().Count <= 2)
            {
                DeleteStructure(polygon);
            }
        }
Beispiel #3
0
        private void ItemSelected(object sender, TreeViewEventArgs e)
        {
            //close currently drawn polygon
            polygonManager.HandleMouseDown();

            var node = e.Node as GeometricNode;

            if (node.Type == NodeType.EdgesList || node.Type == NodeType.VerticesList)
            {
                structureSelected = null;
                return;
            }

            StructureSelected(node.Structure);
        }
Beispiel #4
0
        private void StructureSelected(PlaneStructure structure)
        {
            polygonManager.ClearDrawColor(Color.Black);
            structureSelected = structure;

            if (structure != null)
            {
                structure.DrawingColor = Color.Red;
            }
            else
            {
                treeView.SelectedNode = null;
            }

            polygonManager.UpdateSelectedStructure(structureSelected);
        }
Beispiel #5
0
        public void InitPolygonAdd()
        {
            if (mouseState == MouseState.Drawing && currentStructure is Polygon)
            {
                TryClosePolygon(currentStructure as Polygon);
            }

            if (mouseState != MouseState.Normal)
            {
                return;
            }

            mouseState = MouseState.Drawing;
            var polygon = new Polygon();

            currentStructure = polygon;
            polygons.Add(polygon);
            Update();
            OnStructureChanged?.Invoke(this, polygon);
        }
Beispiel #6
0
 public GeometricNode(String name, NodeType type, PlaneStructure structure) : base(name)
 {
     Structure = structure;
     Type      = type;
 }
Beispiel #7
0
 public void UpdateSelectedStructure(PlaneStructure structure)
 {
     currentStructure = structure;
     Update();
 }