driver.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 <wx/string.h>
  19. #include <Python.h>
  20. #include <wx/wxPython/pseudodc.h>
  21. extern "C" {
  22. #include <grass/gis.h>
  23. #include <grass/Vect.h>
  24. }
  25. class DisplayDriver
  26. {
  27. private:
  28. friend class Digit;
  29. wxPseudoDC *dc, *dcTmp; // device content
  30. wxWindow *parentWin;
  31. /* disabled due to expensive calling dc->SetId()
  32. *
  33. * currently all objects are drawn without id
  34. *
  35. * only selected lines with id '1'
  36. *
  37. * segments with unique id (starting with '1')
  38. * are drawn only when line was selected using SelectLineByPoint()
  39. */
  40. struct _selected {
  41. struct ilist *values;
  42. struct ilist *valuesDupl;
  43. bool isId; /* id or cat ? */
  44. } selected;
  45. bool drawSelected;
  46. bool drawSegments; // draw segments of selected line
  47. struct Map_info *mapInfo;
  48. struct line_pnts *points; // east, north, depth
  49. wxList *pointsScreen; // x, y, z
  50. struct line_cats *cats;
  51. struct _region {
  52. // GRASS region section
  53. BOUND_BOX box; // W,E,N,S,T,B
  54. double ns_res;
  55. double ew_res;
  56. double center_easting;
  57. double center_northing;
  58. // map window section
  59. double map_width; // px
  60. double map_height;
  61. double map_west;
  62. double map_north;
  63. double map_res;
  64. } region;
  65. struct symbol {
  66. bool enabled;
  67. wxColor color;
  68. };
  69. struct _settings {
  70. wxColor highlight;
  71. symbol highlightDupl;
  72. symbol point;
  73. symbol line;
  74. symbol boundaryNo;
  75. symbol boundaryOne;
  76. symbol boundaryTwo;
  77. symbol centroidIn;
  78. symbol centroidOut;
  79. symbol centroidDup;
  80. symbol nodeOne;
  81. symbol nodeTwo;
  82. symbol vertex;
  83. symbol area;
  84. symbol direction;
  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. double DistanceInPixels(double);
  104. int DrawCross(wxPseudoDC *, int, const wxPoint *, int size=5);
  105. int DrawArrow(double, double, double, double, double,
  106. int);
  107. int DrawLine(int);
  108. int DrawLineVerteces(int);
  109. int DrawLineNodes(int);
  110. int DrawDirectionArrow();
  111. int DrawArea(const line_pnts *);
  112. /* debug */
  113. void PrintIds();
  114. /* select feature */
  115. bool IsSelected(int, bool force=false);
  116. bool IsDuplicated(int);
  117. std::vector<int> ListToVector(struct ilist *);
  118. int VectorToList(struct ilist *, const std::vector<int>&);
  119. void ResetTopology();
  120. /* message dialogs */
  121. wxString msgCaption;
  122. void DisplayMsg(void);
  123. void Only2DMsg(void);
  124. void ReadLineMsg(int);
  125. void DeadLineMsg(int);
  126. void WriteLineMsg(void);
  127. void BackgroundMapMsg(const char *);
  128. void DblinkMsg(int);
  129. void DbDriverMsg(const char *);
  130. void DbDatabaseMsg(const char *, const char *);
  131. void DbExecuteMsg(const char *);
  132. void DbSelectCursorMsg(const char *);
  133. void GetLineCatsMsg(int);
  134. public:
  135. /* constructor */
  136. DisplayDriver(void *, void *);
  137. /* destructor */
  138. ~DisplayDriver();
  139. /* display */
  140. int DrawMap(bool);
  141. /* select */
  142. int SelectLinesByBox(double, double, double, double,
  143. double, double, int, bool, bool);
  144. std::vector<double> SelectLineByPoint(double, double, double,
  145. double, int, int);
  146. std::vector<int> GetSelected(bool);
  147. std::map<int, std::vector<double> > GetSelectedCoord();
  148. std::map<int, std::vector <int> > GetDuplicates();
  149. std::vector<double> GetRegionSelected();
  150. int SetSelected(std::vector<int>, bool);
  151. int UnSelect(std::vector<int>);
  152. std::vector<int> GetSelectedVertex(double, double, double);
  153. void DrawSelected(bool);
  154. /* general */
  155. int CloseMap();
  156. int OpenMap(const char *, const char *, bool);
  157. void ReloadMap();
  158. void SetDevice(void *);
  159. /* misc */
  160. std::vector<double> GetMapBoundingBox();
  161. /* set */
  162. void SetRegion(double, double, double, double,
  163. double, double,
  164. double, double,
  165. double, double);
  166. void UpdateSettings(unsigned long,
  167. bool, unsigned long,
  168. bool, unsigned long, /* enabled, color */
  169. bool, unsigned long,
  170. bool, unsigned long,
  171. bool, unsigned long,
  172. bool, unsigned long,
  173. bool, unsigned long,
  174. bool, unsigned long,
  175. bool, unsigned long,
  176. bool, unsigned long,
  177. bool, unsigned long,
  178. bool, unsigned long,
  179. bool, unsigned long,
  180. bool, unsigned long,
  181. int, int);
  182. };
  183. int print_error(const char *, int);
  184. #endif /* WXVDIGIT_DRIVER_H */