driver.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #ifndef WXVDIGIT_DRIVER_H
  2. #define WXVDIGIT_DRIVER_H
  3. #include <iostream> // debug
  4. #include <vector>
  5. #include <map>
  6. #include <cmath>
  7. // For compilers that support precompilation, includes "wx.h".
  8. #include <wx/wxprec.h>
  9. #ifdef __BORLANDC__
  10. #pragma hdrstop
  11. #endif
  12. #ifndef WX_PRECOMP
  13. // Include your minimal set of headers here, or wx.h
  14. #include <wx/wx.h>
  15. #endif
  16. #include <wx/dc.h>
  17. #include <wx/list.h>
  18. #include <Python.h>
  19. #include <wx/wxPython/pseudodc.h>
  20. extern "C" {
  21. #include <grass/gis.h>
  22. #include <grass/Vect.h>
  23. }
  24. class DisplayDriver
  25. {
  26. private:
  27. friend class Digit;
  28. wxPseudoDC *dc; // device content
  29. /* disabled due to expensive calling dc->SetId()
  30. *
  31. * currently all objects are drawn without id
  32. *
  33. * only selected lines with id '1'
  34. *
  35. * segments with unique id (starting with '1')
  36. * are drawn only when line was selected using SelectLineByPoint()
  37. */
  38. struct _selected {
  39. struct ilist *values;
  40. struct ilist *valuesDupl;
  41. bool isId; /* id or cat ? */
  42. } selected;
  43. bool drawSelected;
  44. bool drawSegments; // draw segments of selected line
  45. struct Map_info *mapInfo;
  46. struct line_pnts *points; // east, north, depth
  47. wxList *pointsScreen; // x, y, z
  48. struct line_cats *cats;
  49. struct _region {
  50. // GRASS region section
  51. BOUND_BOX box; // W,E,N,S,T,B
  52. double ns_res;
  53. double ew_res;
  54. double center_easting;
  55. double center_northing;
  56. // map window section
  57. double map_width; // px
  58. double map_height;
  59. double map_west;
  60. double map_north;
  61. double map_res;
  62. } region;
  63. struct symbol {
  64. bool enabled;
  65. wxColor color;
  66. };
  67. struct _settings {
  68. wxColor highlight;
  69. symbol highlightDupl;
  70. symbol point;
  71. symbol line;
  72. symbol boundaryNo;
  73. symbol boundaryOne;
  74. symbol boundaryTwo;
  75. symbol centroidIn;
  76. symbol centroidOut;
  77. symbol centroidDup;
  78. symbol nodeOne;
  79. symbol nodeTwo;
  80. symbol vertex;
  81. symbol area;
  82. symbol direction;
  83. int lineWidth; // screen units
  84. } settings;
  85. struct _topology {
  86. long int highlight;
  87. long int point;
  88. long int line;
  89. long int boundaryNo;
  90. long int boundaryOne;
  91. long int boundaryTwo;
  92. long int centroidIn;
  93. long int centroidOut;
  94. long int centroidDup;
  95. long int nodeOne;
  96. long int nodeTwo;
  97. long int vertex;
  98. } topology;
  99. void Cell2Pixel (double, double, double,
  100. double *, double *, double *);
  101. double DistanceInPixels(double);
  102. int DrawCross(int, const wxPoint *, int size=5);
  103. int DrawArrow(double, double, double, double, double,
  104. int);
  105. int DrawLine(int);
  106. int DrawLineVerteces(int);
  107. int DrawLineNodes(int);
  108. int DrawDirectionArrow();
  109. int DrawArea(const line_pnts *);
  110. /* debug */
  111. void PrintIds();
  112. /* select feature */
  113. bool IsSelected(int, bool force=false);
  114. bool IsDuplicated(int);
  115. std::vector<int> ListToVector(struct ilist *);
  116. int VectorToList(struct ilist *, const std::vector<int>&);
  117. void ResetTopology();
  118. public:
  119. /* constructor */
  120. DisplayDriver(void *);
  121. /* destructor */
  122. ~DisplayDriver();
  123. /* display */
  124. int DrawMap(bool);
  125. /* select */
  126. int SelectLinesByBox(double, double, double, double,
  127. double, double, int, bool);
  128. std::vector<double> SelectLineByPoint(double, double, double,
  129. double, int, int);
  130. std::vector<int> GetSelected(bool);
  131. std::map<int, std::vector <int> > GetDuplicates();
  132. std::vector<int> GetRegionSelected();
  133. int SetSelected(std::vector<int>, bool);
  134. int UnSelect(std::vector<int>);
  135. std::vector<int> GetSelectedVertex(double, double, double);
  136. void DrawSelected(bool);
  137. /* general */
  138. int CloseMap();
  139. int OpenMap(const char *, const char *, bool);
  140. void ReloadMap();
  141. void SetDevice(void *);
  142. /* misc */
  143. std::vector<double> GetMapBoundingBox();
  144. /* set */
  145. void SetRegion(double, double, double, double,
  146. double, double,
  147. double, double,
  148. double, double);
  149. void UpdateSettings(unsigned long,
  150. bool, unsigned long,
  151. bool, unsigned long, /* enabled, color */
  152. bool, unsigned long,
  153. bool, unsigned long,
  154. bool, unsigned long,
  155. bool, unsigned long,
  156. bool, unsigned long,
  157. bool, unsigned long,
  158. bool, unsigned long,
  159. bool, unsigned long,
  160. bool, unsigned long,
  161. bool, unsigned long,
  162. bool, unsigned long,
  163. bool, unsigned long,
  164. int);
  165. };
  166. int print_error(const char *, int);
  167. #endif /* WXVDIGIT_DRIVER_H */