Autor Beitrag
Quivadis
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314

UBUNTU 9.04
D2005 PERS, JAVA, D7 Pers.
BeitragVerfasst: Fr 25.02.05 14:34 
Ich habe folgendes problem:

ich habe ein Polygon auf den Bildschirm mit Anfassern. Die Koordinaten von dennen sind in einer Liste gespeichert. Jeder Anfasser hat einen Nachfolger und und einen Vorgänger.
Die Anfasser können mit der Maus auf den Bildschirm verschoben werden.

Nun möchte ich den Linienverlauf während des ziehens/bewegen der Anfasser mit anzeigen lassen. Damit das ganze nicht so langsam geht möchte ich nur die beiden veränderten Linien neu zeichnen lassen. Also wie bei vektororientierten Malprogramm.

Mit einer Linie bekomme ich es hin. Bei zwei linien geht es nicht.

+..... +
*.....*
*...* <--- Die linien müssen beim bewegen mit bewegt werden.
*.*
*
+

* linie
. Leerzeiche also nichts
+ Anfasser


Neuer Denkanstoss recht vielleicht schon.

Quivadis

_________________
Wissen ist macht, nichts wissen macht auch nichts. ODER: Wer nichts weis, kann nichts vergessen.


Zuletzt bearbeitet von Quivadis am Fr 25.02.05 14:49, insgesamt 1-mal bearbeitet
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 25.02.05 14:49 
also wenn die linien objekte sind kann ja ein anfasser (knoten) mehrere (bei dir vill nur max 2) linien haben
die linien wiederum sind halt objekte und müssen 2 knoten haben

wenn du nun einen knoten bewegst, hast du ja alle zugrif auf die linien - d.h. alle linien die mit dem knoten in verbindung gebracht werden müssen neu gezeichnet werden

du musst das also so machen das du von einer linie auf die beiden knoten kommst und von einem knoten auf alle linien die da hinzeigen



im endeffekt bruach man dann nur noch knoten -> jeder knoten hat bestimmte andere knoten (waraus man lininen zeichnen kann) und eine eigenschafft ob der knoten bwegt werden kann oder nicht

z.b. hast du dann

knoten A,B,C

A -> B
B -> A,C
C -> B



das sieht dann so aus:

a-b-c

wenn nun b bewegt wird, schaust du in die liste -> B zischen A, C müssen neu berechnet werden

also linie AB und BC neuzeichnen


Zuletzt bearbeitet von uall@ogc am Fr 25.02.05 14:51, insgesamt 1-mal bearbeitet
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 25.02.05 14:50 
Ist das Polygon ausgefüllt? Falls ja, ist das Polygon konvex?

Ich glaub ich seh das Problem noch nicht. Wo ist das Problem wenn man einfach die beiden betroffenen Linien löscht und dann neu zeichnet?
Quivadis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314

UBUNTU 9.04
D2005 PERS, JAVA, D7 Pers.
BeitragVerfasst: Fr 25.02.05 14:57 
So das mache ich jetzt. Es erscheint 2 Linien.
Diese müssen aber beim ziehen auf der alten position verschwinden und auf der neuen position wider erscheinen.

dazu wollte ich mit Image1.canvas... mit pmnotxor zeichen. Bein 2 mal sollten sie dann verschwiden.

machen sie aber nicht.

Entweder ichsehe gar kein linie mehr oder mein Bildschirm wird immer schwärzer von den vieln linien die nicht mehr verschwinden.

hier mal der quellcode der funktion:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
procedure tform1.zeichneLinie(Sender: TObject;Shift: TShiftState; X, Y: Integer);
var
  i : integer;
