home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************
- * *
- * Filename : SuppL2.c *
- * *
- *****************************************************************
- * *
- * Comment : Allgemeine Supportfunktionen für alle *
- * Darstellungen. *
- * *
- * Funktionen *
- * ========== *
- * *
- * InitScFunction() Initialisiert die Bildschirmausgabe *
- * InitPlFunction() Initialisiert die Plotterausgabe *
- * TextLine2D() zeichnet eine Hauptlinie in 2D *
- * TextLine3D() zeichnet eine Hauptlinie in 3D *
- * TLinex2D() zeichnet eine Hauptlinie in 2D exp. *
- * TLinex3D() zeichnet eine Hauptlinie in 3D exp. *
- * DrawXaxis() zeichnet und beschriftet X-Achse *
- * DrawYaxis() zeichnet und beschriftet Y-Achse *
- * DrawZaxis() zeichnet und beschriftet Z-Achse *
- * Round() rundet DATA Werte zu Integer *
- * CalcColor() berechnet nächsten Farbwert *
- * CalcLSize() berechnet die Linienlänge *
- * GetGraphics() speichert die aktuellen Graphikwerte *
- * ReSetGraphics() setzt die alten Graphikwerte *
- * GetExp() Ganzzahliger Exponentwert zu 10 *
- * GetExpE() Ganzzahliger Exponentwert zu E *
- * Exp10() 10^x Funktion *
- * PrintTextRel() schreibt relativen Text *
- * PrintExp() schreibt relativen Exponententext *
- * PrintAbs() schreibt absoluten Text *
- * *
- * globale Variablen *
- * ================= *
- * *
- * OpenGraphics Funktionspointer für *
- * GetMaxColor alle Level 3 Funktionen *
- * GetMaxX welche implementiert *
- * GetMaxY wurden. Geordnet nach *
- * GetFgColor Rückgabewert. *
- * GetBackColor Diese Funktionen werden *
- * GetTextSize je nach Ausgabe auf *
- * FillPolyLine die verschiedenen Geräte *
- * CloseGraphics initialisiert. *
- * SetTextSize *
- * DrawText *
- * ClearGraphics *
- * SetFgColor *
- * SetBackColor *
- * DrawLine *
- * DrawRectangle *
- * SetFillStyle *
- * SetLineStyle *
- * *
- * Rev : V1.0 *
- * *
- * History : V1.0 erstellen dieses Files 01/01/90 *
- * *
- * Doc : Plotlibrary User's Guide *
- * *
- * Bugs : keine bekannten *
- * *
- * Autor : Oesch Silvano *
- * *
- * Datum : 01/01/90 *
- * *
- ****************************************************************/
-
- /****************************************************************
- * *
- * allgemeine Includedateien *
- * *
- ****************************************************************/
-
- #include <math.h>
-
- /****************************************************************
- * *
- * Plotlibrary Includedateien *
- * *
- ****************************************************************/
-
- #include "Plot.h"
- #include "PlotL2.h"
- #include "GfxL3.h"
- #include "PltL3.h"
- #include "NivL2.h"
- #include "DispL2.h"
- #include "D3L2.h"
- #include "SuppL2.h"
-
- /****************************************************************
- * *
- * Globale Variablen *
- * *
- ****************************************************************/
-
- int (*OpenGraphics)(), /* Funktionspointer für */
- (*GetMaxColor)(), /* alle Level 3 Funktionen */
- (*GetMaxX)(), /* welche implementiert */
- (*GetMaxY)(), /* wurden. Geordnet nach */
- (*GetFgColor)(), /* Rückgabewert. */
- (*GetBackColor)(), /* Diese Funktionen werden */
- (*GetTextSize)(), /* je nach Ausgabe auf */
- (*FillPolyLine)(); /* die verschiedenen Geräte */
- void (*CloseGraphics)(), /* initialisiert. */
- (*SetTextSize)(),
- (*DrawText)(),
- (*ClearGraphics)(),
- (*SetFgColor)(),
- (*SetBackColor)(),
- (*DrawLine)(),
- (*DrawPolyLine)(),
- (*DrawRectangle)(),
- (*SetFillStyle)(),
- (*SetLineStyle)();
-
- DATA (*xexpfct)(), /* 10^ oder e^ bzw. ln oder */
- (*xlogfct)(), /* log Funktion für X-Achse */
- (*yexpfct)(), /* 10^ oder e^ bzw. ln oder */
- (*ylogfct)(), /* log Funktion für Y-Achse */
- (*zexpfct)(), /* 10^ oder e^ bzw. ln oder */
- (*zlogfct)(); /* log Funktion für Z-Achse */
-
- /****************************************************************
- * *
- * Globale statische Variablen *
- * *
- ****************************************************************/
-
- static int oldfgcolor, /* alte Stiftfarbe */
- oldbackcolor; /* alte Hintergrundfarbe */
-
- /****************************************************************
- * *
- * externe Variablen *
- * *
- ****************************************************************/
-
- extern struct Plot *plot;
- extern int plerr;
-
- /****************************************************************
- * *
- * Function : InitScFunction() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion initialisiert die Level 3 *
- * Bildschirmfunktionen. Die entsprechenden *
- * Funktionen leiten somit ihre Ausgabe auf den *
- * Graphikbildschirm. Das Gegenteil dieser Funktion *
- * ist die InitPlFunction(). *
- * *
- ****************************************************************/
-
- void initscfunction()
- {
- OpenGraphics = ScOpenGraphics; /* Alle Funktionen befinden */
- GetMaxColor = ScGetMaxColor; /* in der Datei GfxL3.c wo */
- GetMaxX = ScGetMaxX; /* sie für die Graphik auf */
- GetMaxY = ScGetMaxY; /* den verschiedenen */
- GetFgColor = ScGetFgColor; /* Rechnern angepasst */
- GetBackColor = ScGetBackColor; /* werden kann. */
- GetTextSize = ScGetTextSize; /* Mit diesem vorgehen */
- CloseGraphics = ScCloseGraphics; /* ist es aber auch möglich */
- SetTextSize = ScSetTextSize; /* die Ausgabe auf ein */
- DrawText = ScDrawText; /* anderes Gerät umzuleiten */
- ClearGraphics = ScClearGraphics; /* wie auf einen Plotter. */
- SetFgColor = ScSetFgColor;
- SetBackColor = ScSetBackColor;
- DrawLine = ScDrawLine;
- DrawPolyLine = ScDrawPolyLine;
- FillPolyLine = ScFillPolyLine;
- DrawRectangle = ScDrawRectangle;
- SetFillStyle = ScSetFillStyle;
- SetLineStyle = ScSetLineStyle;
- }
-
- /****************************************************************
- * *
- * Function : InitplFunction() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion initialisiert die Level 3 *
- * Plotfunktionen. Die entsprechenden Funktionen *
- * leiten somit ihre Ausgabe auf einen Plotter *
- * welcher dem HPGL Standart entspricht. Die Ausgabe *
- * erfolgt über eine Datei welche zu dem ent- *
- * sprechenden Gerät kopiert werden kann. Das *
- * Gegenteil dieser Funktion ist die *
- * InitScFunction(). *
- * *
- ****************************************************************/
-
- void initplfunction()
- {
- OpenGraphics = PlOpenGraphics; /* Alle Funktionen befinden */
- GetMaxColor = PlGetMaxColor; /* in der Datei PltL3.c wo */
- GetMaxX = PlGetMaxX; /* sie für einen Plotter */
- GetMaxY = PlGetMaxY; /* die verschiedenen */
- GetFgColor = PlGetFgColor; /* Befehle in eine Datei */
- GetBackColor = PlGetBackColor; /* schreibt. */
- GetTextSize = PlGetTextSize;
- CloseGraphics = PlCloseGraphics;
- SetTextSize = PlSetTextSize;
- DrawText = PlDrawText;
- ClearGraphics = PlClearGraphics;
- SetFgColor = PlSetFgColor;
- SetBackColor = PlSetBackColor;
- DrawLine = PlDrawLine;
- DrawPolyLine = PlDrawPolyLine;
- FillPolyLine = PlFillPolyLine;
- DrawRectangle = PlDrawRectangle;
- SetFillStyle = PlSetFillStyle;
- SetLineStyle = PlSetLineStyle;
- }
-
- /****************************************************************
- * *
- * Function : TextLine2D() *
- * *
- *****************************************************************
- * *
- * Input : text,x,y,x1,y1,opt *
- * char *text Beschriftungstext *
- * DATA *x Startwert (x/y) *
- * DATA *y *
- * DATA *x1 Endwerte (x1/y1) *
- * DATA *y1 *
- * int opt Beschriftungsoption *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Zeichnet und bechriftet eine Hauptlinie der ver- *
- * schiedenen Achsen für die 2D Darstellung. *
- * *
- ****************************************************************/
-
- void textline2d(text,x,y,x1,y1,opt)
- char *text;
- DATA *x,*y,*x1,*y1;
- int opt;
- {
- drawgline(x,y,x1,y1); /* Linie zeichnen */
- printtextrel2d(text,x,y,opt); /* und beschrifteten */
- }
-
- /****************************************************************
- * *
- * Function : TextLine3D() *
- * *
- *****************************************************************
- * *
- * Input : text,x,y,z,x1,y1,z1,opt *
- * char *text Beschriftungstext *
- * DATA *x Startwert (x/y/z) *
- * DATA *y *
- * DATA *z *
- * DATA *x1 Endwerte (x1/y1/z1) *
- * DATA *y1 *
- * DATA *z1 *
- * int opt Beschriftungsoption *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Zeichnet und bechriftet eine Hauptlinie der ver- *
- * schiedenen Achsen für die 3D Darstellung. *
- * *
- ****************************************************************/
-
- void textline3d(text,x,y,z,x1,y1,z1,opt)
- char *text;
- DATA *x,*y,*z,*x1,*y1,*z1;
- int opt;
- {
- drawgline3d(x,y,z,x1,y1,z1); /* Linie zeichnen */
- printtextrel3d(text,x,y,z,opt); /* und beschrifteten */
- }
-
- /****************************************************************
- * *
- * Function : TLinex2D() *
- * *
- *****************************************************************
- * *
- * Input : exp,mes,x,y,x1,y1,opt *
- * int exp Exponent *
- * int mes Basis *
- * DATA *x Startwert (x/y) *
- * DATA *y *
- * DATA *x1 Endwerte (x1/y1) *
- * DATA *y1 *
- * int opt Beschriftungsoption *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Zeichnet und bechriftet eine Hauptlinie der ver- *
- * schiedenen Achsen für die 2D exponentielle Dar- *
- * stellung. *
- * *
- ****************************************************************/
-
- int tlinex2d(exp,mes,x,y,x1,y1,opt)
- int exp,mes;
- DATA *x,*y,*x1,*y1;
- int opt;
- {
- drawgline(x,y,x1,y1); /* Linie zeichnen und besch */
- return(printexp2d(exp,mes,x,y,opt));
- }
-
- /****************************************************************
- * *
- * Function : TLinex3D() *
- * *
- *****************************************************************
- * *
- * Input : exp,mes,x,y,z,x1,y1,z1,opt *
- * int exp Exponent *
- * int mes Basis *
- * DATA *x Startwert (x/y/z) *
- * DATA *y *
- * DATA *z *
- * DATA *x1 Endwerte (x1/y1/z1) *
- * DATA *y1 *
- * DATA *z1 *
- * int opt Beschriftungsoption *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Zeichnet und bechriftet eine Hauptlinie der ver- *
- * schiedenen Achsen für die 3D exponentielle Dar- *
- * stellung. *
- * *
- ****************************************************************/
-
- int tlinex3d(exp,mes,x,y,z,x1,y1,z1,opt)
- int exp,mes;
- DATA *x,*y,*z,*x1,*y1,*z1;
- int opt;
- {
- drawgline3d(x,y,z,x1,y1,z1); /* Linie zeichnen und besch */
- return(printexp3d(exp,mes,x,y,z,opt));
- }
-
- /****************************************************************
- * *
- * Function : drawxaxis() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Die Achsen werden unterteilt in eine lineare und *
- * eine log. Darstellung. Die X-, Y-, und Z-Achse *
- * unterscheiden sich nur in den berechneten *
- * Koordinaten, desshalb wird nur die X-Achse *
- * erklärt. *
- * *
- * lineare Darstellung *
- * berechne Anzahl Schritte *
- * berechne Grösse Mittelschritte *
- * zeichne für alle Schritte *
- * Schrittwert berechnen *
- * beschrifte Stepwert *
- * zeichne für alle Mittelschritte eine Linie *
- * zeichen eine Steplinie *
- * letzte Beschriftung anbringen *
- * log. Darstellung *
- * berechne Startexponent *
- * berechne Endexponent *
- * für alle Schritte *
- * berechne step *
- * beschrifte Dekade *
- * berechne Mittelschritt *
- * zeichne für alle Mittelschritte eine Linie *
- * zeichne eine Steplinie *
- * letzte Beschriftung anbringen *
- * *
- ****************************************************************/
-
- void drawxaxis()
- {
- int i,j,counts,counte;
-
- DATA lstep,sstep,step,lsize,gsize;
- char buffer[20];
-
- if (plot->typ == D3)
- {
- lsize = calclsize(&plot->ygridmin,BSTEPSIZE,plot->ymes);
- gsize = calclsize(&plot->ygridmin,BGRIDSIZE,plot->ymes);
- }
-
- if (plot->xmes == LIN)
- {
- counts = round((plot->xgridmax-plot->xgridmin)/plot->xstep);
- lstep = plot->xstep/LINSLSTEP;
- for (i=0;i<counts;i++)
- {
- step = plot->xgridmin+i*plot->xstep;
- sprintf(buffer,"%.4lg",step);
-
- if (plot->typ != D3)
- textline2d(buffer,&step,&plot->ygridmin,
- &step,&plot->ygridmax,T_CX|T_T);
- else
- textline3d(buffer,&step,&plot->ygridmin,&plot->zgridmin,
- &step,&gsize,&plot->zgridmin,T_R|T_T);
-
- for (j=1;j<LINSLSTEP;j++)
- {
- sstep =step+lstep*j;
- if (plot->typ != D3)
- drawsline(&sstep,&plot->ygridmin,
- &sstep,&plot->ygridmax);
- else
- drawgline3d(&sstep,&plot->ygridmin,&plot->zgridmin,
- &sstep,&lsize,&plot->zgridmin);
- }
- }
- step = plot->xgridmax;
- sprintf(buffer,"%.4lg",step);
- if (plot->typ != D3)
- textline2d(buffer,&step,&plot->ygridmin,
- &step,&plot->ygridmax,T_CX|T_T);
- else
- textline3d(buffer,&step,&plot->ygridmin,&plot->zgridmin,
- &step,&gsize,&plot->zgridmin,T_R|T_T);
- }
- else
- {
- counts = round(xlogfct(plot->xgridmin));
- counte = round(xlogfct(plot->xgridmax));
-
- for (i=counts;i<counte;i++)
- {
- step = xexpfct((DATA)i);
-
- if (plot->typ != D3)
- tlinex2d(i,plot->xmes,&step,&plot->ygridmin,
- &step,&plot->ygridmax,T_CX|T_T);
- else
- tlinex3d(i,plot->xmes,
- &step,&plot->ygridmin,&plot->zgridmin,
- &step,&gsize,&plot->zgridmin,T_R|T_T);
-
- lstep = (xexpfct((DATA)(i+1))-step)/LOGSLSTEP;
- for (j=1;j<LOGSLSTEP;j++)
- {
- sstep =step+lstep*j;
- if (plot->typ != D3)
- drawsline(&sstep,&plot->ygridmin,
- &sstep,&plot->ygridmax);
- else
- drawgline3d(&sstep,&plot->ygridmin,&plot->zgridmin,
- &sstep,&lsize,&plot->zgridmin);
- }
- }
- step = plot->xgridmax;
- if (plot->typ != D3)
- tlinex2d(i,plot->xmes,&step,&plot->ygridmin,
- &step,&plot->ygridmax,T_CX|T_T);
- else
- tlinex3d(i,plot->xmes,
- &step,&plot->ygridmin,&plot->zgridmin,
- &step,&gsize,&plot->zgridmin,T_R|T_T);
- }
- }
-
- /****************************************************************
- * *
- * Function : drawyaxis() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : int len max. Beschriftungslänge *
- * *
- *****************************************************************
- * *
- * Comment : Siehe drawxaxis *
- * *
- ****************************************************************/
-
- int drawyaxis()
- {
- int len = NULL,lent,i,j,counts,counte;
-
- DATA lstep,sstep,step,lsize,gsize;
- char buffer[20];
-
- if (plot->typ == D3)
- {
- lsize = calclsize(&plot->zgridmin,100-BSTEPSIZE,plot->zmes);
- gsize = calclsize(&plot->zgridmin,100-BGRIDSIZE,plot->zmes);
- }
-
- if (plot->ymes == LIN)
- {
- counts = round((plot->ygridmax-plot->ygridmin)/plot->ystep);
- lstep = plot->ystep/LINSLSTEP;
- for (i=0;i<counts;i++)
- {
- step = plot->ygridmin+i*plot->ystep;
- len = max(len,sprintf(buffer,"%.4lg",step));
-
- if (plot->typ != D3)
- textline2d(buffer,&plot->xgridmin,&step,
- &plot->xgridmax,&step,T_L|T_B);
- else
- textline3d(buffer,&plot->xgridmin,&step,&plot->zgridmax,
- &plot->xgridmin,&step,&gsize,T_L|T_B);
-
- for (j=1;j<LINSLSTEP;j++)
- {
- sstep =step+lstep*j;
- if (plot->typ != D3)
- drawsline(&plot->xgridmin,&sstep,
- &plot->xgridmax,&sstep);
- else
- drawgline3d(&plot->xgridmin,&sstep,&plot->zgridmax,
- &plot->xgridmin,&sstep,&lsize);
- }
- }
- step = plot->ygridmin+i*plot->ystep;
- len = max(len,sprintf(buffer,"%.4lg",step));
- if (plot->typ != D3)
- textline2d(buffer,&plot->xgridmin,&step,
- &plot->xgridmax,&step,T_L|T_B);
- else
- textline3d(buffer,&plot->xgridmin,&step,&plot->zgridmax,
- &plot->xgridmin,&step,&gsize,T_L|T_B);
- }
- else
- {
- counts = round(ylogfct(plot->ygridmin));
- counte = round(ylogfct(plot->ygridmax));
-
- for (i=counts;i<counte;i++)
- {
- step = yexpfct((DATA)i);
- if (plot->typ != D3)
- lent = tlinex2d(i,plot->ymes,&plot->xgridmin,&step,
- &plot->xgridmax,&step,T_L|T_B);
- else
- lent = tlinex3d(i,plot->ymes,
- &plot->xgridmin,&step,&plot->zgridmax,
- &plot->xgridmin,&step,&gsize,T_L|T_B);
- if (len < lent)
- len = lent;
- lstep = (yexpfct((DATA)(i+1))-step)/LOGSLSTEP;
- for (j=1;j<LOGSLSTEP;j++)
- {
- sstep =step+lstep*j;
- if (plot->typ != D3)
- drawsline(&plot->xgridmin,&sstep,
- &plot->xgridmax,&sstep);
- else
- drawgline3d(&plot->xgridmin,&sstep,&plot->zgridmax,
- &plot->xgridmin,&sstep,&lsize);
- }
- }
- step = plot->ygridmax;
- if (plot->typ != D3)
- lent = tlinex2d(i,plot->ymes,&plot->xgridmin,&step,
- &plot->xgridmax,&step,T_L|T_B);
- else
- lent = tlinex3d(i,plot->ymes,
- &plot->xgridmin,&step,&plot->zgridmax,
- &plot->xgridmin,&step,&gsize,T_L|T_B);
- }
- return(len);
- }
-
- /****************************************************************
- * *
- * Function : drawzaxis() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Siehe drawxaxis *
- * *
- ****************************************************************/
-
- void drawzaxis()
- {
- int i,j,counts,counte;
-
- DATA lstep,sstep,step,lsize,gsize;
- char buffer[20];
-
- lsize = calclsize(&plot->ygridmin,BSTEPSIZE,plot->ymes);
- gsize = calclsize(&plot->ygridmin,BGRIDSIZE,plot->ymes);
- if (plot->zmes == LIN)
- {
- counts = round((plot->zgridmax-plot->zgridmin)/plot->zstep);
- lstep = plot->zstep/LINSLSTEP;
- for (i=0;i<counts;i++)
- {
- step = plot->zgridmin+i*plot->zstep;
- sprintf(buffer,"%.4lg",step);
- textline3d(buffer,&plot->xgridmin,&plot->ygridmin,
- &step,&plot->xgridmin,&gsize,&step,T_L|T_T);
- for (j=1;j<LINSLSTEP;j++)
- {
- sstep =step+lstep*j;
- drawgline3d(&plot->xgridmin,&plot->ygridmin,&sstep,
- &plot->xgridmin,&lsize,&sstep);
- }
- }
- step = plot->zgridmin+i*plot->zstep;
- sprintf(buffer,"%.4lg",step);
- textline3d(buffer,&plot->xgridmin,&plot->ygridmin,&step,
- &plot->xgridmin,&gsize,&step,T_L|T_T);
- }
- else
- {
- counts = round(zlogfct(plot->zgridmin));
- counte = round(zlogfct(plot->zgridmax));
-
- for (i=counts;i<counte;i++)
- {
- step = zexpfct((DATA)i);
- tlinex3d(i,plot->zmes,
- &plot->xgridmin,&plot->ygridmin,&step,
- &plot->xgridmin,&gsize,&step,T_L|T_T);
- lstep = (zexpfct((DATA)(i+1))-step)/LOGSLSTEP;
- for (j=1;j<LOGSLSTEP;j++)
- {
- sstep =step+lstep*j;
- drawgline3d(&plot->xgridmin,&plot->ygridmin,&sstep,
- &plot->xgridmin,&lsize,&sstep);
- }
- }
- step = plot->zgridmax;
- tlinex3d(i,plot->zmes,
- &plot->xgridmin,&plot->ygridmin,&step,
- &plot->xgridmin,&gsize,&step,T_L|T_T);
- }
- }
-
- /****************************************************************
- * *
- * Function : round() *
- * *
- *****************************************************************
- * *
- * Input : value *
- * DATA value Zahlenwert *
- * *
- * Output : newval *
- * int newval gerundeter Zahlenwert *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion rundet einen Floatwert und *
- * konvertiert diesen zu einem Integerwert. *
- * *
- ****************************************************************/
-
- int round(val)
- DATA val;
- {
- if (val < 0) /* kleiner als NULL */
- val -= 0.5; /* dann subtrahieren */
- else
- val += 0.5; /* sonst addieren */
- return((int)val); /* zurück mit integer */
- }
-
- /****************************************************************
- * *
- * Function : calccolor() *
- * *
- *****************************************************************
- * *
- * Input : color *
- * int color Farbwert *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion setzt die vom User gesetzte Farbe *
- * wenn sie im Bereich der max. Farben ist. Ansonsten *
- * wird die nächste freie Farbe gesetzt. Wenn keine *
- * freien Farben mehr verfügbar sind, wird wieder von *
- * vorne begonnen. Die globale statische Variable *
- * curcol ist die nächste freie Farbe. *
- * *
- ****************************************************************/
-
- void calccolor(color)
- int color;
- {
- if (color != COLDET) /* User definierte Farbe */
- if (color > plot->maxcol) /* ist sie im Bereich */
- calccolor(COLDET); /* setzte nächste Farbe */
- else /* Ja */
- {
- SetFgColor(color); /* setze Farbe */
- SetLineStyle(SOL_LINE); /* und ganze Linie */
- }
- else /* keine User Farbe */
- {
- if (plot->col > plot->maxcol) /* nächste Farbe im Bereich */
- plot->col = STARTCOL; /* wenn nicht, von vorne */
- calccolor(plot->col++); /* setzte nächste Farbe */
- }
- }
-
- /****************************************************************
- * *
- * Function : getgraphics() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Routine holt die aktuellen Graphikwerte *
- * welche zum Zeitpunk eingestellt sind. *
- * Die folgenden Werte werden in statischen *
- * globalen Variabeln gespeichert: *
- * *
- * 1. Stiftfarbe *
- * 2. Hintergrund *
- * *
- ****************************************************************/
-
- void getgraphics()
- {
- oldfgcolor = GetFgColor(); /* hole Stift */
- oldbackcolor = GetBackColor(); /* hole Hintergrund */
- }
-
- /****************************************************************
- * *
- * Function : resetgraphics() *
- * *
- *****************************************************************
- * *
- * Input : void *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion ist das Gegenstück von getgraphics. *
- * Die gespeicherten Daten des Usergraphik werden *
- * neu gesetzt, sodass keine Veränderung stattfinden *
- * sollte. *
- * *
- ****************************************************************/
-
- void resetgraphics()
- {
- SetFgColor(oldfgcolor); /* setzte alte Stiftfarbe */
- SetBackColor(oldbackcolor); /* setzte alter Hintergrund */
- }
-
- /****************************************************************
- * *
- * Function : getexp() *
- * *
- *****************************************************************
- * *
- * Input : DATA val Zahl *
- * *
- * Output : double exp Exponent zur Basis 10 *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion berechnet den ganzzahligen *
- * Exponenten einer Zahl zur Basis 10. *
- * *
- ****************************************************************/
-
- double getexp(val)
- DATA val;
- {
- val = fabs(val); /* nur pos. Werte erlaubt */
- return(floor(log10(val))); /* gerundeter Exponent */
- }
-
- /****************************************************************
- * *
- * Function : getexpe() *
- * *
- *****************************************************************
- * *
- * Input : DATA val Wert *
- * *
- * Output : double exp Exponet zur Basis e *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion berechnet den ganzzahligen *
- * Exponenten einer Zahl zur Basis e. *
- * *
- ****************************************************************/
-
- double getexpe(val)
- DATA val;
- {
- val = fabs(val); /* nur pos Werte erlaubt */
- return(floor(log(val))); /* gerundeter Exponent */
- }
-
- /****************************************************************
- * *
- * Function : exp10() *
- * *
- *****************************************************************
- * *
- * Input : exponent *
- * DATA exponent Exponent des Wertes *
- * *
- * Output : value *
- * DATA value Werte mit 10^exponent *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion definiert die power Funktion mit *
- * einer Basis von 10. Da nicht alle Compiler die *
- * pow10() Funktion unterstützten, wurde eine eigene *
- * Funktion generiert. *
- * *
- ****************************************************************/
-
- DATA exp10(exponent)
- DATA exponent;
- {
- return(pow(10.0,exponent)); /* klar, oder nicht ? */
- }
-
- /****************************************************************
- * *
- * Function : printtextrel() *
- * *
- *****************************************************************
- * *
- * Input : buffer,x,y,xjust,yjust *
- * char *buffer Text *
- * DATA x rel x Koordinate *
- * DATA y rel y Koordinate *
- * DATA z rel z Koordinate *
- * int just Ausrichtung *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion beschriftet eine relative *
- * Koordinate mit ihrem Wert. Die x, y und z Werte *
- * werden transformiert und entsprechend der *
- * Ausrichtung verschoben. *
- * *
- * Definiert sind für x Richtung: *
- * *
- * T_CX,T_L,T_R *
- * *
- * Definiert sind für y Richtung: *
- * *
- * T_CY,T_T,T_B *
- * *
- ****************************************************************/
-
- void printtextrel(buffer,x,y,z,just)
- char *buffer;
- DATA *x,
- *y,
- *z;
- int just;
- {
- int xn,yn; /* Transformationsvar. */
-
- if (plot->typ != D3)
- trans2d(x,y,&xn,&yn); /* transformiere 2d */
- else
- trans3d(x,y,z,&xn,&yn); /* transformiere 3d */
- printtextabs(buffer,xn,yn,just);
- /* und schreibe absolut */
- }
-
- /****************************************************************
- * *
- * Function : printexp() *
- * *
- *****************************************************************
- * *
- * Input : exp,base,x,y,xjust,yjust *
- * int exp exponent *
- * int base basis *
- * DATA *x rel. x Koordinate *
- * DATA *y rel. y Koordinate *
- * DATA *z rel. z Koordinate *
- * int just Ausrichtung *
- * *
- * Output : int len länge des Textes *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion zeichnet die Exponentenbeschriftung *
- * auf den Bildschirm. Es können auch hier die *
- * Ausrichtungsfaktoren verwendet werden. *
- * *
- * Definiert sind für x Richtung: *
- * *
- * T_CX,T_L,T_R *
- * *
- * Definiert sind für y Richtung: *
- * *
- * T_CY,T_T,T_B *
- * *
- ****************************************************************/
-
- int printexp(exp,base,xo,yo,zo,just)
- int exp,
- base;
- DATA *xo,
- *yo,
- *zo;
- int just;
- {
- int x,y,baselen,len;
- char buffer [10]; /* konvert. Buffer */
- char *expo[] = /* Basistext */
- {
- "10",
- "e"
- };
-
- if (plot->typ != D3)
- trans2d(xo,yo,&x,&y); /* konvertiere x und y */
- else
- trans3d(xo,yo,zo,&x,&y); /* konvertiere x ,y und z */
- (void)sprintf(buffer,"%d",exp); /* Welcher Exponent in char */
- baselen = strlen(expo[base-2]); /* Basislänge */
- len = baselen+strlen(buffer); /* gesammte Länge */
-
- switch (just & (T_L|T_CX|T_R)) /* x Ausrichtung */
- {
- case T_CX:
- x = x-len*plot->xht; /* nach links um die hälfte */
- break;
- case T_L:
- x = x-len*plot->xtext-plot->xht;
- break; /* alles nach links */
- case T_R:
- x = x+plot->xht; /* rechts um halben char. */
- break;
- }
-
- switch (just & (T_T|T_CY|T_B)) /* y Ausrichtung */
- {
- case T_T:
- y = y+2*plot->ytext; /* nach unten um 1 Zeile */
- break;
- case T_CY:
- y = y+plot->yht; /* 1/2 Zeile nach unten */
- break;
- case T_B:
- break;
- }
- DrawText(x,y,expo[base-2]);
- DrawText(x+baselen*plot->xtext,y-plot->yht,buffer);
- return(len);
- }
-
- /****************************************************************
- * *
- * Function : printabs() *
- * *
- *****************************************************************
- * *
- * Input : buffer,x,y,xjust,yjust *
- * char *buffer Text *
- * int x x Koordinate *
- * int y y Koordinate *
- * int just Ausrichtung *
- * *
- * Output : void *
- * *
- *****************************************************************
- * *
- * Comment : Schreibt einen Text an die Koordinatenpunkt (x,y). *
- * Mit den Ausrichtungen wird der eff. Startpunkt *
- * berechnet. *
- * *
- * Definiert sind für x Richtung: *
- * *
- * T_CX,T_L,T_R *
- * *
- * Definiert sind für y Richtung: *
- * *
- * T_CY,T_T,T_B *
- * *
- ****************************************************************/
-
- void printtextabs(buffer,x,y,just)
- char *buffer;
- int x,
- y,
- just;
- {
- switch (just & (T_L|T_CX|T_R)) /* x Ausrichtung */
- {
- case T_CX:
- x = x-strlen(buffer)*plot->xht;
- /* nach links um die hälfte */
- break;
- case T_L:
- x = x-strlen(buffer)*plot->xtext-plot->xht;
- break; /* alles nach links */
- case T_R:
- x = x+plot->xht; /* rechts um halben char. */
- break;
- }
- switch (just & (T_T|T_CY|T_B)) /* y Ausrichtung */
- {
- case T_T:
- y = y+plot->ylt; /* nach unten um 3/2 Zeilen */
- break;
- case T_CY:
- y = y+plot->yht; /* 1/2 Zeile nach unten */
- break;
- case T_B:
- break;
- }
- DrawText(x,y,buffer); /* Zeichne Text */
- }
-
- /****************************************************************
- * *
- * Function : calclsize() *
- * *
- *****************************************************************
- * *
- * Input : min,size,mes *
- * DATA *min Zeiger auf minimalen Gitterwert *
- * int size Länge in % der Linie *
- * int mes Masseinheit *
- * *
- * Output : DATA val Endwert der Linie *
- * *
- *****************************************************************
- * *
- * Comment : Diese Funktion berechnet den Endwert eine Strecke *
- * deren Länge in Prozenten angegeben wird. Diese *
- * Funktion wird nur für das Gitter und auch nur bei *
- * 3D Darstellung benötigt. *
- * *
- ****************************************************************/
-
- static DATA calclsize(min,size,mes)
- DATA *min;
- int size,
- mes;
- {
-
- DATA a,b; /* temp. Speicher */
-
- if (mes == LIN) /* linearer Masstab */
- {
- a = *min; /* minimum und maximum */
- b = *(min+1); /* zuweisen */
- return(a+(b-a)*size/100); /* Endpunkt berechnen */
- }
- else if (mes == LOG) /* log. Masstab */
- {
- a = log10(*min); /* minimum und maximum */
- b = log10(*(min+1)); /* zuweisen */
- return(exp10(a+(b-a)*size/100));
- /* Endpunkt berechnen */
- }
- else /* nat. log. Masstab */
- {
- a = log(*min); /* minimum und maximum */
- b = log(*(min+1)); /* zuweisen */
- return(exp(a+(b-a)*size/100)); /* Endpunkt berechnen */
- }
- }
-
-