Diagram.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. #ifndef Diagramm_H
  2. #define Diagramm_H
  3. #include "Array.h"
  4. #include "Critical.h"
  5. #include "Drawing.h"
  6. namespace Framework
  7. {
  8. class Border; //! Border.h
  9. class AlphaField; //! AlphaField.h
  10. class Text; //! Text.h
  11. class Font; //! Font.h
  12. class HScrollBar; //! Scroll.h
  13. class VScrollBar; //! Scroll.h
  14. class LiveLineDiagram; //! from this file
  15. class LineDiagram; //! from this file
  16. class TextRenderer;
  17. //! A 2D GUI Framework drawing that draws a live diagram of values
  18. class LiveLineDiagram : public DrawableBackground
  19. {
  20. public:
  21. class Style : public DrawableBackground::Style
  22. {
  23. public:
  24. //! A grid is drawn in the diagram for orientation
  25. static const __int64 Gitter = 0x01000;
  26. //! The names of the graphs are displayed
  27. static const __int64 LineName = 0x02000;
  28. //! Combination of flags Visible, Background,
  29. //! Border, Grid, LineName
  30. static const __int64 normal
  31. = Visible | Background | Border | Gitter | LineName;
  32. };
  33. private:
  34. int gF;
  35. Array<int>* lColor;
  36. RCArray<Text>* lName;
  37. RCArray<Array<int>>* ph;
  38. RCArray<Array<int>>* pb;
  39. Array<int>* lastValue;
  40. TextRenderer* textRd;
  41. Point gitterGr;
  42. int lines;
  43. public:
  44. //! Constructor
  45. DLLEXPORT LiveLineDiagram();
  46. //! Destructor
  47. DLLEXPORT virtual ~LiveLineDiagram();
  48. //! Sets the used TextRenderer
  49. //! \param textRd The text renderer
  50. DLLEXPORT void setTextRendererZ(TextRenderer* textRd);
  51. //! Sets a pointer to the used font
  52. //! \param font The font
  53. DLLEXPORT void setFontZ(Font* font);
  54. //! Sets the spacing between the grid lines
  55. //! \param gr For x the spacing between each vertical line in
  56. //! pixels and for y the spacing between each horizontal line in
  57. //! the displayed y values
  58. DLLEXPORT void setGSize(Point& gr);
  59. //! Sets the color of the grid lines
  60. //! \param f The color in A8R8G8B8 format
  61. DLLEXPORT void setGColor(int f);
  62. //! Adds a new graph to the diagram
  63. //! \param name The name of the graph. It is displayed in the diagram
  64. //! when the LineName flag is set
  65. DLLEXPORT void addLine(const char* name);
  66. //! Adds a new graph to the diagram
  67. //! \param name The name of the graph. It is displayed in the diagram
  68. //! when the LineName flag is set
  69. DLLEXPORT void addLine(Text* txt);
  70. //! Sets the color of a graph
  71. //! \param lNum The index of the graph
  72. //! \param f The color in A8R8G8B8 format
  73. DLLEXPORT void setLColor(int lNum, int f);
  74. //! Adds a point to a graph. This shifts all points of the graph
  75. //! to the left so that the new point appears on the right. If a point
  76. //! goes off the left edge of the diagram, it is deleted. This way the
  77. //! diagram appears like a live measurement \param x The distance to the
  78. //! last point in pixels \param y The value of the displayed function at
  79. //! the point
  80. DLLEXPORT void addPoint(int lNum, int x, int h);
  81. //! Removes a graph
  82. //! \param lNum The index of the graph
  83. DLLEXPORT void removeLine(int lNum);
  84. //! Draws the diagram
  85. //! \param zRObj The image to draw into
  86. DLLEXPORT void render(Image& zRObj) override;
  87. //! Returns the used font
  88. DLLEXPORT Font* getFont() const;
  89. //! Returns the used font without increased reference counter
  90. DLLEXPORT Font* zFont() const;
  91. //! Returns the size of a grid square, where the width is in pixels
  92. //! and the height is in y axis values
  93. DLLEXPORT const Point& getGSize() const;
  94. //! Returns the color of the grid in A8R8G8B8 format
  95. DLLEXPORT int getGColor() const;
  96. //! Returns the index of a graph
  97. //! \param name The name of the graph
  98. DLLEXPORT int getLineNumber(const char* name) const;
  99. //! Returns the index of a graph
  100. //! \param name The name of the graph
  101. DLLEXPORT int getLineNumber(Text* name) const;
  102. //! Returns the name of a graph
  103. //! \param lNum The index of the graph
  104. DLLEXPORT Text* getLineName(int lNum) const;
  105. //! Returns the name of a graph without increased reference counter
  106. //! \param lNum The index of the graph
  107. DLLEXPORT Text* zLineNames(int lNum) const;
  108. //! Returns the highest y value of all graphs
  109. DLLEXPORT int getHighestValue() const;
  110. //! Returns the highest y value of a specific graph
  111. //! \param lNum The index of the graph
  112. DLLEXPORT int getHighestValue(int lNum) const;
  113. //! Returns the average value of all points stored in the diagram
  114. //! for a graph \param lNum The index of the graph
  115. DLLEXPORT int getMedian(int lNum) const;
  116. //! Returns the number of graphs
  117. DLLEXPORT int getLCount() const;
  118. //! Returns the y value of the last point of a graph
  119. //! \param lNum The index of the graph
  120. DLLEXPORT int getLastValue(int lNum) const;
  121. };
  122. //! Point of a value in a diagram
  123. struct DiagramPoint
  124. {
  125. //! Position of the point on the horizontal interval of the diagram
  126. double hInterval;
  127. //! Position of the point on the vertical interval of the diagram
  128. double vInterval;
  129. };
  130. //! Value that is visualized in a diagram
  131. struct DiagramValue : public virtual ReferenceCounter
  132. {
  133. //! Style of a diagram value
  134. class Style
  135. {
  136. public:
  137. static const int Visible
  138. = 0x01; //! Determines whether the value should be displayed
  139. static const int Alpha
  140. = 0x02; //! Determines whether alpha blending should be used
  141. //! when drawing the value
  142. static const int Background
  143. = 0x04; //! Determines whether the value has a background
  144. static const int HAlpha
  145. = 0x08; //! Determines whether alpha blending should be used
  146. //! when drawing the background
  147. static const int Name = 0x10; //! Determines whether the name of
  148. //! the value should be drawn
  149. };
  150. //! Style of the value
  151. int style;
  152. //! Color of the value
  153. int color;
  154. //! Background color of the value
  155. int background;
  156. //! Name of the value
  157. Text* name;
  158. //! Points of the value
  159. Array<DiagramPoint*>* punkte;
  160. //! Constructor
  161. DLLEXPORT DiagramValue();
  162. //! Destructor
  163. DLLEXPORT ~DiagramValue();
  164. };
  165. //! Data for a diagram
  166. struct DiagramData : public virtual ReferenceCounter
  167. {
  168. class Style
  169. {
  170. public:
  171. static const int Visible
  172. = 0x0001; //! Determines whether the data should be visible
  173. static const int Raster
  174. = 0x0002; //! Determines whether a grid for orientation
  175. //! should be displayed
  176. static const int RasterAlpha
  177. = 0x0004; //! Determines whether alpha blending should be used
  178. //! for drawing the grid
  179. static const int AutoIntervalHeight
  180. = 0x0008; //! Determines that all values are automatically
  181. //! scaled on the y axis so that the full height of
  182. //! the diagram is always used
  183. static const int AutoIntervalWidth
  184. = 0x0010; //! Determines that all values are automatically
  185. //! scaled on the x axis so that the full width of the
  186. //! diagram is always used
  187. static const int HInterval
  188. = 0x0020; //! Determines whether the X axis should be drawn
  189. static const int VInterval
  190. = 0x0040; //! Determines whether the Y axis should be drawn
  191. static const int HIntervalTexte
  192. = 0x0200; //! Determines whether custom texts for the X axis
  193. //! values should be drawn
  194. static const int VIntervalTexte
  195. = 0x0400; //! Determines whether custom texts for the Y axis
  196. //! values should be drawn
  197. static const int AutoGridWidth
  198. = 0x0800; //! Determines whether the spacing between vertical
  199. //! grid lines should be chosen automatically
  200. static const int AutoGridHeight
  201. = 0x1000; //! Determines whether the spacing between horizontal
  202. //! grid lines should be chosen automatically
  203. static const int intervale
  204. = HInterval | VInterval; //! Combines flags HInterval, VInterval
  205. static const int intervalTexte
  206. = HIntervalTexte
  207. | VIntervalTexte; //! Combines flags HIntervalTexte,
  208. //! VIntervalTexte
  209. static const int autoGrid
  210. = AutoGridHeight | AutoGridWidth
  211. | Raster; //! Combines flags AutoGridHeight,
  212. //! AutoGridWidth, Raster
  213. static const int autoInterval
  214. = AutoIntervalHeight
  215. | AutoIntervalWidth; //! Combines flags AutoIntervalHeight,
  216. //! AutoIntervalWidth
  217. };
  218. //! Style of the diagram
  219. int style;
  220. //! Width of a grid line
  221. int rasterDicke;
  222. //! Width of a grid cell
  223. double gridWidth;
  224. //! Height of a grid cell
  225. double rasterHeight;
  226. //! Color of the grid
  227. int rasterColor;
  228. //! Font color of the horizontal interval
  229. int hIntervalColor;
  230. //! Font color of the vertical interval
  231. int vIntervalColor;
  232. //! Name of the horizontal interval
  233. Text* hIntervalName;
  234. //! Name of the vertical interval
  235. Text* vIntervalName;
  236. //! Labels of the horizontal interval
  237. RCArray<Text>* hIntervalTexte;
  238. //! Labels of the vertical interval
  239. RCArray<Text>* vIntervalTexte;
  240. //! Individual horizontal intervals
  241. Array<double>* hIntervalWerte;
  242. //! Individual vertical intervals
  243. Array<double>* vIntervalWerte;
  244. //! Width of value 1 in pixels for the horizontal interval (overridden
  245. //! by setting AutoIntervalWidth)
  246. double hIntervalWidth;
  247. //! Height of value 1 in pixels for the vertical interval (overridden
  248. //! by setting AutoIntervalHeight)
  249. double vIntervalHeight;
  250. //! Values visualized in the diagram
  251. RCArray<DiagramValue>* werte;
  252. //! Constructor
  253. DLLEXPORT DiagramData();
  254. //! Destructor
  255. DLLEXPORT ~DiagramData();
  256. };
  257. //! Base class for the different diagram types
  258. class BaseDiagram
  259. {
  260. protected:
  261. DiagramData* daten;
  262. bool changed;
  263. ReadWriteLock* lock;
  264. public:
  265. //! Constructor
  266. //! \param lock A pointer to the Critical used to make the diagram class
  267. //! that inherits from this class thread-safe
  268. DLLEXPORT BaseDiagram(ReadWriteLock* lock);
  269. //! Destructor
  270. DLLEXPORT virtual ~BaseDiagram();
  271. //! Sets a pointer to the diagram data
  272. //! \param dd The data
  273. DLLEXPORT void setDiagramDataZ(DiagramData* dd);
  274. //! Copies diagram data
  275. //! \param dd The data
  276. DLLEXPORT void setDiagramData(DiagramData* dd);
  277. //! Sets the grid line thickness
  278. //! \param d The width of a grid line in pixels
  279. DLLEXPORT void setGridThickness(int d);
  280. //! Sets the grid width
  281. //! \param br The spacing between two vertical grid lines in pixels
  282. DLLEXPORT void setGridWidth(int br);
  283. //! Sets the grid height
  284. //! \param hi The spacing between two horizontal grid lines in pixels
  285. DLLEXPORT void setGridHeight(int hi);
  286. //! Sets the grid color
  287. //! \param f The color in A8R8G8B8 format
  288. DLLEXPORT void setGridColor(int f);
  289. //! Sets the interval width
  290. //! \param br The distance between values 0 and 1 on the X axis in
  291. //! pixels
  292. DLLEXPORT void setHIntervalWidth(double br);
  293. //! Sets the interval height
  294. //! \param hi The distance between values 0 and 1 on the Y axis in
  295. //! pixels
  296. DLLEXPORT void setVIntervalHeight(double hi);
  297. //! Sets the color of the X axis
  298. //! \param f The color in A8R8G8B8 format
  299. DLLEXPORT void setHIntervalColor(int f);
  300. //! Sets the color of the Y axis
  301. //! \param f The color in A8R8G8B8 format
  302. DLLEXPORT void setVIntervalColor(int f);
  303. //! Sets the name of the X axis
  304. //! \param name The name
  305. DLLEXPORT void setHIntervalName(const char* name);
  306. //! Sets the name of the X axis
  307. //! \param name The name
  308. DLLEXPORT void setHIntervalName(Text* name);
  309. //! Sets the name of the Y axis
  310. //! \param name The name
  311. DLLEXPORT void setVIntervalName(const char* name);
  312. //! Sets the name of the Y axis
  313. //! \param name The name
  314. DLLEXPORT void setVIntervalName(Text* name);
  315. //! Labels a specific value on the X axis, if the HIntervalTexte flag
  316. //! was set in DiagramData \param hInterval The value to label
  317. //! \param text The label
  318. DLLEXPORT void addHIntervalText(double hInterval, const char* text);
  319. //! Labels a specific value on the X axis, if the HIntervalTexte flag
  320. //! was set in DiagramData \param hInterval The value to label
  321. //! \param text The label
  322. DLLEXPORT void addHIntervalText(double hInterval, Text* text);
  323. //! Sets a pointer to a label for a specific value on the X axis,
  324. //! if the HIntervalTexte flag was set in DiagramData
  325. //! \param hInterval The value to label
  326. //! \param text The label
  327. DLLEXPORT void setHIntervalTextZ(double hInterval, Text* text);
  328. //! Changes a label for a specific value on the X axis, if the
  329. //! HIntervalTexte flag was set in DiagramData \param hInterval The
  330. //! value to label \param text The label
  331. DLLEXPORT void setHIntervalText(double hInterval, Text* text);
  332. //! Changes a label for a specific value on the X axis, if the
  333. //! HIntervalTexte flag was set in DiagramData \param hInterval The
  334. //! value to label \param text The label
  335. DLLEXPORT void setHIntervalText(double hInterval, const char* text);
  336. //! Removes a label for a specific value on the X axis,
  337. //! if the HIntervalTexte flag was set in DiagramData \param
  338. //! hInterval The value that should no longer be labeled
  339. DLLEXPORT void removeHIntervalText(double hInterval);
  340. //! Labels a specific value on the Y axis, if the VIntervalTexte flag
  341. //! was set in DiagramData \param vInterval The value to label
  342. //! \param text The label
  343. DLLEXPORT void addVIntervalText(double vInterval, const char* text);
  344. //! Labels a specific value on the Y axis, if the VIntervalTexte flag
  345. //! was set in DiagramData \param vInterval The value to label
  346. //! \param text The label
  347. DLLEXPORT void addVIntervalText(double vInterval, Text* text);
  348. //! Sets a pointer to a label for a specific value on the Y axis,
  349. //! if the VIntervalTexte flag was set in DiagramData
  350. //! \param vInterval The value to label
  351. //! \param text The label
  352. DLLEXPORT void setVIntervalTextZ(double vInterval, Text* text);
  353. //! Changes a label for a specific value on the Y axis, if the
  354. //! VIntervalTexte flag was set in DiagramData \param vInterval The
  355. //! value to label \param text The label
  356. DLLEXPORT void setVIntervalText(double vInterval, Text* text);
  357. //! Changes a label for a specific value on the Y axis, if the
  358. //! VIntervalTexte flag was set in DiagramData \param vInterval The
  359. //! value to label \param text The label
  360. DLLEXPORT void setVIntervalText(double vInterval, const char* text);
  361. //! Removes a label for a specific value on the Y axis,
  362. //! if the VIntervalTexte flag was set in DiagramData \param
  363. //! vInterval The value that should no longer be labeled
  364. DLLEXPORT void removeVIntervalText(double vInterval);
  365. //! Adds a value (graph) displayed in the diagram
  366. //! \param w The new value
  367. DLLEXPORT void addValueZ(DiagramValue* w);
  368. //! Adds a value (graph) displayed in the diagram by copying
  369. //! another \param w The value to copy
  370. DLLEXPORT void addValue(DiagramValue* w);
  371. //! Adds a value (graph) displayed in the diagram
  372. //! \param name The name of the value
  373. DLLEXPORT void addValue(const char* name);
  374. //! Adds a value (graph) displayed in the diagram
  375. //! \param name The name of the value
  376. DLLEXPORT void addValue(Text* txt);
  377. //! Sets the color of a value
  378. //! \param wNum The index of the value
  379. //! \param fc The color in A8R8G8B8 format
  380. DLLEXPORT void setValueColor(int wNum, int fc);
  381. //! Adds a point to a value
  382. //! \param wNum The index of the value
  383. //! \param p The new point
  384. DLLEXPORT void addPointZ(int wNum, DiagramPoint* p);
  385. //! Adds a point to a value by copying a point
  386. //! \param wNum The index of the value
  387. //! \param p The point to copy
  388. DLLEXPORT void addPoint(int wNum, DiagramPoint* p);
  389. //! Adds a point to a value
  390. //! \param wNum The index of the value
  391. //! \param hI The value of the point on the X axis
  392. //! \param vI The value of the point on the Y axis
  393. DLLEXPORT void addPoint(int wNum, double hI, double vI);
  394. //! Sets a pointer to an existing point of a value
  395. //! \param wNum The index of the value
  396. //! \param hI The X axis value of the point to replace
  397. //! \param p The new point
  398. DLLEXPORT void setPointZ(int wNum, double hI, DiagramPoint* p);
  399. //! Sets an existing point of a value by copying a point
  400. //! \param wNum The index of the value \param hI The X axis value of
  401. //! the point to replace \param p The new point
  402. DLLEXPORT void setPoint(int wNum, double hI, DiagramPoint* p);
  403. //! Sets an existing point of a value
  404. //! \param wNum The index of the value
  405. //! \param hI The X axis value of the point to replace
  406. //! \param h The X axis value of the new point \param v
  407. //! The Y axis value of the new point
  408. DLLEXPORT void setPoint(int wNum, double hI, double h, double v);
  409. //! Sets a pointer to an existing point of a value
  410. //! \param wNum The index of the value
  411. //! \param pNum The index of the point in the value
  412. //! \param p The new point
  413. DLLEXPORT void setPointZ(int wNum, int pNum, DiagramPoint* p);
  414. //! Sets an existing point of a value by copying a point
  415. //! \param wNum The index of the value \param pNum The index of the
  416. //! point in the value \param p The new point
  417. DLLEXPORT void setPoint(int wNum, int pNum, DiagramPoint* p);
  418. //! Sets an existing point of a value
  419. //! \param wNum The index of the value
  420. //! \param pNum The index of the point in the value
  421. //! \param h The X axis value of the new point
  422. //! \param v The Y axis value of the new point
  423. DLLEXPORT void setPoint(int wNum, int pNum, double h, double v);
  424. //! Deletes an existing point
  425. //! \param wNum The index of the value
  426. //! \param hI The X axis value of the point to delete
  427. DLLEXPORT void removePoint(int wNum, double hI);
  428. //! Deletes an existing point
  429. //! \param wNum The index of the value
  430. //! \param pNum The index of the point in the value
  431. DLLEXPORT void removePoint(int wNum, int pNum);
  432. //! Removes a value
  433. //! \param wNum The index of the value
  434. DLLEXPORT void removeValue(int wNum);
  435. //! Removes a value
  436. //! \param name The name of the value
  437. DLLEXPORT void removeValue(const char* name);
  438. //! Removes a value
  439. //! \param name The name of the value
  440. DLLEXPORT void removeValue(Text* name);
  441. //! Adds styles to the DiagramData
  442. //! \param style The new styles
  443. DLLEXPORT void addDataStyle(int style);
  444. //! Sets the styles of the DiagramData
  445. //! \param style The new styles
  446. DLLEXPORT void setDataStyle(int style);
  447. //! Sets the styles of the DiagramData
  448. //! \param style The styles
  449. //! \param addRemove 1 if the styles should be added. 0 if the styles
  450. //! should be removed
  451. DLLEXPORT void setDataStyle(int style, bool addRemove);
  452. //! Removes styles from the DiagramData
  453. //! \param style The styles to remove
  454. DLLEXPORT void removeDataStyle(int style);
  455. //! Adds styles to a specific value
  456. //! \param wNum The index of the value
  457. //! \param style The new styles
  458. DLLEXPORT void addValueStyle(int wNum, int style);
  459. //! Sets the styles of a specific value
  460. //! \param wNum The index of the value
  461. //! \param style The new styles
  462. DLLEXPORT void setValueStyle(int wNum, int style);
  463. //! Sets the styles of a specific value
  464. //! \param wNum The index of the value
  465. //! \param style The styles
  466. //! \param addRemove 1 if the styles should be added. 0 if the styles
  467. //! should be removed
  468. DLLEXPORT void setValueStyle(int wNum, int style, bool addRemove);
  469. //! Removes styles from a specific value
  470. //! \param wNum The index of the value
  471. //! \param style The styles to remove
  472. DLLEXPORT void removeValueStyle(int wNum, int style);
  473. //! Returns the diagram data
  474. DLLEXPORT DiagramData* getDiagramData() const;
  475. //! Returns the diagram data without increased reference counter
  476. DLLEXPORT DiagramData* zDiagramData() const;
  477. //! Returns the data of a value
  478. //! \param wNum The index of the value
  479. DLLEXPORT DiagramValue* getDiagramValue(int wNum) const;
  480. //! Returns the data of a value without increased reference counter
  481. //! \param wNum The index of the value
  482. DLLEXPORT DiagramValue* zDiagramValue(int wNum) const;
  483. //! Returns the data of a value
  484. //! \param name The name of the value
  485. DLLEXPORT DiagramValue* getDiagramValue(const char* name) const;
  486. //! Returns the data of a value without increased reference counter
  487. //! \param name The name of the value
  488. DLLEXPORT DiagramValue* zDiagramValue(const char* name) const;
  489. //! Returns the index of a value
  490. //! \param name The name of the value
  491. DLLEXPORT int getDiagramValuePos(const char* name) const;
  492. //! Returns the index of a point from a value
  493. //! \param wNum The index of the value
  494. //! \param hI The X axis value of the point
  495. DLLEXPORT int getDiagramPointPos(int wNum, double hI) const;
  496. //! Returns the index of a point from a value
  497. //! \param wName The name of the value
  498. //! \param hI The X axis value of the point
  499. DLLEXPORT int getDiagramPointPos(char* wName, double hI) const;
  500. //! Checks whether specific styles are set in the DiagramData
  501. //! \param style The styles
  502. DLLEXPORT inline bool hasDataStyle(int style) const;
  503. //! Checks whether specific styles are not set in the DiagramData
  504. //! \param style The styles
  505. DLLEXPORT inline bool hasDataStyleNot(int style) const;
  506. //! Checks whether specific styles are set for a specific value
  507. //! \param wNum The index of the value
  508. //! \param style The styles
  509. DLLEXPORT inline bool hasValueStyle(int wNum, int style) const;
  510. //! Checks whether specific styles are not set for a specific value
  511. //! \param wNum The index of the value \param style The styles
  512. DLLEXPORT inline bool hasValueStyleNot(int wNum, int style) const;
  513. };
  514. //! A 2D GUI Framework drawing that displays diagram data as
  515. //! line graphs
  516. class LineDiagram : public DrawableBackground,
  517. public BaseDiagram
  518. {
  519. public:
  520. class Style : public DrawableBackground::Style
  521. {
  522. public:
  523. //! Determines whether a border is drawn around the data
  524. static const __int64 DataBorder = 0x0001000;
  525. //! Determines whether the data has a background
  526. static const __int64 DataBackground = 0x02000;
  527. //! Determines whether alpha blending is used when drawing
  528. //! the data background
  529. static const __int64 DataHAlpha = 0x04000;
  530. //! Determines whether an image is used for the data background
  531. static const __int64 DataHImage = 0x008000;
  532. //! Determines whether the data has a color gradient
  533. static const __int64 DataBuffered = 0x010000;
  534. //! Combines flags VScroll and HScroll
  535. static const __int64 scroll = VScroll | HScroll;
  536. //! Combines flags Background, scroll, DataBorder
  537. static const __int64 normal = Background | scroll | DataBorder;
  538. };
  539. private:
  540. TextRenderer* textRd;
  541. Border* dRam;
  542. int dBgF;
  543. Image* dBgB;
  544. AlphaField* dAf;
  545. Image* vIntervalRB;
  546. Image* hIntervalRB;
  547. int fontGr;
  548. //! Processes mouse messages
  549. //! \param me The event triggered by the mouse input
  550. DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;
  551. public:
  552. //! Constructor
  553. DLLEXPORT LineDiagram();
  554. //! Destructor
  555. DLLEXPORT virtual ~LineDiagram();
  556. //! Sets the used TextRenderer
  557. //! \param textRd The text renderer
  558. DLLEXPORT void setTextRendererZ(TextRenderer* textRd);
  559. //! Sets the font
  560. //! \param font The font
  561. DLLEXPORT void setFontZ(Font* font);
  562. //! Sets the font size
  563. //! \param gr The height of a line in pixels
  564. DLLEXPORT void setFontSize(int gr);
  565. //! Sets the inner border around the actual diagram (border around the
  566. //! data) \param ram The border
  567. DLLEXPORT void setDataBorderZ(Border* ram);
  568. //! Sets the inner border around the actual diagram (border around the
  569. //! data) by copying a border \param ram The border to copy
  570. DLLEXPORT void setDataBorder(Border* ram);
  571. //! Sets the width of the inner border around the actual diagram
  572. //! (border around the data) \param br The width in pixels
  573. DLLEXPORT void setDataBorderWidth(int br);
  574. //! Sets the color of the inner border around the actual diagram
  575. //! (border around the data) \param fc The color in A8R8G8B8 format
  576. DLLEXPORT void setDataBorderColor(int fc);
  577. //! Sets the background of the actual diagram
  578. DLLEXPORT void setDataBackgroundColor(int fc);
  579. DLLEXPORT void setDataBackgroundImageZ(Image* b);
  580. DLLEXPORT void setDataBackgroundImage(Image* b);
  581. //! Sets the color gradient of the actual diagram (color gradient of
  582. //! the data) \param af The color gradient
  583. DLLEXPORT void setDataAlphaFieldZ(AlphaField* af);
  584. //! Sets the color gradient of the actual diagram (color gradient of
  585. //! the data) by copying a color gradient \param af The color
  586. //! gradient to copy
  587. DLLEXPORT void setDataAlphaField(AlphaField* af);
  588. //! Sets the color of the color gradient of the actual diagram
  589. //! (color gradient of the data) \param fc The color in A8R8G8B8 format
  590. DLLEXPORT void setDataAlphaFieldColor(int fc);
  591. //! Sets the strength of the color gradient of the actual diagram
  592. //! (color gradient of the data) \param st The strength
  593. DLLEXPORT void setDataAlphaFieldStrength(int st);
  594. //! Draws the object to zRObj if it is visible
  595. //! \param zRObj The image to draw into
  596. DLLEXPORT void render(Image& zRObj) override;
  597. //! Returns the font
  598. DLLEXPORT Font* getFont() const;
  599. //! Returns the font without increased reference counter
  600. DLLEXPORT Font* zFont() const;
  601. //! Returns the inner border around the actual diagram (border around
  602. //! the data)
  603. DLLEXPORT Border* getDataBorder() const;
  604. //! Returns the inner border around the actual diagram without increased
  605. //! reference counter (border around the data)
  606. DLLEXPORT Border* zDataBorder() const;
  607. //! Returns the color of the inner border around the actual diagram in
  608. //! A8R8G8B8 format (border around the data)
  609. DLLEXPORT int getDataBorderColor() const;
  610. //! Returns the width of the inner border around the actual diagram in
  611. //! pixels (border around the data)
  612. DLLEXPORT int getDataBorderWidth() const;
  613. //! Returns the background color of the actual diagram in
  614. //! A8R8G8B8 format (background of the data)
  615. DLLEXPORT int getDataBackgroundColor() const;
  616. //! Returns the background image of the actual diagram
  617. //! (background image of the data)
  618. DLLEXPORT Image* getDataBackgroundImage() const;
  619. //! Returns the background image of the actual diagram without increased
  620. //! reference counter (background image of the data)
  621. DLLEXPORT Image* zDataBackgroundImage() const;
  622. //! Returns the color gradient of the actual diagram
  623. //! (color gradient of the data)
  624. DLLEXPORT AlphaField* getDataAlphaField() const;
  625. //! Returns the color gradient of the actual diagram without increased
  626. //! reference counter (color gradient of the data)
  627. DLLEXPORT AlphaField* zDataAlphaField() const;
  628. //! Returns the color of the color gradient of the actual diagram in
  629. //! A8R8G8B8 format (color gradient of the data)
  630. DLLEXPORT int getDataAlphaFieldColor() const;
  631. //! Returns the strength of the color gradient of the actual diagram
  632. //! (color gradient of the data)
  633. DLLEXPORT int getDataAlphaFieldStrength() const;
  634. };
  635. } // namespace Framework
  636. #endif