13 this->plotManager = plotManager;
15 auto* file =
new QFile(fileName);
17 if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
21 QXmlStreamReader xml(file);
23 while(!xml.atEnd() && !xml.hasError()) {
26 QXmlStreamReader::TokenType token = xml.readNext();
29 if(token == QXmlStreamReader::StartDocument) {
32 if(token == QXmlStreamReader::StartElement) {
33 if(xml.name() ==
"portscope") {
34 QXmlStreamAttributes attributes = xml.attributes();
36 if(attributes.hasAttribute(
"rows")) {
39 if(attributes.hasAttribute(
"columns")) {
42 if(attributes.hasAttribute(
"carrier")) {
45 if(attributes.hasAttribute(
"persistent")) {
52 if (xml.name() ==
"plot") {
54 QXmlStreamAttributes plotAttributes = xml.attributes();
68 if(plotAttributes.hasAttribute(
"title")) {
69 plot_title = plotAttributes.value(
"title").toString();
71 if(plotAttributes.hasAttribute(
"gridx")) {
72 plot_gridx = plotAttributes.value(
"gridx").toInt();
74 if(plotAttributes.hasAttribute(
"gridy")) {
75 plot_gridy = plotAttributes.value(
"gridy").toInt();
77 if(plotAttributes.hasAttribute(
"hspan")) {
78 plot_hspan = plotAttributes.value(
"hspan").toInt();
80 if(plotAttributes.hasAttribute(
"vspan")) {
81 plot_vspan = plotAttributes.value(
"vspan").toInt();
83 if(plotAttributes.hasAttribute(
"minval")) {
84 plot_minval = plotAttributes.value(
"minval").toFloat();
86 if(plotAttributes.hasAttribute(
"maxval")) {
87 plot_maxval = plotAttributes.value(
"maxval").toFloat();
89 if(plotAttributes.hasAttribute(
"size")) {
90 plot_size = plotAttributes.value(
"size").toInt();
92 if(plotAttributes.hasAttribute(
"bgcolor")) {
93 plot_bgcolor = plotAttributes.value(
"bgcolor").toString();
95 if(plotAttributes.hasAttribute(
"autorescale")) {
96 plot_autorescale = QVariant(plotAttributes.value(
"autorescale").toString()).toBool();
98 if(plotAttributes.hasAttribute(
"realtime")) {
99 plot_realtime = QVariant(plotAttributes.value(
"realtime").toString()).toBool();
101 if(plotAttributes.hasAttribute(
"triggermode")) {
102 plot_triggermode = QVariant(plotAttributes.value(
"triggermode").toString()).toBool();
105 plotter = plotManager->
addPlot(plot_title, plot_gridx, plot_gridy, plot_hspan, plot_vspan, plot_minval, plot_maxval, plot_size, plot_bgcolor, plot_autorescale);
106 Q_UNUSED(plot_realtime);
107 Q_UNUSED(plot_triggermode);
111 if (xml.name() ==
"graph") {
113 QXmlStreamAttributes graphAttributes = xml.attributes();
114 QString graph_remote;
119 double graph_y_scale;
122 if(graphAttributes.hasAttribute(
"remote")) {
123 graph_remote = graphAttributes.value(
"remote").toString();
125 qCritical(R
"(Syntax error while loading %s. "remote" attribute not found in element "graph")",fileName.toLatin1().data());
128 if(graphAttributes.hasAttribute(
"index")) {
129 graph_index = graphAttributes.value(
"index").toInt();
130 if(graph_index < 0) {
131 qCritical(R
"(Syntax error while loading %s. "index" attribute not found in element "graph")",fileName.toLatin1().data());
135 qCritical(R
"(Syntax error while loading %s. "index" attribute in element "graph" should be >= 0)",fileName.toLatin1().data());
138 if(graphAttributes.hasAttribute(
"title")) {
139 graph_title = graphAttributes.value(
"title").toString();
141 if(graphAttributes.hasAttribute(
"rescale_y_factor")) {
142 graph_y_scale = graphAttributes.value(
"rescale_y_factor").toDouble();
148 if(graphAttributes.hasAttribute(
"color")) {
149 graph_color = graphAttributes.value(
"color").toString();
151 if(graphAttributes.hasAttribute(
"type")) {
152 graph_type = graphAttributes.value(
"type").toString();
154 if(graphAttributes.hasAttribute(
"size")) {
155 graph_size = graphAttributes.value(
"size").toInt();
162 Graph *graph = plotter->
addGraph(graph_remote,
"",graph_index,graph_title, graph_color, graph_type, graph_size, graph_y_scale);
Plotter * addPlot(const QString &title, int gridx, int gridy, int hspan, int vspan, float minval, float maxval, int size, const QString &bgcolor, bool autorescale)
Adds a new Plotter.
Graph * addGraph(QString remotePort, QString localPort, int index, QString title, QString color, QString type, int size, double graph_y_scale=1.0)
Add a Graph to the current Plotter.