~om26er/ubuntu/oneiric/nux/sru-819721

« back to all changes in this revision

Viewing changes to Nux/TimeGraph.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-18 19:17:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101118191732-rn35790vekj6o4my
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
14
 * You should have received a copy of both the GNU Lesser General Public
 
15
 * License version 3 along with this program.  If not, see
 
16
 * <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef TIMEGRAPH_H
 
24
#define TIMEGRAPH_H
 
25
 
 
26
#include "NuxGraphics/GpuDevice.h"
 
27
#include "NuxGraphics/GLDeviceObjects.h"
 
28
#include "NuxGraphics/GLSh_DrawFunction.h"
 
29
#include "TimerProc.h"
 
30
 
 
31
namespace nux
 
32
{
 
33
 
 
34
  typedef float (*FunctionCallback) (float);
 
35
 
 
36
  class VLayout;
 
37
  class HLayout;
 
38
  class Button;
 
39
  class StaticTextBox;
 
40
  class InputArea;
 
41
 
 
42
  class TimeGraph : public View
 
43
  {
 
44
  public:
 
45
    TimeGraph (const TCHAR *Title, NUX_FILE_LINE_PROTO);
 
46
    ~TimeGraph();
 
47
    virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
48
    virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
 
49
    virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
 
50
    virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
 
51
 
 
52
    void AddValue (float Value);
 
53
    void SetYAxisBounds (float minY, float maxY);
 
54
    unsigned int AddGraph (Color PrimaryColor, Color SecondaryColor);
 
55
    void UpdateGraph (unsigned int index, float Value);
 
56
 
 
57
    void RecvShowBarGraphics (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
58
    void RecvShowCurveGraphics (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
59
    void RecvShowValue (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
60
    void ShowGraphStyle();
 
61
    void ShowColumnStyle();
 
62
    void ShowNumberStyle();
 
63
  protected:
 
64
    void InitializeWidgets();
 
65
    void InitializeLayout();
 
66
    void DestroyLayout();
 
67
 
 
68
  private:
 
69
    static unsigned int sBufferSize;
 
70
    VLayout        *m_vlayout;
 
71
    HLayout        *m_hlayout;
 
72
    HLayout        *m_hlayout2;
 
73
    Button         *m_button;
 
74
    StaticTextBox  *m_GraphTitle;
 
75
    CoreArea       *m_GraphArea;
 
76
    CoreArea       *m_GraphIcon;
 
77
    CoreArea       *m_GraphBarIcon;
 
78
    CoreArea       *m_ValueIcon;
 
79
    NString m_Title;
 
80
 
 
81
    float m_arg0;
 
82
    float m_arg1;
 
83
    float m_arg2;
 
84
    float m_arg3;
 
85
 
 
86
    enum
 
87
    {
 
88
      SHOW_GRAPH,
 
89
      SHOW_COLUMN,
 
90
      SHOW_VALUE
 
91
    };
 
92
 
 
93
    class Graph
 
94
    {
 
95
    public:
 
96
      Graph (Color PrimaryColor, Color SecondaryColor);
 
97
      Graph (const Graph &graph);
 
98
      Graph &operator = (const Graph &graph);
 
99
      ~Graph();
 
100
      void Update (float Value);
 
101
      void Clear();
 
102
      void Reset();
 
103
      std::list<float> m_ValueList;
 
104
      // ! Set to true if the graph has been updated during the graphic refresh period.
 
105
      bool m_HasBeenUpdated;
 
106
      Color m_PrimaryColor;
 
107
      Color m_SecondaryColor;
 
108
    };
 
109
 
 
110
    unsigned int m_Option;
 
111
 
 
112
    std::vector<Graph> m_DynValueArray;
 
113
    unsigned int m_DynValueCount;
 
114
    bool m_DynValueReceived;
 
115
 
 
116
    void GraphTimerInterrupt (void *v);
 
117
    TimerFunctor *m_ScrollTimerFunctor;
 
118
    TimerHandle m_ScrollTimerHandler;
 
119
 
 
120
    float m_minY, m_maxY;
 
121
    FunctionCallback m_FunctionCallback;
 
122
 
 
123
    IntrusiveSP<IOpenGLBaseTexture> Texture;
 
124
    TextureLayer *m_BackgroundLayer;
 
125
    GLSh_DrawFunction *m_DrawFunctionShader;
 
126
  };
 
127
 
 
128
 
 
129
}
 
130
 
 
131
#endif // TIMEGRAPH_H