АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция

Форма 1

Читайте также:
  1. bending strain (майысу деформациясы)
  2. Bending strain (майысу деформациясы)
  3. CASE-технология создания информационных систем
  4. I. ВВЕДЕНИЕ В ИНФОРМАТИКУ
  5. I. Определите, какое из этих высказываний несет психологическую информацию.
  6. I. Основная форма: помешательство.
  7. I. При каких условиях эта психологическая информация может стать психодиагностической?
  8. II. ОСНОВНОЕ ПОНЯТИЕ ИНФОРМАТИКИ – ИНФОРМАЦИЯ
  9. II. Соціальні відносини як форма прояву соціальних взаємодій.
  10. II. Тип организации верховной власти в государстве (форма государственного правления).
  11. III. ИЗМЕРЕНИЕ ИНФОРМАЦИИ
  12. III. Опорная информация

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Drawing.Drawing2D;

 

namespace Рама

{

public partial class Form1: Form

{

public Form2 f2;

Form3 f3;

List<string> list_st = new List<string>();

string st;

string[] St;

public bool dinamika = false;

 

public Double[,] MatrCoor, MatrTop;

public double[] q;

public int i = 0, j = 0, n = 0, m = 0;

public Form1()

{

InitializeComponent();

}

 

private void button1_Click(object sender, EventArgs e)

{

Close();

}

 

private void сохранитьВФайлToolStripMenuItem_Click(object sender, EventArgs e)

{

//Сохранение в файл координатной матрицы

n = 0;

for (i = 0; i < dataGridView1.RowCount - 1; i++) n++;

MatrCoor = new double[n, 9];

 

for (i = 0; i < n; i++)

{

for (j = 0; j < 9; j++)

MatrCoor[i, j] = Convert.ToDouble(dataGridView1.Rows[i].Cells[j].Value);

 

}

if (saveFileDialog1.ShowDialog() == DialogResult.OK)

{

FileStream FS = saveFileDialog1.OpenFile() as FileStream;

StreamWriter SR = new StreamWriter(FS);

//dataGridView1.Rows.Add();

for (i = 0; i < n; i++)

{

st = null;

for (j = 0; j < 9; j++)

{

st = st + MatrCoor[i, j].ToString() + " ";

}

SR.WriteLine(st);

}

SR.Close();

FS.Close();

}

 

}

 

private void считатьИзФайлаToolStripMenuItem_Click(object sender, EventArgs e)

{

// Считывание из файла координатной матрицы

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

FileStream FSR = openFileDialog1.OpenFile() as FileStream;

StreamReader SRR = new StreamReader(FSR);

 

dataGridView1.Rows.Clear();

 

list_st.Clear();

while (SRR.Peek() > 0)

{

list_st.Add(SRR.ReadLine());

//dataGridView1

dataGridView1.Rows.Add();

}

St = list_st.ToArray();

n = St.Length;

MatrCoor = new double[n, 9];

// MatrCoor = new Double[n, 7];

 

 

for (i = 0; i < n; i++)

{

 

St[i] = St[i].Replace(".", ",");;

//Разбиение строки St на подстроки aa

string[] aa = St[i].Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

 

 

for (j = 0; j < aa.Length; j++)

{

//Заполнение матрицы и таблицы

MatrCoor[i, j] = Convert.ToDouble(aa[j]);

dataGridView1.Rows[i].Cells[j].Value = MatrCoor[i, j];

}

}

 

SRR.Close();

FSR.Close();

}

}

 

private void сохранитьВФайлToolStripMenuItem1_Click(object sender, EventArgs e)

{

// Сохранение в файл топологической матрицы

m = 0;

for (i = 0; i < dataGridView2.RowCount - 1; i++) m++;

MatrTop = new double[m, 11];

 

for (i = 0; i < m; i++)

{

for (j = 0; j < 10; j++)

MatrTop[i, j] = Convert.ToDouble(dataGridView2.Rows[i].Cells[j].Value);

 

}

if (saveFileDialog1.ShowDialog() == DialogResult.OK)

{

FileStream FS = saveFileDialog1.OpenFile() as FileStream;

StreamWriter SR = new StreamWriter(FS);

//dataGridView1.Rows.Add();

for (i = 0; i < m; i++)

{

st = null;

for (j = 0; j < 10; j++)

{

st = st + MatrTop[i, j].ToString() + " ";

}

SR.WriteLine(st);

}

SR.Close();

FS.Close();

}

 

}

 

private void считатьИзФайлаToolStripMenuItem1_Click(object sender, EventArgs e)

{

// Считывание из файла топологической матрицы

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

FileStream FSR = openFileDialog1.OpenFile() as FileStream;

StreamReader SRR = new StreamReader(FSR);

 

dataGridView2.Rows.Clear();

 

list_st.Clear();

while (SRR.Peek() > 0)

{

list_st.Add(SRR.ReadLine());

//dataGridView1

dataGridView2.Rows.Add();

}

St = list_st.ToArray();

m = St.Length;

MatrTop = new double[m, 10];

// MatrTop = new Double[m, 10];

 

 

for (i = 0; i < m; i++)

{

 

St[i] = St[i].Replace(".", ",");;

//Разбиение строки St на подстроки aa

string[] aa = St[i].Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

 

 

for (j = 0; j < aa.Length; j++)

{

//Заполнение матрицы и таблицы

MatrTop[i, j] = Convert.ToDouble(aa[j]);

dataGridView2.Rows[i].Cells[j].Value = MatrTop[i, j];

}

}

 

SRR.Close();

FSR.Close();

 

}

 

 

}

 

