#ifndef Diagramm_H #define Diagramm_H #include "Array.h" #include "Critical.h" #include "Drawing.h" namespace Framework { class Rahmen; //! Border.h class AlphaFeld; //! AlphaField.h class Text; //! Text.h class Schrift; //! Font.h class HScrollBar; //! Scroll.h class VScrollBar; //! Scroll.h class SLDiag; //! from this file class LDiag; //! from this file class TextRenderer; //! A 2D GUI Framework drawing that draws a live diagram of values class SLDiag : public ZeichnungHintergrund { public: class Style : public ZeichnungHintergrund::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 LinienName = 0x02000; //! Combination of flags Visible, Background, //! Border, Grid, LineName static const __int64 normal = Sichtbar | Hintergrund | Rahmen | Gitter | LinienName; }; private: int gF; Array* lFarbe; RCArray* lName; RCArray>* ph; RCArray>* pb; Array* lastValue; TextRenderer* textRd; Punkt gitterGr; int lines; public: //! Constructor DLLEXPORT SLDiag(); //! Destructor DLLEXPORT virtual ~SLDiag(); //! Sets the used TextRenderer //! \param textRd The text renderer DLLEXPORT void setTextRendererZ(TextRenderer* textRd); //! Sets a pointer to the used font //! \param schrift The font DLLEXPORT void setSchriftZ(Schrift* schrift); //! 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(Punkt& gr); //! Sets the color of the grid lines //! \param f The color in A8R8G8B8 format DLLEXPORT void setGFarbe(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 addLinie(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 addLinie(Text* txt); //! Sets the color of a graph //! \param lNum The index of the graph //! \param f The color in A8R8G8B8 format DLLEXPORT void setLFarbe(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 addPunkt(int lNum, int x, int h); //! Removes a graph //! \param lNum The index of the graph DLLEXPORT void removeLinie(int lNum); //! Draws the diagram //! \param zRObj The image to draw into DLLEXPORT void render(Bild& zRObj) override; //! Returns the used font DLLEXPORT Schrift* getSchrift() const; //! Returns the used font without increased reference counter DLLEXPORT Schrift* zSchrift() const; //! Returns the size of a grid square, where the width is in pixels //! and the height is in y axis values DLLEXPORT const Punkt& getGSize() const; //! Returns the color of the grid in A8R8G8B8 format DLLEXPORT int getGFarbe() const; //! Returns the index of a graph //! \param name The name of the graph DLLEXPORT int getLinienNummer(const char* name) const; //! Returns the index of a graph //! \param name The name of the graph DLLEXPORT int getLinienNummer(Text* name) const; //! Returns the name of a graph //! \param lNum The index of the graph DLLEXPORT Text* getLinienName(int lNum) const; //! Returns the name of a graph without increased reference counter //! \param lNum The index of the graph DLLEXPORT Text* zLinienNamen(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 getLAnzahl() 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 DiagPunkt { //! Position of the point on the horizontal interval of the diagram double hIntervall; //! Position of the point on the vertical interval of the diagram double vIntervall; }; //! Value that is visualized in a diagram struct DiagWert : public virtual ReferenceCounter { //! Style of a diagram value class Style { public: static const int Sichtbar = 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 Hintergrund = 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 farbe; //! Background color of the value int hintergrund; //! Name of the value Text* name; //! Points of the value Array* punkte; //! Constructor DLLEXPORT DiagWert(); //! Destructor DLLEXPORT ~DiagWert(); }; //! Data for a diagram struct DiagDaten : public virtual ReferenceCounter { class Style { public: static const int Sichtbar = 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 AutoIntervallHeight = 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 AutoIntervallBreite = 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 HIntervall = 0x0020; //! Determines whether the X axis should be drawn static const int VIntervall = 0x0040; //! Determines whether the Y axis should be drawn static const int HIntervallTexte = 0x0200; //! Determines whether custom texts for the X axis //! values should be drawn static const int VIntervallTexte = 0x0400; //! Determines whether custom texts for the Y axis //! values should be drawn static const int AutoRasterBreite = 0x0800; //! Determines whether the spacing between vertical //! grid lines should be chosen automatically static const int AutoRasterHeight = 0x1000; //! Determines whether the spacing between horizontal //! grid lines should be chosen automatically static const int intervalle = HIntervall | VIntervall; //! Combines flags HIntervall, VIntervall static const int intervallTexte = HIntervallTexte | VIntervallTexte; //! Combines flags HIntervallTexte, //! VIntervallTexte static const int autoRaster = AutoRasterHeight | AutoRasterBreite | Raster; //! Combines flags AutoRasterHeight, //! AutoRasterBreite, Raster static const int autoIntervall = AutoIntervallHeight | AutoIntervallBreite; //! Combines flags AutoIntervallHeight, //! AutoIntervallBreite }; //! Style of the diagram int style; //! Width of a grid line int rasterDicke; //! Width of a grid cell double rasterBreite; //! Height of a grid cell double rasterHeight; //! Color of the grid int rasterFarbe; //! Font color of the horizontal interval int hIntervallFarbe; //! Font color of the vertical interval int vIntervallFarbe; //! Name of the horizontal interval Text* hIntervallName; //! Name of the vertical interval Text* vIntervallName; //! Labels of the horizontal interval RCArray* hIntervallTexte; //! Labels of the vertical interval RCArray* vIntervallTexte; //! Individual horizontal intervals Array* hIntervallWerte; //! Individual vertical intervals Array* vIntervallWerte; //! Width of value 1 in pixels for the horizontal interval (overridden //! by setting AutoIntervallBreite) double hIntervallBreite; //! Height of value 1 in pixels for the vertical interval (overridden //! by setting AutoIntervallHeight) double vIntervallHeight; //! Values visualized in the diagram RCArray* werte; //! Constructor DLLEXPORT DiagDaten(); //! Destructor DLLEXPORT ~DiagDaten(); }; //! Base class for the different diagram types class BaseDiag { protected: DiagDaten* 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 BaseDiag(Critical* lock); //! Destructor DLLEXPORT virtual ~BaseDiag(); //! Sets a pointer to the diagram data //! \param dd The data DLLEXPORT void setDiagDatenZ(DiagDaten* dd); //! Copies diagram data //! \param dd The data DLLEXPORT void setDiagDaten(DiagDaten* dd); //! Sets the grid line thickness //! \param d The width of a grid line in pixels DLLEXPORT void setRasterDicke(int d); //! Sets the grid width //! \param br The spacing between two vertical grid lines in pixels DLLEXPORT void setRasterBreite(int br); //! Sets the grid height //! \param hi The spacing between two horizontal grid lines in pixels DLLEXPORT void setRasterHeight(int hi); //! Sets the grid color //! \param f The color in A8R8G8B8 format DLLEXPORT void setRasterFarbe(int f); //! Sets the interval width //! \param br The distance between values 0 and 1 on the X axis in pixels DLLEXPORT void setHIntervallBreite(double br); //! Sets the interval height //! \param hi The distance between values 0 and 1 on the Y axis in pixels DLLEXPORT void setVIntervallHeight(double hi); //! Sets the color of the X axis //! \param f The color in A8R8G8B8 format DLLEXPORT void setHIntervallFarbe(int f); //! Sets the color of the Y axis //! \param f The color in A8R8G8B8 format DLLEXPORT void setVIntervallFarbe(int f); //! Sets the name of the X axis //! \param name The name DLLEXPORT void setHIntervallName(const char* name); //! Sets the name of the X axis //! \param name The name DLLEXPORT void setHIntervallName(Text* name); //! Sets the name of the Y axis //! \param name The name DLLEXPORT void setVIntervallName(const char* name); //! Sets the name of the Y axis //! \param name The name DLLEXPORT void setVIntervallName(Text* name); //! Labels a specific value on the X axis, if the HIntervallTexte flag //! was set in DiagDaten \param hIntervall The value to label //! \param text The label DLLEXPORT void addHIntervallText(double hIntervall, const char* text); //! Labels a specific value on the X axis, if the HIntervallTexte flag //! was set in DiagDaten \param hIntervall The value to label //! \param text The label DLLEXPORT void addHIntervallText(double hIntervall, Text* text); //! Sets a pointer to a label for a specific value on the X axis, //! if the HIntervallTexte flag was set in DiagDaten //! \param hIntervall The value to label //! \param text The label DLLEXPORT void setHIntervallTextZ(double hIntervall, Text* text); //! Changes a label for a specific value on the X axis, if the //! HIntervallTexte flag was set in DiagDaten \param hIntervall The //! value to label \param text The label DLLEXPORT void setHIntervallText(double hIntervall, Text* text); //! Changes a label for a specific value on the X axis, if the //! HIntervallTexte flag was set in DiagDaten \param hIntervall The //! value to label \param text The label DLLEXPORT void setHIntervallText(double hIntervall, const char* text); //! Removes a label for a specific value on the X axis, //! if the HIntervallTexte flag was set in DiagDaten \param //! hIntervall The value that should no longer be labeled DLLEXPORT void removeHIntervallText(double hIntervall); //! Labels a specific value on the Y axis, if the VIntervallTexte flag //! was set in DiagDaten \param vIntervall The value to label //! \param text The label DLLEXPORT void addVIntervallText(double vIntervall, const char* text); //! Labels a specific value on the Y axis, if the VIntervallTexte flag //! was set in DiagDaten \param vIntervall The value to label //! \param text The label DLLEXPORT void addVIntervallText(double vIntervall, Text* text); //! Sets a pointer to a label for a specific value on the Y axis, //! if the VIntervallTexte flag was set in DiagDaten //! \param vIntervall The value to label //! \param text The label DLLEXPORT void setVIntervallTextZ(double vIntervall, Text* text); //! Changes a label for a specific value on the Y axis, if the //! VIntervallTexte flag was set in DiagDaten \param vIntervall The //! value to label \param text The label DLLEXPORT void setVIntervallText(double vIntervall, Text* text); //! Changes a label for a specific value on the Y axis, if the //! VIntervallTexte flag was set in DiagDaten \param vIntervall The //! value to label \param text The label DLLEXPORT void setVIntervallText(double vIntervall, const char* text); //! Removes a label for a specific value on the Y axis, //! if the VIntervallTexte flag was set in DiagDaten \param //! vIntervall The value that should no longer be labeled DLLEXPORT void removeVIntervallText(double vIntervall); //! Adds a value (graph) displayed in the diagram //! \param w The new value DLLEXPORT void addWertZ(DiagWert* w); //! Adds a value (graph) displayed in the diagram by copying //! another \param w The value to copy DLLEXPORT void addWert(DiagWert* w); //! Adds a value (graph) displayed in the diagram //! \param name The name of the value DLLEXPORT void addWert(const char* name); //! Adds a value (graph) displayed in the diagram //! \param name The name of the value DLLEXPORT void addWert(Text* txt); //! Sets the color of a value //! \param wNum The index of the value //! \param fc The color in A8R8G8B8 format DLLEXPORT void setWertFarbe(int wNum, int fc); //! Adds a point to a value //! \param wNum The index of the value //! \param p The new point DLLEXPORT void addPunktZ(int wNum, DiagPunkt* 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 addPunkt(int wNum, DiagPunkt* 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 addPunkt(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 setPunktZ(int wNum, double hI, DiagPunkt* 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 setPunkt(int wNum, double hI, DiagPunkt* 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 setPunkt(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 setPunktZ(int wNum, int pNum, DiagPunkt* 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 setPunkt(int wNum, int pNum, DiagPunkt* 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 setPunkt(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 removePunkt(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 removePunkt(int wNum, int pNum); //! Removes a value //! \param wNum The index of the value DLLEXPORT void removeWert(int wNum); //! Removes a value //! \param name The name of the value DLLEXPORT void removeWert(const char* name); //! Removes a value //! \param name The name of the value DLLEXPORT void removeWert(Text* name); //! Adds styles to the DiagDaten //! \param style The new styles DLLEXPORT void addDatenStyle(int style); //! Sets the styles of the DiagDaten //! \param style The new styles DLLEXPORT void setDatenStyle(int style); //! Sets the styles of the DiagDaten //! \param style The styles //! \param addRemove 1 if the styles should be added. 0 if the styles //! should be removed DLLEXPORT void setDatenStyle(int style, bool addRemove); //! Removes styles from the DiagDaten //! \param style The styles to remove DLLEXPORT void removeDatenStyle(int style); //! Adds styles to a specific value //! \param wNum The index of the value //! \param style The new styles DLLEXPORT void addWertStyle(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 setWertStyle(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 setWertStyle(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 removeWertStyle(int wNum, int style); //! Returns the diagram data DLLEXPORT DiagDaten* getDiagDaten() const; //! Returns the diagram data without increased reference counter DLLEXPORT DiagDaten* zDiagDaten() const; //! Returns the data of a value //! \param wNum The index of the value DLLEXPORT DiagWert* getDiagWert(int wNum) const; //! Returns the data of a value without increased reference counter //! \param wNum The index of the value DLLEXPORT DiagWert* zDiagWert(int wNum) const; //! Returns the data of a value //! \param name The name of the value DLLEXPORT DiagWert* getDiagWert(const char* name) const; //! Returns the data of a value without increased reference counter //! \param name The name of the value DLLEXPORT DiagWert* zDiagWert(const char* name) const; //! Returns the index of a value //! \param name The name of the value DLLEXPORT int getDiagWertPos(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 getDiagPunktPos(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 getDiagPunktPos(char* wName, double hI) const; //! Checks whether specific styles are set in the DiagDaten //! \param style The styles DLLEXPORT inline bool hatDatenStyle(int style) const; //! Checks whether specific styles are not set in the DiagDaten //! \param style The styles DLLEXPORT inline bool hatDatenStyleNicht(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 hatWertStyle(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 hatWertStyleNicht(int wNum, int style) const; }; //! A 2D GUI Framework drawing that displays diagram data as //! line graphs class LDiag : public ZeichnungHintergrund, public BaseDiag { public: class Style : public ZeichnungHintergrund::Style { public: //! Determines whether a border is drawn around the data static const __int64 DatenRahmen = 0x0001000; //! Determines whether the data has a background static const __int64 DatenHintergrund = 0x02000; //! Determines whether alpha blending is used when drawing //! the data background static const __int64 DatenHAlpha = 0x04000; //! Determines whether an image is used for the data background static const __int64 DatenHBild = 0x008000; //! Determines whether the data has a color gradient static const __int64 DatenBuffered = 0x010000; //! Combines flags VScroll and HScroll static const __int64 scroll = VScroll | HScroll; //! Combines flags Background, scroll, DataBorder static const __int64 normal = Hintergrund | scroll | DatenRahmen; }; private: TextRenderer* textRd; Rahmen* dRam; int dBgF; Bild* dBgB; AlphaFeld* dAf; Bild* vIntervallRB; Bild* hIntervallRB; int schriftGr; //! Processes mouse messages //! \param me The event triggered by the mouse input DLLEXPORT void doMausEreignis(MausEreignis& me, bool userRet) override; public: //! Constructor DLLEXPORT LDiag(); //! Destructor DLLEXPORT virtual ~LDiag(); //! Sets the used TextRenderer //! \param textRd The text renderer DLLEXPORT void setTextRendererZ(TextRenderer* textRd); //! Sets the font //! \param schrift The font DLLEXPORT void setSchriftZ(Schrift* schrift); //! Sets the font size //! \param gr The height of a line in pixels DLLEXPORT void setSchriftSize(int gr); //! Sets the inner border around the actual diagram (border around the //! data) \param ram The border DLLEXPORT void setDatenRahmenZ(Rahmen* 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 setDatenRahmen(Rahmen* ram); //! Sets the width of the inner border around the actual diagram //! (border around the data) \param br The width in pixels DLLEXPORT void setDatenRahmenBreite(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 setDatenRahmenFarbe(int fc); //! Sets the background of the actual diagram DLLEXPORT void setDatenHintergrundFarbe(int fc); DLLEXPORT void setDatenHintergrundBildZ(Bild* b); DLLEXPORT void setDatenHintergrundBild(Bild* b); //! Sets the color gradient of the actual diagram (color gradient of //! the data) \param af The color gradient DLLEXPORT void setDatenAlphaFeldZ(AlphaFeld* 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 setDatenAlphaFeld(AlphaFeld* 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 setDatenAlphaFeldFarbe(int fc); //! Sets the strength of the color gradient of the actual diagram //! (color gradient of the data) \param st The strength DLLEXPORT void setDatenAlphaFeldStrength(int st); //! Draws the object to zRObj if it is visible //! \param zRObj The image to draw into DLLEXPORT void render(Bild& zRObj) override; //! Returns the font DLLEXPORT Schrift* getSchrift() const; //! Returns the font without increased reference counter DLLEXPORT Schrift* zSchrift() const; //! Returns the inner border around the actual diagram (border around //! the data) DLLEXPORT Rahmen* getDatenRahmen() const; //! Returns the inner border around the actual diagram without increased //! reference counter (border around the data) DLLEXPORT Rahmen* zDatenRahmen() const; //! Returns the color of the inner border around the actual diagram in //! A8R8G8B8 format (border around the data) DLLEXPORT int getDatenRahmenFarbe() const; //! Returns the width of the inner border around the actual diagram in //! pixels (border around the data) DLLEXPORT int getDatenRahmenBreite() const; //! Returns the background color of the actual diagram in //! A8R8G8B8 format (background of the data) DLLEXPORT int getDatenHintergrundFarbe() const; //! Returns the background image of the actual diagram //! (background image of the data) DLLEXPORT Bild* getDatenHintergrundBild() const; //! Returns the background image of the actual diagram without increased //! reference counter (background image of the data) DLLEXPORT Bild* zDatenHintergrundBild() const; //! Returns the color gradient of the actual diagram //! (color gradient of the data) DLLEXPORT AlphaFeld* getDatenAlphaFeld() const; //! Returns the color gradient of the actual diagram without increased //! reference counter (color gradient of the data) DLLEXPORT AlphaFeld* zDatenAlphaFeld() const; //! Returns the color of the color gradient of the actual diagram in //! A8R8G8B8 format (color gradient of the data) DLLEXPORT int getDatenAlphaFeldFarbe() const; //! Returns the strength of the color gradient of the actual diagram //! (color gradient of the data) DLLEXPORT int getDatenAlphaFeldStrength() const; }; } // namespace Framework #endif