#ifndef Diagramm_H #define Diagramm_H #include "Array.h" #include "Critical.h" #include "Drawing.h" namespace Framework { class Border; //! Border.h class AlphaField; //! AlphaField.h class Text; //! Text.h class Font; //! Font.h class HScrollBar; //! Scroll.h class VScrollBar; //! Scroll.h class LineDiagram; //! from this file class BarDiagram; //! from this file class TextRenderer; //! A 2D GUI Framework drawing that draws a live diagram of values class LineDiagram : public DrawableBackground { public: class Style : public DrawableBackground::Style { public: //! A grid is drawn in the diagram for orientation static const __int64 Gitter = 0x01000; //! The names of the graphs are displayed static const __int64 LineName = 0x02000; //! Combination of flags Visible, Background, //! Border, Grid, LineName static const __int64 normal = Visible | Background | Border | Gitter | LineName; }; private: int gF; Array* lColor; RCArray* lName; RCArray>* ph; RCArray>* pb; Array* lastValue; TextRenderer* textRd; Point gitterGr; int lines; public: //! Constructor DLLEXPORT LineDiagram(); //! Destructor DLLEXPORT virtual ~LineDiagram(); //! Sets the used TextRenderer //! \param textRd The text renderer DLLEXPORT void setTextRendererZ(TextRenderer* textRd); //! Sets a pointer to the used font //! \param font The font DLLEXPORT void setFontZ(Font* font); //! Sets the spacing between the grid lines //! \param gr For x the spacing between each vertical line in //! pixels and for y the spacing between each horizontal line in //! the displayed y values DLLEXPORT void setGSize(Point& gr); //! Sets the color of the grid lines //! \param f The color in A8R8G8B8 format DLLEXPORT void setGColor(int f); //! Adds a new graph to the diagram //! \param name The name of the graph. It is displayed in the diagram //! when the LineName flag is set DLLEXPORT void addLine(const char* name); //! Adds a new graph to the diagram //! \param name The name of the graph. It is displayed in the diagram //! when the LineName flag is set DLLEXPORT void addLine(Text* txt); //! Sets the color of a graph //! \param lNum The index of the graph //! \param f The color in A8R8G8B8 format DLLEXPORT void setLColor(int lNum, int f); //! Adds a point to a graph. This shifts all points of the graph //! to the left so that the new point appears on the right. If a point //! goes off the left edge of the diagram, it is deleted. This way the //! diagram appears like a live measurement \param x The distance to the //! last point in pixels \param y The value of the displayed function at the point DLLEXPORT void addPoint(int lNum, int x, int h); //! Removes a graph //! \param lNum The index of the graph DLLEXPORT void removeLine(int lNum); //! Draws the diagram //! \param zRObj The image to draw into DLLEXPORT void render(Image& zRObj) override; //! Returns the used font DLLEXPORT Font* getFont() const; //! Returns the used font without increased reference counter DLLEXPORT Font* zFont() const; //! Returns the size of a grid square, where the width is in pixels //! and the height is in y axis values DLLEXPORT const Point& getGSize() const; //! Returns the color of the grid in A8R8G8B8 format DLLEXPORT int getGColor() const; //! Returns the index of a graph //! \param name The name of the graph DLLEXPORT int getLineNumber(const char* name) const; //! Returns the index of a graph //! \param name The name of the graph DLLEXPORT int getLineNumber(Text* name) const; //! Returns the name of a graph //! \param lNum The index of the graph DLLEXPORT Text* getLineName(int lNum) const; //! Returns the name of a graph without increased reference counter //! \param lNum The index of the graph DLLEXPORT Text* zLineNames(int lNum) const; //! Returns the highest y value of all graphs DLLEXPORT int getHighestValue() const; //! Returns the highest y value of a specific graph //! \param lNum The index of the graph DLLEXPORT int getHighestValue(int lNum) const; //! Returns the average value of all points stored in the diagram //! for a graph \param lNum The index of the graph DLLEXPORT int getMedian(int lNum) const; //! Returns the number of graphs DLLEXPORT int getLCount() const; //! Returns the y value of the last point of a graph //! \param lNum The index of the graph DLLEXPORT int getLastValue(int lNum) const; }; //! Point of a value in a diagram struct DiagramPoint { //! Position of the point on the horizontal interval of the diagram double hInterval; //! Position of the point on the vertical interval of the diagram double vInterval; }; //! Value that is visualized in a diagram struct DiagramValue : public virtual ReferenceCounter { //! Style of a diagram value class Style { public: static const int Visible = 0x01; //! Determines whether the value should be displayed static const int Alpha = 0x02; //! Determines whether alpha blending should be used //! when drawing the value static const int Background = 0x04; //! Determines whether the value has a background static const int HAlpha = 0x08; //! Determines whether alpha blending should be used //! when drawing the background static const int Name = 0x10; //! Determines whether the name of //! the value should be drawn }; //! Style of the value int style; //! Color of the value int color; //! Background color of the value int background; //! Name of the value Text* name; //! Points of the value Array* punkte; //! Constructor DLLEXPORT DiagramValue(); //! Destructor DLLEXPORT ~DiagramValue(); }; //! Data for a diagram struct DiagramData : public virtual ReferenceCounter { class Style { public: static const int Visible = 0x0001; //! Determines whether the data should be visible static const int Raster = 0x0002; //! Determines whether a grid for orientation //! should be displayed static const int RasterAlpha = 0x0004; //! Determines whether alpha blending should be used //! for drawing the grid static const int AutoIntervalHeight = 0x0008; //! Determines that all values are automatically scaled //! on the y axis so that the full height of the //! diagram is always used static const int AutoIntervalWidth = 0x0010; //! Determines that all values are automatically scaled //! on the x axis so that the full width of the //! diagram is always used static const int HInterval = 0x0020; //! Determines whether the X axis should be drawn static const int VInterval = 0x0040; //! Determines whether the Y axis should be drawn static const int HIntervalTexte = 0x0200; //! Determines whether custom texts for the X axis //! values should be drawn static const int VIntervalTexte = 0x0400; //! Determines whether custom texts for the Y axis //! values should be drawn static const int AutoGridWidth = 0x0800; //! Determines whether the spacing between vertical //! grid lines should be chosen automatically static const int AutoGridHeight = 0x1000; //! Determines whether the spacing between horizontal //! grid lines should be chosen automatically static const int intervale = HInterval | VInterval; //! Combines flags HInterval, VInterval static const int intervalTexte = HIntervalTexte | VIntervalTexte; //! Combines flags HIntervalTexte, //! VIntervalTexte static const int autoGrid = AutoGridHeight | AutoGridWidth | Raster; //! Combines flags AutoGridHeight, //! AutoGridWidth, Raster static const int autoInterval = AutoIntervalHeight | AutoIntervalWidth; //! Combines flags AutoIntervalHeight, //! AutoIntervalWidth }; //! Style of the diagram int style; //! Width of a grid line int rasterDicke; //! Width of a grid cell double gridWidth; //! Height of a grid cell double rasterHeight; //! Color of the grid int rasterColor; //! Font color of the horizontal interval int hIntervalColor; //! Font color of the vertical interval int vIntervalColor; //! Name of the horizontal interval Text* hIntervalName; //! Name of the vertical interval Text* vIntervalName; //! Labels of the horizontal interval RCArray* hIntervalTexte; //! Labels of the vertical interval RCArray* vIntervalTexte; //! Individual horizontal intervals Array* hIntervalWerte; //! Individual vertical intervals Array* vIntervalWerte; //! Width of value 1 in pixels for the horizontal interval (overridden //! by setting AutoIntervalWidth) double hIntervalWidth; //! Height of value 1 in pixels for the vertical interval (overridden //! by setting AutoIntervalHeight) double vIntervalHeight; //! Values visualized in the diagram RCArray* werte; //! Constructor DLLEXPORT DiagramData(); //! Destructor DLLEXPORT ~DiagramData(); }; //! Base class for the different diagram types class BaseDiagram { protected: DiagramData* daten; bool changed; Critical* lock; public: //! Constructor //! \param lock A pointer to the Critical used to make the diagram class //! that inherits from this class thread-safe DLLEXPORT BaseDiagram(Critical* lock); //! Destructor DLLEXPORT virtual ~BaseDiagram(); //! Sets a pointer to the diagram data //! \param dd The data DLLEXPORT void setDiagramDataZ(DiagramData* dd); //! Copies diagram data //! \param dd The data DLLEXPORT void setDiagramData(DiagramData* dd); //! Sets the grid line thickness //! \param d The width of a grid line in pixels DLLEXPORT void setGridThickness(int d); //! Sets the grid width //! \param br The spacing between two vertical grid lines in pixels DLLEXPORT void setGridWidth(int br); //! Sets the grid height //! \param hi The spacing between two horizontal grid lines in pixels DLLEXPORT void setGridHeight(int hi); //! Sets the grid color //! \param f The color in A8R8G8B8 format DLLEXPORT void setGridColor(int f); //! Sets the interval width //! \param br The distance between values 0 and 1 on the X axis in pixels DLLEXPORT void setHIntervalWidth(double br); //! Sets the interval height //! \param hi The distance between values 0 and 1 on the Y axis in pixels DLLEXPORT void setVIntervalHeight(double hi); //! Sets the color of the X axis //! \param f The color in A8R8G8B8 format DLLEXPORT void setHIntervalColor(int f); //! Sets the color of the Y axis //! \param f The color in A8R8G8B8 format DLLEXPORT void setVIntervalColor(int f); //! Sets the name of the X axis //! \param name The name DLLEXPORT void setHIntervalName(const char* name); //! Sets the name of the X axis //! \param name The name DLLEXPORT void setHIntervalName(Text* name); //! Sets the name of the Y axis //! \param name The name DLLEXPORT void setVIntervalName(const char* name); //! Sets the name of the Y axis //! \param name The name DLLEXPORT void setVIntervalName(Text* name); //! Labels a specific value on the X axis, if the HIntervalTexte flag //! was set in DiagramData \param hInterval The value to label //! \param text The label DLLEXPORT void addHIntervalText(double hInterval, const char* text); //! Labels a specific value on the X axis, if the HIntervalTexte flag //! was set in DiagramData \param hInterval The value to label //! \param text The label DLLEXPORT void addHIntervalText(double hInterval, Text* text); //! Sets a pointer to a label for a specific value on the X axis, //! if the HIntervalTexte flag was set in DiagramData //! \param hInterval The value to label //! \param text The label DLLEXPORT void setHIntervalTextZ(double hInterval, Text* text); //! Changes a label for a specific value on the X axis, if the //! HIntervalTexte flag was set in DiagramData \param hInterval The //! value to label \param text The label DLLEXPORT void setHIntervalText(double hInterval, Text* text); //! Changes a label for a specific value on the X axis, if the //! HIntervalTexte flag was set in DiagramData \param hInterval The //! value to label \param text The label DLLEXPORT void setHIntervalText(double hInterval, const char* text); //! Removes a label for a specific value on the X axis, //! if the HIntervalTexte flag was set in DiagramData \param //! hInterval The value that should no longer be labeled DLLEXPORT void removeHIntervalText(double hInterval); //! Labels a specific value on the Y axis, if the VIntervalTexte flag //! was set in DiagramData \param vInterval The value to label //! \param text The label DLLEXPORT void addVIntervalText(double vInterval, const char* text); //! Labels a specific value on the Y axis, if the VIntervalTexte flag //! was set in DiagramData \param vInterval The value to label //! \param text The label DLLEXPORT void addVIntervalText(double vInterval, Text* text); //! Sets a pointer to a label for a specific value on the Y axis, //! if the VIntervalTexte flag was set in DiagramData //! \param vInterval The value to label //! \param text The label DLLEXPORT void setVIntervalTextZ(double vInterval, Text* text); //! Changes a label for a specific value on the Y axis, if the //! VIntervalTexte flag was set in DiagramData \param vInterval The //! value to label \param text The label DLLEXPORT void setVIntervalText(double vInterval, Text* text); //! Changes a label for a specific value on the Y axis, if the //! VIntervalTexte flag was set in DiagramData \param vInterval The //! value to label \param text The label DLLEXPORT void setVIntervalText(double vInterval, const char* text); //! Removes a label for a specific value on the Y axis, //! if the VIntervalTexte flag was set in DiagramData \param //! vInterval The value that should no longer be labeled DLLEXPORT void removeVIntervalText(double vInterval); //! Adds a value (graph) displayed in the diagram //! \param w The new value DLLEXPORT void addValueZ(DiagramValue* w); //! Adds a value (graph) displayed in the diagram by copying //! another \param w The value to copy DLLEXPORT void addValue(DiagramValue* w); //! Adds a value (graph) displayed in the diagram //! \param name The name of the value DLLEXPORT void addValue(const char* name); //! Adds a value (graph) displayed in the diagram //! \param name The name of the value DLLEXPORT void addValue(Text* txt); //! Sets the color of a value //! \param wNum The index of the value //! \param fc The color in A8R8G8B8 format DLLEXPORT void setValueColor(int wNum, int fc); //! Adds a point to a value //! \param wNum The index of the value //! \param p The new point DLLEXPORT void addPointZ(int wNum, DiagramPoint* p); //! Adds a point to a value by copying a point //! \param wNum The index of the value //! \param p The point to copy DLLEXPORT void addPoint(int wNum, DiagramPoint* p); //! Adds a point to a value //! \param wNum The index of the value //! \param hI The value of the point on the X axis //! \param vI The value of the point on the Y axis DLLEXPORT void addPoint(int wNum, double hI, double vI); //! Sets a pointer to an existing point of a value //! \param wNum The index of the value //! \param hI The X axis value of the point to replace //! \param p The new point DLLEXPORT void setPointZ(int wNum, double hI, DiagramPoint* p); //! Sets an existing point of a value by copying a point //! \param wNum The index of the value \param hI The X axis value of //! the point to replace \param p The new point DLLEXPORT void setPoint(int wNum, double hI, DiagramPoint* p); //! Sets an existing point of a value //! \param wNum The index of the value //! \param hI The X axis value of the point to replace //! \param h The X axis value of the new point \param v //! The Y axis value of the new point DLLEXPORT void setPoint(int wNum, double hI, double h, double v); //! Sets a pointer to an existing point of a value //! \param wNum The index of the value //! \param pNum The index of the point in the value //! \param p The new point DLLEXPORT void setPointZ(int wNum, int pNum, DiagramPoint* p); //! Sets an existing point of a value by copying a point //! \param wNum The index of the value \param pNum The index of the //! point in the value \param p The new point DLLEXPORT void setPoint(int wNum, int pNum, DiagramPoint* p); //! Sets an existing point of a value //! \param wNum The index of the value //! \param pNum The index of the point in the value //! \param h The X axis value of the new point //! \param v The Y axis value of the new point DLLEXPORT void setPoint(int wNum, int pNum, double h, double v); //! Deletes an existing point //! \param wNum The index of the value //! \param hI The X axis value of the point to delete DLLEXPORT void removePoint(int wNum, double hI); //! Deletes an existing point //! \param wNum The index of the value //! \param pNum The index of the point in the value DLLEXPORT void removePoint(int wNum, int pNum); //! Removes a value //! \param wNum The index of the value DLLEXPORT void removeValue(int wNum); //! Removes a value //! \param name The name of the value DLLEXPORT void removeValue(const char* name); //! Removes a value //! \param name The name of the value DLLEXPORT void removeValue(Text* name); //! Adds styles to the DiagramData //! \param style The new styles DLLEXPORT void addDataStyle(int style); //! Sets the styles of the DiagramData //! \param style The new styles DLLEXPORT void setDataStyle(int style); //! Sets the styles of the DiagramData //! \param style The styles //! \param addRemove 1 if the styles should be added. 0 if the styles //! should be removed DLLEXPORT void setDataStyle(int style, bool addRemove); //! Removes styles from the DiagramData //! \param style The styles to remove DLLEXPORT void removeDataStyle(int style); //! Adds styles to a specific value //! \param wNum The index of the value //! \param style The new styles DLLEXPORT void addValueStyle(int wNum, int style); //! Sets the styles of a specific value //! \param wNum The index of the value //! \param style The new styles DLLEXPORT void setValueStyle(int wNum, int style); //! Sets the styles of a specific value //! \param wNum The index of the value //! \param style The styles //! \param addRemove 1 if the styles should be added. 0 if the styles //! should be removed DLLEXPORT void setValueStyle(int wNum, int style, bool addRemove); //! Removes styles from a specific value //! \param wNum The index of the value //! \param style The styles to remove DLLEXPORT void removeValueStyle(int wNum, int style); //! Returns the diagram data DLLEXPORT DiagramData* getDiagramData() const; //! Returns the diagram data without increased reference counter DLLEXPORT DiagramData* zDiagramData() const; //! Returns the data of a value //! \param wNum The index of the value DLLEXPORT DiagramValue* getDiagramValue(int wNum) const; //! Returns the data of a value without increased reference counter //! \param wNum The index of the value DLLEXPORT DiagramValue* zDiagramValue(int wNum) const; //! Returns the data of a value //! \param name The name of the value DLLEXPORT DiagramValue* getDiagramValue(const char* name) const; //! Returns the data of a value without increased reference counter //! \param name The name of the value DLLEXPORT DiagramValue* zDiagramValue(const char* name) const; //! Returns the index of a value //! \param name The name of the value DLLEXPORT int getDiagramValuePos(const char* name) const; //! Returns the index of a point from a value //! \param wNum The index of the value //! \param hI The X axis value of the point DLLEXPORT int getDiagramPointPos(int wNum, double hI) const; //! Returns the index of a point from a value //! \param wName The name of the value //! \param hI The X axis value of the point DLLEXPORT int getDiagramPointPos(char* wName, double hI) const; //! Checks whether specific styles are set in the DiagramData //! \param style The styles DLLEXPORT inline bool hasDataStyle(int style) const; //! Checks whether specific styles are not set in the DiagramData //! \param style The styles DLLEXPORT inline bool hasDataStyleNot(int style) const; //! Checks whether specific styles are set for a specific value //! \param wNum The index of the value //! \param style The styles DLLEXPORT inline bool hasValueStyle(int wNum, int style) const; //! Checks whether specific styles are not set for a specific value //! \param wNum The index of the value \param style The styles DLLEXPORT inline bool hasValueStyleNot(int wNum, int style) const; }; //! A 2D GUI Framework drawing that displays diagram data as //! line graphs class BarDiagram : public DrawableBackground, public BaseDiagram { public: class Style : public DrawableBackground::Style { public: //! Determines whether a border is drawn around the data static const __int64 DataBorder = 0x0001000; //! Determines whether the data has a background static const __int64 DataBackground = 0x02000; //! Determines whether alpha blending is used when drawing //! the data background static const __int64 DataHAlpha = 0x04000; //! Determines whether an image is used for the data background static const __int64 DataHImage = 0x008000; //! Determines whether the data has a color gradient static const __int64 DataBuffered = 0x010000; //! Combines flags VScroll and HScroll static const __int64 scroll = VScroll | HScroll; //! Combines flags Background, scroll, DataBorder static const __int64 normal = Background | scroll | DataBorder; }; private: TextRenderer* textRd; Border* dRam; int dBgF; Image* dBgB; AlphaField* dAf; Image* vIntervalRB; Image* hIntervalRB; int fontGr; //! Processes mouse messages //! \param me The event triggered by the mouse input DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override; public: //! Constructor DLLEXPORT BarDiagram(); //! Destructor DLLEXPORT virtual ~BarDiagram(); //! Sets the used TextRenderer //! \param textRd The text renderer DLLEXPORT void setTextRendererZ(TextRenderer* textRd); //! Sets the font //! \param font The font DLLEXPORT void setFontZ(Font* font); //! Sets the font size //! \param gr The height of a line in pixels DLLEXPORT void setFontSize(int gr); //! Sets the inner border around the actual diagram (border around the //! data) \param ram The border DLLEXPORT void setDataBorderZ(Border* ram); //! Sets the inner border around the actual diagram (border around the //! data) by copying a border \param ram The border to copy DLLEXPORT void setDataBorder(Border* ram); //! Sets the width of the inner border around the actual diagram //! (border around the data) \param br The width in pixels DLLEXPORT void setDataBorderWidth(int br); //! Sets the color of the inner border around the actual diagram //! (border around the data) \param fc The color in A8R8G8B8 format DLLEXPORT void setDataBorderColor(int fc); //! Sets the background of the actual diagram DLLEXPORT void setDataBackgroundColor(int fc); DLLEXPORT void setDataBackgroundImageZ(Image* b); DLLEXPORT void setDataBackgroundImage(Image* b); //! Sets the color gradient of the actual diagram (color gradient of //! the data) \param af The color gradient DLLEXPORT void setDataAlphaFieldZ(AlphaField* af); //! Sets the color gradient of the actual diagram (color gradient of //! the data) by copying a color gradient \param af The color //! gradient to copy DLLEXPORT void setDataAlphaField(AlphaField* af); //! Sets the color of the color gradient of the actual diagram //! (color gradient of the data) \param fc The color in A8R8G8B8 format DLLEXPORT void setDataAlphaFieldColor(int fc); //! Sets the strength of the color gradient of the actual diagram //! (color gradient of the data) \param st The strength DLLEXPORT void setDataAlphaFieldStrength(int st); //! Draws the object to zRObj if it is visible //! \param zRObj The image to draw into DLLEXPORT void render(Image& zRObj) override; //! Returns the font DLLEXPORT Font* getFont() const; //! Returns the font without increased reference counter DLLEXPORT Font* zFont() const; //! Returns the inner border around the actual diagram (border around //! the data) DLLEXPORT Border* getDataBorder() const; //! Returns the inner border around the actual diagram without increased //! reference counter (border around the data) DLLEXPORT Border* zDataBorder() const; //! Returns the color of the inner border around the actual diagram in //! A8R8G8B8 format (border around the data) DLLEXPORT int getDataBorderColor() const; //! Returns the width of the inner border around the actual diagram in //! pixels (border around the data) DLLEXPORT int getDataBorderWidth() const; //! Returns the background color of the actual diagram in //! A8R8G8B8 format (background of the data) DLLEXPORT int getDataBackgroundColor() const; //! Returns the background image of the actual diagram //! (background image of the data) DLLEXPORT Image* getDataBackgroundImage() const; //! Returns the background image of the actual diagram without increased //! reference counter (background image of the data) DLLEXPORT Image* zDataBackgroundImage() const; //! Returns the color gradient of the actual diagram //! (color gradient of the data) DLLEXPORT AlphaField* getDataAlphaField() const; //! Returns the color gradient of the actual diagram without increased //! reference counter (color gradient of the data) DLLEXPORT AlphaField* zDataAlphaField() const; //! Returns the color of the color gradient of the actual diagram in //! A8R8G8B8 format (color gradient of the data) DLLEXPORT int getDataAlphaFieldColor() const; //! Returns the strength of the color gradient of the actual diagram //! (color gradient of the data) DLLEXPORT int getDataAlphaFieldStrength() const; }; } // namespace Framework #endif