home *** CD-ROM | disk | FTP | other *** search
- /* DIAGDEMO.C - Beispielprogramm für Diagrammgrafiken
- *
- * Sofern GRAPHICS.LIB und PGCHART.LIB bei der Installation nicht in
- * die Laufzeit-Bibliothek eingefügt wurden, müssen die beiden
- * Bibliotheken in die Programmliste von DIAGDEMO.MAK aufgenommen
- * oder auf der Befehlszeile angegeben werden.
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <bios.h>
- #include <conio.h>
- #include <graph.h>
- #include <pgchart.h>
- #include "diagdemo.h"
-
- /* Strukturen für System-Konfiguration und Diagrammumgebung. */
- struct videoconfig vc;
- chartenv ce;
-
- /* Kategorievariablen. */
- short cCat;
- char _far * aCat[MAXWERTE];
-
- /* Folgenvariablen */
- short cFolge;
- short _far acFolge[MAXFOLGEN];
- char _far * aFolgeName[MAXFOLGEN];
-
- /* Vorübergendes Aufbewahrungs-Datenfeld für alle Daten. Datenwerte für
- * Balken-, Säulen- und Strichdiagramme aus Mehrfachfolgen bleiben hier.
- * Daten für andere Diagramme werden auf die folgenden Datenfelder
- * übertragen.
- */
- float _far aWert[MAXFOLGEN][MAXWERTE];
-
- /* Datenwerte für Diagramme aus Einzelfolgen. Das erste Datenfeld wird
- * für Balken-, Säulen, Linien und Kreisdiagramme verwendet. Für das
- * Einzelfolgen-Streudiagramm werden sowohl das erste also auch das
- * zweite benutzt.
- */
- float _far axWert[MAXWERTE];
- float _far ayWert[MAXWERTE];
-
- /* Datenwerte für Mehrfachfolgen-Streudiagramme. */
- float _far axWertMS[MAXWERTE][MAXWERTE];
- float _far ayWertMS[MAXWERTE][MAXWERTE];
-
- /* Herausgezogene Bezeichner für Kreisdiagramm. */
- short _far aExplode[MAXWERTE];
-
- /* Die Variablen zum Verfolgen von Steuerung und Bildschirmposition. */
- struct SCREENINFO si;
-
- /* Farben der Menüs und Eingabeaufforderungen */
- struct tagFarbe co;
-
- /* Kennung ob vorgegebene oder importierte Daten verwendet werden sollen. */
- BOOL fDefault = WAHR;
-
- /* Zeichenfolge-Datenfelder für die Menü-Funktion. Die erste Zeichenfolge
- * ist der Menütitel. Die nächsten Zeichenfolgen ungleich Null sind die
- * Wahlmöglichkeiten des Menüs. Eine Null-Zeichenfolge bedeutet das Ende der
- * Liste
- */
-
- char *pszDiagrammOpt[] =
- { "Optionen", "Modus (Bildschirm)", "Fenster", "Titel",
- "Achse (X und Y)", "Beschriftung", "Schriften", "Zurücksetzen", "" };
-
- char *pszDiagrammTyp[] =
- { "Typ", "Balken", "Säulen", "Linien", "Streu", "Kreis", "" };
-
- char *pszHauptMenue[] =
- { "Hauptmenü", "Demo", "Ansicht", "Typ",
- "Optionen", "Werte anzeigen", "Ende", "" };
-
- /* Beispieldaten */
- #define O_SAFT 0
- #define E_TEE 1
- #define KAKAO 2
- #define TEMPERATUR 3
-
- char _far * aViertel[] =
- { "Erstes", "Zweites", "Drittes", "Viertes" };
-
- char _far * aMonate[] =
- { "Jan", "Feb", "Mrz", "Apr", "Mai", "Jun",
- "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" };
-
- float _far aVerkauf[3][12] =
- {
- { 3.6F, 3.2F, 3.3F, 3.4F, 3.1F, 2.9F,
- 3.0F, 3.6F, 3.2F, 3.3F, 3.5F, 3.9F },
- { 1.0F, 1.3F, 1.4F, 1.7F, 2.2F, 2.9F,
- 2.9F, 3.1F, 2.6F, 1.8F, 1.1F, 1.2F },
- { 2.4F, 2.3F, 2.0F, 1.6F, 1.3F, 1.0F,
- 0.9F, 0.8F, 1.1F, 1.4F, 1.9F, 2.5F }
- };
-
- float _far aTemperatur[12] =
- { 6.1F, 8.5F, 10.9F, 12.8F, 16.0F, 19.5F,
- 22.0F, 21.2F, 17.0F, 13.7F, 11.1F, 9.3F };
-
- char _far * aVerkaufTitel[] =
- { "Orangensaftverkauf", "Eisteeverkauf", "Kakaoverkauf" };
-
- char *TempTitel = "Durchschnittstemperatur";
-
- int main()
- {
- Initialisiere();
- HauptMenue();
-
- /* Rücksetzen des Videomodus und der Bildschirmfarben vor Abschluß */
- _setvideomode( _DEFAULTMODE );
- _settextcolor( co.InfoFarbe );
- _clearscreen( _GCLEARSCREEN );
-
- return 0;
- }
-
- /* DiagrammOptionen - Ruft Diagramm-Optionen ab.
- *
- * Parameter: Keine
- */
- void DiagrammOptionen()
- {
- int iWahl;
-
- PushTitel( pszDiagrammOpt[0] );
- while( (iWahl = Menue( pszDiagrammOpt )) != ESCAPE )
- {
-
- /* Diagramm-Optionen holen. */
- switch( iWahl )
- {
-
- /* Zum entsprechenden Menü verzweigen. */
- case 1:
- BschirmModus();
- break;
-
- case 2:
- Fenster();
- break;
-
- case 3:
- Titel();
- break;
-
- case 4:
- Achsen();
- break;
-
- case 5:
- Beschriftung();
- break;
-
- case 6:
- SchriftOptionen();
- break;
-
- case 7:
- RuecksetzOptionen();
- break;
-
- }
- }
- PopTitel();
- }
-
- /* DiagrammTyp - Holt Diagrammtyp.
- *
- * Parameter: Keine
- */
- void DiagrammTyp()
- {
- int iWahl;
-
- /* Get chart type. */
- PushTitel( pszDiagrammTyp[0] );
- iWahl = Menue( pszDiagrammTyp );
-
- if( iWahl != ESCAPE )
- {
- /* Diagrammtyp bestimmen und Diagrammart holen. */
- ce.charttype = iWahl;
- switch( iWahl )
- {
-
- case 1:
- case 2:
- iWahl = BlankMenue( "Stil", "Einfache Balken", "Balken Übereinander" );
- break;
-
- case 3:
- case 4:
- iWahl = BlankMenue( "Stil", "Linien-Punkte", "Nur Punkte" );
- break;
-
- case 5:
- iWahl = BlankMenue( "Stil", "Prozent", "Kein Prozent" );
- }
-
- if( iWahl != ESCAPE)
- ce.chartstyle = iWahl;
-
- /* Vorgabedaten einrichten, ohne Umgebungsvorgaben zu ändern. */
- VorgabeDaten( ce.charttype, ce.chartstyle, FALSCH );
- PopTitel();
- }
- PopTitel();
- }
-
-
- /* DatenLoeschen - Löscht Daten für Kategorie und Wert.
- *
- * Parameter: fWirklich - Kennung, ob bestätigt werden soll. */
- void DatenLoeschen( BOOL fWirklich )
- {
- char chAntwort = 'J';
- int iCat;
-
- WrtForm( 18 );
-
- /* Anfrage nach Bestätigung. */
- if( fWirklich )
- chAntwort = EingabeChar( "Sind Sie sicher? ", "JN\x1b" );
-
- if( chAntwort == 'J' )
- {
-
- /* Alle relevanten Daten löschen. */
- for( iCat = 0; iCat < cCat; iCat++ )
- aCat[iCat] = NULL;
- cCat = 0;
- cFolge = 0;
- }
- }
-
- /* VorgabeDaten - Initialisiert Vorgabedaten für jeden Diagrammtyp.
- *
- * Parameter: iTyp - Zu initialisierender Diagrammtyp
- * iStil - Diagrammstil
- * fLoesch - Signal, alle Vorgaben zu löschen
- */
- void VorgabeDaten( short iTyp, short iStil, BOOL fLoesch )
- {
- int iCat, iWert, iSubWert, iFolge;
-
- /* Vorgabediagramm aufrufen um alte Werte zu löschen. */
- if( fLoesch )
- _pg_defaultchart( &ce, iTyp, iStil );
-
- /* Kategorietitel initialisieren. */
- cCat = 12;
- for( iCat = 0; iCat < cCat; iCat++ )
- aCat[iCat] = aMonate[iCat];
-
- switch( ce.charttype )
- {
-
- /* Daten für jeden Diagrammtyp initialisieren. */
- case _PG_BARCHART:
-
- strcpy( ce.maintitle.title, "Orangensaft- und Eisteeverkauf" );
- cFolge = 2;
- for( iFolge = 0; iFolge < cFolge; iFolge++ )
- {
- aFolgeName[iFolge] = aVerkaufTitel[iFolge];
- acFolge[iFolge] = cCat;
- for( iWert = 0; iWert < cCat; iWert++ )
- aWert[iFolge][iWert] = (float)aVerkauf[iFolge][iWert];
- }
- break;
-
- case _PG_COLUMNCHART:
-
- strcpy( ce.maintitle.title, "Orangensaftverkauf" );
- cFolge = 1;
- for( iFolge = 0; iFolge < cFolge; iFolge++ )
- {
- aFolgeName[iFolge] = aVerkaufTitel[iFolge];
- acFolge[iFolge] = cCat;
- for( iWert = 0; iWert < cCat; iWert++ )
- aWert[iFolge][iWert] = (float)aVerkauf[iFolge][iWert];
- }
- break;
-
- case _PG_LINECHART:
-
- strcpy( ce.maintitle.title, "Getränkeverkauf" );
- cFolge = 3;
- for( iFolge = 0; iFolge < cFolge; iFolge++ )
- {
- aFolgeName[iFolge] = aVerkaufTitel[iFolge];
- acFolge[iFolge] = cCat;
- for( iWert = 0; iWert < cCat; iWert++ )
- aWert[iFolge][iWert] = (float)aVerkauf[iFolge][iWert];
- }
- break;
-
- case _PG_SCATTERCHART:
-
- strcpy( ce.maintitle.title,
- "Durchschnittstemperatur im Vergleich zum Getränkeverkauf"
- );
- /* ce.chartstyle = _PG_POINTONLY; */
- cFolge = 4;
-
- aFolgeName[0] = aVerkaufTitel[E_TEE];
- aFolgeName[2] = aVerkaufTitel[KAKAO];
- acFolge[0] = acFolge[1] = acFolge[2] = acFolge[3] = 12;
- for( iWert = 0; iWert < 12; iWert++ )
- {
- aWert[0][iWert] = (float)aVerkauf[E_TEE][iWert] ;
- aWert[1][iWert] = (float)aVerkauf[TEMPERATUR][iWert] ;
- aWert[2][iWert] = (float)aVerkauf[KAKAO][iWert] ;
- aWert[3][iWert] = (float)aVerkauf[TEMPERATUR][iWert] ;
- }
- break;
-
- case _PG_PIECHART:
- default:
-
- strcpy( ce.maintitle.title, "Eisteeverkauf" );
- cCat = 4;
- for( iCat = 0; iCat < cCat; iCat++ )
- aCat[iCat] = aViertel[iCat];
-
- cFolge = 1;
- aFolgeName[0] = aVerkaufTitel[E_TEE];
- acFolge[0] = cCat;
-
- for( iWert = 0; iWert < cCat; iWert++ )
- {
- aWert[0][iWert] = 0.0F;
- for( iSubWert = 0; iSubWert < 3; iSubWert++ )
- aWert[0][iWert] += (float)aVerkauf[E_TEE][iSubWert * iWert];
- }
- aExplode[3] = 1;
- break;
- }
- }
-
- /* Demo - Zeigt eine Reihe von Diagrammbeispielen.
- *
- * Parameter: Keine
- */
- void Demo()
- {
- int cWert;
- palettetype palette_struct;
-
- /* Zeigt Beispielsdaten in Tabellenform. */
- ZeigeBspielDaten();
-
- VorgabeDaten( _PG_PIECHART, _PG_NOPERCENT, WAHR );
-
- /* Videomodus einrichten und Diagramme zeichnen. Vorgabedaten für
- * jedes Diagramm einrichten und gewünschte Umgebungsfelder ändern.
- * Im Fall eines Fehlers, Demo abbrechen.
- */
- _setvideomode( si.mode );
-
- cWert = 4;
- strcpy( ce.subtitle.title, "Vorgegebenes Kreisdiagramm" );
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- strcpy( ce.subtitle.title, "Geändertes Kreisdiagramm" );
- ce.chartstyle = _PG_PERCENT;
- ce.legend.place = _PG_BOTTOM;
- if (si.fFarbe)
- {
- ce.maintitle.titlecolor = ce.subtitle.titlecolor = 0;
- ce.chartwindow.background = 1;
- ce.datawindow.background = ce.legend.legendwindow.background = 6;
- ce.legend.textcolor = 1;
- }
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- cWert = 12;
- VorgabeDaten( _PG_BARCHART, _PG_PLAINBARS, WAHR );
- strcpy( ce.subtitle.title, "Vorgegebenes Balkendiagramm" );
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- strcpy( ce.subtitle.title, "Spezielles Überlagertes Balkendiagramm" );
- strcpy( ce.xaxis.axistitle.title, "Verkauf in Tausenden" );
- strcpy( ce.yaxis.axistitle.title, "Monat" );
- ce.chartstyle = _PG_STACKEDBARS;
- ce.legend.place = _PG_RIGHT;
- ce.xaxis.ticdecimals = 2;
- if (si.fFarbe)
- {
- ce.maintitle.titlecolor = ce.subtitle.titlecolor = 12;
- ce.chartwindow.background = 7;
- ce.datawindow.background = 8;
- ce.legend.textcolor = 0;
- ce.legend.legendwindow.background = 8;
- ce.legend.autosize = FALSCH;
- ce.legend.legendwindow.y1 = vc.numypixels - 85;
- ce.legend.legendwindow.y2 = vc.numypixels - 45;
- }
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- VorgabeDaten( _PG_COLUMNCHART, _PG_PLAINBARS, WAHR );
- strcpy( ce.subtitle.title, "Vorgegebenees Säulendiagramm" );
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- strcpy( ce.subtitle.title, "Geändertes Säulendiagramm" );
- strcpy( ce.xaxis.axistitle.title, "Monat" );
- strcpy( ce.yaxis.axistitle.title, "Verkauf in Tausenden" );
- ce.legend.place = _PG_BOTTOM;
- if (si.fFarbe)
- {
- ce.maintitle.titlecolor = 0;
- ce.subtitle.titlecolor = 0;
- ce.chartwindow.background = 8;
- ce.datawindow.background = 2;
- ce.legend.legendwindow.background = 10;
- }
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- VorgabeDaten( _PG_LINECHART, _PG_POINTANDLINE, WAHR );
- strcpy( ce.subtitle.title, "Vorgegebenes Liniendiagramm" );
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- strcpy( ce.subtitle.title, "Geändertes Liniendiagramm" );
- strcpy( ce.xaxis.axistitle.title, "Monat" );
- strcpy( ce.yaxis.axistitle.title, "Verkauf in Tausenden" );
- ce.legend.place = _PG_RIGHT;
- if (si.fFarbe)
- {
- ce.maintitle.titlecolor = 1;
- ce.subtitle.titlecolor = 1;
- ce.chartwindow.background = 3;
- ce.datawindow.background = 7;
- ce.legend.legendwindow.background = 7;
- ce.legend.autosize = FALSCH;
- ce.legend.legendwindow.y1 = vc.numypixels - 85;
- ce.legend.legendwindow.y2 = vc.numypixels - 45;
- }
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- VorgabeDaten( _PG_SCATTERCHART, _PG_POINTONLY, WAHR );
- strcpy( ce.subtitle.title, "Vorgegebenes Streudiagramm" );
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- cFolge = 4;
- strcpy( ce.subtitle.title, "Geändertes Streudiagramm" );
- strcpy( ce.xaxis.axistitle.title, "Verkauf in Tausenden" );
- strcpy( ce.yaxis.axistitle.title, "Durchschnittstemperatur" );
- ce.legend.place = _PG_RIGHT;
- if (si.fFarbe)
- {
- ce.maintitle.titlecolor = 0;
- ce.subtitle.titlecolor = 0;
- ce.chartwindow.background = 4;
- ce.datawindow.background = 8;
- ce.legend.legendwindow.background = 8;
- ce.legend.autosize = FALSCH;
- ce.legend.legendwindow.y1 = vc.numypixels - 85;
- ce.legend.legendwindow.y2 = vc.numypixels - 45;
- }
- if( DiagrammAnsicht() )
- return;
- else
- _clearscreen( _GCLEARSCREEN );
-
- VorgabeDaten( _PG_BARCHART, _PG_PERCENT, WAHR );
- }
-
- /* FindVideoMode - Findet "besten" Videomodus für eingebauten Adapter.
- *
- * Parameter: vc - Struktur des Typs struct videoconfig
- *
- * Ergibt: Besten Videomodus
- */
- int FindVideoMode( struct videoconfig vc )
- {
- switch( vc.adapter )
- {
- case _CGA:
- case _OCGA:
- return _HRESBW;
- case _EGA:
- case _OEGA:
- return( vc.monitor == _MONO ) ? _ERESNOCOLOR : _ERESCOLOR;
- case _VGA:
- case _OVGA:
- case _MCGA:
- return _VRES16COLOR;
- case _HGC:
- return _HERCMONO;
- default:
- return _DEFAULTMODE;
- }
- }
-
-
- /* Initialisiere - Initialisiert diverse Werte.
- *
- * Parameter: Keine
- */
- void Initialisiere( void )
- {
- int iFolge, iWert;
-
- /* Initialisiert alle Wert-Datenfelder auf fehlend. */
- for( iFolge = 0; iFolge < MAXFOLGEN; iFolge++ )
- {
-
- axWert[iFolge] = _PG_MISSINGVALUE;
- ayWert[iFolge] = _PG_MISSINGVALUE;
-
- for( iWert = 0; iWert < MAXWERTE; iWert++ )
- aWert[iFolge][iWert] = _PG_MISSINGVALUE;
-
- for( iWert = 0; iWert < MAXWERTE; iWert++ )
- {
- axWertMS[iFolge][iWert] = _PG_MISSINGVALUE;
- ayWertMS[iFolge][iWert] = _PG_MISSINGVALUE;
- }
- }
-
- /* Nullreihen initialisieren. */
- cFolge = 0;
-
- /* Vorgabe Diagrammumgebung, Bildschirmmodus und Daten initialisieren.*/
- _pg_initchart();
- _getvideoconfig( &vc );
-
- /* Besten Modus zur Anzeige finden.
- * NICHT auf 256 Farben bei mittlerer Auflösung (_MRES256COLOR).
- */
- si.mode = FindVideoMode( vc );
-
- if( si.mode == _TEXTMONO )
- {
- _clearscreen( _GCLEARSCREEN );
- _outtext( "Grafik nicht verfügbar - kann Demo nicht fahren." );
- exit( 1 );
- }
-
- SetDisplayColors();
-
- SetGraphMode( si.mode );
- VorgabeDaten( _PG_BARCHART, _PG_PLAINBARS, WAHR );
-
- _setvideomode( _DEFAULTMODE );
-
- }
-
-
- /* HauptMenue - Verwaltet das Hauptmenü.
- *
- * Parameter: Keine
- */
- void HauptMenue( void )
- {
- int iWahl;
- char chAntwort = 'J';
- char chBestaetigen;
-
- PushTitel( pszHauptMenue[0] );
- do
- {
- /* Wählt der Benutzer Ende, enthält iWahl 6. Drückt er die
- * ESC-Taste, wird iWahl zu ESCAPE, d.h. gleich 27.
- * In jedem Fall können wir auf beide Bedingungen prüfen, indem
- * geprüft wird, ob iWahl kleiner als 6 ist.
- */
- while( (iWahl = Menue( pszHauptMenue )) < 6 )
- {
- /* Hauptmenü-Auswahl holen. */
- switch( iWahl )
- {
-
- case 1:
- /* Demo-Diagramme anzeigen. */
- Demo();
- _setvideomode( _DEFAULTMODE );
- break;
-
- case 2:
- /* Auf Grafikmodus schalten, gegenwärtiges Diagramm
- * anzeigen und wieder auf Textmodus rücksetzen.
- */
- _setvideomode( si.mode );
- DiagrammAnsicht();
- _setvideomode( _DEFAULTMODE );
- break;
-
- case 3:
- /* Diagrammtyp und Stil holen. */
- DiagrammTyp();
- break;
-
- case 4:
- /* Diagrammoptionen holen. */
- DiagrammOptionen();
- break;
- case 5:
- /* Diagrammdaten zeigen. */
- ZeigeDiagrammDaten();
- break;
-
- }
-
- }
-
- /* Versucht der Benutzer das Programm über die ESCAPE-Taste zu
- * verlassen, muß dies jeweils bestätigt werden, denn sonst könnte
- * man mit zu häufigem Drücken von ESCAPE versehentlich an einer
- * ungeplanten Stelle aussteigen.
- */
- if( iWahl == ESCAPE )
- {
- Hilfe( "Drücken Sie \"E\", um wirklich zu Beenden", co.EingabeFarbe );
-
- putchar( SIGNAL );
- _settextposition( si.help - 1, 32 );
- chBestaetigen = getch();
- if( tolower( chBestaetigen ) != 'e' )
- iWahl = 0;
- else
- iWahl = 6;
- }
-
- } while( iWahl != 6 );
- PopTitel();
- }
-
- /* RuecksetzOptionen - Nach Bestätigung Diagrammoptionen
- * auf Vorgabe rücksetzen.
- *
- * Parameter: Keine
- */
- void RuecksetzOptionen()
- {
- char chAntwort;
-
- /* Aufforderung zur Bestätigung vor Rücksetzen zur Vorgabeumgebung. */
- LschForm();
- Hilfe( "Mit 'J' alle Optionen, mit 'N' beibehalten.", co.EingabeFarbe );
- chAntwort = EingabeChar( "Sind Sie sicher? ", "JN\x1b" );
- if( chAntwort == 'J' )
- _pg_defaultchart( &ce, 1, 1 );
-
- }
-
- /* SetGraphMode - Prüft den verlangten Grafikmodus und richtet die Werte
- * xMax und yMax in der si-Struktur ein (si = Screen Information).
- *
- * Parameter: modus
- *
- * Ergibt: FALSCH wenn der Modus ungültig ist, sonst WAHR.
- */
- BOOL SetGraphMode(int modus)
- {
- if (!_setvideomode( modus ) )
- return FALSCH;
- else
- {
- _getvideoconfig ( &vc );
- if( !vc.numxpixels )
- return FALSCH;
- si.xMax = vc.numxpixels;
- si.yMax = vc.numypixels;
- si.mode = modus;
-
- /* Kennung einsetzen, ob mehrfache Farben verfügbar sind. */
- si.fFarbe = iscolor( modus );
-
- return WAHR;
- }
- }
-
- /* ZeigeDiagrammDaten - Zeigt die Daten in der Diagrammumgebung.
- *
- * Parameter: Keine
- */
- void ZeigeDiagrammDaten()
- {
- int iReihe = 2;
- struct _fontinfo fd;
- static char *szWeiter =
- "Beliebige Taste zum Fortsetzen drücken, mit ESC zurück zum Menü.";
-
- _clearscreen( _GCLEARSCREEN );
- SAusgabePos( iReihe++, 1, "short charttype = %d", ce.charttype );
- SAusgabePos( iReihe++, 1, "short chartstyle = %d", ce.chartstyle );
- SAusgabePos( iReihe++, 1, "windowtype chartwindow =" );
- iReihe = ZeigeFensterTyp( iReihe, 1, ce.chartwindow );
- SAusgabePos( iReihe++, 1, "windowtype datawindow =" );
- iReihe = ZeigeFensterTyp( iReihe, 1, ce.datawindow );
- SAusgabePos( ++iReihe, 1, szWeiter );
- if( getch() == ESCAPE )
- return;
-
- iReihe = 2;
- _clearscreen( _GCLEARSCREEN );
- SAusgabePos( iReihe++, 1, "titletype maintitle =" );
- iReihe = ZeigeTitelTyp( iReihe, 1, ce.maintitle );
- SAusgabePos( iReihe++, 1, "titletype subtitle =" );
- iReihe = ZeigeTitelTyp( iReihe, 1, ce.subtitle );
- SAusgabePos( ++iReihe, 1, szWeiter );
- if( getch() == ESCAPE )
- return;
-
- iReihe = 2;
- _clearscreen( _GCLEARSCREEN );
- SAusgabePos( iReihe++, 1, "axistype xaxis =" );
- iReihe = ZeigeAchsenTyp( iReihe, 1, ce.xaxis );
- SAusgabePos( ++iReihe, 1, szWeiter );
- if( getch() == ESCAPE )
- return;
-
- iReihe = 2;
- _clearscreen( _GCLEARSCREEN );
- SAusgabePos( iReihe++, 1, "axistype yaxis =" );
- iReihe = ZeigeAchsenTyp( iReihe, 1, ce.yaxis );
- SAusgabePos( ++iReihe, 1, szWeiter );
- if( getch() == ESCAPE )
- return;
-
- iReihe = 2;
- _clearscreen( _GCLEARSCREEN );
- SAusgabePos( iReihe++, 1, "legendtype Beschriftung =" );
- iReihe = ZeigeBeschriftungTyp( iReihe, 1, ce.legend );
- SAusgabePos( ++iReihe, 1, "Press any key to continue . . ." );
- getch();
-
- iReihe = 2;
- _clearscreen( _GCLEARSCREEN );
- if( _getfontinfo( &fd ) != -1)
- {
- SAusgabePos( ++iReihe, 1, "struct _fontinfo =" );
- iReihe = ZeigeFontInfo( iReihe, 1, fd);
- SAusgabePos( ++iReihe, 1, "Press any key to continue . . ." );
- getch();
- }
- }
-
- /* ZeigeAchsenTyp - Zeigt Daten in einer Variablen des Typs "axistype".
- *
- * Parameter: iReihe - Anfangsreihe
- * iSplt - Spalten einzurücken
- * dieAchse - anzuzeigende Variable des Typs "axistype"
- *
- * Ergibt: Nächste verfügbare Reihe
- */
- int ZeigeAchsenTyp( int iReihe, int iSplt, axistype dieAchse )
- {
- SAusgabePos( iReihe++, iSplt + 5, "short .grid = %d",
- dieAchse.grid );
- SAusgabePos( iReihe++, iSplt + 5, "short .gridstyle = %d",
- dieAchse.gridstyle );
- SAusgabePos( iReihe++, iSplt + 5, "titletype axistitle=" );
- iReihe = ZeigeTitelTyp( iReihe, iSplt + 5, dieAchse.axistitle );
- SAusgabePos( iReihe++, iSplt + 5, "short .axiscolor = %d",
- dieAchse.axiscolor );
- SAusgabePos( iReihe++, iSplt + 5, "short .labeled = %s",
- (dieAchse.labeled) ? "WAHR" : "FALSCH" );
- SAusgabePos( iReihe++, iSplt + 5, "short .rangetype = %d",
- dieAchse.rangetype );
- SAusgabePos( iReihe++, iSplt + 5, "float .logbase = %f",
- dieAchse.logbase );
- SAusgabePos( iReihe++, iSplt + 5, "short .autoscale = %s",
- (dieAchse.autoscale) ? "WAHR" : "FALSCH" );
- SAusgabePos( iReihe++, iSplt + 5, "float .scalemin = %f",
- dieAchse.scalemin );
- SAusgabePos( iReihe++, iSplt + 5, "float .scalemax = %f",
- dieAchse.scalemax );
- SAusgabePos( iReihe++, iSplt + 5, "float .scalefactor = %f",
- dieAchse.scalefactor );
- iReihe = ZeigeTitelTyp( iReihe, iSplt + 5, dieAchse.scaletitle );
- SAusgabePos( iReihe++, iSplt + 5, "float .ticinterval = %f",
- dieAchse.ticinterval );
- SAusgabePos( iReihe++, iSplt + 5, "short .ticformat = %d",
- dieAchse.ticformat );
- SAusgabePos( iReihe++, iSplt + 5, "short .ticdecimals = %d",
- dieAchse.ticdecimals );
-
- return iReihe;
- }
-
- /* ZeigeFontInfo - Gibt die Daten einer Variable vom Typ "_fontinfo" aus.
- *
- * Parameter: iReihe - Anfangsreihe
- * iSplt - Spalten einzurücken
- * derFont - auszugebende Variable vom Typ "_fontinfo"
- * Ergibt: Nächste verfügbare Reihe
- */
-
- int ZeigeFontInfo ( int iReihe, int iSplt, struct _fontinfo derFont)
- {
- SAusgabePos( iReihe, iSplt + 5, "int .type = %d", derFont.type );
- SAusgabePos( iReihe, iSplt + 5, "int .ascent = %d", derFont.ascent );
- SAusgabePos( iReihe, iSplt + 5, "int .pixwidth = %d", derFont.pixwidth );
- SAusgabePos( iReihe, iSplt + 5, "int .pixheight = %d", derFont.pixheight );
- SAusgabePos( iReihe, iSplt + 5, "int .avgwidth = %d", derFont.avgwidth );
- SAusgabePos( iReihe, iSplt + 5, "int .filename = %d", derFont.filename );
- SAusgabePos( iReihe, iSplt + 5, "int .facename = %d", derFont.facename );
-
- return iReihe;
-
- }
-
- /* ZeigeBeschriftungTyp - Zeigt Daten des Variablentyps "legendtype".
- *
- * Parameter: iReihe - Anfangsreihe
- * iSplt - Spalten einzurücken
- * dieBeschriftung - anzuzeigende Variable des Typs "legendtype"
- *
- * Ergibt: Nächste verfügbare Reihe
- */
- int ZeigeBeschriftungTyp( int iReihe, int iSplt, legendtype dieBeschriftung )
- {
- SAusgabePos( iReihe++, iSplt + 5, "short .legend = %s",
- (dieBeschriftung.legend) ? "WAHR" : "FALSCH" );
- SAusgabePos( iReihe++, iSplt + 5, "short .place = %d",
- dieBeschriftung.place );
- SAusgabePos( iReihe++, iSplt + 5, "short .textcolor = %d",
- dieBeschriftung.textcolor );
- SAusgabePos( iReihe++, iSplt + 5, "short .autosize = %d",
- dieBeschriftung.autosize );
- SAusgabePos( iReihe++, iSplt + 5, "windowtype legendwindow =" );
- iReihe = ZeigeFensterTyp( iReihe, iSplt + 5,
- dieBeschriftung.legendwindow );
-
- return iReihe;
- }
-
- /* ZeigeBspielDaten - Zeigt die Beispielsdaten für das Demoprogramm.
- *
- * Parameter: Keine
- */
- void ZeigeBspielDaten()
- {
- int iCat, y, iFolge, iWert;
- char szTmp[80];
-
- /* Daten in Tabellenform darstellen. */
- _clearscreen( _GCLEARSCREEN );
- AusgabePos( 1, 40 - strlen(szTmp) / 2, "Daten in Tabellenform", -1 );
-
- /* Titel schreiben und Trennlinie zeichnen. */
- y = 3;
- for( iCat = 1; iCat <= 12; iCat++ )
- AusgabePos( y, iCat * 6, aMonate[iCat - 1], -1 );
-
- memset( szTmp, '-', 69 );
- szTmp[69] = 0;
- AusgabePos( ++y, 6, szTmp, -1 );
-
- /* Daten schreiben. */
- for( iFolge = 1; iFolge <= 3; iFolge++ )
- {
- AusgabePos( y += 2, 4, aVerkaufTitel[iFolge - 1], -1 );
- y += 2;
- for( iWert = 1; iWert <= 12; iWert++ )
- {
- sprintf( szTmp, "%#3.2f", aVerkauf[iFolge - 1][iWert - 1] );
- AusgabePos( y, iWert * 6, (char _far *)szTmp, -1 );
- }
- }
- AusgabePos( y += 2, 4, TempTitel, -1 );
- y += 2;
- for( iWert = 1; iWert <= 12; iWert++ )
- {
- sprintf( szTmp, "%#3.1f", aTemperatur[iWert - 1] );
- AusgabePos( y, iWert * 6, szTmp, -1 );
- }
-
- AusgabePos( y += 2, 1, "Weiter mit beliebiger Taste . . .", -1 );
- getche();
- }
-
- /* ZeigeTitelTyp - Zeigt Daten des Variablentyps "titletype".
- *
- * Parameter: iReihe - Anfangsreihe
- * iSplt - Spalten einzurücken
- * derTitel - anzuzeigende Variable des Typs "titletype"
- *
- * Ergibt: Nächste verfügbare Reihe
- */
- int ZeigeTitelTyp( int iReihe, int iSplt, titletype derTitel )
- {
- SAusgabePos( iReihe++, iSplt + 5, "char .title[%d] = \"%s\"",
- _PG_TITLELEN,
- derTitel.title );
- SAusgabePos( iReihe++, iSplt + 5, "short .titlecolor = %d",
- derTitel.titlecolor );
- SAusgabePos( iReihe++, iSplt + 5, "short .justify = %d",
- derTitel.justify );
-
- return iReihe;
- }
-
- /* ZeigeFensterTyp - Zeigt Daten des Variablentyps "windowtype".
- *
- * Parameter: iReihe - Anfangsreihe
- * iSplt - Spalten einzurücken
- * dasFenster - anzuzeigende Variable des Typs "windowtype"
- *
- * Ergibt: Nächste verfügbare Reihe
- */
- int ZeigeFensterTyp( int iReihe, int iSplt, windowtype dasFenster )
- {
- SAusgabePos( iReihe++, iSplt + 5, "short .x1 = %d", dasFenster.x1
- );
- SAusgabePos( iReihe++, iSplt + 5, "short .y1 = %d", dasFenster.y1
- );
- SAusgabePos( iReihe++, iSplt + 5, "short .x2 = %d", dasFenster.x2
- );
- SAusgabePos( iReihe++, iSplt + 5, "short .y2 = %d", dasFenster.y2
- );
- SAusgabePos( iReihe++, iSplt + 5, "short .border = %d",
- dasFenster.border );
- SAusgabePos( iReihe++, iSplt + 5, "short .background = %d",
- dasFenster.background );
- SAusgabePos( iReihe++, iSplt + 5, "short .borderstyle = %d",
- dasFenster.borderstyle );
- SAusgabePos( iReihe++, iSplt + 5, "short .bordercolor = %d",
- dasFenster.bordercolor );
-
- return iReihe;
- }
-
- /* ZeigeFehler - Bringt Fehlermeldung für einen der Diagrammbibliotheks-
- * Fehler.
- *
- * Parameter: iErr - Fehlernummer
- */
- void ZeigeFehler( int iErr )
- {
- char szTmp[50];
-
- /* Auf Textbildschirm wechseln. */
- _setvideomode( _DEFAULTMODE );
-
- /* Den Fehlertext wählen. */
- switch( iErr )
- {
- case _PG_NOTINITIALIZED:
- strcpy( szTmp, "Diagrammbibliothek nicht initialisiert" );
- break;
- case _PG_BADSCREENMODE:
- strcpy( szTmp, "Ungültiger Bildschirmmodus" );
- break;
- case _PG_BADCHARTTYPE:
- strcpy( szTmp, "Ungültiger Diagrammtyp" );
- break;
- case _PG_BADCHARTSTYLE:
- strcpy( szTmp, "Ungültiger Diagrammstil" );
- break;
- case _PG_BADLEGENDWINDOW:
- strcpy( szTmp, "Ungültiges Beschriftungsfenster" );
- break;
- case _PG_BADDATAWINDOW:
- strcpy( szTmp, "Kein Platz für Datenfenster" );
- break;
- case _PG_BADCHARTWINDOW:
- strcpy( szTmp, "Ungültige Diagramm Fensterkoordinaten" );
- break;
- case _PG_NOMEMORY:
- strcpy( szTmp, "Unzureichend Speicher für Daten-Datenfelder" );
- break;
- case _PG_BADLOGBASE:
- strcpy( szTmp, "Log-Basis X oder Y <= 0" );
- break;
- case _PG_BADSCALEFACTOR:
- strcpy( szTmp, "Skalenfaktor X oder Y = 0" );
- break;
- case _PG_TOOSMALLN:
- strcpy( szTmp, "Zu wenige Datenwerte" );
- break;
- case _PG_TOOFEWSERIES:
- strcpy( szTmp, "Es wurde keine Datenfolge bestimmt" );
- break;
- default:
- strcpy( szTmp, "Unbekannter Fehler" );
- }
-
- FehlerMldg( szTmp );
- }
-
- /* DiagrammAnsicht - Zeichnet das gegenwärtige Diagramm.
- *
- * Parameter: Keine
- */
- int DiagrammAnsicht()
- {
- int cWert, iWert, iFolge, iErr;
-
- /* Sich vergewissern, daß Daten vorliegen. */
- if( cFolge <= 0 )
- {
- fDefault = WAHR;
- VorgabeDaten( ce.charttype, ce.chartstyle, FALSCH );
- }
-
- /* Die längste Folge finden. */
- cWert = 0;
- for( iFolge = 0; iFolge < cFolge; iFolge++ )
- if( acFolge[iFolge] > cWert )
- cWert = acFolge[iFolge];
-
- _setvideomode( si.mode );
-
-
- /* Je nach Diagrammtyp verarbeiten. */
- switch( ce.charttype )
- {
-
- case _PG_PIECHART:
- case _PG_BARCHART:
- case _PG_COLUMNCHART:
- case _PG_LINECHART:
-
- /* Daten initialisieren und Kreisdiagramm oder Einzelfolgen-
- * Balkendiagramm, Säulen- oder Liniendiagramm zeichnen.
- */
- if( (cFolge == 1) ||( ce.charttype == _PG_PIECHART) )
- {
-
- /* Daten zu eindimensionalem Datenfeld übertragen. */
- for( iWert = 0; iWert < cWert; iWert++ )
- axWert[iWert] = aWert[0][iWert];
-
- /* Diagramm zeichnen. */
- if( ce.charttype == _PG_PIECHART )
- iErr = _pg_chartpie( &ce, aCat, axWert,
- aExplode, cWert );
- else
- iErr = _pg_chart( &ce, aCat, axWert, cWert );
- }
- /* Wenn Mehrfachfolge, sind Daten in Ordnung;
- * dann einfach Diagramm zeichnen.
- */
- else
- iErr = _pg_chartms( &ce, aCat, (float _far *)aWert,
- cFolge, cWert, cWert, aFolgeName );
- break;
-
- case _PG_SCATTERCHART:
-
- /* Sich vergewissern, daß genug Datensets vorliegen. */
- if( cFolge == 1 )
- {
- _setvideomode( _DEFAULTMODE );
- si.help = 10;
- FehlerMldg( "Zu wenig Wertdatenspalten für Streudiagramm." );
- return 1;
-
- }
- /* Im Fall eines Einzelfolgen-Streudiagramms, Daten zu ein-
- * dimensionalen Datenfeldern übertragen, dann Diagrammaufruf
- * machen.
- */
- else if( cFolge == 2 )
- {
- for( iWert = 0; iWert < cWert; iWert++ )
- {
- axWert[iWert] = aWert[0][iWert];
- ayWert[iWert] = aWert[1][iWert];
- }
- cFolge = 1;
- iErr = _pg_chartscatter( &ce, axWert, ayWert, cWert );
-
- }
- /* Im Falle eines Mehrfachfolgen-Streudiagramms, ungerade
- * Spalten zur X-Achsen- und gerade zur Y-Achs-Datenfeld
- * übertragen; dann Diagrammaufruf machen.
- * chart call.
- */
- else
- {
-
- for( iFolge = 1; iFolge < cFolge; iFolge += 2 )
- {
- aFolgeName[iFolge / 2] = aFolgeName[iFolge - 1];
- for( iWert = 0; iWert < cWert; iWert++ )
- {
- axWertMS[iFolge / 2][iWert] =
- aWert[iFolge - 1][iWert];
- ayWertMS[iFolge / 2][iWert] =
- aWert[iFolge][iWert];
- }
- }
- cFolge /= 2;
-
- iErr = _pg_chartscatterms( &ce, (float _far *)axWertMS,
- (float _far *)ayWertMS,
- cFolge, cWert, cWert,
- aFolgeName );
- }
- }
-
- if( !fDefault )
- DatenLoeschen( FALSCH );
-
- /* Im Fall eines Fehlers, diesen zeigen, sonst mit Diagramm auf dem
- * Bildschirm auf das Drücken einer Taste warten.
- */
- if( iErr )
- {
- ZeigeFehler( iErr );
- return iErr;
- }
- else
- return ( getch() == ESCAPE ); /* ESCAPE bedeutet Abbruch der Demo */
- }
-
-