Professional Documents
Culture Documents
Звіт Лаб 13
Звіт Лаб 13
Факультет електроніки
та комп’ютерних технологій
Звіт
«»
Виконав:
Корпан Денис
Перевірив:
Львів-2020
Завдання: Програмування графіка на контролі pictureBox Visual C++.
namespace Lab13 {
double Xe[1000];
double Ye[1000];
/// <summary>
/// </summary>
public:
MyForm(void)
InitializeComponent();
//
//
protected:
/// <summary>
/// </summary>
~MyForm()
if (components)
delete components;
protected:
protected:
private:
/// <summary>
/// </summary>
System::ComponentModel::Container ^components;
/// <summary>
/// </summary>
void InitializeComponent(void)
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>pictureBox1))->BeginInit();
this->groupBox1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown3))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown2))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->button2);
this->groupBox1->Controls->Add(this->button1);
this->groupBox1->Controls->Add(this->numericUpDown3);
this->groupBox1->Controls->Add(this->numericUpDown2);
this->groupBox1->Controls->Add(this->numericUpDown1);
this->groupBox1->Controls->Add(this->textBox3);
this->groupBox1->Controls->Add(this->textBox2);
this->groupBox1->Controls->Add(this->textBox1);
this->groupBox1->Controls->Add(this->label9);
this->groupBox1->Controls->Add(this->label8);
this->groupBox1->Controls->Add(this->label7);
this->groupBox1->Controls->Add(this->label6);
this->groupBox1->Controls->Add(this->label5);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->label1);
static_cast<System::Byte>(204)));
this->groupBox1->TabIndex = 1;
this->groupBox1->TabStop = false;
//
// button2
//
this->button2->Name = L"button2";
this->button2->TabIndex = 16;
this->button2->Text = L"Вихід";
this->button2->UseVisualStyleBackColor = true;
//
// button1
//
this->button1->Name = L"button1";
this->button1->TabIndex = 15;
this->button1->Text = L"Побудова";
this->button1->UseVisualStyleBackColor = true;
//
// numericUpDown3
//
this->numericUpDown3->Name = L"numericUpDown3";
this->numericUpDown3->ReadOnly = true;
this->numericUpDown3->TabIndex = 14;
//
// numericUpDown2
//
this->numericUpDown2->Name = L"numericUpDown2";
this->numericUpDown2->ReadOnly = true;
this->numericUpDown2->TabIndex = 13;
//
// numericUpDown1
//
this->numericUpDown1->Name = L"numericUpDown1";
this->numericUpDown1->ReadOnly = true;
this->numericUpDown1->TabIndex = 12;
//
// textBox3
//
this->textBox3->TabIndex = 11;
//
// textBox2
//
this->textBox2->Name = L"textBox2";
this->textBox2->TabIndex = 10;
//
// textBox1
//
this->textBox1->Name = L"textBox1";
this->textBox1->TabIndex = 9;
//
// label9
//
this->label9->AutoSize = true;
this->label9->Name = L"label9";
this->label9->TabIndex = 8;
//
// label8
//
this->label8->AutoSize = true;
this->label8->Name = L"label8";
this->label8->TabIndex = 7;
this->label8->Text = L"Товщина лінії графіку ф-ції";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Name = L"label7";
this->label7->TabIndex = 6;
//
// label6
//
this->label6->AutoSize = true;
this->label6->Name = L"label6";
this->label6->TabIndex = 5;
this->label6->Text = L"Ne=";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Name = L"label5";
this->label5->TabIndex = 4;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(35, 20);
this->label4->TabIndex = 3;
this->label4->Text = L"bl=";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Name = L"label3";
this->label3->TabIndex = 2;
this->label3->Text = L"al=";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Name = L"label2";
this->label2->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Name = L"label1";
this->label1->TabIndex = 0;
//
// MyForm
//
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->pictureBox1);
this->Name = L"MyForm";
this->Text = L"Lab13";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>pictureBox1))->EndInit();
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown3))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown2))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this-
>numericUpDown1))->EndInit();
this->ResumeLayout(false);
#pragma endregion
int Ne;
//Опис функції
double f(double x)
return x * Math::Sin(x);
double h;
h = (bl - al) / Ne;
Xe[0] = al;
Ye[i] = f(Xe[i]);
Xe[i + 1] = Xe[i] + h;
Graphics^ g = pictureBox1->CreateGraphics();
g->Clear(Color::White);
L = 40;
al = Convert::ToDouble(textBox1->Text);
bl = Convert::ToDouble(textBox2->Text);
Ne = Convert::ToInt32(textBox3->Text);
TabF(Xe, Ye);
minx = Xe[0];
miny = Ye[0];
maxy = Ye[0];
KrokY = (pb_Height - 2 * L) / 9;
xx = minx; yy = maxy; krx = (maxx - minx) / 10.0; kry = (maxy - miny) / 10.6;
xx = xx + krx;
yy = yy - kry;
Close();
};
Результати:
Функція x*Sin(x):
Функція x*Cos(x):
Висновок: Під час виконання лабораторної роботи я повторив алгоритм, який я
використовував при побудові власного графіка в середовищі Delphi. Робота
мовою С++ хоч і була схожою, проте було цікавою.