//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#include "UnidadII.h"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
PaintBox1->Refresh();
int x1=Edit1->Text.ToIntDef(0);
int y1=Edit2->Text.ToIntDef(0);
int x2=Edit3->Text.ToIntDef(200);
int y2=Edit4->Text.ToIntDef(200);
Canvas->Pen->Color=clBlue;
Canvas->Pen->Width=3;
Canvas->MoveTo(PaintBox1->Width/2,0);
Canvas->LineTo(PaintBox1->Width/2,PaintBox1->Height);
Canvas->MoveTo(0,PaintBox1->Height/2);
Canvas->LineTo(PaintBox1->Height,PaintBox1->Width/2);
UnidadII Transforma;
Transforma.Ventana(0,0,500,500);
Transforma.Puerto_Vision(0,0,500,500);
Canvas->Pen->Color=clBlue;
Canvas->Pen->Width=3;
int xx1;
int yy1;
int xx2;
int yy2;
int L=0;
int M=PaintBox1->Height;
Transforma.Mapeo(x1,y1,&xx1,&yy1,L,M);
PaintBox1->Canvas->MoveTo(xx1,yy1);
Transforma.Mapeo(x2,y2,&xx2,&yy2,L,M);
PaintBox1->Canvas->LineTo(xx2,yy2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
PaintBox1->Refresh();
int x1=Edit1->Text.ToIntDef(-10);
int y1=Edit2->Text.ToIntDef(-10);
int x2=Edit3->Text.ToIntDef(100);
int y2=Edit4->Text.ToIntDef(100);
Canvas->Pen->Color=clBlue;
Canvas->Pen->Width=3;
Canvas->MoveTo(PaintBox1->Width/2,0);
Canvas->LineTo(PaintBox1->Width/2,PaintBox1->Height);
Canvas->MoveTo(0,PaintBox1->Height/2);
Canvas->LineTo(PaintBox1->Height,PaintBox1->Width/2);
//Canvas->LineTo(PaintBox1->Width-2,PaintBox1->Height-2);
UnidadII Transforma;
Transforma.Ventana(0,0,PaintBox1->Width,PaintBox1->Height);
Transforma.Puerto_Vision(0,0,PaintBox1->Width/2,PaintBox1->Height/2);
int xx1;
int yy1;
int xx2;
int yy2;
int L=PaintBox1->Width/2;
int M=PaintBox1->Height/2;
Transforma.Mapeo(x1,y1,&xx1,&yy1,L,M);
PaintBox1->Canvas->MoveTo(xx1,yy1);
Transforma.Mapeo(x2,y2,&xx2,&yy2,L,M);
PaintBox1->Canvas->LineTo(xx2,yy2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
PaintBox1->Refresh();
int x1=Edit1->Text.ToIntDef(-10);
int y1=Edit2->Text.ToIntDef(-10);
int x2=Edit3->Text.ToIntDef(100);
int y2=Edit4->Text.ToIntDef(100);
Canvas->Pen->Color=clBlue;
Canvas->Pen->Width=3;
Canvas->MoveTo(PaintBox1->Width/2,0);
Canvas->LineTo(PaintBox1->Width/2,PaintBox1->Height);
Canvas->MoveTo(0,PaintBox1->Height/2);
Canvas->LineTo(PaintBox1->Height,PaintBox1->Width/2);
UnidadII Transforma;
Transforma.Ventana(0,0,PaintBox1->Width,PaintBox1->Height);
Transforma.Puerto_Vision(0,0,PaintBox1->Width/2,PaintBox1->Height/2);
int xx1;
int yy1;
int xx2;
int yy2;
int L=0;
int M=PaintBox1->Height/2;
Transforma.Mapeo(x1,y1,&xx1,&yy1,L,M);
PaintBox1->Canvas->MoveTo(xx1,yy1);
Transforma.Mapeo(x2,y2,&xx2,&yy2,L,M);
PaintBox1->Canvas->LineTo(xx2,yy2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Repaint();
Canvas->Pen->Width=3;
Canvas->Rectangle(0,0,PaintBox1->Width/2,PaintBox1->Height/2);
int x1=Edit1->Text.ToIntDef(-10);
int y1=Edit2->Text.ToIntDef(-10);
int x2=Edit3->Text.ToIntDef(100);
int y2=Edit4->Text.ToIntDef(100);
UnidadII Transforma;
Transforma.Ventana(0,0,PaintBox1->Width,PaintBox1->Height);
Transforma.Puerto_Vision(0,0,PaintBox1->Width/2,PaintBox1->Height/2);
int xx1;
int yy1;
int xx2;
int yy2;
int L=0;
int M=PaintBox1->Height/2;
Transforma.Mapeo(x1,y1,&xx1,&yy1,L,M);
PaintBox1->Canvas->MoveTo(xx1,yy1);
Transforma.Mapeo(x2,y2,&xx2,&yy2,L,M);
PaintBox1->Canvas->LineTo(xx2,yy2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
Repaint();
Canvas->Pen->Width=3;
Canvas->Rectangle(180,200,281,301);
int x1=Edit1->Text.ToIntDef(11);
int y1=Edit2->Text.ToIntDef(14);
int x2=Edit3->Text.ToIntDef(22);
int y2=Edit4->Text.ToIntDef(28);
UnidadII Transforma;
Transforma.Ventana(0,0,22,28);
Transforma.Puerto_Vision(180,200,280,300);
//Transforma.Puerto_Vision(180,190,400,470);
int xx1;
int yy1;
int xx2;
int yy2;
int L=0;
int M=500; //480;
Transforma.Mapeo(x1,y1,&xx1,&yy1,L,M);
PaintBox1->Canvas->MoveTo(xx1,yy1);
Transforma.Mapeo(x2,y2,&xx2,&yy2,L,M);
PaintBox1->Canvas->LineTo(xx2,yy2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
int fig [4][2]={{1,1},{3,1},{2,3},{1,1}};
Repaint();
int ezq_y1=100;
int ezq_y2=380;
Canvas->Pen->Width=3;
Canvas->Rectangle(100,ezq_y1,321,ezq_y2);
UnidadII Transforma;
Transforma.Ventana(0,0,10,10);
Transforma.Puerto_Vision(100,ezq_y1,321,ezq_y2);
//Transforma.Puerto_Vision(180,190,400,470);
int x,y;
int L=0;
int M=ezq_y1+ezq_y2;; //480;
Transforma.Mapeo(fig[0][0],fig[0][1],&x,&y,L,M);
PaintBox1->Canvas->MoveTo(x,y);
for(int i=1;i<4;i++) { Transforma.Mapeo(fig[i][0],fig[i][1],&x,&y,L,M); PaintBox1->Canvas->LineTo(x,y);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key=VK_UP)
PaintBox1->Canvas->TextOut(10,10,"Presionaste felcha arriba");
else if(Key=VK_DOWN)
PaintBox1->Canvas->TextOut(20,20,"Presionaste felcha abajo");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
int fig [5][3]={{1,1},{3,1},{2,3},{3,2},{1,1}};
Repaint();
int ezq_y1=100;
int ezq_y2=380;
Canvas->Pen->Width=3;
Canvas->Rectangle(100,ezq_y1,321,ezq_y2);
UnidadII Transforma;
Transforma.Ventana(0,0,10,10);
Transforma.Puerto_Vision(100,ezq_y1,321,ezq_y2);
//Transforma.Puerto_Vision(180,190,400,470);
int x,y;
int L=0;
int M=ezq_y1+ezq_y2;; //480;
Transforma.Mapeo(fig[0][0],fig[0][1],&x,&y,L,M);
PaintBox1->Canvas->MoveTo(x,y);
for(int i=1;i<4;i++) { Transforma.Mapeo(fig[i][0],fig[i][1],&x,&y,L,M); PaintBox1->Canvas->LineTo(x,y);
}
}
//---------------------------------------------------------------------------
No hay comentarios:
Publicar un comentario