/************************************************************************ ** ** FILE : hakadelta.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "hakadelta.h" #include "hawin.h" #include "haka.h" #include "ka.h" #include "colors" #include "cellname.h" #define DeDrawX( t, p, gc) XDrawImageString( MyDisplay, HaGraphPixmap, \ gc, \ (p)->PosDelta.x, (p)->PosDelta.y, \ t, strlen( t) ) #define DeDrawW( t, p, gc) XDrawImageString( MyDisplay, XtWindow( HaGraphPlane), \ gc, \ (p)->PosDelta.x, (p)->PosDelta.y, \ t, strlen( t) ) /************************************************************************* ** FUNKTION: HaKaDDrawX ** ZWECK: zeichnet Gewicht einer Kante nach Pixmap ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaDDrawX( SNr, TNr, ActualGC) int SNr, TNr; GC ActualGC; { KANTE *pst, *pts; BOOLEAN fST, fTS; STRING text; KANTE *pST, *pTS; pST = KaKante[ SNr][ TNr].NachTrans; pTS = KaKante[ SNr][ TNr].NachStelle; fST = ( (pST) && !(pST->NegativKante) ); fTS = ( (pTS) && !(pTS->NegativKante) ); if (fST && fTS && (pST->Ecke == NULL) && (pTS->Ecke == NULL) ) { sprintf( text, "%d+%d", pST->delta, pTS->delta ); DeDrawX( text, pST, ActualGC); return; } if (fST && (pST->delta < -1) ) { sprintf( text, "%d", -(pST->delta) ); DeDrawX( text, pST, ActualGC); } if (fTS && (pTS->delta > 1) ) { sprintf( text, "%d", pTS->delta ); DeDrawX( text, pTS, ActualGC); } } /************************************************************************* ** FUNKTION: HaKaDDraw ** ZWECK: zeichnet Gewicht einer Kante nach Pixmap und Window ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaDDraw( SNr, TNr, ActualGC) int SNr, TNr; GC ActualGC; { STRING text; KANTE *pST, *pTS; BOOLEAN fST, fTS; pST = KaKante[ SNr][ TNr].NachTrans; pTS = KaKante[ SNr][ TNr].NachStelle; fST = ( (pST) && !(pST->NegativKante) ); fTS = ( (pTS) && !(pTS->NegativKante) ); /**** LIEGEN KANTE UND GEGENKANTE AUFEINANDER ? ********************/ if (fST && fTS && (pST->Ecke == NULL) && (pTS->Ecke == NULL) ) { sprintf( text, "%d+%d", pST->delta, pTS->delta ); DeDrawX( text, pST, ActualGC); DeDrawW( text, pST, ActualGC); return; } /**** DELTA ST-KANTE ZEICHNEN **************************************/ if (fST && (pST->delta < -1) ) { sprintf( text, "%d", -(pST->delta) ); DeDrawX( text, pST, ActualGC); DeDrawW( text, pST, ActualGC); } /**** DELTA TS-KANTE ZEICHNEN **************************************/ if (fTS && (pTS->delta > 1) ) { sprintf( text, "%d", pTS->delta ); DeDrawX( text, pTS, ActualGC); DeDrawW( text, pTS, ActualGC); } } /************************************************************************* ** FUNKTION: HaKaDWriteX ** ZWECK: schreibt nach Pixmap und Cell ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaDWriteX( SNr, TNr) int SNr, TNr; { KANTE *pST, *pTS; STRING text; BOOLEAN fST, fTS; pST = KaKante[ SNr][ TNr].NachTrans; pTS = KaKante[ SNr][ TNr].NachStelle; fST = ( (pST) && !(pST->NegativKante) ); fTS = ( (pTS) && !(pTS->NegativKante) ); if (fST && fTS && (pST->Ecke == NULL) && (pTS->Ecke == NULL) ) { sprintf( text, "%d+%d", pST->delta, pTS->delta ); CellKaDEin( pST->OrgKaD, &(pST->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pST, KaGC); return; } if (fST && (pST->delta < -1) ) { sprintf( text, "%d", -(pST->delta) ); CellKaDEin( pST->OrgKaD, &(pST->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pST, KaGC); } if (fTS && (pTS->delta > 1) ) { sprintf( text, "%d", pTS->delta ); CellKaDEin( pTS->OrgKaD, &(pTS->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pTS, KaGC); } } /************************************************************************* ** FUNKTION: HaKaDClearX ** ZWECK: loescht aus Pixmap und Cell ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaDClearX( SNr, TNr) int SNr, TNr; { KANTE *pST, *pTS; STRING text; BOOLEAN fST, fTS; pST = KaKante[ SNr][ TNr].NachTrans; pTS = KaKante[ SNr][ TNr].NachStelle; fST = ( (pST) && !(pST->NegativKante) ); fTS = ( (pTS) && !(pTS->NegativKante) ); if (fST && fTS && (pST->Ecke == NULL) && (pTS->Ecke == NULL) ) { sprintf( text, "%d+%d", pST->delta, pTS->delta ); CellKaDDel( pST->OrgKaD, &(pST->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pST, ClearGC); return; } if (fST && (pST->delta < -1) ) { sprintf( text, "%d", -(pST->delta) ); CellKaDDel( pST->OrgKaD, &(pST->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pST, ClearGC); } if (fTS && (pTS->delta > 1) ) { sprintf( text, "%d", pTS->delta ); CellKaDDel( pTS->OrgKaD, &(pTS->PosDelta), XTextWidth( HaNameFont, text, strlen( text)) ); DeDrawX( text, pTS, ClearGC); } } /************************************************************************* ** FUNKTION: HaKaSTDReplX ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaSTDReplX( SNr, TNr, Neu) int SNr, TNr; int Neu; { KANTE *pST, *pTS; pST = KaKante[ SNr][ TNr].NachTrans; if (pST->delta == Neu) return; HaKaDClearX( SNr, TNr); pST->delta = Neu; HaKaDWriteX( SNr, TNr); } /************************************************************************* ** FUNKTION: HaKaTSDReplX ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HaKaTSDReplX( SNr, TNr, Neu) int SNr, TNr; int Neu; { KANTE *pST, *pTS; pTS = KaKante[ SNr][ TNr].NachStelle; if (pTS->delta == Neu) return; HaKaDClearX( SNr, TNr); pTS->delta = Neu; HaKaDWriteX( SNr, TNr); }