block.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include <circogen/nodelist.h>
  15. typedef struct block block_t;
  16. typedef struct {
  17. block_t *first;
  18. block_t *last;
  19. } blocklist_t;
  20. struct block {
  21. Agnode_t *child; /* if non-null, points to node in parent block */
  22. block_t *next; /* sibling block */
  23. Agraph_t *sub_graph; /* nodes and edges in this block */
  24. double radius; /* radius of block and subblocks */
  25. double rad0; /* radius of block */
  26. nodelist_t circle_list; /* ordered list of nodes in block */
  27. blocklist_t children; /* child blocks */
  28. double parent_pos; /* if block has 1 node, angle to place parent */
  29. int flags;
  30. };
  31. extern block_t *mkBlock(Agraph_t *);
  32. extern void freeBlock(block_t * sp);
  33. extern int blockSize(block_t * sp);
  34. extern void initBlocklist(blocklist_t *);
  35. extern void appendBlock(blocklist_t * sp, block_t * sn);
  36. extern void insertBlock(blocklist_t * sp, block_t * sn);
  37. #ifdef DEBUG
  38. extern void printBlocklist(blocklist_t * snl);
  39. #endif
  40. #define CHILD(b) ((b)->child)
  41. #define BLK_PARENT(b) (CHILD(b)? PARENT(CHILD(b)) : 0)
  42. #define BLK_FLAGS(b) ((b)->flags)
  43. #define COALESCED_F (1 << 0)
  44. #define COALESCED(b) (BLK_FLAGS(b)&COALESCED_F)
  45. #define SET_COALESCED(b) (BLK_FLAGS(b) |= COALESCED_F)
  46. #ifdef __cplusplus
  47. }
  48. #endif