home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March / PCWK3A99.iso / Linux / DDD331 / DDD-3_1_.000 / DDD-3_1_ / ddd-3.1.1 / ddd / GraphGC.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-05  |  6.3 KB  |  194 lines

  1. // $Id: GraphGC.h,v 1.19 1998/10/05 12:21:08 zeller Exp $
  2. // Graph graphics context
  3.  
  4. // Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller <zeller@ips.cs.tu-bs.de>.
  6. // 
  7. // This file is part of DDD.
  8. // 
  9. // DDD is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // DDD is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU General Public
  20. // License along with DDD -- see the file COPYING.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. // 
  24. // DDD is the data display debugger.
  25. // For details, see the DDD World-Wide-Web page, 
  26. // `http://www.cs.tu-bs.de/softech/ddd/',
  27. // or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.
  28.  
  29. #ifndef _DDD_GraphGC_h
  30. #define _DDD_GraphGC_h
  31.  
  32. #ifdef __GNUG__
  33. #pragma interface
  34. #endif
  35.  
  36. #include <X11/Xlib.h>
  37. #include "BoxPoint.h"
  38. #include "Box.h"
  39. #include "TypeInfo.h"
  40. #include "explicit.h"
  41.  
  42. // Where to attach edges
  43. enum EdgeAttachMode {
  44.     Straight,    // attach edge on nearest edge point
  45.     Circle,     // ...but assume nodes to be displayed as circles
  46.     Centered    // attach edge on center of node edge
  47. };
  48.  
  49. // Where to attach edges pointing at self
  50. enum SelfEdgePosition {
  51.     NorthEast,            // Upper right corner
  52.     SouthEast,            // Lower right corner
  53.     NorthWest,            // Upper left corner
  54.     SouthWest            // Lower left corner
  55. };
  56.  
  57. // How to align edges pointing at self
  58. enum SelfEdgeDirection { Clockwise, Counterclockwise };
  59.  
  60. struct GraphGC {
  61.     DECLARE_TYPE_INFO
  62.  
  63.     // Drawing stuff
  64.     bool           redraw;         // Redraw only marked nodes?
  65.  
  66.     GC             nodeGC;           // X Graphics context for nodes
  67.     GC             hintGC;           // X Graphics context for hints
  68.     GC             edgeGC;           // X Graphics context for edges
  69.     GC             invertGC;         // X Graphics context for inverting
  70.     GC             clearGC;          // X Graphics context for clearing
  71.  
  72.     BoxPoint       offsetIfSelected; // Offset to apply if nodes are selected
  73.     EdgeAttachMode edgeAttachMode;   // Where to attach edges
  74.     bool           drawArrowHeads;   // Flag: draw arrow heads?
  75.     bool           drawHints;        // Flag: draw hints?
  76.     bool       drawAnnotations;  // Flag: draw annotations?
  77.     BoxCoordinate  hintSize;         // Hint size (in pixels)
  78.     unsigned       arrowAngle;       // Arrow angle (in degrees)
  79.     unsigned       arrowLength;      // Arrow length (in pixels)
  80.  
  81.     BoxCoordinate     selfEdgeDiameter;  // Diameter of edge pointing at self
  82.     SelfEdgePosition  selfEdgePosition;  // Its position relative to the node
  83.     SelfEdgeDirection selfEdgeDirection; // Its direction
  84.  
  85.     // Printing stuff
  86.     PrintGC     *printGC;               // Graphics context for printing
  87.     bool        printSelectedNodesOnly; // Flag: print selected nodes only?
  88.  
  89.     unsigned short edge_red;            // Colors to use for edges [0..65535]
  90.     unsigned short edge_green;
  91.     unsigned short edge_blue;
  92.  
  93.     unsigned short node_red;            // Colors to use for nodes [0..65535]
  94.     unsigned short node_green;
  95.     unsigned short node_blue;
  96.  
  97.     static PostScriptPrintGC defaultPrintGC;
  98.  
  99.     // Default Constructor
  100.     explicit GraphGC(GC n = 0, GC e = 0, GC i = 0, GC c = 0):
  101.     redraw(false),
  102.         nodeGC(n),
  103.         hintGC(n),
  104.         edgeGC(e),
  105.         invertGC(i),
  106.         clearGC(c),
  107.         offsetIfSelected(0,0),
  108.     edgeAttachMode(Straight),
  109.         drawArrowHeads(true),
  110.         drawHints(false),
  111.         drawAnnotations(true),
  112.         hintSize(8),
  113.         arrowAngle(30),
  114.         arrowLength(10),
  115.     selfEdgeDiameter(32),
  116.     selfEdgePosition(NorthEast),
  117.     selfEdgeDirection(Counterclockwise),
  118.     printGC(&defaultPrintGC),
  119.     printSelectedNodesOnly(false),
  120.     edge_red(0),
  121.     edge_green(0),
  122.     edge_blue(0),
  123.     node_red(0),
  124.     node_green(0),
  125.     node_blue(0)
  126.     {}
  127.  
  128.     // Copy Constructor
  129.     GraphGC(const GraphGC& g):
  130.     redraw(g.redraw),
  131.         nodeGC(g.nodeGC),
  132.         hintGC(g.hintGC),
  133.         edgeGC(g.edgeGC),
  134.         invertGC(g.invertGC),
  135.         clearGC(g.clearGC),
  136.         offsetIfSelected(g.offsetIfSelected),
  137.     edgeAttachMode(g.edgeAttachMode),
  138.         drawArrowHeads(g.drawArrowHeads),
  139.         drawHints(g.drawHints),
  140.         drawAnnotations(g.drawAnnotations),
  141.         hintSize(g.hintSize),
  142.         arrowAngle(g.arrowAngle),
  143.         arrowLength(g.arrowLength),
  144.     selfEdgeDiameter(g.selfEdgeDiameter),
  145.     selfEdgePosition(g.selfEdgePosition),
  146.     selfEdgeDirection(g.selfEdgeDirection),
  147.     printGC(g.printGC),
  148.     printSelectedNodesOnly(g.printSelectedNodesOnly),
  149.     edge_red(g.edge_red),
  150.     edge_green(g.edge_green),
  151.     edge_blue(g.edge_blue),
  152.     node_red(g.node_red),
  153.     node_green(g.node_green),
  154.     node_blue(g.node_blue)
  155.     {}
  156.  
  157.     // Assignment
  158.     GraphGC& operator = (const GraphGC& g)
  159.     {
  160.     if (&g != this)
  161.     {
  162.         redraw                 = g.redraw;
  163.         nodeGC                 = g.nodeGC;
  164.         hintGC                 = g.hintGC;
  165.         edgeGC                 = g.edgeGC;
  166.         invertGC               = g.invertGC;
  167.         clearGC                = g.clearGC;
  168.         offsetIfSelected       = g.offsetIfSelected;
  169.         edgeAttachMode         = g.edgeAttachMode;
  170.         drawArrowHeads         = g.drawArrowHeads;
  171.         drawHints              = g.drawHints;
  172.         drawAnnotations        = g.drawAnnotations;
  173.         hintSize               = g.hintSize;
  174.         arrowAngle             = g.arrowAngle;
  175.         arrowLength            = g.arrowLength;
  176.         selfEdgeDiameter       = g.selfEdgeDiameter;
  177.         selfEdgePosition       = g.selfEdgePosition;
  178.         selfEdgeDirection      = g.selfEdgeDirection;
  179.         printGC                = g.printGC;
  180.         printSelectedNodesOnly = g.printSelectedNodesOnly;
  181.         edge_red               = g.edge_red;
  182.         edge_green             = g.edge_green;
  183.         edge_blue              = g.edge_blue;
  184.         node_red               = g.node_red;
  185.         node_green             = g.node_green;
  186.         node_blue              = g.node_blue;
  187.     }
  188.     return *this;
  189.     }
  190. };
  191.  
  192. #endif // _DDD_GraphGC_h
  193. // DON'T ADD ANYTHING BEHIND THIS #endif
  194.