STMAP16

Top  Previous  Next

{ TStMapW  : A StellaMap komponens család alap tagja;

-------

Őse     : TCustomControl

Cél     : StellaMap, ITR, DXF, DAT térképek megjelenítése, mozgatása, nagyítása

           és nyomtatása.

Funkciók: rmNincs      = Nincs, csak képmozgatás;

           rmNagyito    = nagyítás, kicsinyités;

           rmAblak      = Ablakozás;

           rmTavmeres   = Távoéság mérés;

           rmTer        = területmérés akt rétegben;

           rmHrsz       = Helyrajzi szám keresés;

 

TStellaMap : A StellaMap komponens család interaktív grafikus tagja;

----------

Őse     : TStMapW ;

Cél     : Térképszerkesztés

}

unit Stmap16;

 

interface

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, ExtCtrls, Menus, ClipBrd,

Graphics, Controls, StdCtrls, Forms, Dialogs, Printers, Szoveg, Szamok,

AlmType, stmap161, StPrint, StMap16W;

 

Type

 

TRajzmod  = TRajzmodType;

 

TPaintEvent = procedure(Sender: TObject) of object;

TRajzmodEvent = procedure(Sender: TObject; rmod: TRajzmod) of object;

TAlakzatmodEvent = procedure(Sender: TObject; rmod: TAlakzatmod) of object;

TOrigoChangeEvent = procedure(Sender: TObject; OrigoX,OrigoY:double) of object;

TSearchEvent = procedure(Sender: TObject; No:integer; AktPos : longint; var Rec) of object;

                {No = 1..4 a rajzelemek, Rec=record}

 

 

TStellaMap = class(TStMapW)

private

   FFeliratmod        : TFeliratmod;{A szövegkiírás stilusa:}

   FJelkulcsCombo     : TCombobox; {jelkulcsok neveinek Combo-ja}

   FAktJelkulcsKod    : integer;   {aktuális jelkulcs kódja}

   FRajzmod           : TRajzmod;  {Rajzmód}

   FOnSearch: TSearchEvent;        {Keresési esemény}

{    FOnDistanceChange  : TDistanceChange;} {Távmérés,vonalhúzás során a távolság érzékelése}

   procedure SetJelkulcsCombo(Value: TCombobox);

   procedure JelkulcsClick(Sender:TObject);virtual;

