home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / move.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-07  |  2.0 KB  |  86 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1986, 1988 Regents of the University of California
  5.    Copyright (c) 1989, Tera Computer Company
  6.  **/
  7.  
  8.   /**
  9.      move a node.  The routines in gview.c do the interesting stuff.
  10.      We just pack up some information about the node and send it off.
  11.    **/
  12.  
  13. #include "malloc.h"
  14. #include "digraph.h"
  15. #include "scrdep.h"
  16. #include "globals.h"
  17. #include "interf.h"
  18.  
  19. static NODE *moveNode;
  20.  
  21. void DoSetUpMove()
  22.   /**
  23.      Before moving the node, we delete the displayed edges so it doesn't 
  24.      look sloppy.  Of course, *we* don't do that, the routines in gview.c
  25.      do.  But we need to tell it where the edges are, so...
  26.  
  27.      The edges in the *digraph* are never deleted, just the displayed edges.
  28.    **/
  29. {
  30.     char **prevNodes, **nextNodes;
  31.     int numprev, numnext;
  32.     int i;
  33.     VNO from_vno, to_vno;
  34.  
  35.     IChangeStatusLine("Moving node ...", TRUE);
  36.  
  37.     moveNode = (NODE *) ICurNode();
  38.  
  39.     numprev = card(Ante_set(moveNode));
  40.     numnext = card(Succ_set(moveNode));
  41.     prevNodes = (char **) malloc(numprev * sizeof(char *));
  42.     nextNodes = (char **) malloc(numnext * sizeof(char *));
  43.  
  44.     i = 0;
  45.     each_element(Ante_set(moveNode), from_vno)
  46.     loop
  47.     prevNodes[i] = (char *) Node(digraph, from_vno);
  48.     i++;
  49.     endloop;
  50.  
  51.     i = 0;
  52.     each_element(Succ_set(moveNode), to_vno)
  53.     loop
  54.     nextNodes[i] = (char *) Node(digraph, to_vno);
  55.     i++;
  56.     endloop;
  57.  
  58.     ISetupMove((char*) moveNode, prevNodes, nextNodes, numprev, numnext);
  59. }
  60.  
  61. void DoMoveEnd()
  62.   /**
  63.      Redraw the node centered on the current position.
  64.      Redraw the edges.
  65.    **/
  66. {
  67.     int curx, cury;
  68.  
  69.     IGetCurPos(&curx, &cury);
  70.     X_position(moveNode) = SCRX_TO_ABSX(&screen, curx);
  71.     Y_position(moveNode) = SCRY_TO_ABSY(&screen, cury);
  72.  
  73.     draw_node(digraph, moveNode, &screen, TRUE);
  74.     draw_in_edges(digraph, moveNode, &screen, TRUE, TRUE);
  75.     draw_out_edges(digraph, moveNode, &screen, TRUE);
  76.  
  77.     EndMove();
  78. }
  79.  
  80. EndMove()
  81. {
  82.     IChangeStatusLine("End moving node", FALSE);
  83.     graphChanged = TRUE;
  84.     ckpt_done = FALSE;
  85. }
  86.