home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / 2DLab / TwoDView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-14  |  3.3 KB  |  145 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #include <math.h>
  5. #include <stdio.h>
  6. #include <sys/file.h>
  7.  
  8. #import <dpsclient/wraps.h>
  9.  
  10. #import <streams/streams.h>
  11.  
  12. #import <appkit/Matrix.h> 
  13. #import <appkit/Form.h> 
  14. #import <appkit/Button.h> 
  15. #import <appkit/NXColorWell.h>
  16. #import <appkit/TextField.h>
  17. #import <appkit/Slider.h>
  18. #import <appkit/color.h>
  19. #import <appkit/nextstd.h>
  20. #import <appkit/Pasteboard.h>
  21. #import <appkit/SavePanel.h>
  22. #import <appkit/Panel.h>
  23. #import <appkit/NXBitmapImageRep.h>
  24.  
  25. #include "headers.h" /* for Voronoi */
  26.  
  27. typedef enum { OP_PRIM_MST,OP_KRUSKAL_MST,OP_JARVIS_HULL, OP_GRAHAM_HULL,
  28.                OP_VORONOI_DIAGRAM,OP_DELAUNAY_TRIANGULATION, OP_GABRIEL_GRAPH,
  29.                OP_RELATIVE_NEIGHBORHOOD_GRAPH,
  30.             OP_TSP_STUPID_NEIGHBOR,
  31.             OP_TSP_CHEAPEST_INSERTION,
  32.             OP_TSP_NEAREST_NEIGHBOR,
  33.                     OP_TSP_NEAREST_ADDITION,
  34.             OP_TSP_FARTHEST_INSERTION} op;
  35.  
  36. typedef enum { DISP_PTS_ONLY, DISP_PTS_RESULTS } displayFlagType;
  37. /* handy macros */
  38. #define X(i) data[(i)*2]
  39. #define Y(i) data[(i)*2+1]
  40.  
  41. /* when we want to refer to a 2D point by `name' (in cost function calls) */
  42. #define XY(i) &data[(i)*2]
  43.  
  44. /* extern */
  45. extern long random();
  46. extern void srandom(int);
  47.  
  48. @interface TwoDView: View
  49. {
  50.   float *data; /* data[i*2+j], j=0,1, i=1..numPoints (dynamic) */
  51.   int numPoints;
  52.   op operation;
  53.   BOOL instanceMode;
  54.   int autoUpdate;
  55.   float width;
  56.  
  57.   id numPointsForm;
  58.   id bgColorWell;
  59.   id fgColorWell;
  60.   id lineWidthText;
  61.   id lineWidthSlider;
  62.   id optimalValueFormCell;
  63.   id timeSlider;
  64.   id timeField;
  65.   id optimizeButton; /* to run the Optimization routines */
  66.   
  67.   /* storange must be allocated for some output data structures.
  68.      Specifically, we need to allocate an array of indices for the
  69.      MST edges ((numPoints-1)*2 integers), an array of (numPoints)
  70.      integers for the convex hull edges (worst case).
  71.  
  72.      We don't need any visible storage for the voronoi/Delaunay data
  73.      structure because the libvoronoi routines allocate memory for that
  74.      stuff internally. */
  75.  
  76.   BOOL mstExists;
  77.   int *mst_edge;
  78.   BOOL chExists;
  79.   int *ch_vertex;
  80.   int nch_vertices;
  81.   BOOL vorExists;   /* voronoi OK => Delaunay OK */
  82.   BOOL dtExists;
  83.   int *dt_edge;
  84.   int ndt_edge;
  85.   BOOL ggExists;
  86.   int *gg_edge;
  87.   int ngg_edge;
  88.   BOOL rngExists;
  89.   int *rng_edge;
  90.   int nrng_edge;
  91. /* TSP data WGR */
  92.   int *tsp_edges;
  93. @public
  94.   id statusText;
  95.   long drawTime; // time in Usec to wait between drawings
  96.   id highColorWell;
  97.   displayFlagType displayFlag;
  98.   id optimalValueField; // value of optimal Path.
  99. }
  100.  
  101. + newFrame:(NXRect *)frameRect;
  102.  
  103. - setFgColorWell:sender;
  104. - setBgColorWell:sender;
  105. - setHighColorWell:sender;
  106. - setAutoUpdate:sender;
  107. - setOperation:sender;
  108. - timeValue: sender; // in tsp category.
  109. - appDidInit: sender; // do some initialization.
  110. - doOptimize: sender; // do the optimize routines.
  111. - random:sender;
  112. - animThenDisp:sender;
  113. - disp:sender;
  114. - (BOOL)acceptsFirstResponder;
  115. - mouseDown:(NXEvent *)theEvent;
  116. - free;
  117. - doPrimMST;
  118. - doKruskalMST;
  119. - doJarvisHull;
  120. - doGrahamHull;
  121. - erase;
  122. - drawEdge:(float)x1:(float)y1:(float)x2:(float)y2;
  123. - drawDT;
  124. - drawGG;
  125. - drawRNG;
  126. - drawSelf:(NXRect *)rects:(int) rectCount;
  127. - doVoronoiDiagram;
  128. - doDelaunayTriangulation;
  129. - doGabrielGraph;
  130. - doRelativeNeighborhoodGraph;
  131.  
  132. -saveTIFF:sender;
  133. -saveEPS:sender;
  134.  
  135. -openData:sender;
  136. -saveData:sender;
  137. -close:sender;
  138.  
  139. -copy:sender;
  140.  
  141. -lineWidthChanged:sender;
  142. -(BOOL)acceptsFirstMouse;
  143. @end
  144.  
  145.