Gmprat logarithms now O(1) not O(N)
[ipdf/code.git] / src / debugscript.h
1 #ifndef _DEBUGSCRIPT_H
2 #define _DEBUGSCRIPT_H
3
4 #include "real.h"
5 #include "view.h"
6 #include "screen.h"
7 #include <iostream>
8 #include <fstream>
9
10 namespace IPDF
11 {
12
13 class DebugScript
14 {
15 public:
16         DebugScript() : inp(), currentAction(), m_actions(), m_labels(), m_index(0) {}
17         virtual ~DebugScript() {}
18         void Load(const char *filename)
19         {
20                 inp.open(filename);
21         }
22         bool Execute(View *view, Screen *scr);
23 private:
24         enum ActionType
25         {
26                 AT_WaitFrame,
27                 AT_Translate,
28                 AT_Zoom,
29                 AT_TranslatePx,
30                 AT_ZoomPx,
31                 AT_SetCPURendering,
32                 AT_SetGPURendering,
33                 AT_EnableLazyRendering,
34                 AT_DisableLazyRendering,
35                 AT_LoadSVG,
36                 AT_Label,
37                 AT_Goto,
38                 AT_Debug,
39                 AT_ClearDocument,
40                 AT_ClearPerformance,
41                 AT_PrintPerformance,
42                 AT_RecordPerformance,
43                 AT_DebugFont,
44                 AT_Quit
45         };
46
47         struct Action
48         {
49                 ActionType type;
50                 Real x, y;
51                 int ix, iy;
52                 Real z;
53                 int iz;
54                 int loops;
55                 std::string textargs;
56                 Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
57         };
58
59         std::ifstream inp;
60
61         Action currentAction;
62         std::vector<Action> m_actions;
63         std::map<std::string, int> m_labels;
64         unsigned m_index;
65         
66         struct PerformanceData
67         {
68                 clock_t clock;
69                 unsigned object_count;
70                 Rect view_bounds;
71         };
72         
73         PerformanceData m_perf_start;
74         PerformanceData m_perf_last;
75         
76         void PrintPerformance(View * view, Screen * scr);
77         void ClearPerformance(View * view, Screen * scr);
78         
79         void ParseAction();
80 };
81
82 }
83
84 #endif

UCC git Repository :: git.ucc.asn.au