protected

   t             : TRect;

   Origin        : TPoint;        {rámutatási pont}

   MovePt        : TPoint;        {elmozdulás a rámutatási ponthoz képest}

   oldOrigin     : TPoint;

   oldMovePt     : TPoint;

   apont           : longint;

   wrec,wrec1,wrec2: TVonalrecord;

   pontsorszam     : Longint;      {Pontsorszamok}

   von1            : boolean;

   uj_szoveg       : boolean;

   Rajzmodstring   : string[18];  {rajzmód szövegesen}

   xx,yy           : real;        {térkép koordináták}

   TFP1,TFP11,TFP2,TFP22 : TPoint2D;     {Eredeti és végpontok betranszformáláshoz}

   pfazis : integer;             {betranszformálás: 0..4 fázisa,

                                                  0 = nincs transzormálás kijelölve,

                                                  1 = 1. eredeti pont kijelölve,

                                                  2 = 1. végpont kijelölve,

                                                  3 = 2. eredeti pont kijelölve,

                                                  4 = 2. végpont kijelölve,

                                                  }

   procedure SetRajzmod(Value: TRajzmod); override;

   procedure MouseDown(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

   procedure MouseUp(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   procedure Notification(AComponent: TComponent;

     Operation: TOperation); override;

{    procedure STKeresesek(x,y:integer;event:boolean);}

   procedure Rajzol( T,B: TPoint; AMode: TPenMode; ujrajz: Boolean);virtual;

   procedure PoligonMentes(var terulet,kerulet:real);

public

   constructor Create(AOwner:TComponent);override;

   destructor Destroy;override;

   property Canvas;

{    procedure Ujrarajzol(ca:TCanvas;tt:TRect);virtual;}

   function Ujpont(var p: Tpontrecord):boolean;

   function Ujvonal(p: Tvonalrecord):boolean;

   function Ujfelirat(p: Tszovegrecord):boolean;

   function Ujjelkulcs(p: Tjelkulcsrecord):boolean;

   Procedure PontRekordIr(arec: longint; pr: TPontrecord);

   Procedure VonalRekordIr(arec: longint; vr: TVonalrecord);

   Procedure SzovegRekordIr(arec: longint; pr: TSzovegrecord);

   Procedure JelkulcsRekordIr(arec: longint; jr: TJelkulcsrecord);

published

   property Feliratmod : TFeliratmod read FFeliratmod write FFeliratmod;

   property AktJelkulcsKod : integer read FAktJelkulcsKod write FAktJelkulcsKod;

   property JelkulcsCombo: TComboBox read FJelkulcsCombo write SetJelkulcsCombo;

   property RajzMod;

   property Align;

   property Enabled;

   property Hint;

   property ParentShowHint;

   property PopupMenu;

   property Visible;

   Property OnDblClick;

   property OnClick;

   property OnDistanceChange;

   property OnDragDrop;

   property OnDragOver;

   property OnEndDrag;

   property OnEnter;

   property OnExit;

   property OnKeyDown;

   property OnKeyPress;

   property OnKeyUp;

   Property OnMouseDown;

   Property OnMouseMove;

   Property OnMouseUp;

   property OnNewMapFile;

end;

 

{ --------------- TStellaMap komponens --------------}

implementation

 

constructor TStellaMap.Create(AOwner:TComponent);

var h: HCursor;

begin

inherited Create(AOwner);

AktJelkulcsKod:=1;

Feliratmod  := szSzimpla;

end;

 

destructor TStellaMap.Destroy;

begin

    inherited Destroy;

end;

 

procedure TStellaMap.SeTRajzmod(Value: TRajzmod);

var s:string;

begin

    FRajzmod:=Value;

    cw.rmod := Value;

    s := Rajzmodfelirat[Ord(Value)];

    von1:=False;

    VrecNull(wrec);

    VrecNull(wrec1);

    pfazis := 0;

    {Keresés módok beállítása}

    If Value in [rmPont,rmPontKijelol,rmPontVonallal,rmPontAtrak,rmPontTorol

                ,rmVonal,rmTransform,rmTeglalap,rmMeroleges,rmKoriv,rmVonalosztas,rmSzakasz]

                then kMODE := kmPont;

    If Value in [rmVonalKijelol,rmVonaltorol,rmVonalAtemel]

                then kMODE := kmVonal;

    If Value in [rmFelirat,rmFeliratkijelol,rmFelirattorol,rmHrsz,rmHRSZker]

                then kMODE := kmFelirat;

    If Value in [rmJelkulcs,rmJelkulcskijelol,rmJelkulcstorol]

                then kMODE := kmJelkulcs;

    If (Alakzatmod=pKeres) and (Ord(Value)<5)

       then kMODE := TKeresesMod(Ord(TRajzmodType(Ord(Value))));

 

    Cursor := crDefault;

    Case Value of

      rmPont  :

        Case Alakzatmod of

        pRajzol: begin

                  pontsorszam := MaxPontszamKeres(tm[1])+1;

                  pontsorszam := StrToInt(InputBox('Pontsorszámozás','Kezdő érték:',

                              IntToStr(pontsorszam)));

                 end;

        pKeres: s:='Pontkeresés';

        end;

      rmVonal  : If Alakzatmod=pKeres then kMODE:=kmVonal;

      rmFelirat: begin

                 szrecnull(szrec); uj_szoveg:=False;

                 If not cw.szoveglatszik then cw.szoveglatszik := True;

                 Szoveg_rajzolas(Canvas,t,tm[3],rtgstream,fontstream,lreteg,cw);

                 Case Alakzatmod of

                 pRajzol:

                 If Feliratmod in [szSzimpla,szSzogben] then begin

                    If InputQuery('Új felirat aktuális rétegbe','TEXT : ',szrec.szoveg)

                    then begin

                        szrec.reteg:=Aktreteg; uj_szoveg:=True;

                        kMode := kmNone;

                    end;

                 end;

                 end;

        end;

      rmPontVonallal  : begin

                  pontsorszam := MaxPontszamKeres(tm[1])+1;

                  pontsorszam := StrToInt(InputBox('Pontsorszámozás','Kezdő érték:',

                              IntToStr(pontsorszam)));

                        end;

      rmTransform,rmTeglalap,rmMeroleges : begin

                  pfazis := 0;

                    end;

      rmPontbeillesztes,rmMetszes,rmIvmetszes,rmBemeres,rmElometszes,rmVetites,rmKituzes: kMode:=kmVonal;

      rmTavmeres : kMode:=kmPont;

    end;

    inherited SetRajzmod(Value);

    Cur:=Cursor; oldCur:=Cursor;

end;

 

procedure TStellaMAP.SetJelkulcsCombo(Value: TCombobox);

begin

    FJelkulcsCombo:=Value;

    If JelkulcsFile<>'' then JelkulcsMegnyit(JelkulcsFile);

    FJelkulcsCombo.OnClick:=JelkulcsClick;

    Invalidate;

end;

 

{A RetegCombo Click event-je az aktuális réteg kijelölésére}

procedure TStellaMap.JelkulcsClick(Sender:TObject);

begin AktJelkulcsKod:=JelkulcsCombo.Itemindex; end;

 

 

procedure TStellaMap.MouseDown(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer);

var ymax,my,i,j,k,el : integer;

    x1,y1,x2,y2 : integer;

    szog,alfa,beta,teru,ker: real;

    p,p1        : TPoint2D;

    pontvan,vonalvan,talalt : boolean;

    RecNo       : longint;

    alappont,kp,keppont : TPoint2D;

    tp,tp1,tp2  : TPoint;

    d,d1,d2,nyujtas : real;

    egy1,egy2   : TEgyenesfgv;

    tpp,tpp1,tpp2 : TPoint2d;

    s1,s2     : string;

    tp2d        : TPoint2D;

    op1,op2,op3,op4 : TPoint;

    rec_no: longint;

    kiv : TPoint3d;

 

       function GetFelirat(x,y: integer; var szrec:TSzovegrecord;

                           var aktszoveg: longint): boolean;

       var i,j: integer;

       begin

          If not uj_szoveg and not von1 and

             Feliratkeres(x,y,szrec,aktszoveg) then begin

             Movept := MapToScreen(Canvas,szrec.x,szrec.y,cw);

             rrec:=RetegrekordKap(szrec.reteg);

             If szrec.szog=0 then k:=120 else k:=20;

             For i:=1 to 5 do begin

                 For j:=1 to k do Szovegrajzol(Canvas,szrec,cw.alapszin);

                 For j:=1 to k do Szovegrajzol(Canvas,szrec,rrec.szovegszin);

             end;

          end;

       end;

begin

oldOrigin := Origin;

oldMovePt := MovePt;

Origin := Point(X, Y);

MovePt := Origin;

ymax   := Height;

my     := ymax-y;

keppont := ScreenToMap(Point(x,ymax-y),cw);

 

Keresesek(x,my,True);

d := KeTPontTavolsaga(vrec.x1,vrec.y1,vrec.x2,vrec.y2);

 

If (Button = mbRight) and (RajzMod=rmNagyito) then RajzMod := rmKicsinyito;

If (Button = mbLeft) and (RajzMod=rmKicsinyito) then RajzMod := rmNagyito;

 

Case Rajzmod of

 

rmKoriv: begin

          Inc(pfazis);

          case pfazis of

          1: teglalap.a:=Point2d(x,y);

          2: begin

             teglalap.c:=Point2d(x,y);

             teglalap.b:=FelezoPont(teglalap.a,teglalap.c);

             MovePt:=ClientToScreen(Point(Trunc(teglalap.b.x),Trunc(teglalap.b.y)));

             SetCursorPos(MovePt.x,MovePt.y);

             KorivRajzol(Canvas,teglalap.a,teglalap.b,teglalap.c);

             end;

          3: begin

               teglalap.b:=Point2d(x,y);

               Canvas.Pen.Color:=clRed;

               KorivRajzol(Canvas,teglalap.a,teglalap.b,teglalap.c);

               pfazis:=0;

             end;

          end;

          Pontrajzol(Canvas,x,y,cw.pontmeret,clBlue);

          end;

 

rmTransform:

     if button=mbLeft then begin

     if vanPont then

        p:=Point2d(prec.x,prec.y)

     else

        p:=keppont;

     Case pfazis of

     0: begin

          TFP1:=p;

          Pontrajzol(Canvas,x,y,2*cw.pontmeret,clRed);

        end;

     1: begin

          TFP2:=p;

          Pontrajzol(Canvas,x,y,2*cw.pontmeret,clRed);

        end;

     2: begin

          TFP11:=p;

          TransFormTo(tm,True,False,False,TFP11,TFP11.x-TFP1.x,TFP11.y-TFP1.y,szog,nyujtas,7);

          Invalidate;

        end;

     3: begin

          TFP22:=p;

          szog    := Relangle2d(TFP2,TFP1)-Relangle2d(TFP22,TFP11);

          nyujtas := RelDist2D(TFP22,TFP11)/RelDist2D(TFP2,TFP1);

          TransFormTo(tm,False,True,True,TFP11,TFP11.x-TFP1.x,TFP11.y-TFP1.y,szog,nyujtas,7);

          Rajzmod:=rmNincs;

        end;

     end;

     Inc(pfazis);

     end else if button=mbRight then Rajzmod:=rmNincs;

 

rmPont   :    begin

       Case Alakzatmod of

       pRajzol:

       If not vanpont then begin

          Precnull(prec);

          With prec do begin

             reteg := cw.Aktreteg;

             x     := keppont.x;

             y     := keppont.y;

             No    := pontsorszam;

          end;

          Pontrajzol(Canvas,x,y,cw.pontmeret,cw.pontszin);

          If cw.pontszamlatszik then Canvas.TextOut(x+2,y+2,IntToStr(prec.No));

          UjPont(prec);

       end;

       end;

       end;

 

rmPontbeillesztes:

       if vanVonal then begin

          wrec1:=vrec; wrec2:=vrec;

          vrec.jelzo:=vrec.jelzo or 1;

          VonalRekordir(aktvonal,vrec);

          egy1:=KetPontonAtmenoEgyenes(vrec.x1,vrec.y1,vrec.x2,vrec.y2);

          egy2:=EgypontonAtmenoMeroleges(egy1,keppont);

          tpp1 := KetEgyenesMetszespontja(egy1,egy2);

          wrec1.x2:=tpp1.x; wrec1.y2:=tpp1.y;

          wrec2.x1:=tpp1.x; wrec2.y1:=tpp1.y;

          UjVonal(wrec1); UjVonal(wrec2);

          Precnull(prec);

          With prec do begin

             x     := tpp1.x;

             y     := tpp1.y;

             No    := maxpontszamkeres(tm[1])+1;

          end;

          UjPont(prec);

          invalidate;

       end;

 

rmVonal,rmPontVonallal,rmSzakasz,rmNegyszog,rmTeglalap,rmIvmetszes,rmBemeres,

rmMeroleges,rmVonalosztas:

        begin

         If von1 and not pontvan then

            pontvan := pontkeres(oldmovept.x,ymax-oldMovePt.y,prec,aktPont)

         else pontvan:=pontkeres(x,ymax-y,prec,aktPont);

         If rajzmod in [rmNegyszog,rmPontVonallal,rmTeglalap,rmMeroleges] then begin

            If not pontvan then begin

               prec.x:= keppont.x; prec.y:=keppont.y;

            end;

            prec.No:=pontsorszam;

            pontvan:=True;

         end;

         If pontvan then

          If (not von1) then begin

             If button = mbLeft then

              begin

                     VrecNull(wrec);

                     wrec.reteg := aktreteg;

                     wrec.x1 := prec.x; wrec.y1 := prec.y;

                     wrec.x2 := prec.x; wrec.y2 := prec.y;

                     Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

                     MovePt := Origin;

                        If Rajzmod=rmPontVonallal then begin

                           UjPont(prec);

                        end;

                     von1     := True;

              end;

          end else begin

             Case button of

             mbLeft: begin

                     wrec.reteg := aktreteg;

                     wrec.x2 := prec.x; wrec.y2 := prec.y;

                     Rajzol(oldOrigin,oldMovePt,pmCopy,True);

                     Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

 

                     Case rajzmod of

                     rmVonal,rmPontVonallal,rmTeglalap,rmMeroleges:begin

                        d := KeTPontTavolsaga(wrec.x1,wrec.y1,wrec.x2,wrec.y2);

                        tavolsag:=d;

                        If Assigned(FOnDistanceChange) then FOnDistanceChange(Self,tavolsag);

                        If Rajzmod in [rmTeglalap,rmMeroleges] then begin

                        Inc(pfazis);

                        Case pFazis of

                        1: begin

                           oldTeglalap.a:=Point2d(wrec.x1,wrec.y1);

                           oldTeglalap.b:=Point2d(wrec.x2,wrec.y2);

                           oldTeglalap.c:=oldTeglalap.b;

                           oldTeglalap.d:=oldTeglalap.a;

                           end;

                        2:begin

                           Teglalap:=HarompontbolTeglalap(oldTeglalap.a,oldTeglalap.b,keppont);

                           Op1 := MapToScreen(Canvas,Teglalap.a.x,Teglalap.a.y,cw);

                           Op2 := MapToScreen(Canvas,Teglalap.b.x,Teglalap.b.y,cw);

                           Op3 := MapToScreen(Canvas,Teglalap.c.x,Teglalap.c.y,cw);

                           Op4 := MapToScreen(Canvas,Teglalap.d.x,Teglalap.d.y,cw);

                             PrecNull(prec); VrecNull(vrec); vrec.jelzo:=0;

                             VrecNull(vrec); vrec.reteg:=aktreteg;

                             prec.x:=Teglalap.a.x;prec.y:=Teglalap.a.y;

                             vrec.x1:=prec.x; vrec.y1:=prec.y;

                             UjPont(prec);

                             PrecNull(oldprec); prec.x:=Teglalap.b.x;prec.y:=Teglalap.b.y;

                             UjPont(prec);

                             vrec.x2:=prec.x; vrec.y2:=prec.y; UjVonal(vrec);

                             PrecNull(prec); prec.x:=Teglalap.c.x;prec.y:=Teglalap.c.y;

                             UjPont(prec);

                             vrec.x1:=prec.x; vrec.y1:=prec.y; UjVonal(vrec);

                           Canvas.Pen.Mode := pmCopy;

                           ShowLine(Canvas,op1.x,op1.y,op2.x,op2.y);

                           ShowLine(Canvas,op2.x,op2.y,op3.x,op3.y);

                        If Rajzmod = rmTeglalap then begin

                           ShowLine(Canvas,op3.x,op3.y,op4.x,op4.y);

                           ShowLine(Canvas,op1.x,op1.y,op4.x,op4.y);

                           PrecNull(prec); prec.x:=Teglalap.d.x;prec.y:=Teglalap.d.y;

                           UjPont(prec);

                           vrec.x2:=prec.x; vrec.y2:=prec.y; UjVonal(vrec);

                           vrec.x1:=Teglalap.a.x; vrec.y1:=Teglalap.a.y; UjVonal(vrec);

                        end;

                           pfazis:=0;

                           von1:=False;

                           invalidate;

                           end;

                        end;

                        end else begin

                            UjVonal(wrec);

                            If (Rajzmod=rmPontVonallal) then

                               UjPont(prec);

                        end;

                     end;

 

                     rmSzakasz: vrec:=wrec;

 

                     rmVonalosztas:

                       Try

                       If Vonalkeres((Origin.x+oldOrigin.x) div 2,ymax-((Origin.y+oldOrigin.y) div 2),vrec,aktvonal) then

                       begin

                          s1:=InputBox('Szakasz felosztás :','Osztási arány [pl=2:5]:','');

                          d1:=StrToFloat(Copy(s1,1,Pos(':',s1)-1));

                          d2:=StrToFloat(Copy(s1,Pos(':',s1)+1,100));

                          kp:=Osztopont(Point2d(wrec.x1,wrec.y1),Point2d(wrec.x2,wrec.y2),d1/(d1+d2));

                          PrecNull(prec);

                          prec.x:=kp.x; prec.y:=kp.y;

                          UjPont(prec);

                          vrec.jelzo:=vrec.jelzo or 1;

                          VonalRekordir(aktvonal,vrec);

{                          vrec:=wrec;}

                          wrec.x1:=vrec.x1; wrec.y1:=vrec.y1;

                          wrec.x2:=kp.x; wrec.y2:=kp.y;

                          UjVonal(wrec);

                          wrec.x1:=vrec.x2; wrec.y1:=vrec.y2;

                          wrec.x2:=kp.x; wrec.y2:=kp.y;

                          UjVonal(wrec);

                       end;

                       Finally

                           von1:=False;

                           invalidate;

                       end;

 

                     rmNegyszog:begin

                        precNull(prec);

                        prec.reteg:=0;

                        vrec:=wrec;

 

                        vrec.y2:=wrec.y1;

                        UjVonal(vrec);

                        prec.x:=wrec.x1; prec.y:= wrec.y1;

                        prec.No:=pontsorszam;

                        If UjPont(prec) then Inc(prec.No);

 

                        vrec.x1:=wrec.x2; vrec.y2:=wrec.y2;

                        UjVonal(vrec);

                        prec.x:=wrec.x2; prec.y:= wrec.y1;

                        If UjPont(prec) then Inc(prec.No);

 

                        vrec.x1:=wrec.x1; vrec.x2:=wrec.x2;vrec.y1:=wrec.y2;

                        vrec.y2:=wrec.y2;

                        UjVonal(vrec);

                        prec.x:=wrec.x2; prec.y:= wrec.y2;

                        If UjPont(prec) then Inc(prec.No);

 

                        vrec.x2:=wrec.x1; vrec.y1:=wrec.y1; vrec.y2:=wrec.y2;

                        UjVonal(vrec);

                        prec.x:=wrec.x1; prec.y:= wrec.y2;

                        If UjPont(prec) then Inc(prec.No);

 

                        von1 := False; pontsorszam:=prec.No;

                        Invalidate;

                     end;

 

                     rmIvmetszes,rmBemeres: begin

                           d:=Ketponttavolsaga(wrec.x1,wrec.y1,wrec.x2,wrec.y2);

                           s1:=InputBox('Vonalhossz :'+Format('%9.3f',[d]),'Táv. az 1. ponttól :','');

                           s2:=InputBox('Vonalhossz :'+Format('%9.3f',[d]),'Táv. az 2. ponttól :','');

                           If s2<>'' then begin

                              d1 := StrToFloat(s1);

                              d2 := StrToFloat(s2);

                              Case rajzmod of

                              rmIvmetszes : vanpont:=IvMetszes(wrec.x1,wrec.y1,d1,

                                            wrec.x2,wrec.y2,d2,tpp1);

                              rmBemeres :    vanpont:=Bemeres(wrec.x1,wrec.y1,d1,

                                            wrec.x2,wrec.y2,d2,tpp1);

                              end;

                              If vanpont then begin

                                   PrecNull(prec);

                                   prec.reteg := cw.aktreteg;

                                   prec.x:=tpp1.x;

                                   prec.y:=tpp1.y;

                                   prec.No:=MaxPontszamKeres(tm[1])+1;

                                   UjPont(prec);

                                   Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

                                   PontRajzol(Canvas,origin.x,origin.y,cw.pontmeret,clRed);

                              end else

                              MessageDlg('Nincs metszéspont',mtInformation,[mbOk],0);

                              von1 := False;

                           end;

                        end;

 

                     rmElometszes:

                        begin

                          s1:=InputBox('Vonalhossz :'+Format('%9.3f',[d]),'1. szög (alfa)','');

                          s2:=InputBox('Vonalhossz :'+Format('%9.3f',[d]),'2. szög (béta)','');

                          If s2<>'' then begin

                             alfa:=Radian(StrToFloat(s1));

                             beta:=Radian(StrToFloat(s2));

                              If alfa<>beta then begin

                                 tp2d := Elometszes(Point2D(wrec.X1,wrec.Y1),

                                      Point2D(wrec.X2,wrec.Y2),alfa,beta);

                                   PrecNull(prec);

                                   prec.reteg := cw.aktreteg;

                                   prec.x:=tp2d.x;

                                   prec.y:=tp2d.y;

                                   prec.No:=MaxPontszamKeres(tm[1])+1;

                                   UjPont(prec);

                                   Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

                                   PontRajzol(Canvas,origin.x,origin.y,cw.pontmeret,clRed);

                                   Canvas.Pen.Style:=psDot;

                                   Rajzol(Origin,MapToScreen(Canvas,

                                      wrec.x1,wrec.y1,cw),pmCopy,True);

                                   Rajzol(Origin,MapToScreen(Canvas,

                                      wrec.x2,wrec.y2,cw),pmCopy,True);

                              end else

                              MessageDlg('Nincs metszéspont',mtInformation,[mbOk],0);

                              von1 := False;

                          end;

                        end;

                     end;

                     wrec.x1 := wrec.x2;

                     wrec.y1 := wrec.y2;

                     end;

             end;

                     MovePt := Origin;

                     oldOrigin := Origin;

                     oldMovePt := MovePt;

          end else begin

             Origin := oldOrigin;

             MovePt := oldMovePt;

          end;

          If (Button=mbRight) and von1 then begin

             von1 := False;

             Rajzol(oldOrigin,oldMovePt,pmNotXor,False);

             pfazis:=0;

             invalidate;

          end;

          end;

 

   rmVetites,rmKituzes :

          If not von1 then begin

             if vanVonal then begin

                wrec:=vrec;

                Origin := MapToScreen(Canvas,wrec.x1,wrec.y1,cw);

                Movept := MapToScreen(Canvas,wrec.x2,wrec.y2,cw);

                Rajzol(Origin,MovePt,pmNotxor,True);

                von1:=True;

             end

          end else

             If pontkeres(x,ymax-y,prec,aktPont) then begin

                egy1:=KetPontonAtmenoEgyenes(wrec.x1,wrec.y1,wrec.x2,wrec.y2);

                egy2:=EgypontonAtmenoMeroleges(egy1,Point2D(prec.x,prec.y));

                tpp1 := KetEgyenesMetszespontja(egy1,egy2);

                Origin := MapToScreen(Canvas,tpp1.x,tpp1.y,cw);

                Pontrajzol(Canvas,Origin.x,Origin.y,Pontmeret,clRed);

                Canvas.Pen.Color:=clRed;

                wrec1:=WREC; wrec2:=WREC;

                vrec.x1:=prec.x;vrec.y1:=prec.y;vrec.x2:=tpp1.x;vrec.y2:=tpp1.y;

                VonalRajzol(Canvas,vrec);

                vrec.x1:=wrec.x1;vrec.y1:=wrec.y1;

                VonalRajzol(Canvas,vrec);

                vrec.x1:=wrec.x2;vrec.y1:=wrec.y2;

                VonalRajzol(Canvas,vrec);

                von1:=False;

             end;

 

rmPontAtrak: begin

        If not von1 then begin

           If vanpont then begin

              oldprec:=prec;

              oprec:=prec;

              apont:=aktpont;

              von1:=True;

           end;

        end else begin

            von1:=False;

            Case button of

            mbLeft: begin

              If vanpont then begin

                 If not (aktPont=apont) then begin

                    oprec.jelzo:=SetBit(oprec.jelzo,0,1);

                    PontrekordIr(aPont,oprec);

                 end;

              end else begin

                 prec:=oldprec;

                 prec.x:=keppont.x; prec.y:=keppont.y;

                 Op1 := MapToScreen(Canvas,oldprec.x,oldprec.y,cw);

                 Op2 := MapToScreen(Canvas,prec.x,prec.y,cw);

                 Pontrajzol(Canvas,op1.x,op1.y,pontmeret,alapszin);

                 PontrekordIr(aPont,prec);

              end;

              d := KeTPontTavolsaga(oprec.x,oprec.y,prec.x,prec.y);

              If Assigned(FOnDistanceChange) then FOnDistanceChange(Self,d);

              rec_no:=0;

              While rec_no<cw.vonalszam do

              if VonalVegpontKeres(tm[2],oprec.x,oprec.y,vrec,rec_no) then

              begin

                   VonalVegpontAtrak(vrec,oprec,prec);

                   If (RetegbenFedoVonal(tm[2],vrec)>0) then

                       vrec.jelzo:=SetBit(vrec.jelzo,0,1);

                   VonalRekordIr(rec_no,vrec);

                   rec_no:=rec_no+1;

                   Vonalrajzol(Canvas,vrec);

              end;

            end;

        end;

        invalidate;

        end;

   end;

 

rmVonalAtemel:

        If (Button=mbLeft) then begin

            Case kMODE of

             kmVonal: If vanvonal then begin

                         wrec1:=vrec; wrec:=vrec;  {eredeti vonal tárolása}

                         d1 := KeTPontTavolsaga(vrec.x1,vrec.y1,keppont.x,keppont.y);

                         d2 := KeTPontTavolsaga(vrec.x2,vrec.y2,keppont.x,keppont.y);

                         If d2>d1 then begin

                            wrec.x1:=vrec.x2; wrec.y1:=vrec.y2; wrec.z1:=vrec.z2;

                         end;

                         Origin := MapToScreen(Canvas,wrec.x1,wrec.y1,cw);

                         MovePt := Origin;

                         oldOrigin := Origin; oldMovePt := MovePt;

                         von1 := True;

                         kMODE:=kmPont;

                      end;

             kmPont:  If vanpont then begin

                         wrec.x2 := prec.x; wrec.y2 := prec.y; wrec.z2 := prec.z;

                         Rajzol(oldOrigin,oldMovePt,pmCopy,True);

                         If not IsAzonosVonal(wrec,wrec1) then begin

                            If (RetegbenFedoVonal(tm[2],wrec)>0) then

                               wrec.jelzo:=wrec.jelzo or 1;

                            VonalRekordIr(aktvonal,wrec);

                         end;

                         von1 := False;

                         kMODE:=kmVonal;

                         invalidate;

                      end;

             end;

        end else If (Button=mbRight) then begin

                    kMODE:=kmVonal;von1 := False;

                    invalidate;

                 end;

 

rmJelkulcs:

       Case Alakzatmod of

       pRajzol:

          If (Button=mbLeft) then begin

             JrecNull(jrec);

             With jrec do begin

                kod  := AktJelkulcsKod;

                reteg:= aktreteg;

                x    := keppont.x;

                y    := keppont.y;

                meret:= 100;

             end;

             UjJelkulcs(jrec);

             Jelkulcsrajz(Canvas,Jelkulcsstream,jrec,x,y,jrec.szog,cw);

          end;

       end;

 

rmPontkijelol  :

           If pontvan then begin

                prec.jelzo := InversBit(prec.jelzo,7);

                PontrekordIr(aktPont,prec);

                Movept := MapToScreen(Canvas,prec.x,prec.y,cw);

                Pontrajzol(Canvas,Movept.x,Movept.y,cw.pontmeret,clBlue);

           end;

 

rmVonalkijelol,rmMetszes:

          If VanVonal then begin

             VonalRec := vrec;

             If rajzmod=rmVonalkijelol then begin

                vrec.jelzo := InversBit(vrec.jelzo,7);

                VonalrekordIr(aktvonal,vrec);

             end;

             If rajzmod=rmMetszes then begin

                if von1 then begin

                   wrec2 := vrec;

                   PrecNull(prec);

                   prec  := EgyenesekMetszese(wrec1,wrec2);

                   With prec do begin

                     pkod:=0; info:=0; obj:=0; jelzo:=0;

                     No:=MaxPontszamKeres(tm[1])+1;

                   end;

                   UjPont(prec);

                   Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

                   Pontrajzol(Canvas,Origin.x,Origin.y,cw.pontmeret,clRed);

                   von1 := False;

                end else begin

                   wrec1 := vrec;

                   von1 := True;

                end;

             end;

             Origin := MapToScreen(Canvas,vrec.x1,vrec.y1,cw);

             Movept := MapToScreen(Canvas,vrec.x2,vrec.y2,cw);

             Rajzol(Origin,MovePt,pmNotxor,True);

          end;

 

rmJelkulcskijelol  :

           If vanJelkulcs then begin

                jrec.jelzo := InversBit(jrec.jelzo,7);

                JelkulcsrekordIr(aktJelkulcs,jrec);

                Movept := MapToScreen(Canvas,jrec.x,jrec.y,cw);

                Pontrajzol(Canvas,Movept.x,Movept.y,cw.pontmeret,clBlue);

           end;

 

rmPonttorol:  If vanpont then begin

                prec.jelzo := InversBit(prec.jelzo,0);

                PontrekordIr(aktPont,prec);

                Movept := MapToScreen(Canvas,prec.x,prec.y,cw);

                {

                el := PontbolEl(prec);

                RecNo := 0;

                For i:=1 to el do begin

                    If CsatoltVonal(alappont,vrec,Recno) then begin

                       vrec.jelzo := vrec.jelzo or 1;

                       VonalrekordIr(RecNo,vrec);

                       Inc(Recno);

                    end;

                end;

                }

                Pontrajzol(Canvas,MovePt.x,MovePt.y,cw.pontmeret,alapszin);

             end;

 

rmVonaltorol:

          If vanVonal then begin

             Origin := MapToScreen(Canvas,vrec.x1,vrec.y1,cw);

             Movept := MapToScreen(Canvas,vrec.x2,vrec.y2,cw);

             vrec.jelzo := InversBit(vrec.jelzo,0);

             VonalrekordIr(aktvonal,vrec);

             Rajzol(Origin,MovePt,pmNot,True);

             Invalidate;

          end;

 

rmFelirattorol:

          If vanszoveg then begin

             Movept := MapToScreen(Canvas,szrec.x,szrec.y,cw);

             Pontrajzol(Canvas,Movept.x,Movept.y,cw.pontmeret,clBlue);

             szrec.jelzo := InversBit(szrec.jelzo,0);

             SzovegrekordIr(aktszoveg,szrec);

             Invalidate;

          end;

 

rmJelkulcstorol:

          If vanJelkulcs then begin

                jrec.jelzo := InversBit(jrec.jelzo,0);

                JelkulcsrekordIr(aktjelkulcs,jrec);

                Movept := MapToScreen(Canvas,jrec.x,jrec.y,cw);

                alappont.x:=jrec.x;

                alappont.y:=jrec.y;

                {Jelkulcsrajz(Canvas,Jelkulcsstream,MovePt.x,MovePt.y,cw.alapszin);}

             end;

 

rmFelirat:

      Case Alakzatmod of

      pRajzol:

      begin

          If feliratmod<>szSzogben then begin

             szrec.x := keppont.x;

             szrec.y := keppont.y;

          end;

 

          Case Feliratmod of

{           szSzovegkeres :

             begin

               GetFelirat(x,y,szrec,aktszoveg);

               FeliratRec := szrec;

               If Assigned(FOnSearch) then FOnSearch(Self,3,aktszoveg,FeliratRec);

             end;}

          szSzimpla:

             begin

               szrec.reteg:=aktreteg;

               Ujfelirat(szrec);

               Szovegrajzol(Canvas,szrec,rrec.szovegszin);

               If (szrec.reteg=10) and (HRSZCombo<>nil) then

                  HRSZCombo.Items.Add(szrec.szoveg);

               Rajzmod:=rmFelirat;

             end;

          szEltolas:

             begin

               If not uj_szoveg and GetFelirat(x,y,szrec,aktszoveg) then begin

                  uj_szoveg := True;

                  LBI;

                  Szovegrajzol(Canvas,szrec,alapszin);

               end else If Button=mbLeft then begin

                  SzovegrekordIr(aktSzoveg,szrec);

                  Szovegrajzol(Canvas,szrec,rrec.szovegszin);

                  uj_szoveg:=False;

                  Invalidate;

               end;

             end;

          szVonalra:

               If not uj_szoveg and GetFelirat(x,y,szrec,aktszoveg) then begin

                  oldszrec:=szrec;

                  uj_szoveg := True;

               end else

               If Button=mbLeft then begin

                  If Vonalkeres(x,ymax-y,vrec,aktvonal) then begin

                  szog:=Fok(Szakaszszog(vrec.x1,vrec.y1,vrec.x2,vrec.y2));

                  If (szog>=90) and (szog<=270) then

                       szrec.szog:= 10*Trunc(szog-180)

                  else szrec.szog:= Trunc(10*szog);

                  SzovegrekordIr(aktSzoveg,szrec);

                  If not uj_szoveg then

                     Szovegrajzol(Canvas,oldszrec,alapszin);

                  Szovegrajzol(Canvas,szrec,rrec.szovegszin);

                  uj_szoveg:=False;

               end;

               end;

            szSzogben:

               If Button=mbLeft then begin

                  If not von1 and not uj_szoveg then begin

                  If GetFelirat(x,y,szrec,aktszoveg) then LBI;

                  end;

                  If von1 or uj_szoveg then begin

                     szrec.x:=keppont.x; szrec.y:=keppont.y;

                     If uj_szoveg then von1:=True;

                  end;

               end else begin

                   von1:=False;

               end;

            szNormal:

               If GetFelirat(x,y,szrec,aktszoveg) then begin

                  szrec.szog:=0; SzovegrekordIr(aktSzoveg,szrec);

                  Invalidate;

               end;

            szAtemel:

               If GetFelirat(x,y,szrec,aktszoveg) then begin

                  szrec.reteg:=aktreteg; SzovegrekordIr(aktSzoveg,szrec);

                  Invalidate;

               end;

          end;

          If uj_szoveg then kMode:=kmNone else kMode:=kmFelirat;

{           Invalidate;}

       end;

       end;

 

rmSokszog,rmPoligonkijelol,rmTermanual: begin

          pontvan := pontkeres(oldmovept.x,ymax-oldMovePt.y,prec,aktPont);

          if not pontvan then pontvan:=pontkeres(x,ymax-y,prec,aktPont);

          Case button of

          mbLeft :

          begin

            If not pontvan then begin

            PrecNull(prec);

            With prec do begin

                 No    := pontsorszam;

                 x     := keppont.x;

                 y     := keppont.y;

            end;

            end;

            If polirec.PointsCount=0 then begin

               oldprec:=prec;

               talalt:=False;

            end;

            If cw.pontszamlatszik then Canvas.TextOut(x+2,y+2,IntToStr(prec.No));

            If (not von1) then begin

               VrecNull(wrec);

               wrec.reteg := aktreteg;

               wrec.x1 := prec.x;

               wrec.y1 := prec.y;

               wrec.x2 := prec.x;

               wrec.y2 := prec.y;

               Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

               MovePt := Origin;

               von1     := True;

            end else begin

               wrec.x2 := prec.x;

               wrec.y2 := prec.y;

               Rajzol(oldOrigin,oldMovePt,pmCopy,True);

               Origin := MapToScreen(Canvas,prec.x,prec.y,cw);

               MovePt := Origin;

               oldOrigin := Origin;

               oldMovePt := MovePt;

               wrec.x1 := wrec.x2;

               wrec.y1 := wrec.y2;

            end;

            If polirec.PointsCount>0 then begin

               tp := MapToScreen(Canvas,oldprec.x,oldprec.y,cw);

               d := KeTPontTavolsaga(x,y,tp.x,tp.y);

               If d<cw.tentativtures then begin

                  Polirec.kesz:=True;

                  Poligonmentes(teru,ker);

                  terulet:=teru; kerulet:=ker;

                  MouseUp(Button,Shift,X, Y);

                  polirec.kesz:=False;

                  poliStream.Clear;

                  Polirec.PointsCount:=0;

                  von1:=False;

                  cw.kijelolesek:=True;

                  exit;

               end;

            end;

               Polirec.PointsCount:=Polirec.PointsCount+1;

               Inc(pontsorszam); prec.reteg := cw.Aktreteg;

               poliStream.Write(prec,SizeOf(prec));

            end;

          mbRight :

               If Polirec.PointsCount>0 then begin

                  If Polirec.mentes then Poligonmentes(teru,ker);

                  terulet:=teru; kerulet:=ker;

                  Rajzol(oldOrigin,oldMovePt,pmNotXor,False);

                  poliStream.Clear;

                  Polirec.PointsCount:=0;

                  von1:=False;

               end;

          end;

          end;

 

 

end;

 

inherited MouseDown(Button, Shift, X, Y);

end;

 

procedure TStellaMap.MouseMove(Shift: TShiftState; X, Y: Integer);

var x1,y1,x2,y2,ymax,my : integer;

   pt: TPoint;

   d,d1 : real;

   kp,kp1,keppont: TPoint2D;

   fRect,cRect: TRect;

   ca: TCanvas;

   op1,op2,op3,op4: TPoint;

   rec_no: longint;

   pp: TPontrecord;

   szog: extended;

begin

oldMovePt := MovePt;

MovePt := Point(X, Y);

ymax   := Height;

my     := ymax-y;

keppont := ScreenToMap(Point(x,ymax-y),cw);

IF cw.nagyitas<>0 then begin

    xx := cw.origox + x / cw.nagyitas;

    yy := cw.origoy + my / cw.nagyitas;

    KoordLabel.Caption:=Format('%9.3f',[xx])+' : '+Format('%9.3f',[yy]);

end;

 

If not (Rajzmod in [rmNincs,rmNagyito,rmKicsinyito,rmAblak,rmPoligonkijelol,

                     rmAblaknagyitas])

then begin

If (Abs(oldMovePt.x-x)<cw.tentativtures) or (Abs(oldMovePt.y-y)<cw.tentativtures)

then

     If (Rajzmod = rmFelirat) and (kMode<>kmNone) then

        Keresesek(x,my,False);

end;

 

Case Rajzmod of

 

  rmVonal,rmSokszog,rmTermanual,rmIvmetszes,rmBemeres,rmElometszes,

  {rmPoligonkijelol,}rmPontVonallal,rmTeglalap,rmVonalAtemel,rmMeroleges,

  rmSzakasz,rmVonalosztas:

  begin

         If von1 then begin

              kp.x := xx; kp.y := yy;

              pp   := LegkozelebbiPont(kp,aktPont);

              kp.x := x; kp.y := y;

              Pt := MapToScreen(Canvas,pp.x,pp.y,cw);

              d := KeTPontTavolsaga(x,y,Pt.x,Pt.y);

              If d<cw.tentativtures then MovePt:=Pt;

              If rajzmod<>rmVonal then begin

                 pp:=oldprec;

                 Pt := MapToScreen(Canvas,pp.x,pp.y,cw);

                 d1 := KeTPontTavolsaga(x,y,Pt.x,Pt.y);

                 If (d1<cw.tentativtures) and (d1<d) then MovePt:=Pt;

              end;

            kp := ScreenToMap(Origin,cw);

            kp1:= ScreenToMap(MovePt,cw);

            d := KeTPontTavolsaga(kp.x,kp.y,kp1.x,kp1.y);

          Rajzol(Origin,oldMovePt,pmNotXor,False);

          Rajzol(Origin,MovePt,pmNotXor,False);

          If (Rajzmod in [rmTeglalap,rmMeroleges]) and (pfazis=1) then begin

            Canvas.Pen.Mode:=pmNotXor;

            Op1 := MapToScreen(Canvas,oldTeglalap.a.x,oldTeglalap.a.y,cw);

            Op2 := MapToScreen(Canvas,oldTeglalap.b.x,oldTeglalap.b.y,cw);

            Op3 := MapToScreen(Canvas,oldTeglalap.c.x,oldTeglalap.c.y,cw);

            Op4 := MapToScreen(Canvas,oldTeglalap.d.x,oldTeglalap.d.y,cw);

            ShowLine(Canvas,op1.x,op1.y,op2.x,op2.y);

            ShowLine(Canvas,op2.x,op2.y,op3.x,op3.y);

            If Rajzmod = rmTeglalap then begin

               ShowLine(Canvas,op3.x,op3.y,op4.x,op4.y);

               ShowLine(Canvas,op1.x,op1.y,op4.x,op4.y);

            end;

            oldTeglalap:=HarompontbolTeglalap(oldTeglalap.a,oldTeglalap.b,keppont);

            Op4 := MapToScreen(Canvas,oldTeglalap.d.x,oldTeglalap.d.y,cw);

            Op3 := MapToScreen(Canvas,oldTeglalap.c.x,oldTeglalap.c.y,cw);

            ShowLine(Canvas,op1.x,op1.y,op2.x,op2.y);

            ShowLine(Canvas,op2.x,op2.y,op3.x,op3.y);

            If Rajzmod = rmTeglalap then begin

               ShowLine(Canvas,op3.x,op3.y,op4.x,op4.y);

               ShowLine(Canvas,op1.x,op1.y,op4.x,op4.y);

            end;

            d := KeTPontTavolsaga(op2.x,op2.y,op3.x,op3.y);

          end;

          If Assigned(FOnDistanceChange) then FOnDistanceChange(Self,d);

         end;

  end;

 

rmPontAtrak:

   If von1 then begin

        prec :=oldprec;

        prec.x:=keppont.x; prec.y:=keppont.y;

        Op1 := MapToScreen(Canvas,oldprec.x,oldprec.y,cw);

        Op2 := MapToScreen(Canvas,prec.x,prec.y,cw);

        Canvas.Pen.Color := clTeal;

        Canvas.Pen.width := 2;

        Canvas.Pen.Mode  := pmNotXor;

        ShowLine(Canvas,Origin.x,Origin.y,oldMovePt.x,oldMovePt.y);

        Canvas.Pen.Mode  := pmNotXor;

        ShowLine(Canvas,Origin.x,Origin.y,MovePt.x,MovePt.y);

        rec_no:=0;

        While rec_no<cw.vonalszam do

        if VonalVegpontKeres(tm[2],oprec.x,oprec.y,vrec,rec_no) then

        begin

           VonalVegpontAtrak(vrec,oprec,oldprec);

           Rajzol(MapToScreen(Canvas,vrec.x1,vrec.y1,cw),

                  MapToScreen(Canvas,vrec.x2,vrec.y2,cw),pmNotXor,False);

           VonalVegpontAtrak(vrec,oldprec,prec);

           Rajzol(MapToScreen(Canvas,vrec.x1,vrec.y1,cw),

                  MapToScreen(Canvas,vrec.x2,vrec.y2,cw),pmNotXor,False);

           rec_no:=rec_no+1;

        end;

        oldprec := prec;

   end;

 

  rmNegyszog,rmAblakkijelol,rmPoligonkijelol :

         If von1 then begin

          Rajzol(Origin,oldMovePt,pmNotXor,False);

          Rajzol(Origin,MovePt,pmNotXor,False);

         end;

 

  rmFelirat : begin

         Case Feliratmod of

         szSzogben:

             If (Shift=[ssLeft]) then begin

               If von1 or uj_szoveg then begin

                   szog:=Fok(Szakaszszog(Origin.x,MovePt.y,MovePt.x,Origin.y));

                   If (szog>=90) and (szog<=270) then szrec.szog:=10*Trunc(szog-180)

                   else szrec.szog:= Trunc(10*szog);

               end;

               LBI;

               Szovegrajzol(Canvas,szrec,rrec.szovegszin);

             end else

             If uj_szoveg or von1 then begin

               szrec.x:=xx; szrec.y:=yy;

               LBI;

               Szovegrajzol(Canvas,szrec,rrec.szovegszin);

             end;

         szVonalra:

             If Vonalkeres(x,my,vrec,aktvonal) then

             begin

                  Cursor := crDrag;

                  d := KeTPontTavolsaga(vrec.x1,vrec.y1,vrec.x2,vrec.y2);

             end else begin

                 Cursor := crDefault;

             end;

         end;

          If (Feliratmod<>szSzogben) or not von1 then begin

                        szrec.x:=xx; szrec.y:=yy;

          end;

          If (Feliratmod<>szSzovegkeres) and uj_szoveg then begin

             LBI;

             Szovegrajzol(Canvas,szrec,rrec.szovegszin);

          end;

         end;

 

  rmVonalkijelol,rmVonaltorol :

          If Vonalkeres(x,my,vrec,aktvonal) then

          begin

             Cursor := crDrag;

             If AdatLabel<>nil then

                 AdatLabel.Caption:=IntToStr(vrec.reteg);

             d := KeTPontTavolsaga(vrec.x1,vrec.y1,vrec.x2,vrec.y2);

          end else begin

             Cursor := crDefault;

             If AdatLabel<>nil then

                 AdatLabel.Caption:='';

          end;

 

rmFeliratkijelol:

          begin

             szrec:=LegkozelebbiSzoveg(Point2D(xx,yy),aktszoveg);

             AdatLabel.Caption:=szrec.szoveg;

          end;

 

rmKoriv: If (pfazis=2) {nd (oldMovePt.x<>MovePt.x) and (oldMovePt.y<>MovePt.y)}

          then begin

             Canvas.Pen.Mode:=pmNotXor;

             KorivRajzol(Canvas,teglalap.a,teglalap.b,teglalap.c);

             teglalap.b:=Point2d(x,y);

             KorivRajzol(Canvas,teglalap.a,teglalap.b,teglalap.c);

             Canvas.Pen.Mode:=pmCopy;

          end;

 

  end;

inherited MouseMove(Shift,x,y);

end;

 

procedure TStellaMap.MouseUp(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer);

Var dx,dy,xm,ym,ii,j: longint;

   tr1,tr2: TRect;

   xx,yy,szog:  extended;

   b:integer;   {keret vastagság csúsztatásnál}

   tr: HRgn;

   pTomb: Array[0..100] of TPoint;

   tp,tp1: TPoint;

begin

  IF nagyitas<>0 then begin

  xx := cw.origox + x / cw.nagyitas;

  yy := cw.origoy + (height-y) / cw.nagyitas;

  end;

  Case Rajzmod of

 

  rmFelirat :

     If (Feliratmod=szSzogben) then

     If not von1 then von1:=True else begin

          szog:=Fok(Szakaszszog(Origin.x,MovePt.y,MovePt.x,Origin.y));

             If (szog>=90) and (szog<=270) then

                 szrec.szog:= 10*Trunc(szog-180)

             else szrec.szog:= Trunc(10*szog);

          rrec:=RetegrekordKap(szrec.reteg);

          LBI;

          If uj_szoveg then begin

             szrec.reteg:=aktreteg;

             Ujfelirat(szrec);

               If (szrec.reteg=10) and (HRSZCombo<>nil) then

                  HRSZCombo.Items.Add(szrec.szoveg);

          end else SzovegrekordIr(aktSzoveg,szrec);

          von1:=False;

          Szovegrajzol(Canvas,szrec,rrec.szovegszin);

          Invalidate;

     end;

 

  rmAblakkijelol,rmPoligonkijelol :

     If Button=mbLeft then begin

 

          Case Rajzmod of

          rmAblakkijelol:

          If not von1 then begin

             polirec.kesz := False;

             von1:=True;

          end else

          begin

                tr := CreateRectRgn(oldOrigin.x,oldOrigin.y,x,y);

                InvertRgn(Canvas.Handle,tr);

                polirec.kesz:=True;

                von1:=False;

          end;

          rmPoligonkijelol :

          if polirec.kesz then begin

                polistream.Seek(0,0);

                For ii:=0 to Polirec.Pointscount-1 do begin

                    PoliStream.Read(prec,SizeOf(prec));

                    pTomb[ii]:=MapToScreen(Canvas,prec.x,prec.y,cw);

                end;

                tr := CreatePolygonRgn(pTomb,Polirec.Pointscount,ALTERNATE);

          end;

          end;

 

          if polirec.kesz then begin

          StreamMeretek(cw);

          For ii:=1 to 4 do begin

              tm[ii].Seek(0,0);

              Case ii of

              1: if cw.pontlatszik then

                 For j:=1 to cw.pontszam do begin

                    tm[1].Read(prec,SizeOf(prec));

                    tp := MapToScreen(Canvas,prec.x,prec.y,cw);

                    If PtInRegion(tr,tp.x,tp.y) then begin

                       prec.jelzo := prec.jelzo or 128;

                       tm[1].Seek(-SizeOf(prec),1);

                       tm[1].Write(prec,SizeOf(prec));

                    end;

                 end;

              2: if cw.vonallatszik then

                 For j:=1 to cw.vonalszam do begin

                    tm[2].Read(vrec,SizeOf(vrec));

                    tp := MapToScreen(Canvas,vrec.x1,vrec.y1,cw);

                    tp1:= MapToScreen(Canvas,vrec.x2,vrec.y2,cw);

                    If PtInRegion(tr,tp.x,tp.y) and PtInRegion(tr,tp1.x,tp1.y) then

                    begin

                       vrec.jelzo := vrec.jelzo or 128;

                       tm[2].Seek(-SizeOf(vrec),1);

                       tm[2].Write(vrec,SizeOf(vrec));

                    end;

                 end;

              3: if cw.szoveglatszik then

                 For j:=1 to cw.szovegszam do begin

                    tm[3].Read(szrec,SizeOf(szrec));

                    tp := MapToScreen(Canvas,szrec.x,szrec.y,cw);

                     If PtInRegion(tr,tp.x,tp.y) then begin

                      szrec.jelzo := szrec.jelzo or 128;

                       tm[3].Seek(-SizeOf(szrec),1);

                       tm[3].Write(szrec,SizeOf(szrec));

                    end;

                 end;

              4: if cw.jelkulcslatszik then

                 For j:=1 to cw.jelkulcsszam do begin

                    tm[4].Read(jrec,SizeOf(jrec));

                    tp := MapToScreen(Canvas,jrec.x,jrec.y,cw);

                    If PtInRegion(tr,tp.x,tp.y) then begin

                       jrec.jelzo := jrec.jelzo or 128;

                       tm[4].Seek(-SizeOf(jrec),1);

                       tm[4].Write(jrec,SizeOf(jrec));

                    end;

                 end;

              end;

          end;

          DeleteObject(tr);

          end;

     end else begin

         von1:=False;

         invalidate;

     end;

 

  end;

  Inherited MouseUp(Button,Shift,X, Y);

end;

 

{----------------------- Rutinok -------------------------------------}

 

{ Teljes térkép felrajzolása }

{

procedure TStellaMap.Ujrarajzol(ca:TCanvas;tt:TRect);

begin

inherited Ujrarajzol(ca,tt);

end;

}

procedure TStellaMap.Rajzol( T,B: TPoint; AMode: TPenMode; ujrajz: Boolean);

var DC:HDC;

begin

DC := GetDC(Canvas.Handle);

With Canvas do

begin

   rrec:=RetegRekordKap(aktreteg);

   If Amode=pmNotXor then

      SetPen(canvas,not Alapszin,1,TPenStyle(rrec.vonalstylus),AMode)

   else

      SetPen(canvas,rrec.vonalszin,rrec.vonalvastag,TPenStyle(rrec.vonalstylus),AMode);

   Brush.Color:=clWhite;

   Brush.style:=bsClear;

   If (T.X<>B.x) OR (T.Y<>B.Y) then

   begin

       If ujrajz then

           case RajzMod of

           rmPont :      Pen.Color := cw.pontszin;

           rmFelirat :   Pen.Color := rrec.szovegszin;

           rmTermanual,rmMetszes,rmVetites,rmIvmetszes,rmPoligonkijelol,

              rmBemeres,rmKituzes,rmVonalAtemel:

              begin Pen.Color := clRed; Pen.Width:=2; end;

           end;

       case RajzMod of

       rmPont:  Rectangle(T.X-pontmeret,T.Y-pontmeret,T.X+pontmeret,T.Y+pontmeret);

       rmvonal,rmSokszog,rmPontAtrak,rmPoligonkijelol,rmTeglalap,rmMeroleges,

       rmTermanual,rmMetszes,rmVetites,rmIvmetszes,rmBemeres,rmKituzes,

       rmElometszes,rmHatrametszes,rmVonalAtemel,rmSzakasz,rmVonalosztas:

           If pfazis=0 then begin

               MoveTo(T.X, T.Y); LineTo(B.X, B.Y);

           end;

       rmPontVonallal:

           begin

               MoveTo(T.X, T.Y); LineTo(B.X, B.Y);

               Pen.Color := cw.pontszin;

               Rectangle(T.X-pontmeret,T.Y-pontmeret,T.X+pontmeret,T.Y+pontmeret);

               Rectangle(B.X-pontmeret,B.Y-pontmeret,B.X+pontmeret,B.Y+pontmeret);

           end;

       rmAblak      :

           begin

               SetPen(canvas,Alapszin xor clRed,4,TPenStyle(psSolid),pmNotXor);

               Rectangle(T.X, T.Y, B.X, B.Y);

           end;

       rmNegyszog,rmAblakkijelol  : Rectangle(T.X, T.Y, B.X, B.Y);

       rmEllipszis  : Ellipse(T.X, T.Y, B.X, B.Y);

       end;

   end;

end;

RestoreDC(Canvas.Handle,DC);

end;

 

function TStellaMap.Ujpont(var p: Tpontrecord):boolean;

begin

Result := False;

If demovar and (cw.pontszam>100) then

begin

    ShowMessage('Demo : Max. 100 elem!'); exit;

end;

If (VanMarPont(tm[1],p)=0) and not IsVedett(rtgstream,p.reteg,p.jelzo,True) then begin

    tm[1].Seek(0,2);tm[1].Write(p,SizeOf(p));

    Inc(pontsorszam);

    Inc(cw.pontszam);

    Result := True;

end;

end;

 

function TStellaMap.Ujvonal(p: Tvonalrecord):boolean;

begin

Result := False;

If demovar and (cw.vonalszam>100) then

begin

    ShowMessage('Demo : Max. 100 elem!'); exit;

end;

If (RetegbenFedoVonal(tm[2],p)=0) and not IsVedett(rtgstream,p.reteg,p.jelzo,True) then begin

    tm[2].Seek(0,2);tm[2].Write(p,SizeOf(p));

    Inc(cw.vonalszam);

    Result := True;

end;

end;

 

function TStellaMap.Ujfelirat(p: Tszovegrecord):boolean;

begin

Result := False;

If demovar and (cw.szovegszam>100) then

begin

    ShowMessage('Demo : Max. 100 elem!'); exit;

end;

If not IsVedett(rtgstream,p.reteg,p.jelzo,True) then begin

    tm[3].Seek(0,2);tm[3].Write(p,SizeOf(p));

    Inc(cw.szovegszam);

    Result := True;

end;

end;

 

function TStellaMap.Ujjelkulcs(p: Tjelkulcsrecord):boolean;

begin

Result := False;

If demovar and (cw.jelkulcsszam>100) then

begin

    ShowMessage('Demo : Max. 100 elem!'); exit;

end;

If not IsVedett(rtgstream,p.reteg,p.jelzo,True) then begin

    tm[4].Seek(0,2);tm[4].Write(p,SizeOf(p));

    Inc(cw.jelkulcsszam);

    Result := True;

end;

end;

 

Procedure TStellaMap.PontRekordIr(arec: longint; pr: TPontrecord);

begin If not IsVedett(rtgstream,pr.reteg,pr.jelzo,True) then WriteRec(tm[1],arec,pr,SizeOf(pr));

end;

 

Procedure TStellaMap.VonalRekordIr(arec: longint; vr: TVonalrecord);

begin If not IsVedett(rtgstream,vr.reteg,vr.jelzo,True) then WriteRec(tm[2],arec,vr,SizeOf(vr));

end;

 

Procedure TStellaMap.SzovegRekordIr(arec: longint; pr: TSzovegrecord);

begin If not IsVedett(rtgstream,pr.reteg,pr.jelzo,True) then WriteRec(tm[3],arec,pr,SizeOf(pr));

end;

 

Procedure TStellaMap.JelkulcsRekordIr(arec: longint; jr: TJelkulcsrecord);

begin If not IsVedett(rtgstream,jr.reteg,jr.jelzo,True) then WriteRec(tm[4],arec,jr,SizeOf(jr));

end;

 

procedure TStellaMap.Notification(AComponent: TComponent;

Operation: TOperation);

begin

inherited Notification(AComponent, Operation);

if (Operation = opRemove) Then AComponent:=nil;

end;

 

procedure TStellaMap.PoligonMentes(var terulet,kerulet:real);

var i: longint;

   pr,kiindulo: Tpontrecord;

   Rgn: HRgn;

   pTomb: Array[0..100] of TPoint;

begin

If polirec.PointsCount>0 then begin

terulet := 0;  kerulet := 0;

tm[1].seek(0,2);  tm[2].seek(0,2);

PoliStream.seek(0,0);

For i:=0 to polirec.PointsCount-1 do begin

     PoliStream.Read(pr,SizeOf(pr));

     if cw.rmod=rmPoligonkijelol then

        pTomb[i]:=MapToScreen(Canvas,pr.x,pr.y,cw);

     if polirec.mentes then UjPont(pr);

     If i=1 then kiindulo:=prec;

     VrecNull(vrec);

     if i>1 then begin

     With vrec do begin

        reteg := pr.reteg;

        x1    := oldprec.x;

        y1    := oldprec.y;

        x2    := pr.x;

        y2    := pr.y;

     end;

     terulet := Abs(terulet-(pr.x-oldprec.x)*(pr.y+oldprec.y)/2);

     kerulet := kerulet+KeTPonttavolsaga(pr.x,pr.y,oldprec.x,oldprec.y);

     end;

     oldprec:=prec;

end;

     if cw.rmod=rmPoligonkijelol then begin

        Rgn:=CreatePolygonRgn(pTomb,polirec.PointsCount,ALTERNATE);

        Canvas.Brush.Color:=clBlue;

        Canvas.Brush.style:=bsSolid;

        InvertRgn(Canvas.Handle,Rgn);

        DeleteObject(Rgn);

     end;

end;

end;

 

end.