nux-1.14.0
TimeGraph.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef TIMEGRAPH_H
00024 #define TIMEGRAPH_H
00025 
00026 #include "NuxGraphics/GpuDevice.h"
00027 #include "NuxGraphics/GLDeviceObjects.h"
00028 #include "NuxGraphics/GLSh_DrawFunction.h"
00029 #include "TimerProc.h"
00030 
00031 namespace nux
00032 {
00033 
00034   typedef float (*FunctionCallback) (float);
00035 
00036   class VLayout;
00037   class HLayout;
00038   class Button;
00039   class StaticTextBox;
00040   class InputArea;
00041 
00042   class TimeGraph : public View
00043   {
00044     NUX_DECLARE_OBJECT_TYPE (TimeGraph, View);
00045   public:
00046     TimeGraph (const TCHAR *Title, NUX_FILE_LINE_PROTO);
00047     ~TimeGraph();
00048     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00049     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00050     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00051     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00052 
00053     void AddValue (float Value);
00054     void SetYAxisBounds (float minY, float maxY);
00055     unsigned int AddGraph (Color PrimaryColor, Color SecondaryColor);
00056     void UpdateGraph (unsigned int index, float Value);
00057 
00058     void RecvShowBarGraphics (int x, int y, unsigned long button_flags, unsigned long key_flags);
00059     void RecvShowCurveGraphics (int x, int y, unsigned long button_flags, unsigned long key_flags);
00060     void RecvShowValue (int x, int y, unsigned long button_flags, unsigned long key_flags);
00061     void ShowGraphStyle();
00062     void ShowColumnStyle();
00063     void ShowNumberStyle();
00064   protected:
00065     void InitializeWidgets();
00066     void InitializeLayout();
00067 
00068   private:
00069     static unsigned int sBufferSize;
00070     VLayout        *m_vlayout;
00071     HLayout        *m_hlayout;
00072     HLayout        *m_hlayout2;
00073     StaticTextBox  *m_GraphTitle;
00074     InputArea       *m_GraphArea;
00075     InputArea       *m_GraphIcon;
00076     InputArea       *m_GraphBarIcon;
00077     InputArea       *m_ValueIcon;
00078     NString m_Title;
00079 
00080     enum
00081     {
00082       SHOW_GRAPH = 0,
00083       SHOW_COLUMN,
00084       SHOW_VALUE
00085     };
00086 
00087     class Graph
00088     {
00089     public:
00090       Graph (Color PrimaryColor, Color SecondaryColor);
00091       Graph (const Graph &graph);
00092       Graph &operator = (const Graph &graph);
00093       ~Graph();
00094       void Update (float Value);
00095       void Clear();
00096       void Reset();
00097       std::list<float> m_ValueList;
00098       // ! Set to true if the graph has been updated during the graphic refresh period.
00099       bool m_HasBeenUpdated;
00100       Color m_PrimaryColor;
00101       Color m_SecondaryColor;
00102     };
00103 
00104     unsigned int m_Option;
00105 
00106     std::vector<Graph> m_DynValueArray;
00107 
00108     float m_minY, m_maxY;
00109 
00110     ObjectPtr<IOpenGLBaseTexture> Texture;
00111     TextureLayer *m_BackgroundLayer;
00112     GLSh_DrawFunction *m_DrawFunctionShader;
00113   };
00114 
00115 
00116 }
00117 
00118 #endif // TIMEGRAPH_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends