This repository was archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
99 lines (71 loc) · 2 KB
/
main.cpp
File metadata and controls
99 lines (71 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <QApplication>
#include <QFile>
#include <QXmlStreamReader>
#include <QtDebug>
#include "Main/system.h"
#include <QElapsedTimer>
#include "UI/mainwindow.h"
void debugParser()
{
QString appPath = QCoreApplication::applicationDirPath();
QElapsedTimer t;
t.start();
// Select&open model file - currently still static
const QString path = appPath + "/../SLX-Viewer/Tests/blockdiagram.xml";
QFile *f = new QFile(path);
f->open(QIODevice::ReadOnly);
// Create input stream
QXmlStreamReader *in = new QXmlStreamReader;
in->setDevice( f );
// Create and read system
System s(in);
qDebug() << "Loading time: " << t.elapsed() << " ms for " << in->lineNumber() << " lines";
f->close();
}
void debugRenderer()
{
QString appPath = QCoreApplication::applicationDirPath();
// Select&open model file - currently still static
const QString path = appPath + "/../SLX-Viewer/Tests/blockdiagram.xml";
QFile *f = new QFile(path);
f->open(QIODevice::ReadOnly);
QElapsedTimer t;
t.start();
// Create input stream
QXmlStreamReader *in = new QXmlStreamReader;
in->setDevice( f );
// Create and read system
System s(in);
qDebug() << "Model loading time: " << t.elapsed() << " ms";
t.restart();
// Render system
QPixmap map = s.render();
qDebug() << "Rendering time: " << t.elapsed() << " ms";
map.save(appPath + "/../SLX-Viewer/Tests/model.png");
if( in->hasError() )
{
// Error handling
qDebug() << "An error has occured...";
}
f->close();
}
void debugUI()
{
MainWindow w;
w.show();
}
int main(int argc, char *argv[])
{
const int DEBUG_PARSER = 1;
const int DEBUG_RENDERER = 2;
const int DEBUG_UI = 3;
QApplication app(argc,argv);
int action = DEBUG_RENDERER;
if( action == DEBUG_PARSER )
debugParser();
else if( action == DEBUG_RENDERER )
debugRenderer();
else if( action == DEBUG_UI )
debugUI();
return 0;
}