9895ddc39c09a68743fdeba14440184e249dc51a
[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_Quit
44         };
45
46         struct Action
47         {
48                 ActionType type;
49                 Real x, y;
50                 int ix, iy;
51                 Real z;
52                 int iz;
53                 int loops;
54                 std::string textargs;
55                 Action() : type(AT_WaitFrame), x(0), y(0), ix(0), iy(0), z(0), loops(0), textargs("") {}
56         };
57
58         std::ifstream inp;
59
60         Action currentAction;
61         std::vector<Action> m_actions;
62         std::map<std::string, int> m_labels;
63         unsigned m_index;
64         
65         struct PerformanceData
66         {
67                 clock_t clock;
68                 unsigned object_count;
69                 Rect view_bounds;
70         };
71         
72         PerformanceData m_perf_start;
73         PerformanceData m_perf_last;
74         
75         void PrintPerformance(View * view, Screen * scr);
76         void ClearPerformance(View * view, Screen * scr);
77         
78         void ParseAction();
79 };
80
81 }
82
83 #endif

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