summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/ResultsSummaryWindow.cpp
blob: 8170591865c9fb178052d81d21de9f6bebe4e7a7 (plain)
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
// Copyright 2007 Nanorex, Inc.  See LICENSE file for details.

#include "ResultsSummaryWindow.h"


/* CONSTRUCTOR */
ResultsSummaryWindow::ResultsSummaryWindow(const QString& filename,
										   NXDataStoreInfo* dataStoreInfo,
										   QWidget *parent)
		: DataWindow(parent), Ui_ResultsSummaryWindow() {
	this->dataStoreInfo = dataStoreInfo;

	setupUi(this);
	QString title = tr("Results Summary - %1").arg(filename);
	setWindowTitle(title);
	setWindowFlags(Qt::Dialog | Qt::Tool);
	printSummary();
}


/* DESTRUCTOR */
ResultsSummaryWindow::~ResultsSummaryWindow() {
}


/* FUNCTION: refresh */
void ResultsSummaryWindow::refresh() {
	printSummary();
}


/* FUNCTION: printSummary */
void ResultsSummaryWindow::printSummary() {
	NXProperties* properties = dataStoreInfo->getResultsSummary();
	if (properties == NULL) {
		textEdit->insertHtml(tr("<i><b>Results Summary</b><br>No results summary found.</i>"));
		
	} else {
		QString html =
			QString("<i><b>Results Summary</b></i><br><table border=0 cellspacing=0 cellpadding=0>");
		vector<string> keys = properties->getPropertyKeys();
		vector<string>::iterator iter = keys.begin();
		string key, value, units;
		while (iter != keys.end()) {
			key = *iter;
			value = properties->getProperty(*iter);
			if (value != "") {
				formatParameter(key, value, units);
				html.append
					(tr("<tr><td align=right><b>%1: </b></td>%2 %3</tr>")
					 .arg(key.c_str()).arg(value.c_str()).arg(units.c_str()));
			}
			iter++;
		}
		html.append("</table>");
		textEdit->clear();
		textEdit->setHtml(html);
	}
}