private void button2_Click(object sender, EventArgs e)

{

//Построение

double[] x, y;

Double My = 0, MaxY = 0, Mx = 0, MaxX = 0;

int[] yint, xint;

 

 

Bitmap myBmp;

 

x = new double[n];

y = new double[n];

for (i = 0; i < n; i++)

{

x[i] = MatrCoor[i, 1];

y[i] = MatrCoor[i, 2];

}

 

if (x == null || y == null) return;

MaxY = 0.001;

 

MaxX = 0.001;

 

for (i = 0; i < n; i++)

{

if (System.Math.Abs(y[i]) > MaxY)

{

MaxY = System.Math.Abs(y[i]);;

}

if (System.Math.Abs(x[i]) > MaxX)

{

MaxX = System.Math.Abs(x[i]);

}

 

}

if (MaxY >= MaxX)

MaxX = MaxY;

else

MaxY = MaxX;

My = (pictureBox1.Height) / 1.2 / MaxY;

 

Mx = (pictureBox1.Width) / 1.2 / MaxX;

 

yint = new int[n];

 

xint = new int[n];

for (int i = 0; i < n; i++)

{

yint[i] = Convert.ToInt32(pictureBox1.Height / 1.1) - Convert.ToInt32(y[i] * My);

 

xint[i] = Convert.ToInt32(pictureBox1.Width / 10) + Convert.ToInt32(x[i] * Mx);

 

}

 

myBmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);

Graphics gr1 = Graphics.FromImage(myBmp);

Pen P1 = new Pen(Color.Red, 2);

gr1.DrawRectangle(P1, 1, 1, pictureBox1.Width - 2, pictureBox1.Height - 2);

 

Pen P2 = new Pen(Color.Green, 2);

Pen P5 = new Pen(Color.Green, 12);

Brush B2 = new SolidBrush(Color.Azure);

Brush B3 = new SolidBrush(Color.Brown);

 

int[] Zakx = new int[n];

int[] Zaky = new int[n];

int[] ZakFi = new int[n];

for (i = 0; i < n; i++)

{

Zakx[i] = Convert.ToInt32(MatrCoor[i, 6]);

Zaky[i] = Convert.ToInt32(MatrCoor[i, 7]);

ZakFi[i] = Convert.ToInt32(MatrCoor[i, 8]);

 

}

 

 

Pen P3 = new Pen(Color.Brown, 4);

Pen P6 = new Pen(Color.Aqua, 18);

 

for (i = 0; i < m; i++)

