Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (IsTableFilled())
            {
                Triangulator  triangulate = new Triangulator();
                List <Vertex> listvertex  = new List <Vertex>();

                SetVectors();
                List <Triangle> tr      = triangulate.Triangulation(V);
                Monitoring      monitor = new Monitoring(tr);
                monitor.GetArrayOfOutsideEdge();
                monitor.AllDensities();
                foreach (Triangle t in monitor.triangles)
                {
                    draw.BrushTriangle(t);
                    draw.drawTriangle(t);
                    for (int i = 0; i < t.edgemas.Length; i++)
                    {
                        if (t.edgemas[i].isOutside)
                        {
                            draw.drawEdge(t.edgemas[i]);
                        }
                        //if (t.edgemas[i].brother != null) G.drawEdge(t.edgemas[i].brother, new Pen(Color.Aqua));
                    }
                    richTextBox1.Text += t.ToString();
                }
                for (int i = 0; i < V.Count; i++)
                {
                    draw.drawVertex(V[i], (i + 1).ToString());
                }

                //переписать не под вызов конструктора, а под вызов метода, который будет сравнивать треугольники.
                //т.е. Equals для треугольников, который сравнивает по вершинам.

                foreach (Vertex vert in V)
                {
                    draw.drawVector(vert);
                }
                sheet.Image = draw.GetBitmap();
            }
            else
            {
                MessageBox.Show("Заполните значения векторов", "Ошибка заполнения");
            }
        }
Beispiel #2
0
        public DrawPanelForm()
        {
            InitializeComponent();
            //sheet.Size = new Size(1000,1000);
            double d = Math.Sqrt(4) - (double)2;


            coordinatesTable.Visible = false;
            V    = new List <Vertex>();
            VV   = new BindingList <Vertex>();
            draw = new Drawing(sheet.Width, sheet.Height);
            E    = new List <Edge>();
            //graph = new Graph();
            sheet.Image = draw.GetBitmap();
            mainTab_dataGridView.AutoGenerateColumns = false;

            mainTab_dataGridView.Columns.Add("num", "№ вершины");
            mainTab_dataGridView.Columns.Add("xVertex", "X вершины");
            mainTab_dataGridView.Columns.Add("yVertex", "Y вершины");
            mainTab_dataGridView.Columns.Add("xVector", "X вектора");
            mainTab_dataGridView.Columns.Add("xVector", "Y вектора");

            mainTab_dataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            mainTab_dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            mainTab_dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            mainTab_dataGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            mainTab_dataGridView.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;



            //создание столбца кнопок
            DataGridViewButtonColumn button_column = new DataGridViewButtonColumn();

            button_column.Name       = "deleteVertex";
            button_column.HeaderText = "Удалить";
            button_column.FlatStyle  = FlatStyle.Popup;
            button_column.DefaultCellStyle.BackColor = Color.Tomato;
            button_column.Text = "✕";



            mainTab_dataGridView.Columns.Add(button_column);

            mainTab_dataGridView.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            mainTab_dataGridView.Columns[1].DataPropertyName = "x";
            mainTab_dataGridView.Columns[2].DataPropertyName = "y";
            mainTab_dataGridView.Columns[3].DataPropertyName = "xVector";
            mainTab_dataGridView.Columns[4].DataPropertyName = "yVector";

            // mainTab_dataGridView.Columns[3].DataPropertyName = "";

            //// Bind the list to the BindingSource.
            //this.customersBindingSource.DataSource = VV;

            //// Attach the BindingSource to the DataGridView.
            //this.coordinate_dGV.DataSource = this.customersBindingSource;
            TriangleInfo_dgv.AutoGenerateColumns = false;
            TriangleInfo_dgv.Columns.Add("num", "№ треугольника");
            TriangleInfo_dgv.Columns.Add("density", "Плотность");
            TriangleInfo_dgv.Columns.Add("edge1", "Ребро 1");
            TriangleInfo_dgv.Columns.Add("edge2", "Ребро 2");
            TriangleInfo_dgv.Columns.Add("edge3", "Ребро 3");


            TriangleInfo_dgv.Columns[0].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            TriangleInfo_dgv.Columns[1].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            TriangleInfo_dgv.Columns[2].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            TriangleInfo_dgv.Columns[3].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            TriangleInfo_dgv.Columns[4].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            TriangleInfo_dgv.Columns[2].DataPropertyName = "sE1";
            TriangleInfo_dgv.Columns[3].DataPropertyName = "sE2";
            TriangleInfo_dgv.Columns[4].DataPropertyName = "sE3";
            TriangleInfo_dgv.Columns[1].DataPropertyName = "DensityOfTriangle";

            monitor = new Monitoring();
            monitor.TriangulationHappened += Triangulation_On;


            ScaleNUD.ValueChanged += ScaleNUD_ValueChanged;
        }