nux-0.9.46
|
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 void DestroyLayout(); 00068 00069 private: 00070 static unsigned int sBufferSize; 00071 VLayout *m_vlayout; 00072 HLayout *m_hlayout; 00073 HLayout *m_hlayout2; 00074 StaticTextBox *m_GraphTitle; 00075 InputArea *m_GraphArea; 00076 InputArea *m_GraphIcon; 00077 InputArea *m_GraphBarIcon; 00078 InputArea *m_ValueIcon; 00079 NString m_Title; 00080 00081 enum 00082 { 00083 SHOW_GRAPH = 0, 00084 SHOW_COLUMN, 00085 SHOW_VALUE 00086 }; 00087 00088 class Graph 00089 { 00090 public: 00091 Graph (Color PrimaryColor, Color SecondaryColor); 00092 Graph (const Graph &graph); 00093 Graph &operator = (const Graph &graph); 00094 ~Graph(); 00095 void Update (float Value); 00096 void Clear(); 00097 void Reset(); 00098 std::list<float> m_ValueList; 00099 // ! Set to true if the graph has been updated during the graphic refresh period. 00100 bool m_HasBeenUpdated; 00101 Color m_PrimaryColor; 00102 Color m_SecondaryColor; 00103 }; 00104 00105 unsigned int m_Option; 00106 00107 std::vector<Graph> m_DynValueArray; 00108 00109 float m_minY, m_maxY; 00110 00111 ObjectPtr<IOpenGLBaseTexture> Texture; 00112 TextureLayer *m_BackgroundLayer; 00113 GLSh_DrawFunction *m_DrawFunctionShader; 00114 }; 00115 00116 00117 } 00118 00119 #endif // TIMEGRAPH_H