{

//Построение распределенной нагрузки

if ((MatrTop[i, 3]!= 0) || (MatrTop[i, 4]!= 0) || (MatrTop[i, 5]!= 0) || (MatrTop[i, 6]!= 0))

{

gr1.DrawLine(P6, xint[(int)MatrTop[i, 1] - 1], yint[(int)MatrTop[i, 1] - 1], xint[(int)MatrTop[i, 2] - 1], yint[(int)MatrTop[i, 2] - 1]);

}

//Построение линий конечных элементов

gr1.DrawLine(P3, xint[(int)MatrTop[i, 1] - 1], yint[(int)MatrTop[i, 1] - 1], xint[(int)MatrTop[i, 2] - 1], yint[(int)MatrTop[i, 2] - 1]);

 

}

//Нанесение прямоугольников на расположение узлов

for (i = 0; i < n; i++)

{

 

 

gr1.FillRectangle(B3, xint[i] - 4, yint[i] - 4, 8,8);

gr1.DrawRectangle(P2, xint[i] - 4, yint[i] - 4, 8, 8);

 

}

// Линии шириной 12 п. в точках закрепления

for (i = 0; i < n; i++)

{

 

if (Zakx[i] < 0 || Zaky[i] < 0)

{

gr1.DrawLine(P5, xint[i] - 24, yint[i] + 10, xint[i] + 24, yint[i] + 10);

}

//Нанесение окружностей на расположение шарниров

if ((Zakx[i]!= 0 || Zaky[i]!= 0) & (ZakFi[i] == 0))

{

 

gr1.FillEllipse(B2, xint[i] - 6, yint[i] - 6, 12, 12);

gr1.DrawEllipse(P2, xint[i] - 6, yint[i] - 6, 12, 12);

 

}

 

}

double Mp = 0, MaxP = 0.001, P = 0;

double[] Px = new double[n];

double[] Py = new double[n];

double[] PM = new double[n];

int[] intPx = new int[n];

int[] intPy = new int[n];

Pen P4 = new Pen(Color.Indigo, 6);

// Стиль пера с наконечниками

P4.SetLineCap(LineCap.Flat, LineCap.ArrowAnchor, DashCap.Flat);

//Изображение сил и моментов

for (i = 0; i < n; i++)

{

Px[i] = MatrCoor[i, 3];

Py[i] = MatrCoor[i, 4];

PM[i] = MatrCoor[i, 5];

P = Math.Sqrt(Px[i] * Px[i] + Py[i] * Py[i]);

if (MaxP <= P)

MaxP = P;

}

Mp = pictureBox1.Width / 8 / MaxP;

for (i = 0; i < n; i++)

{

intPy[i] = Convert.ToInt32(Py[i] * Mp);

intPx[i] = Convert.ToInt32(Px[i] * Mp);

 

}

for (i = 0; i < n; i++)

{

if (intPx[i]!= 0 || intPy[i]!= 0)

{

gr1.DrawLine(P4, xint[i], yint[i], xint[i] + intPx[i], yint[i] - intPy[i]);

}

if (PM[i]>0)

{

gr1.DrawArc(P4, xint[i]-20, yint[i]-20, 40,40,0,-150);

}

if (PM[i] < 0)

{

gr1.DrawArc(P4, xint[i] - 20, yint[i] - 20, 40, 40, 0, 150);

}

}

//---------------------------------------------------------------------------------------

//Построение второго слоя после вычисления перемещений

double[] x1 = new double[n];

double[] y1 = new double[n];

double Md = 1;

// Условие продолжения построений

if (q!= null)

