home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / MISC / EEDPR23S.ZIP / EEREDRAW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-03  |  4.2 KB  |  116 lines

  1. /*****************************************************************************
  2. *   Program to draw EE diagrams.                         *
  3. *                                         *
  4. * This module redraw/draw all structs.                         *
  5. *                                         *
  6. * Written by:  Gershon Elber            IBM PC Ver 1.0,    Oct. 1989    *
  7. *****************************************************************************/
  8.  
  9. #include "program.h"
  10. #include "igraph.h"
  11. #include "eeredraw.h"
  12. #include "eestring.h"
  13.  
  14. static void RedrawStructList(DrawGenericStruct *Structs);
  15. static void RedrawOneStruct(DrawGenericStruct *Struct);
  16. static void RedrawPolylineStruct(DrawPolylineStruct *Struct);
  17. static void RedrawConnectionStruct(DrawConnectionStruct *Struct);
  18. static void RedrawTextStruct(DrawTextStruct *Struct);
  19.  
  20. /*****************************************************************************
  21. * Routine to redraw all screen. A list of all active structs is provided.    *
  22. *****************************************************************************/
  23. void RedrawAllScreen(void)
  24. {
  25.     RedrawStructList(EEDrawList);
  26. }
  27.  
  28. /*****************************************************************************
  29. * Routine to redraw list of structs.                         *
  30. * If the list is of DrawPickStruct types then the picked item are drawn.     *
  31. *****************************************************************************/
  32. static void RedrawStructList(DrawGenericStruct *Structs)
  33. {
  34.     while (Structs) {
  35.     RedrawOneStruct(Structs);
  36.     Structs = Structs -> Pnext;
  37.     }
  38. }
  39.  
  40. /*****************************************************************************
  41. * Routine to redraw list of structs.                         *
  42. *****************************************************************************/
  43. static void RedrawOneStruct(DrawGenericStruct *Struct)
  44. {
  45.     switch (Struct -> StructType)
  46.     {
  47.     case DRAW_POLYLINE_STRUCT_TYPE:
  48.         RedrawPolylineStruct((DrawPolylineStruct *) Struct);
  49.         break;
  50.     case DRAW_CONNECTION_STRUCT_TYPE:
  51.         RedrawConnectionStruct((DrawConnectionStruct *) Struct);
  52.         break;
  53.     case DRAW_TEXT_STRUCT_TYPE:
  54.         RedrawTextStruct((DrawTextStruct *) Struct);
  55.         break;
  56.     case DRAW_LIB_ITEM_STRUCT_TYPE:
  57.         DrawLibPart((DrawLibItemStruct *) Struct);
  58.         break;
  59.     }
  60. }
  61.  
  62. /*****************************************************************************
  63. * Routine to redraw polyline struct.                         *
  64. * Note wide lines are corrent for horizontal/vertical lines only.         *
  65. *****************************************************************************/
  66. static void RedrawPolylineStruct(DrawPolylineStruct *Struct)
  67. {
  68.     int i, j, x, y;
  69.  
  70.     if (Struct -> Width == NORM_WIDTH) {
  71.     IGMoveTo(Struct -> Points[0], Struct -> Points[1]);
  72.     for (i = 1; i < Struct -> NumOfPoints; i++)
  73.         IGLineTo(Struct -> Points[i * 2], Struct -> Points[i * 2 + 1]);
  74.     }
  75.     else {
  76.     for (i = 1; i < Struct -> NumOfPoints; i++) {
  77.         x = Struct -> Points[(i - 1) * 2];
  78.         y = Struct -> Points[(i - 1) * 2 + 1];
  79.         if (x == Struct -> Points[i * 2]) {  /* Same X value (Vertical). */
  80.         for (j = -1; j <= 1; j++)
  81.             IGLineNoMap(IGMapX(x) + j,
  82.                 IGMapY(y),
  83.                 IGMapX(Struct -> Points[i * 2]) + j,
  84.                 IGMapY(Struct -> Points[i * 2 + 1]));
  85.         }
  86.         else {                /* Assume same Y Value (Horizontal). */
  87.         for (j = -1; j <= 1; j++)
  88.             IGLineNoMap(IGMapX(x),
  89.                 IGMapY(y) + j,
  90.                 IGMapX(Struct -> Points[i * 2]),
  91.                 IGMapY(Struct -> Points[i * 2 + 1]) + j);
  92.         }
  93.     }
  94.     }
  95. }
  96.  
  97. /*****************************************************************************
  98. * Routine to redraw connection struct.                         *
  99. *****************************************************************************/
  100. static void RedrawConnectionStruct(DrawConnectionStruct *Struct)
  101. {
  102.     int Width = DEFAULT_SNAP_DISTANCE / 2;
  103.  
  104.     IGBar(Struct -> PosX - Width, Struct -> PosY - Width,
  105.       Struct -> PosX + Width, Struct -> PosY + Width);
  106. }
  107.  
  108. /*****************************************************************************
  109. * Routine to redraw text struct.                         *
  110. *****************************************************************************/
  111. static void RedrawTextStruct(DrawTextStruct *Struct)
  112. {
  113.     PutTextInfo(Struct -> Orient, Struct -> PosX, Struct -> PosY,
  114.                        Struct -> Scale,    Struct -> Text);
  115. }
  116.