begin
  i :=tshape(sender).Tag;  // auslesen Nr. des Anfassers/Shape
  label1.Caption:=inttostr(tshape(sender).Tag);
  if i>=0 then
  // vorherige Linie übermalen
  begin
    canvas.Pen.Color:=clblack;
    image1.Picture.Bitmap.canvas.Pen.Style:=psSolid;
    image1.Picture.Bitmap.canvas.Brush.Style:=bsClear;
    image1.Picture.Bitmap.Canvas.Pen.Width:=2;
    image1.Picture.Bitmap.canvas.Pen.Mode:=pmnotxor;
    if i=0 then
    begin
      // erster anfasser

      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[objList.Count-1]).top);
      Image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[objList.Count-1]).Left,Tshape(objList.items[objList.Count-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
     //image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
     //image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end;

    if i=(objList.count-1) then
    begin
      // letzter anfasser
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.LineTo(Tshape(objList.items[0]).Left,Tshape(objList.items[0]).top);
     //image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i+1]).Left,Tshape(objList.items[i+1]).top);
     //image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end;

  // neue linie setzen
    //image1.Picture.Bitmap.canvas.Pen.Mode:=pmcopy;

    if i=0 then
    begin
      // erster anfasser
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[ObjList.Count-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[ObjList.Count-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
    end
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
    end;

    if i=(objList.count-1) then
    begin
      // letzter anfasser
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.LineTo(Tshape(objList.items[0]).Left,Tshape(objList.items[0]).top);
    End
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i+1]).Left,Tshape(objList.items[i+1]).top);
    end;

  end;
  
  x3:=x;
  y3:=y;
  label4.Caption:=floattostr(flaeche)+' pixel^2';
end;

_________________
Wissen ist macht, nichts wissen macht auch nichts. ODER: Wer nichts weis, kann nichts vergessen.
Quivadis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314

UBUNTU 9.04
D2005 PERS, JAVA, D7 Pers.
BeitragVerfasst: Fr 25.02.05 15:37 
So habe mein Fehler gefunden.

Danke euch beiden.

Hier der fertige Code:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
procedure tform1.zeichneLinie(Sender: TObject;Shift: TShiftState; X, Y: Integer);
var
  i : integer;
begin
  i :=tshape(sender).Tag;  // auslesen Nr. des Anfassers/Shape
  label1.Caption:=inttostr(tshape(sender).Tag);
  if i>=0 then
  // vorherige Linie übermalen
  begin
    canvas.Pen.Color:=clblack;
    image1.Picture.Bitmap.canvas.Pen.Style:=psSolid;
    image1.Picture.Bitmap.canvas.Brush.Style:=bsClear;
    image1.Picture.Bitmap.Canvas.Pen.Width:=2;
    image1.Picture.Bitmap.canvas.Pen.Mode:=pmnotxor;
    if i=0 then
    begin
      // erster anfasser

      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[objList.Count-1]).top);
      Image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[objList.Count-1]).Left,Tshape(objList.items[objList.Count-1]).top);
      //image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
     image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
     // image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
     image1.Picture.Bitmap.canvas.lineto(x3,y3);
    end;

    if i=(objList.count-1) then
    begin
      // letzter anfasser

      //image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
       image1.Picture.Bitmap.canvas.moveto(x3,y3);
      // image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(x3,y3);
      image1.Picture.Bitmap.canvas.LineTo(Tshape(objList.items[0]).Left,Tshape(objList.items[0]).top);

    end
    else
    begin
      //image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
       image1.Picture.Bitmap.canvas.moveto(x3,y3);
      // image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(x3,y3);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i+1]).Left,Tshape(objList.items[i+1]).top);
    end;

  // neue linie setzen
    //image1.Picture.Bitmap.canvas.Pen.Mode:=pmcopy;

    if i=0 then
    begin
      // erster anfasser
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[ObjList.Count-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[ObjList.Count-1]).Left,Tshape(objList.items[ObjList.Count-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
    end
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i-1]).Left,Tshape(objList.items[i-1]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
    end;

    if i=(objList.count-1) then
    begin
      // letzter anfasser
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.LineTo(Tshape(objList.items[0]).Left,Tshape(objList.items[0]).top);
    End
    else
    begin
      image1.Picture.Bitmap.canvas.moveto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i]).Left,Tshape(objList.items[i]).top);
      image1.Picture.Bitmap.canvas.lineto(Tshape(objList.items[i+1]).Left,Tshape(objList.items[i+1]).top);
    end;
  end;
  x3:=Tshape(objList.items[i]).Left;          //x;
  y3:=Tshape(objList.items[i]).Top;           //y;
  label4.Caption:=floattostr(flaeche)+' pixel^2';
end;

_________________
Wissen ist macht, nichts wissen macht auch nichts. ODER: Wer nichts weis, kann nichts vergessen.