{

Md = Convert.ToDouble(textBox2.Text);

for (i = 0; i < 3 * n; i++)

{

if (i % 3 == 0)

{

x1[i / 3] = x[i / 3] + q[i] * Md;

y1[i / 3] = y[i / 3] + q[i+1] * Md;

}

}

 

 

int[] yint1 = new int[n];

 

int[] xint1 = new int[n];

for (int i = 0; i < n; i++)

{

yint1[i] = Convert.ToInt32(pictureBox1.Height / 1.1) - Convert.ToInt32(y1[i] * My);

 

xint1[i] = Convert.ToInt32(pictureBox1.Width / 10) + Convert.ToInt32(x1[i] * Mx);

 

}

 

 

Pen P11 = new Pen(Color.Aqua, 1);

gr1.DrawRectangle(P11, 1, 1, pictureBox1.Width - 2, pictureBox1.Height - 2);

 

Pen P12 = new Pen(Color.Green, 1);

Pen P15 = new Pen(Color.Green, 2);

Brush B12 = new SolidBrush(Color.Azure);

 

 

Pen P26 = new Pen(Color.Aqua, 9);

Pen P13 = new Pen(Color.Red, 2);

for (i = 0; i < m; i++)

{

if ((MatrTop[i, 3]!= 0) || (MatrTop[i, 4]!= 0) || (MatrTop[i, 5]!= 0) || (MatrTop[i, 6]!= 0))

{

gr1.DrawLine(P26, xint1[(int)MatrTop[i, 1] - 1], yint1[(int)MatrTop[i, 1] - 1], xint1[(int)MatrTop[i, 2] - 1], yint1[(int)MatrTop[i, 2] - 1]);

}

gr1.DrawLine(P13, xint1[(int)MatrTop[i, 1] - 1], yint1[(int)MatrTop[i, 1] - 1], xint1[(int)MatrTop[i, 2] - 1], yint1[(int)MatrTop[i, 2] - 1]);

}

for (i = 0; i < n; i++)

{

 

 

// gr1.FillRectangle(B2, xint1[i] - 4, yint1[i] - 4, 8, 8);

gr1.DrawRectangle(P2, xint1[i] - 4, yint1[i] - 4, 8, 8);

 

}

for (i = 0; i < n; i++)

{

 

if (Zakx[i] < 0 || Zaky[i] < 0)

{

gr1.DrawLine(P5, xint[i] - 24, yint[i] + 10, xint[i] + 24, yint[i] + 10);

}

 

if ((Zakx[i]!= 0 || Zaky[i]!= 0) & (ZakFi[i] == 0))

{

 

gr1.FillEllipse(B2, xint1[i] - 6, yint1[i] - 6, 12, 12);

gr1.DrawEllipse(P2, xint1[i] - 6, yint1[i] - 6, 12, 12);

 

}

 

}

Pen P14 = new Pen(Color.Blue, 3);

// Стиль пера с наконечниками

P14.SetLineCap(LineCap.Flat, LineCap.ArrowAnchor, DashCap.Flat);

 

for (i = 0; i < n; i++)

{

intPy[i] = Convert.ToInt32(Py[i] * Mp);

intPx[i] = Convert.ToInt32(Px[i] * Mp);

 

}

Pen P24 = new Pen(Color.Blue, 1);

P24.SetLineCap(LineCap.Flat, LineCap.ArrowAnchor, DashCap.Flat);

for (i = 0; i < n; i++)

{

if (intPx[i]!= 0 || intPy[i]!= 0)

{

gr1.DrawLine(P14, xint1[i], yint1[i], xint1[i] + intPx[i], yint1[i] - intPy[i]);

}

if (PM[i] > 0)

{

gr1.DrawArc(P24, xint1[i] - 20, yint1[i] - 20, 40, 40, 0, -150);

}

if (PM[i] < 0)

{

gr1.DrawArc(P24, xint1[i] - 20, yint1[i] - 20, 40, 40, 0, 150);

}

}

 

}

 

pictureBox1.Image = myBmp;

}

 

private void матрицаЖесткостиToolStripMenuItem_Click(object sender, EventArgs e)

{

// Запуск статических вычислений

// Вычисление

// Создание формы 2

 

f2 = new Form2(this);

f2.Show();

}

 

private void продольнаяСилаToolStripMenuItem_Click(object sender, EventArgs e)

{

f3 = new Form3(this);

f3.Show();

}

 

private void матрицаЖесткостиToolStripMenuItem1_Click(object sender, EventArgs e)

{

dinamika = true;

матрицаЖесткостиToolStripMenuItem_Click(sender, e);

dinamika = false;

}

 

private void амплитудыМоментовToolStripMenuItem_Click(object sender, EventArgs e)

{

продольнаяСилаToolStripMenuItem_Click(sender, e);

}

 

private void Form1_Load(object sender, EventArgs e)

{

 

}

}

}


1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Поиск по сайту:



Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.049 сек.)