driver.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #ifndef __DRIVER_H__
  2. #define __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. /*
  39. struct lineDesc {
  40. int npoints;
  41. long int startId;
  42. };
  43. typedef std::map<int, lineDesc> ids_map;
  44. ids_map ids; // gId : {dcIds, ...}
  45. */
  46. struct ilist *selected;
  47. struct ilist *selectedDupl;
  48. bool drawSegments; // draw segments of selected line
  49. struct Map_info *mapInfo;
  50. struct line_pnts *points; // east, north, depth
  51. wxList *pointsScreen; // x, y, z
  52. struct line_cats *cats;
  53. struct _region {
  54. // GRASS region section
  55. BOUND_BOX box; // W,E,N,S,T,B
  56. double ns_res;
  57. double ew_res;
  58. double center_easting;
  59. double center_northing;
  60. // map window section
  61. double map_width; // px
  62. double map_height;
  63. double map_west;
  64. double map_north;
  65. double map_res;
  66. } region;
  67. struct symbol {
  68. bool enabled;
  69. wxColor color;
  70. };
  71. struct _settings {
  72. wxColor highlight;
  73. symbol highlightDupl;
  74. symbol point;
  75. symbol line;
  76. symbol boundaryNo;
  77. symbol boundaryOne;
  78. symbol boundaryTwo;
  79. symbol centroidIn;
  80. symbol centroidOut;
  81. symbol centroidDup;
  82. symbol nodeOne;
  83. symbol nodeTwo;
  84. symbol vertex;
  85. int lineWidth; // screen units
  86. } settings;
  87. struct _topology {
  88. long int highlight;
  89. long int point;
  90. long int line;
  91. long int boundaryNo;
  92. long int boundaryOne;
  93. long int boundaryTwo;
  94. long int centroidIn;
  95. long int centroidOut;
  96. long int centroidDup;
  97. long int nodeOne;
  98. long int nodeTwo;
  99. long int vertex;
  100. } topology;
  101. void Cell2Pixel (double, double, double,
  102. double *, double *, double *);
  103. int DrawCross(int, const wxPoint *, int size=5);
  104. int DrawLine(int);
  105. int DrawLineVerteces(int);
  106. int DrawLineNodes(int);
  107. /* debug */
  108. void PrintIds();
  109. /* select feature */
  110. bool IsSelected(int);
  111. bool IsDuplicated(int);
  112. std::vector<int> ListToVector(struct ilist *);
  113. int VectorToList(struct ilist *, const std::vector<int>&);
  114. void ResetTopology();
  115. public:
  116. /* constructor */
  117. DisplayDriver(void *);
  118. /* destructor */
  119. ~DisplayDriver();
  120. /* display */
  121. int DrawMap(bool);
  122. /* select */
  123. int SelectLinesByBox(double, double, double, double, double, double, int);
  124. std::vector<double> SelectLineByPoint(double, double, double,
  125. double, int, int);
  126. std::vector<int> GetSelected(bool);
  127. std::map<int, std::vector <int> > GetDuplicates();
  128. int SetSelected(std::vector<int>);
  129. int UnSelect(std::vector<int>);
  130. std::vector<int> GetSelectedVertex(double, double, double);
  131. /* general */
  132. int CloseMap();
  133. int OpenMap(const char *, const char *, bool);
  134. void ReloadMap();
  135. void SetDevice(void *);
  136. /* misc */
  137. std::vector<double> GetMapBoundingBox();
  138. /* set */
  139. void SetRegion(double, double, double, double,
  140. double, double,
  141. double, double,
  142. double, double);
  143. void UpdateSettings(unsigned long,
  144. bool, unsigned long,
  145. bool, unsigned long, /* enabled, color */
  146. bool, unsigned long,
  147. bool, unsigned long,
  148. bool, unsigned long,
  149. bool, unsigned long,
  150. bool, unsigned long,
  151. bool, unsigned long,
  152. bool, unsigned long,
  153. bool, unsigned long,
  154. bool, unsigned long,
  155. bool, unsigned long,
  156. int);
  157. };
  158. int print_error(const char *, int);
  159. #endif /* __DRIVER_H__ */