Guiliani  Version 2.6 revision 7293 (documentation build 12)
GUIChart.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifndef _GUICHART_H_
11#define _GUICHART_H_
12
13#include "GUIObject.h"
14#include "GUIColorPropertyObserver.h"
15
16#include "GUIImageResource.h"
17#include "GUIFontResource.h"
18#include "GUIPropertyResource.h"
19
20#include "eC_TArray.h"
21
22#include "GUICommonEnums.h"
23
28{
29public:
32 {
34 POINTS_AND_LINES,
41 };
42
45 {
50 };
51
54 struct Data_t
55 {
56 eC_Value vData;
57 eC_Value vOffset;
59 };
60
86 CGUICompositeObject* const pkParent,
87 const eC_Value& vX,
88 const eC_Value& vY,
89 const eC_Value& vWidth,
90 const eC_Value& vHeight,
91 eC_UInt iAxisColor, eC_UInt TextLabelColor, eC_UInt DrawLineColor, eC_UInt DrawPointColor, eC_UInt BarColor,
92 eC_Value AxisLineWidth, eC_Value DrawLineWidth, eC_Value vScaleLength, eC_Value vPointSize,
93 eC_UInt uiScalingXAxis, eC_UInt uiScalingYAxis,
94 eC_Value vMaxShownNumberY, eC_Value vMinShownNumberY,
95 eC_Value vZoomFactorY, eC_UInt uiZoomFactorX,
96 const ObjectHandle_t& eID = NO_HANDLE);
97
114 CGUICompositeObject* const pkParent,
115 const eC_Value& vX,
116 const eC_Value& vY,
117 const eC_Value& vWidth,
118 const eC_Value& vHeight,
119 const ObjectHandle_t& eID = NO_HANDLE);
120
140 CGUICompositeObject* const pkParent,
141 const eC_Value& vX,
142 const eC_Value& vY,
143 const eC_Value& vWidth,
144 const eC_Value& vHeight,
145 eC_Int iScalingXAxis, eC_Int iScalingYAxis,
146 eC_Value vMaxShownNumberY, eC_Value vMinShownNumberY,
147 const ObjectHandle_t& eID = NO_HANDLE);
148
150 virtual ~CGUIChart();
151
152 virtual eC_Bool DoDraw();
153
154 virtual eC_Bool DoDragEnd(const eC_Value& vAbsX, const eC_Value& vAbsY);
155
156 virtual eC_Bool DoDrag(const eC_Value& vDeltaX, const eC_Value& vDeltaY, const eC_Value& vAbsX, const eC_Value& vAbsY);
157
158 virtual eC_Bool DoButtonDown(const eC_Value& vAbsX, const eC_Value& vAbsY);
159
160 virtual eC_Bool DoClick(const eC_Value& vAbsX, const eC_Value& vAbsY);
161
162 virtual void SetWidth(const eC_Value& vX);
163
164 virtual void SetHeight(const eC_Value& vY);
165
166 virtual eC_Bool IsHighlightable() const { return false; }
167
168#ifndef GUILIANI_NO_DATAPOOL
174 virtual eC_Bool SetValue(CDataPoolEntry& rkValue);
175#endif
176
177 // data
184 void AddData(eC_Value vDataValue, eC_UInt uiDimension = 0);
185
186 // sets all images to standart images
191 // set images
192
202 void SetImages(const ImageResource_t &eImageBG);
203
207 void SetFont(const FontResource_t& eFontId);
208
209 // potentially public methods
213 void ZoomInY();
214
218 void ZoomOutY();
219
220 // increase/decrease x
221
225 void ZoomInX();
226
230 void ZoomOutX();
231
236 void SetDataRepresentation(const DataRepresentation_t& eDataRepresentation);
237
243
249
255
261
267
273
279
284 void SetHorizontalHelperLineColor(const eC_UInt& uiColor);
285
291
297
302 void SetVerticalHelperLineColor(const eC_UInt& uiColor);
303
309
315
321 void SetShowBarData(const eC_Bool& bShowBarData);
322
326 eC_Bool GetShowBarData() const;
327
331 void SetAxisColor(const eC_UInt& uiAxisColor);
332
336 void SetAxisColor(const GlobalProperty_t& eAxisColor);
337
342 eC_UInt GetAxisColor() const;
343
347 void SetTextLabelColor(const eC_UInt& uiTextLabelColor);
348
352 void SetTextLabelColor(const GlobalProperty_t& eTextLabelColor);
353
358 eC_UInt GetTextLabelColor() const;
359
364 void SetLineColor(const eC_UInt& uiIndex, const eC_UInt& uiLineColor);
365
370 void SetLineColor(const eC_UInt& uiIndex, const GlobalProperty_t& eLineColor);
371
378 eC_UInt GetLineColor(const eC_UInt& uiIndex) const;
379
384 void SetPointColor(const eC_UInt& uiIndex, const eC_UInt& uiPointColor);
385
390 void SetPointColor(const eC_UInt& uiIndex, const GlobalProperty_t& ePointColor);
391
398 eC_UInt GetPointColor(const eC_UInt& uiIndex) const;
399
404 void SetBarColor(const eC_UInt& uiIndex, const eC_UInt& uiBarColor);
405
410 void SetBarColor(const eC_UInt& uiIndex, const GlobalProperty_t& eBarColor);
411
418 eC_UInt GetBarColor(const eC_UInt& uiIndex) const;
419
423 void SetSelectionColor(const eC_UInt& uiSelectionColor);
424
428 void SetSelectionColor(const GlobalProperty_t& eSelectionColor);
429
435 eC_UInt GetSelectionColor() const;
436
442 void SetZoomFactorX(const eC_Value& vZoomFactorX);
443
448 eC_Value GetZoomFactorX() const;
449
455 void SetZoomFactorY(const eC_Value& vZoomFactorY);
456
461 eC_Value GetZoomFactorY() const;
462
468 void SetScalingXAxis(const eC_UInt& uiScalingXAxis);
469
474 eC_UInt GetScalingXAxis() const;
475
481 void SetScalingYAxis(const eC_UInt& uiScalingYAxis);
482
487 eC_UInt GetScalingYAxis() const;
488
493 void SetAxisLineWidth(const eC_Value& vAxisLineWidth);
494
499 eC_Value GetAxisLineWidth() const;
500
505 void SetDrawLineWidth(const eC_Value& vDrawLineWidth);
506
511 eC_Value GetDrawLineWidth() const;
512
517 void SetScaleLength(const eC_Value& vScaleLength);
518
523 eC_Value GetScaleLength() const;
524
529 void SetPointSize(const eC_Value& vPointSize);
530
535 eC_Value GetPointSize() const;
536
541 void SetStartLabelValue(const eC_Int& iStartValue);
542
546 eC_Int GetStartLabelValue() const;
547
551 void SetMinValueY(const eC_Value& vMinNumber);
552
556 void SetMaxValueY(const eC_Value& vMaxNumber);
557
564 void SetRangeX(const eC_Int& iMinNumber, const eC_Int& iMaxNumber);
565
570 void GetRangeX(eC_Int& iMinNumber, eC_Int& iMaxNumber) const;
571
576 void SetRangeY(const eC_Value& vMinValue, const eC_Value& vMaxValue);
577
582 void GetRangeY(eC_Value& vMinValue, eC_Value& vMaxValue) const;
583
588
594 void JumpToDataPoint(const eC_Int& iMinShownData);
595
596 //Data managment
602
608
614 void KeepLastXElemenets(const eC_UInt& uiDataAmountToKepp);
615
616private:
617 void Init(eC_UInt iAxisColor, eC_UInt TextLabelColor, eC_UInt DrawLineColor, eC_UInt DrawPointColor, eC_UInt BarColor,
618 eC_Value AxisLineWidth, eC_Value DrawLineWidth, eC_Value vScaleLength, eC_Value vPointSize,
619 eC_UInt uiScalingXAxis, eC_UInt uiScalingYAxis,
620 eC_Value vMaxShownNumberY, eC_Value vMinShownNumberY,
621 eC_Value vZoomFactorY, eC_UInt uiZoomFactorX);
622
623 void DeInit();
624
625 // add colors
633 void AddDrawLineColor(const eC_UInt& uiDrawLineColor);
634
642 void AddDrawPointColor(const eC_UInt& uiDrawPointColor);
643
651 void AddBarColor(const eC_UInt& uiBarColor);
652
656 void DrawAllCharts();
657
662 void DrawLineChart(const eC_UInt& uiChartIndex);
663
668 void DrawStackedLineChart(const eC_UInt& uiChartIndex);
669
674 void DrawPointChart(const eC_UInt& uiChartIndex);
675
680 void DrawStackedPointChart(const eC_UInt& uiChartIndex);
681
686 void DrawBarChart(const eC_UInt& uiChartIndex);
687
692 void DrawStackedBarChart(const eC_UInt& uiChartIndex);
693
701 eC_UInt GetChartColor(const eC_UInt& uiChartIndex, const eC_TArray<eC_UInt>& kColors);
702
708 void Zoom(const eC_Value& vZoomFactorX, const eC_Value& vZoomFactorY);
709
713 void DrawXAxis();
714
720 eC_Value CalculateYLabelStepSizeInData();
721
726 eC_Value CalculateYLabelStepSizeInPixel();
727
731 void DrawYAxis();
732
738 eC_Value TranslateRelXPosToDataPos(const eC_Value& vXPos);
739
745 eC_Value TranslateRelYPosToDataPos(const eC_Value& vYPos);
746
752 eC_Value TranslateDataPosToAbsXPos(const eC_Value& vXPos);
753
759 eC_Value TranslateDataPosToAbsYPos(const eC_Value& vYPos);
760
761 // labeling data
770 void DrawYLabel(
771 const eC_Value& vXPos,
772 const eC_Value& vYPos,
773 const eC_String& kLabel,
774 const eC_UInt& uiPreviousColor);
775
784 void DrawXLabel(
785 const eC_Value& vXPos,
786 const eC_Value& vYPos,
787 const eC_String& kLabel,
788 const eC_UInt& uiPreviousColor);
789
793 void DrawSelectionLabel();
794
795 // formats the long float string into something more readable
801 void FormatString(eC_String &vStringToFormat);
802
806 void RecalculateChartArea();
807
811 void RecalculateChartOffsets();
812
821 eC_Bool DetectDataEntry(
822 const eC_Value& vXAbsPos,
823 const eC_Value& vYAbsPos,
824 eC_UInt& uiChartIndex,
825 eC_UInt& uiValueIndex);
826
834 void GetPointRect(
835 const eC_UInt& uiChartIndex,
836 const eC_UInt& uiValueIndex,
837 const eC_Value& vPointSize,
838 CGUIRect& pkRect);
839
847 void GetStackedPointRect(
848 const eC_UInt& uiChartIndex,
849 const eC_UInt& uiValueIndex,
850 const eC_Value& vPointSize,
851 CGUIRect& pkRect);
852
859 void GetLineRect(
860 const eC_UInt& uiChartIndex,
861 const eC_UInt& uiValueIndex,
862 CGUIRect& pkRect);
863
870 void GetStackedLineRect(
871 const eC_UInt& uiChartIndex,
872 const eC_UInt& uiValueIndex,
873 CGUIRect& pkRect);
874
881 void GetBarRect(
882 const eC_UInt& uiChartIndex,
883 const eC_UInt& uiValueIndex,
884 CGUIRect& pkRect);
885
892 void GetStackedBarRect(
893 const eC_UInt& uiChartIndex,
894 const eC_UInt& uiValueIndex,
895 CGUIRect& pkRect);
896
900 void CalculateOffsets();
901
902 eC_UInt GetStartValue();
903
904 eC_UInt GetEndValue(const eC_UInt& uiMaxValue);
905
906 void UpdateFocussedData();
907
908public:
909#ifdef GUILIANI_STREAM_GUI
915
916 virtual void ReadFromStream();
917#endif
918#ifdef GUILIANI_WRITE_GUI
919 virtual void WriteToStream(const eC_Bool bWriteClassID = false);
920#endif
921
922protected:
923#ifndef GUILIANI_STREAM_GUI
926 CGUIChart();
927#endif
928
929private:
933 void UpdateDataArea();
934
935
936private:
937 static const eC_UInt INDEX_AXISCOLOR;
938 static const eC_UInt INDEX_TEXTCOLOR;
939 static const eC_UInt INDEX_SELECTIONCOLOR;
940 static const eC_UInt INDEX_HELPERHORCOLOR;
941 static const eC_UInt INDEX_HELPERVERCOLOR;
942 static const eC_UInt INDEX_POINTCOLOR;
943 static const eC_UInt INDEX_LINECOLOR;
944 static const eC_UInt INDEX_BARCOLOR;
945
946 eC_UInt m_uiNumberPointColors;
947 eC_UInt m_uiNumberLineColors;
948 eC_UInt m_uiNumberBarColors;
949
951 ImageResource_t m_eImageBackground;
952
954 CGUIRect m_kChartArea;
955
957 eC_Bool m_bRestrictNavigation;
958
960 CGUIRect m_kFocusDataArea;
961
963 CGUIRect m_kDataBoundingBox;
964
966 eC_Bool m_bIsDataAreaDirty;
967
969 FontResource_t m_eFont;
970
972 eC_TArray<eC_TArray<Data_t> > m_kAllData;
973
974 //enums
975 DataRepresentation_t m_eDataRepresentation;
976 AxisRepresentation_t m_eXAxisRepresentation;
977 AxisRepresentation_t m_eYAxisRepresentation;
978
980 eC_Bool m_bDraggingMode;
981
983 CGUICommonEnums::AxisAlignment_t m_eHelperLinesRepresentation;
984
986 eC_Bool m_bEnableSelection;
987
988 //in how many parts is axis cut
989 eC_UInt m_uiScalingXAxis;
990 eC_UInt m_uiScalingYAxis;
991 // points of data so far
992 eC_Int m_iPointsOfData;
993
994 // points drawn
995 eC_Int m_iPointsAvailible;
996
997 // X zoom related
998 eC_Value m_vZoomFactorX;
999 eC_Value m_vZoomFactorY;
1000
1004 eC_Int m_iStartingNumber;
1005
1007 eC_Value m_vAxisLineWidth;
1008
1010 eC_Value m_vDrawLineWidth;
1011
1013 eC_Value m_vScaleLineLength;
1014
1016 eC_Value m_vBorderSize;
1017
1019 eC_Value m_vChartOffsetX;
1020
1022 eC_Value m_vChartOffsetY;
1023
1025 eC_Value m_vPointSize;
1026
1028 eC_Value m_vPointSelectionTolerance;
1029
1031 eC_Value m_vBarWidth;
1032
1034 eC_Value m_vXUnitWidthInPx;
1035
1037 eC_UInt m_uiSelectedChartIndex;
1038
1040 eC_UInt m_uiSelectedDataIndex;
1041
1043 eC_Bool m_bShowSelection;
1044
1046 eC_Value m_vMinYStepSize;
1047
1049 eC_Value m_vMinX;
1050 eC_Value m_vMaxX;
1051 eC_Value m_vMinY;
1052 eC_Value m_vMaxY;
1053};
1054
1055#endif // _GUICHART_H_
Helper Macros in Guiliani
FontResource_t
List of font resource ids.
Definition: GUIFontResource.h:54
Helper Macros in Guiliani
ImageResource_t
Enumeration of image resource ids.
Definition: GUIImageResource.h:126
ObjectHandle_t
List of object resource ids.
Definition: GUIObjectHandleResource.h:55
Helper Macros in Guiliani
GlobalProperty_t
List of property resource ids.
Definition: GUIPropertyResource.h:67
A single entry in the DataPool. The DataPoolEntry class represents a single entry (unique id + a valu...
Definition: GUIDataPool.h:108
This control can be used to visualize multiple data-sources in line- or bar-charts.
Definition: GUIChart.h:28
virtual void SetWidth(const eC_Value &vX)
void ZoomOutX()
void SetFont(const FontResource_t &eFontId)
eC_UInt GetVerticalHelperLineColor() const
CGUIChart(CGUICompositeObject *const pkParent, const eC_Value &vX, const eC_Value &vY, const eC_Value &vWidth, const eC_Value &vHeight, eC_UInt iAxisColor, eC_UInt TextLabelColor, eC_UInt DrawLineColor, eC_UInt DrawPointColor, eC_UInt BarColor, eC_Value AxisLineWidth, eC_Value DrawLineWidth, eC_Value vScaleLength, eC_Value vPointSize, eC_UInt uiScalingXAxis, eC_UInt uiScalingYAxis, eC_Value vMaxShownNumberY, eC_Value vMinShownNumberY, eC_Value vZoomFactorY, eC_UInt uiZoomFactorX, const ObjectHandle_t &eID=NO_HANDLE)
void SetZoomFactorX(const eC_Value &vZoomFactorX)
eC_Value GetDrawLineWidth() const
eC_Int GetStartLabelValue() const
void SetZoomFactorY(const eC_Value &vZoomFactorY)
void SetTextLabelColor(const eC_UInt &uiTextLabelColor)
virtual eC_Bool DoDrag(const eC_Value &vDeltaX, const eC_Value &vDeltaY, const eC_Value &vAbsX, const eC_Value &vAbsY)
void SetAxisColor(const eC_UInt &uiAxisColor)
void SetScalingXAxis(const eC_UInt &uiScalingXAxis)
void SetAxisColor(const GlobalProperty_t &eAxisColor)
virtual eC_Bool IsHighlightable() const
Definition: GUIChart.h:166
eC_UInt GetSelectionColor() const
void SetStandardImages()
void SetRepresentationYAxis(const AxisRepresentation_t &eYAxis)
eC_UInt GetAxisColor() const
DataRepresentation_t
enum how to disply values
Definition: GUIChart.h:32
@ RING
ring-chart (stacked datasets)
Definition: GUIChart.h:38
@ LINES
points and lines
Definition: GUIChart.h:35
@ PIE
pie-chart (only one dataset)
Definition: GUIChart.h:37
@ BARS
Bars Raising out of x-axis.
Definition: GUIChart.h:36
@ POINTS
only points
Definition: GUIChart.h:33
@ STACKED_BARS
stacked bars on top of each other
Definition: GUIChart.h:40
@ STACKED_LINES
stacked lines on top of each other
Definition: GUIChart.h:39
void SetHorizontalHelperLineColor(const eC_UInt &uiColor)
void SetTextLabelColor(const GlobalProperty_t &eTextLabelColor)
void SetImages(const ImageResource_t &eImageBG)
void SetRepresentationXAxis(const AxisRepresentation_t &eXAxis)
void SetHorizontalHelperLineColor(const GlobalProperty_t &eColor)
virtual eC_Bool DoClick(const eC_Value &vAbsX, const eC_Value &vAbsY)
void SetVerticalHelperLineColor(const eC_UInt &uiColor)
void ZoomInX()
void SetAxisLineWidth(const eC_Value &vAxisLineWidth)
void SetLineColor(const eC_UInt &uiIndex, const GlobalProperty_t &eLineColor)
void SetMinValueY(const eC_Value &vMinNumber)
virtual eC_Bool DoDragEnd(const eC_Value &vAbsX, const eC_Value &vAbsY)
void KeepLastXElemenets(const eC_UInt &uiDataAmountToKepp)
void SetScaleLength(const eC_Value &vScaleLength)
void SetRangeY(const eC_Value &vMinValue, const eC_Value &vMaxValue)
void SetSelectionColor(const GlobalProperty_t &eSelectionColor)
void WipeAllData()
AxisRepresentation_t GetRepresentationYAxis() const
CGUIChart(CGUICompositeObject *const pkParent, const eC_Value &vX, const eC_Value &vY, const eC_Value &vWidth, const eC_Value &vHeight, eC_Int iScalingXAxis, eC_Int iScalingYAxis, eC_Value vMaxShownNumberY, eC_Value vMinShownNumberY, const ObjectHandle_t &eID=NO_HANDLE)
virtual eC_Bool SetValue(CDataPoolEntry &rkValue)
virtual void ReadFromStream()
eC_Bool GetShowBarData() const
virtual eC_Bool DoDraw()
void SetSelectionColor(const eC_UInt &uiSelectionColor)
CGUIChart(CGUICompositeObject *const pkParent, const eC_Value &vX, const eC_Value &vY, const eC_Value &vWidth, const eC_Value &vHeight, const ObjectHandle_t &eID=NO_HANDLE)
virtual ~CGUIChart()
AxisRepresentation_t GetRepresentationXAxis() const
virtual void SetHeight(const eC_Value &vY)
void GetRangeX(eC_Int &iMinNumber, eC_Int &iMaxNumber) const
void GetRangeY(eC_Value &vMinValue, eC_Value &vMaxValue) const
void SetBarColor(const eC_UInt &uiIndex, const eC_UInt &uiBarColor)
void SetRangeX(const eC_Int &iMinNumber, const eC_Int &iMaxNumber)
void SetScalingYAxis(const eC_UInt &uiScalingYAxis)
eC_Value GetAxisLineWidth() const
CGUICommonEnums::AxisAlignment_t GetHelperLineRepresentation() const
void SetPointColor(const eC_UInt &uiIndex, const GlobalProperty_t &ePointColor)
void SetShowBarData(const eC_Bool &bShowBarData)
void SetDataRepresentation(const DataRepresentation_t &eDataRepresentation)
eC_UInt GetPointColor(const eC_UInt &uiIndex) const
void SetBarColor(const eC_UInt &uiIndex, const GlobalProperty_t &eBarColor)
void ZoomInY()
eC_UInt GetHorizontalHelperLineColor() const
CGUIRect GetFocusArea() const
void ZoomOutY()
eC_Value GetPointSize() const
void JumpToDataPoint(const eC_Int &iMinShownData)
eC_UInt GetScalingYAxis() const
void SetPointColor(const eC_UInt &uiIndex, const eC_UInt &uiPointColor)
void SetStartLabelValue(const eC_Int &iStartValue)
eC_UInt GetLineColor(const eC_UInt &uiIndex) const
eC_Value GetZoomFactorX() const
void JumpToTheEnd()
DataRepresentation_t GetDataRepresentation() const
virtual void WriteToStream(const eC_Bool bWriteClassID=false)
void SetVerticalHelperLineColor(const GlobalProperty_t &eColor)
AxisRepresentation_t
enum how the axis are displayed
Definition: GUIChart.h:45
@ LINE_AND_SCALING
Dots of data connected with 1 line.
Definition: GUIChart.h:48
@ LINE_SCALING_AND_TEXT
Bars Raising out of x-axis.
Definition: GUIChart.h:49
@ NONE
do not show axis
Definition: GUIChart.h:46
@ LINE
show only line of axis
Definition: GUIChart.h:47
eC_Value GetScaleLength() const
virtual eC_Bool DoButtonDown(const eC_Value &vAbsX, const eC_Value &vAbsY)
void SetLineColor(const eC_UInt &uiIndex, const eC_UInt &uiLineColor)
eC_UInt GetTextLabelColor() const
void SetDrawLineWidth(const eC_Value &vDrawLineWidth)
eC_UInt GetScalingXAxis() const
void SetMaxValueY(const eC_Value &vMaxNumber)
void SetHelperLineRepresentation(const CGUICommonEnums::AxisAlignment_t &eRepresentation)
void SetPointSize(const eC_Value &vPointSize)
eC_UInt GetBarColor(const eC_UInt &uiIndex) const
eC_Value GetZoomFactorY() const
void AddData(eC_Value vDataValue, eC_UInt uiDimension=0)
This observer provides the base-interface for controls when using color-properties.
Definition: GUIColorPropertyObserver.h:23
AxisAlignment_t
Axis-alignment for freedom of control.
Definition: GUICommonEnums.h:23
This is the Guiliani base class for all composite objects.
Definition: GUICompositeObject.h:70
This is the Guiliani base class all controls are derived from.
Definition: GUIObject.h:81
Helper class to supply a platform independent rectangle implementation.
Definition: GUIRect.h:63
Definition: GUIChart.h:55
eC_Value vOffset
offset values for stacked charts
Definition: GUIChart.h:57
eC_Value vData
data-value
Definition: GUIChart.h:56
eC_Int iNumberForLabel
current index
Definition: GUIChart.h:58