home *** CD-ROM | disk | FTP | other *** search
- {---------------------------------------------------------------------------}
- { gsxlib1.pas - GSX Bibliothek: }
- { Geraete-, einf. Grafik-, Text- und Attribut-Funktionen }
- {---------------------------------------------------------------------------}
-
- { Inhalt:
- Open_Workstation, Close_Workstation, Clear_Workstation, Update_Workstation,
- Enter_Graphics, Exit_Graphics,
- Set_Turtle, Hide_Turtle, Ploy_Line, Ploy_Marker, Ploy_Fill, Graph_Text,
- Cell_Array,
- Text_Resolution, Cursor, Goto_XY, Where_XY, Write_Text,
- Draw_Mode, Video, Text_Height, Text_Direction, Set_Color, Line_Type,
- Line_Width, Line_Color, Marker_Type, Marker_Height, Marker_Color,
- Marker_Color, Text_Font, Text_Color, Fill_Style, Fill_Index, Fill_Color }
-
- {---------------------------------------------------------------------------}
- { geraetespez. Funktionen: }
- {---------------------------------------------------------------------------}
- { Ein Grafik-Geraet als Ausgabemedium waehlen. Es wird entsprechend den Pa-
- rametern im Eingabefeld initialisiert. Gearaetespez. Informationen werden
- in den globalen Variablen zur Auswertung durch das Anwendungsprogramm be-
- reitgestellt. Der Grafik-Modus wird gewaehlt und, bei einem Monitor, der
- Bildschirm geloescht. }
-
- PROCEDURE Open_Workstation (Device: INTEGER);
-
- BEGIN
- VDI_Error := TRUE;
- IF Device IN [Screen, Plotter, Printer] THEN
- BEGIN
- contrl[1] := 1; contrl[2] := 0; contrl[4] := 10;
- intin[1] := Device;
- { Vorbesetzung der Geraeteeigenschaften: }
- intin[2] := Solid; { Linestyle }
- intin[3] := Red; { Linecolor: Monochrom = weiss, Drucker/
- Plotter = Schwarz, Farbe = Rot }
- intin[4] := Dot; { Markertype }
- intin[5] := Red; { Markercolor, s. Linecolor }
- intin[6] := Standard; { TextFont }
- intin[7] := Red; { Textcolor, s. Linecolor }
- intin[8] := Hollow; { Fuell-Art }
- intin[9] := Vertical; { Fuell-Muster }
- intin[10] := Red; { Fillcolor, s. Linecolor }
-
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- VDI_Error := (contrl[3] <> 6);
-
- HRes := intout[1]; VRes := intout[2];
- Scaling := (intout[3] = 0);
- PixWidth := intout[4]; PixHeight := intout[5];
- CharHeights := intout[6];
- Lines := intout[7]; LineWidths := intout[8];
- Markers := intout[9]; MarkerSizes := intout[10];
- Fonts := intout[11]; Patterns := intout[12];
- HatchStyles := intout[13]; GDPs := intout[15];
- ColorDevice := (intout[36] = 1);
- Colors := intout[14]; ColorsAvail := intout[40];
- TextRotation := (intout[37] = 1); AreaFill := (intout[38] = 1);
- CellArrays := (intout[39] = 1); InputLocators := intout[41];
- InputValuators := intout[42]; InputChoices := intout[43];
- InputStrings := intout[44]; WorkstationType := intout[45];
- MinCharHeight := ptsout[2]; MaxCharHeight := ptsout[4];
- MinLineWidth := ptsout[5]; MaxLineWidth := ptsout[7];
- MinMarkHeight := ptsout[10]; MaxMarkHeight := ptsout[12];
- END;
- END;
-
- {---------------------------------------------------------------------------}
- { Verbindung zum Grafik-Gereat aufheben und weitere Ausgaben zu diesem ver-
- hindern. Bei Monitoren wird der Textmodus gewaehlt und der Bildschirm ge-
- loescht. Bei einem Drucker wird vorher ein 'update' (s.u.) ausgefuehrt. }
-
- PROCEDURE Close_Workstation;
-
- BEGIN
- contrl[1] := 2; contrl[2] := 0;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Monitor: Bildschirm wird geloescht. Drucker: Papiervorschub mit nachfol-
- gendem 'update'. Plotter: Es wird ein neues Blatt verlangt. }
-
- PROCEDURE Clear_Workstation;
-
- BEGIN
- contrl[1] := 3; contrl[2] := 0;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Es wird die Ausfuehrung aller noch nicht vom Geraet ausgefuehrten Grafik-
- Befehle bewirkt. Bei Druckern muss diese Prozedur aufgerufen werden, um
- die Ausgabe zu starten. }
-
- PROCEDURE Update_Workstation;
-
- BEGIN
- contrl[1] := 4; contrl[2] := 0;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Unterscheidet das Grafik-Geraet zwischen Text- und Grafik-Modus, wird mit
- dieser Prozedur explizit der Grafik-Modus aktiviert. Dabei wird das Geraet
- 'geloescht'. }
-
- PROCEDURE Enter_Graphics;
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := 2;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Wie Enter_Graphics, jedoch wird wieder in den Text-Modus umgeschaltet. }
-
- PROCEDURE Exit_Graphics;
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := 3;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Grafik-Funktionen: }
- {---------------------------------------------------------------------------}
- { Grafik-Cursor positionieren und darstellen. Die Darstellung des Grafik-
- Cursors ist geraeteabhaengig. }
-
- PROCEDURE Set_Turtle (xpos, ypos: INTEGER);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 2; contrl[6] := 18;
- ptsin[1] := xpos; ptsin[2] := ypos;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Den zuletzt mit 'Set_Turtle' gesetzten Grafik-Cursor wieder entfernen. }
-
- PROCEDURE Hide_Turtle;
-
- BEGIN
- contrl[1] := 5; contrl[2] := 2; contrl[6] := 19;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Polygonzug mit 'n' Punkten Zeichnen. Die Koordinaten der einzelnen Punkte
- werden im Parameter 'ptsin' vom Typ 'VDI_ptsin' erwartet. Anordnung der
- Koordinaten in 'ptsin':
- ptsin[1]: xpos1, ptsin[2]: ypos1; ptsin[3]: xpos2, ptsin[4]: ypos2;
- ptsin[5]: xpos3, ptsin[6]: ypos3; usw.
- Die Linien werden in den aktuellen 'Line'-Attributen gezeichnet.
- Bei einem einzelnen Koordinatenpaar wird nichts gezeichnet; eine Linie
- der Laenge 0 (d.h. zwei identische Koordinatenpaare) wird gezeichnet. }
-
- PROCEDURE Poly_Line (n: INTEGER; VAR ptsin: VDI_ptsin);
-
- BEGIN
- contrl[1] := 6; contrl[2] := n;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Wie 'Poly_Line', jedoch werden an den Koordinaten nur Markierungen in den
- aktuellen 'Marker'-Attributen gesetzt. }
-
- PROCEDURE Poly_Marker (n: INTEGER; VAR ptsin: VDI_ptsin);
-
- BEGIN
- contrl[1] := 7; contrl[2] := n;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Wie 'Poly_Line', jedoch wird der Polygonzug automatisch geschlossen und in
- den aktuellen 'Fill'-Attributen ausgefuellt. }
-
- PROCEDURE Poly_Fill (n: INTEGER; VAR ptsin: VDI_ptsin);
-
- BEGIN
- contrl[1] := 9; contrl[2] := n;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Text ab der Position x,y in den aktuellen 'Text'-Attributen schreiben. Die
- x,y-Position bezeichnet die linke, untere Ecke des ersten Zeichens. Der
- String-Parameter ist ev. anzupassen. }
-
- PROCEDURE Graph_Text (x, y: INTEGER; s: VDI_STRING);
-
- BEGIN
- contrl[1] := 8; contrl[2] := 1; contrl[4] := Length(s);
- ptsin[1] := x; ptsin[2] := y;
- FOR x := 1 TO Length(s) DO
- intin[x] := Ord(s[x]);
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Zeichnen eines durch zwei Eckpunkte begrenzten Rechtecks. Dieses wird mit
- einem Farbmuster gefuellt, das durch das Feld 'ColorIndexArray' vom Typ
- 'VDI_intin' bestimmt wird. In diesem sind die zu verwendenten Farben zum
- Fuellen der Flaeche zeilenweise einzutragen. Ausserdem wird die Laenge
- einer Zeile 'Columns' desselben (d.h. wieviel Farben fuer 'eine Zeile'
- des Rechtecks vorgesehen sind), wieviel davon schliesslich benutzt werden
- sollen, wieviel solcher Zeilen 'Rows' es insgesamt im 'ColorIndexArray'
- gibt, sowie der Zeichen-Modus, verlangt (s. Begleitartikel). }
-
- PROCEDURE Cell_Array (xlb, ylb, { linke, untere Ecke }
- xrt, yrt: INTEGER; { rechte, obere Ecke }
- VAR ColorIndexArray: VDI_intin;
- Rows, Columns,
- Elements: INTEGER;
- DrawMode: Draw_Modes);
-
- BEGIN
- contrl[1] := 10; contrl[2] := 2;
- contrl[4] := Rows*Columns; contrl[6] := Columns; contrl[7] := Elements;
- contrl[8] := Rows; contrl[9] := DrawMode;
- ptsin[1] := xlb; ptsin[2] := ylb;
- ptsin[3] := xrt; ptsin[4] := yrt;
- VDI_Call(contrl, ColorIndexArray, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Text-Funktionen: }
- {---------------------------------------------------------------------------}
- { Anzahl von adressierbaren Text-Zeilen und -Spalten des Ausgabegeraets
- ermitteln. -1 in Zeilen oder Spalten bedeutet, dass direkte Cursor-
- Adressierung nicht moeglich ist. }
-
- PROCEDURE Text_Resolution (Var Rows, Columns: INTEGER);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := 1;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Rows := intout[1]; { meisten 24 Zeilen }
- Columns := intout[2]; { meisten 80 Spalten }
- END;
-
- {---------------------------------------------------------------------------}
- { Mit dieser Prozedur kann der Textcursor manoeveriert werden.
- Parameter siehe Cursor_Operations. }
-
- PROCEDURE Cursor (Op: Cursor_Operations);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := Op;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Textcursor an die Position x,y setzen. x = Spalte, y = Zeile }
-
- PROCEDURE Goto_XY (x, y: INTEGER);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := 11;
- intin[1] := y; intin[2] := x;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Ermittelt Zeile und Spalte, in der der Textcursor steht. }
-
- PROCEDURE Where_XY (VAR x, y: INTEGER);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := 15;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- y := intout[1]; x := intout[2];
- END;
-
- {---------------------------------------------------------------------------}
- { Gibt eine Zeichenkette ab der aktuellen Textcursor-Position in dem akt.
- 'Video'-Attribut aus. }
-
- PROCEDURE Write_Text (s: VDI_STRING);
-
- VAR i: INTEGER;
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[4] := Length(s); contrl[6] := 12;
- FOR i := 1 TO Length(s) DO
- intin[i] := Ord(s[i]);
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Attribut-Funktionen: }
- {---------------------------------------------------------------------------}
- { Zeichenmodus festlegen: Replace, Transparent, Complement, Erase }
-
- FUNCTION Draw_Mode (Mode: Draw_Modes): INTEGER;
-
- BEGIN
- contrl[1] := 32; contrl[2] := 0; contrl[3] := Mode;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Draw_Mode := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Darstellung von folgenden Textausgaben im Textmodus 'Reverse' oder
- 'Normal' setzen. }
-
- PROCEDURE Video (Attribute: Video_Attributes);
-
- BEGIN
- contrl[1] := 5; contrl[2] := 0; contrl[6] := Attribute;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Zeichenhoehe in Geraeteeinheiten (Punkte, Plotter-Schrittweite) setzen.
- Zurueckgegeben wird die tatsaechlich eingestellte Zeichenbreite, -hoehe,
- Zeichenzellenbreite und -hoehe. Die Zeichenzelle stellt hierbei eine 8x8
- Matrix dar, in der das Zeichen 7 Einheiten hoch ist. Die unterste Zellen-
- zeile ist leer. Als Drehpunkt fuer Schriftdrehung (s.u.) dient das Zellen-
- element in der zweiten Zeile von unten links. Die zurueckgegebene Zeichen-
- groesse bezieht sich auf ein grosses "W". }
-
- PROCEDURE Text_Height (Height: INTEGER;
- VAR CharWidth, CharHeight,
- CellWidth, CellHeight: INTEGER);
-
- BEGIN
- contrl[1] := 12; contrl[2] := 1;
- ptsin[1] := 0; ptsin[2] := Height;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- CharWidth := ptsout[1]; CharHeight := ptsout[2];
- CellWidth := ptsout[3]; CellHeight := ptsout[4];
- VDI_Error := (contrl[3] <> 2);
- END;
-
- {---------------------------------------------------------------------------}
- { Schreibrichtung (Winkel) setzen, so gut es das angewaehlte Geraet zu-
- laesst. Der tatsaechlich eingestellte Winkel wird von der Funktion in
- Grad zurueckgegeben. }
-
- FUNCTION Text_Direction (angle: REAL): REAL;
-
- BEGIN
- contrl[1] := 13; contrl[2] := 0;
- intin[1] := Trunc(angle*10.0);
- intin[2] := Round(cos(angle)*100.0);
- intin[3] := Round(sin(angle)*100.0);
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Text_Direction := intout[1] / 10;
- END;
-
- {---------------------------------------------------------------------------}
- { Representation der Farbe 'ColorNr' durch die Farbanteile Rot, Gruen und
- Blau bestimmen. Die Farbanteile muessen in 1/10 Prozent (0..1000) ange-
- geben werden. Der Erfolg dieser Procedur ist geraeteabhaengig. Wenigsten
- zwei Farben sind durch 'Open_Workstation' schon initialisiert. }
-
- PROCEDURE Set_Color (Color: Color_Index; Red, Green, Blue: INTEGER);
-
- BEGIN
- contrl[1] := 14; contrl[2] := 0;
- intin[1] := Color;
- intin[2] := Red; intin[3] := Green; intin[4] := Blue;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- END;
-
- {---------------------------------------------------------------------------}
- { Linientyp fuer kuenftige Zeichenoperatioenen bestimmen. Es wird der
- wirklich eingestellte Linientyp (geraetabhaengig) zurueck gegeben. }
-
- FUNCTION Line_Type (LType: Line_Types ): INTEGER;
-
- BEGIN
- contrl[1] := 15; contrl[2] := 0; intin[1] := LType;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Line_Type := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Linienbreite festlegen und zurueckmelden. }
-
- FUNCTION Line_Width (LWidth: INTEGER): INTEGER;
-
- BEGIN
- contrl[1] := 16; contrl[2] := 1;
- ptsin[1] := LWidth; ptsin[2] := 0;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- VDI_Error := (contrl[3] <> 1) OR (ptsout[2] <> 0);
- Line_Width := ptsout[1]
- END;
-
- {---------------------------------------------------------------------------}
- { Farbe von zu zeichnenden Linien bestimmen und Ergebnis melden. }
-
- FUNCTION Line_Color (Color: Color_Index): INTEGER;
-
- BEGIN
- contrl[1] := 17; contrl[2] := 0; intin[1] := Color;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- VDI_Error := (contrl[3] <> 1);
- Line_Color := intout[1]
- END;
-
- {---------------------------------------------------------------------------}
- { Markierungszeichen festlegen (s. gsxconst.pas) }
-
- FUNCTION Marker_Type (MType: Marker_Types): INTEGER;
-
- BEGIN
- contrl[1] := 18; contrl[2] := 0; intin[1] := MType;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Marker_Type := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Groesse (Hoehe) der Markierungszeichen festlegen. }
-
- FUNCTION Marker_Heigth (Heigth: INTEGER): INTEGER;
-
- BEGIN
- contrl[1] := 19; contrl[2] := 1; ptsin[1] := 0; ptsin[2] := Heigth;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- VDI_Error := (contrl[3] <> 1) OR (ptsout[1] <> 0);
- Marker_Heigth := ptsout[2]
- END;
-
- {---------------------------------------------------------------------------}
- { Farbe der Markierungszeichen... }
-
- FUNCTION Marker_Color (Color: INTEGER): INTEGER;
-
- BEGIN
- contrl[1] := 20; contrl[2] := 0; intin[1] := Color;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Marker_Color := intout[1]
- END;
-
- {---------------------------------------------------------------------------}
- { Zeichensatz fuer zukuenftige Text-Funktionen waehlen. Diese sind Geraete-
- abhaengig und von 1 bis ??? numeriert (s. gsxconst, gsxtype u. gsxvar) }
-
- FUNCTION Text_Font (Font: INTEGER): INTEGER;
-
- BEGIN
- contrl[1] := 21; contrl[2] := 0; intin[1] := Font;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Text_Font := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Textfarbe... }
-
- FUNCTION Text_Color (Color: Color_Index): INTEGER;
-
- BEGIN
- contrl[1] := 22; contrl[2] := 0; intin[1] := Color;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Text_Color := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Setzt die Fuellart fuer Polygone. Modifizierbar mit Fill_Index. Steht die
- gewuenschte Fuellart nicht zur Verfuegung, sollte 'Hollow' benutzt werden }
-
- FUNCTION Fill_Style (Style: Fill_Styles): INTEGER;
-
- BEGIN
- contrl[1] := 23; contrl[2] := 0; intin[1] := Style;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Fill_Style := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Die Funktion modifiziert die mit Fill_Style festgelegte Fuellart. Sie
- zeigt keine Wirkung, wenn Fill_Style 'Hollow' oder 'Solid' ist. Der Index
- geht von 1 bis zu einem geraeteabhaengigen Maximum. Bei Fill_Style =
- Hatch (Schraffur) entsprechen die in gsxconst.pas definierten Konstanten
- dem erzielten Effekt. Bei Fill_Style = Pattern (Halbton-Muster) werden
- Grautoene mit dem Index 1-6 benutzt (1: hell, 6: dunkel). }
-
- FUNCTION Fill_Index (Index: INTEGER): INTEGER;
-
- BEGIN
- contrl[1] := 24; contrl[2] := 0; intin[1] := Index;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Fill_Index := intout[1];
- END;
-
- {---------------------------------------------------------------------------}
- { Fuellfarbe waehlen... }
-
- FUNCTION Fill_Color (Color: Color_Index): INTEGER;
-
- BEGIN
- contrl[1] := 25; contrl[2] := 0; intin[1] := Color;
- VDI_Call(contrl, intin, intout, ptsin, ptsout);
- Fill_Color := intout[1]
- END;
-
- {---------------------------------------------------------------------------}
- { Ende von gsxlib1.pas }
-