Browse Source

Adds Precompiled Header.

Tom Troppmann 4 years ago
parent
commit
74ed542818

BIN
Distribution.PNG


+ 0 - 232
metavis/CustomLineGraph.cpp

@@ -1,232 +0,0 @@
-#include "CustomLineGraph.h"
-
-#include <QDebug>
-#include <QBrush>
-#include <random>
-#include <algorithm>
-
-#define X_AXIS_GAP_AMOUNT 5
-#define Y_AXIS_GAP_AMOUNT 10
-#define X_AXIS_NUMBER_LINE_LENGTH 5
-#define Y_AXIS_NUMBER_LINE_LENGTH 5
-
-
-
-CustomLineGraph::CustomLineGraph(QWidget* parent, QString title, int lineWidth, double circleRadius):QWidget(parent), title(title), lineWidth(lineWidth), circleRadius(circleRadius), linePen(Qt::blue), rectPen(Qt::red), axisPen(Qt::black)
-{
-	linePen.setWidth(lineWidth);
-	linePen.setJoinStyle(Qt::PenJoinStyle::RoundJoin);
-	
-	//Populate data with DummyData
-	//Draw Points
-	std::random_device rd;  //Will be used to obtain a seed for the random number engine
-	std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
-	std::uniform_real_distribution<double> doubleDistr(0.0, 1.0);
-	hueoffset = doubleDistr(gen);
-	
-}
-
-CustomLineGraph::~CustomLineGraph()
-{
-}
-void CustomLineGraph::paintEvent(QPaintEvent* event)
-{
-	QPainter painter(this);
-	painter.setRenderHint(QPainter::RenderHint::HighQualityAntialiasing);
-	if (seriesVec.empty()) {
-		painter.setPen(axisPen);
-		painter.setFont(QFont("Arial", 12, QFont::Bold));
-		painter.drawText(rect(), Qt::AlignCenter, "No Data connected");
-		return;
-	}
-	//Calculate LineRect
-	QRect lineRect(rect());
-	lineRect.setBottom(lineRect.bottom() - 20);
-	lineRect.setLeft(lineRect.left() + 40);
-	lineRect.setTop(lineRect.top() + 20);
-	lineRect.setRight(lineRect.right() - 10);
-	lineRect.setWidth(lineRect.width() - (lineRect.width() % X_AXIS_GAP_AMOUNT) + 1);
-	lineRect.setHeight(lineRect.height() - (lineRect.height() % Y_AXIS_GAP_AMOUNT) + 1);
-
-
-	//draw Title
-	painter.setPen(axisPen);
-	painter.setFont(QFont("Arial", 12));
-	QRect titleRect(QPoint(rect().left(), rect().top()), QPoint(lineRect.right(), lineRect.top()));
-	painter.drawText(titleRect, Qt::AlignCenter, title);
-
-	painter.setFont(QFont("Arial", 8));
-	//draw X-Axis
-	QRect xAxisRect(QPoint(lineRect.left(), lineRect.bottom()), QPoint(lineRect.right(), rect().bottom()));
-	QPainterPath xAxisPath;
-	xAxisPath.moveTo(xAxisRect.left(), xAxisRect.top());
-	xAxisPath.lineTo(xAxisRect.right(), xAxisRect.top());
-	int xGap = xAxisRect.width() / X_AXIS_GAP_AMOUNT;
-	QRect textRect(0, 0, 40, 9);
-
-	for (int i = 0; i < 11; i++) {
-		xAxisPath.moveTo(xAxisRect.left() + i * xGap, xAxisRect.top() + X_AXIS_NUMBER_LINE_LENGTH);
-		xAxisPath.lineTo(xAxisRect.left() + i * xGap, xAxisRect.top());
-		textRect.moveCenter(QPoint(xAxisRect.left() + i * xGap, xAxisRect.top() + 10));
-		painter.drawText(textRect, Qt::AlignCenter, xAxisNumbers[i]);
-	}
-	painter.drawPath(xAxisPath);
-
-	//draw Y-Axis
-	QRect yAxisRect(QPoint(rect().left(), lineRect.top()), QPoint(lineRect.left(), lineRect.bottom()));
-	QPainterPath yAxisPath;
-	yAxisPath.moveTo(yAxisRect.right(), yAxisRect.bottom());
-	yAxisPath.lineTo(yAxisRect.right(), yAxisRect.top());
-	int yGap = yAxisRect.height() / Y_AXIS_GAP_AMOUNT;
-	for (int i = 0; i < 11; i++) {
-		yAxisPath.moveTo(yAxisRect.right() - Y_AXIS_NUMBER_LINE_LENGTH, yAxisRect.bottom() - i * yGap);
-		yAxisPath.lineTo(yAxisRect.right(), yAxisRect.bottom() - i * yGap);
-		textRect.moveCenter(QPoint(yAxisRect.right() - Y_AXIS_NUMBER_LINE_LENGTH - 20, yAxisRect.bottom() - i * yGap));
-		painter.drawText(textRect, Qt::AlignCenter, yAxisNumbers[i]);
-	}
-	painter.drawPath(yAxisPath);
-
-
-
-	
-	
-
-	painter.setPen(linePen);
-	double stregth_factorX = lineRect.width() / rangeGraphX;
-	double stregth_factorY = lineRect.height() / rangeGraphY;
-	for (LineGraphSeries lgs : seriesVec) {
-		linePen.setColor(lgs.color);
-		painter.setPen(linePen);
-		QPointF translation(lineRect.left(), lineRect.top());
-		if (!lgs.type == LineGraphSeries::Dot) {
-			QPainterPath painterPath;
-			painterPath.moveTo(transformPoint(lgs.data[0], stregth_factorX, stregth_factorY));
-			for(int i = 1; i < lgs.data.size(); i++) {
-				painterPath.lineTo(transformPoint(lgs.data[i], stregth_factorX, stregth_factorY));
-			}
-			painterPath.translate(translation);
-			painter.drawPath(painterPath);
-		}
-		/* only draw when circle can be seen*/
-		if (!(lineWidth > 4 * circleRadius || circleRadius == 0)) {
-			painter.setBrush(lgs.color);
-			for (int i = 0; i < lgs.data.size(); i++) {
-				painter.drawEllipse(transformPoint(lgs.data[i], stregth_factorX, stregth_factorY) + translation, circleRadius, circleRadius);
-			}
-			painter.setBrush(Qt::BrushStyle::NoBrush);
-		}
-	}
-	
-}
-
-QPointF CustomLineGraph::transformPoint(QPointF& point, double stregth_factorX, double stregth_factorY)
-{
-	return QPointF((point.x() - minGraphX)* stregth_factorX , (maxGraphY - point.y()) * stregth_factorY);
-}
-
-void CustomLineGraph::calculateMinMaxGraphXY()
-{
-	minGraphX = std::min_element(std::begin(seriesVec), std::end(seriesVec), [](const LineGraphSeries& a, const LineGraphSeries& b) -> bool {return a.minX < b.minX; })->minX;
-	maxGraphX = std::max_element(std::begin(seriesVec), std::end(seriesVec), [](const LineGraphSeries& a, const LineGraphSeries& b) -> bool {return a.maxX < b.maxX; })->maxX;
-	minGraphY = std::min_element(std::begin(seriesVec), std::end(seriesVec), [](const LineGraphSeries& a, const LineGraphSeries& b) -> bool {return a.minY < b.minY; })->minY;
-	maxGraphY = std::max_element(std::begin(seriesVec), std::end(seriesVec), [](const LineGraphSeries& a, const LineGraphSeries& b) -> bool {return a.maxY < b.maxY; })->maxY;
-	rangeGraphX = std::abs(maxGraphX - minGraphX);
-	rangeGraphY = std::abs(maxGraphY - minGraphY);
-	if (std::abs(rangeGraphX) < 0.01) {
-		minGraphX -= 1.0;
-		maxGraphX += 1.0;
-		rangeGraphX = 2;
-	}
-	if (std::abs(rangeGraphY) < 0.01) {
-		minGraphY -= 1.0;
-		maxGraphY += 1.0;
-		rangeGraphY = 2;
-	}
-}
-
-void CustomLineGraph::popullateLineGraphSeries(std::vector<QPointF>& line, LineGraphSeries& lgs)
-{
-	lgs.data = line;
-	auto pairX = std::minmax_element(std::begin(lgs.data), std::end(lgs.data), [](const QPointF& a, const QPointF& b) -> bool {return a.x() < b.x(); });
-	lgs.minX = pairX.first->x();
-	lgs.maxX = pairX.second->x();
-	auto pairY = std::minmax_element(std::begin(lgs.data), std::end(lgs.data), [](const QPointF& a, const QPointF& b) -> bool {return a.y() < b.y(); });
-	lgs.minY = pairY.first->y();
-	lgs.maxY = pairY.second->y();
-}
-
-void CustomLineGraph::addSeries(std::vector<QPointF>& line, QColor color, LineGraphSeries::SeriesType type)
-{
-	if (line.empty()) {
-		return;
-	}
-	LineGraphSeries lgs;
-	lgs.type = type;
-	popullateLineGraphSeries(line, lgs);
-	lgs.color = color;
-	seriesVec.push_back(lgs);
-	calculateMinMaxGraphXY();
-	generateAxisNumberStrings();
-}
-
-QColor CustomLineGraph::generateNextColorForGraph()
-{
-	/* http://devmag.org.za/2012/07/29/how-to-choose-colours-procedurally-algorithms/
-		use golden ratio 0.618033988749895f
-	*/
-	hueoffset = std::fmod(hueoffset + 0.618033988749895f, 1.0);
-	return QColor::fromHsvF(hueoffset, 0.83, 1.0);
-}
-
-void CustomLineGraph::generateAxisNumberStrings()
-{
-	for (int i = 0; i < 11; i++) {
-		xAxisNumbers[i] = QString::number(minGraphX + i * (rangeGraphX / (double)X_AXIS_GAP_AMOUNT), 'f', 1);
-		yAxisNumbers[i] = QString::number(minGraphY + i * (rangeGraphY / (double)Y_AXIS_GAP_AMOUNT), 'f', 1);
-	}
-}
-
-void CustomLineGraph::generateAndAddRandomLine()
-{
-	std::random_device rd;  //Will be used to obtain a seed for the random number engine
-	std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
-
-
-	std::uniform_real_distribution<double> realDistr(-30, 30);
-	std::uniform_int_distribution<int> intScaleDistr(1, 3);
-
-	for (int randomSeries = 0; randomSeries < 1; randomSeries++) {
-		std::vector<QPointF> randomPointVec(101);
-		int scale = intScaleDistr(gen);
-		for (int i = 0; i < randomPointVec.size(); i++) {
-			randomPointVec[i] = QPointF(i + 500, i * scale + realDistr(gen));
-		}
-		addLine(randomPointVec);
-	}
-}
-
-void CustomLineGraph::addLine(std::vector<QPointF>& line)
-{
-	addLine(line, generateNextColorForGraph());
-}
-
-void CustomLineGraph::addLine(std::vector<QPointF>& line, QColor color)
-{
-	addSeries(line, color, LineGraphSeries::Line);
-}
-
-void CustomLineGraph::addDots(std::vector<QPointF>& dots)
-{
-	addSeries(dots, generateNextColorForGraph(), LineGraphSeries::Dot);
-}
-
-void CustomLineGraph::addDots(std::vector<QPointF>& dots, QColor color)
-{
-	addSeries(dots, color, LineGraphSeries::Dot);
-}
-
-
-
-
-
-

+ 229 - 0
metavis/GraphView.cpp

@@ -0,0 +1,229 @@
+#include "pch.h"
+#include "GraphView.h"
+
+#include <QDebug>
+#include <QBrush>
+#include <random>
+#include <algorithm>
+
+#define X_AXIS_GAP_AMOUNT 5
+#define Y_AXIS_GAP_AMOUNT 10
+#define X_AXIS_NUMBER_LINE_LENGTH 5
+#define Y_AXIS_NUMBER_LINE_LENGTH 5
+#define X_AXIS_NUMBER_GAP_LENGTH 10
+#define Y_AXIS_NUMBER_GAP_LENGTH 20
+
+
+GraphView::GraphView(QWidget* parent, QString title) :QWidget(parent), title(title), linePen(Qt::blue), rectPen(Qt::red), axisPen(Qt::black)
+{
+	
+	linePen.setJoinStyle(Qt::PenJoinStyle::RoundJoin);
+
+	//Populate data with DummyData
+	//Draw Points
+	std::random_device rd;  //Will be used to obtain a seed for the random number engine
+	std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
+	std::uniform_real_distribution<double> doubleDistr(0.0, 1.0);
+	hueoffset = doubleDistr(gen);
+
+}
+
+GraphView::~GraphView()
+{
+}
+void GraphView::paintEvent(QPaintEvent* event)
+{
+	QPainter painter(this);
+	painter.setRenderHint(QPainter::RenderHint::HighQualityAntialiasing);
+	if (graphSeriesVec.empty()) {
+		painter.setPen(axisPen);
+		painter.setFont(QFont("Arial", 12, QFont::Bold));
+		painter.drawText(rect(), Qt::AlignCenter, "No Data connected");
+		return;
+	}
+	//Calculate LineRect
+	QRect graphDisplayRect(rect());
+	graphDisplayRect.setBottom(graphDisplayRect.bottom() - 20);
+	graphDisplayRect.setLeft(graphDisplayRect.left() + 50);
+	graphDisplayRect.setTop(graphDisplayRect.top() + 20);
+	graphDisplayRect.setRight(graphDisplayRect.right() - 10);
+	graphDisplayRect.setWidth(graphDisplayRect.width() - (graphDisplayRect.width() % X_AXIS_GAP_AMOUNT) + 1);
+	graphDisplayRect.setHeight(graphDisplayRect.height() - (graphDisplayRect.height() % Y_AXIS_GAP_AMOUNT) + 1);
+
+	//Font for Axis;
+	painter.setFont(QFont("Arial", 8));
+	//draw X-Axis
+	QRect xAxisRect(QPoint(graphDisplayRect.left(), graphDisplayRect.bottom()), QPoint(graphDisplayRect.right(), rect().bottom()));
+	QPainterPath xAxisPath;
+	xAxisPath.moveTo(xAxisRect.left(), xAxisRect.top());
+	xAxisPath.lineTo(xAxisRect.right(), xAxisRect.top());
+	int xGap = xAxisRect.width() / X_AXIS_GAP_AMOUNT;
+	QRect textRect(0, 0, 40, 9);
+
+	for (int i = 0; i < 11; i++) {
+		xAxisPath.moveTo(xAxisRect.left() + i * xGap, xAxisRect.top() + X_AXIS_NUMBER_LINE_LENGTH);
+		xAxisPath.lineTo(xAxisRect.left() + i * xGap, xAxisRect.top());
+		textRect.moveCenter(QPoint(xAxisRect.left() + i * xGap, xAxisRect.top() + X_AXIS_NUMBER_GAP_LENGTH));
+		painter.drawText(textRect, Qt::AlignCenter, xAxisNumbers[i]);
+	}
+	painter.drawPath(xAxisPath);
+
+	//draw Y-Axis
+	QRect yAxisRect(QPoint(rect().left(), graphDisplayRect.top()), QPoint(graphDisplayRect.left(), graphDisplayRect.bottom()));
+	QPainterPath yAxisPath;
+	yAxisPath.moveTo(yAxisRect.right(), yAxisRect.bottom());
+	yAxisPath.lineTo(yAxisRect.right(), yAxisRect.top());
+	int yGap = yAxisRect.height() / Y_AXIS_GAP_AMOUNT;
+	for (int i = 0; i < 11; i++) {
+		yAxisPath.moveTo(yAxisRect.right() - Y_AXIS_NUMBER_LINE_LENGTH, yAxisRect.bottom() - i * yGap);
+		yAxisPath.lineTo(yAxisRect.right(), yAxisRect.bottom() - i * yGap);
+		textRect.moveCenter(QPoint(yAxisRect.right() - Y_AXIS_NUMBER_GAP_LENGTH, yAxisRect.bottom() - i * yGap));
+		painter.drawText(textRect, Qt::AlignCenter, yAxisNumbers[i]);
+	}
+	painter.drawPath(yAxisPath);
+
+
+
+
+
+
+	painter.setPen(linePen);
+	double stregth_factorX = graphDisplayRect.width() / rangeGraphX;
+	double stregth_factorY = graphDisplayRect.height() / rangeGraphY;
+	for (GraphSeries graphSeries : graphSeriesVec) {
+		linePen.setColor(graphSeries.color);
+		painter.setPen(linePen);
+		QPointF translation(graphDisplayRect.left(), graphDisplayRect.top());
+
+		if (graphSeries.type == GraphSeries::SeriesType::Line || graphSeries.type == GraphSeries::SeriesType::LineDot) {
+			linePen.setWidth(graphSeries.lineWidth);
+			painter.setPen(linePen);
+			QPainterPath painterPath;
+			painterPath.moveTo(transformPoint(graphSeries.data->at(0), stregth_factorX, stregth_factorY));
+			for (int i = 1; i < graphSeries.data->size(); i++) {
+				painterPath.lineTo(transformPoint(graphSeries.data->at(i), stregth_factorX, stregth_factorY));
+			}
+			painterPath.translate(translation);
+			painter.drawPath(painterPath);
+		}
+		if (graphSeries.type == GraphSeries::SeriesType::Dot || graphSeries.type == GraphSeries::SeriesType::LineDot) {
+			painter.setBrush(graphSeries.color);
+			for (int i = 0; i < graphSeries.data->size(); i++) {
+				painter.drawEllipse(transformPoint(graphSeries.data->at(i), stregth_factorX, stregth_factorY) + translation, graphSeries.circleRadius, graphSeries.circleRadius);
+			}
+			painter.setBrush(Qt::BrushStyle::NoBrush);
+		}
+	}
+}
+
+QPointF GraphView::transformPoint(QPointF& point, double stregth_factorX, double stregth_factorY)
+{
+	return QPointF((point.x() - minGraphX) * stregth_factorX, (maxGraphY - point.y()) * stregth_factorY);
+}
+
+void GraphView::calculateMinMaxGraphXY()
+{
+	minGraphX = std::min_element(std::begin(graphSeriesVec), std::end(graphSeriesVec), [](const GraphSeries& a, const GraphSeries& b) -> bool {return a.minX < b.minX; })->minX;
+	maxGraphX = std::max_element(std::begin(graphSeriesVec), std::end(graphSeriesVec), [](const GraphSeries& a, const GraphSeries& b) -> bool {return a.maxX < b.maxX; })->maxX;
+	minGraphY = std::min_element(std::begin(graphSeriesVec), std::end(graphSeriesVec), [](const GraphSeries& a, const GraphSeries& b) -> bool {return a.minY < b.minY; })->minY;
+	maxGraphY = std::max_element(std::begin(graphSeriesVec), std::end(graphSeriesVec), [](const GraphSeries& a, const GraphSeries& b) -> bool {return a.maxY < b.maxY; })->maxY;
+	rangeGraphX = std::abs(maxGraphX - minGraphX);
+	rangeGraphY = std::abs(maxGraphY - minGraphY);
+	if (std::abs(rangeGraphX) < 0.01) {
+		minGraphX -= 1.0;
+		maxGraphX += 1.0;
+		rangeGraphX = 2;
+	}
+	if (std::abs(rangeGraphY) < 0.01) {
+		minGraphY -= 1.0;
+		maxGraphY += 1.0;
+		rangeGraphY = 2;
+	}
+}
+
+void GraphView::calculateMinMaxXY(std::vector<QPointF>& line, GraphSeries& lgs)
+{
+	auto pairX = std::minmax_element(lgs.data->begin(), lgs.data->end(), [](const QPointF& a, const QPointF& b) -> bool {return a.x() < b.x(); });
+	lgs.minX = pairX.first->x();
+	lgs.maxX = pairX.second->x();
+	auto pairY = std::minmax_element(lgs.data->begin(), lgs.data->end(), [](const QPointF& a, const QPointF& b) -> bool {return a.y() < b.y(); });
+	lgs.minY = pairY.first->y();
+	lgs.maxY = pairY.second->y();
+}
+
+void GraphView::addSeries(std::vector<QPointF>& line, QColor color, GraphSeries::SeriesType type)
+{
+	if (line.empty()) {
+		return;
+	}
+	GraphSeries lgs;
+	lgs.data = &line;
+	lgs.type = type;
+	calculateMinMaxXY(line, lgs);
+	lgs.color = color;
+	graphSeriesVec.push_back(lgs);
+	calculateMinMaxGraphXY();
+	generateAxisNumberStrings();
+}
+
+QColor GraphView::generateNextColorForGraph()
+{
+	/* http://devmag.org.za/2012/07/29/how-to-choose-colours-procedurally-algorithms/
+		use golden ratio 0.618033988749895f
+	*/
+	hueoffset = std::fmod(hueoffset + 0.618033988749895f, 1.0);
+	return QColor::fromHsvF(hueoffset, 0.83, 1.0);
+}
+
+void GraphView::generateAxisNumberStrings()
+{
+	for (int i = 0; i < 11; i++) {
+		xAxisNumbers[i] = QString::number(minGraphX + i * (rangeGraphX / (double)X_AXIS_GAP_AMOUNT), 'f', 1);
+		yAxisNumbers[i] = QString::number(minGraphY + i * (rangeGraphY / (double)Y_AXIS_GAP_AMOUNT), 'f', 1);
+	}
+}
+
+void GraphView::generateAndAddRandomLine()
+{
+	std::random_device rd;  //Will be used to obtain a seed for the random number engine
+	std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
+
+
+	std::uniform_real_distribution<double> realDistr(-30, 30);
+	std::uniform_int_distribution<int> intScaleDistr(1, 3);
+
+	for (int randomSeries = 0; randomSeries < 1; randomSeries++) {
+		std::vector<QPointF> randomPointVec(101);
+		int scale = intScaleDistr(gen);
+		for (int i = 0; i < randomPointVec.size(); i++) {
+			randomPointVec[i] = QPointF(i + 500, i * scale + realDistr(gen));
+		}
+		addLine(randomPointVec);
+	}
+}
+
+void GraphView::addLine(std::vector<QPointF>& line)
+{
+	addSeries(line, generateNextColorForGraph(), GraphSeries::SeriesType::Line);
+}
+
+void GraphView::addLine(std::vector<QPointF>& line, QColor color)
+{
+	addSeries(line, color, GraphSeries::SeriesType::Line);
+}
+
+void GraphView::addDots(std::vector<QPointF>& dots)
+{
+	addSeries(dots, generateNextColorForGraph(), GraphSeries::SeriesType::Dot);
+}
+
+void GraphView::addDots(std::vector<QPointF>& dots, QColor color)
+{
+	addSeries(dots, color, GraphSeries::SeriesType::Dot);
+}
+
+
+
+
+
+

+ 25 - 20
metavis/CustomLineGraph.h → metavis/GraphView.h

@@ -5,51 +5,56 @@
 #include <QPainter>
 #include <vector>
 
-struct LineGraphSeries {
-	std::vector<QPointF> data;
+struct GraphSeries {
+	std::vector<QPointF>* data;
 	double minX, maxX;
 	double minY, maxY;
-	QColor color;
 	QString name;
-	enum SeriesType{ Line, Dot};
+	QColor color;
+	int lineWidth = 2;
+	double circleRadius = 1.0;
+	enum class SeriesType{ Line, Dot, LineDot};
 	SeriesType type;
 };
 
-//bool compTest(QPoint a, QPoint b) {
-//	return a.x() < b.x();
-//}
 
-class CustomLineGraph :public QWidget
+class GraphView :public QWidget
 {
 	Q_OBJECT
 
 public:
-	CustomLineGraph(QWidget* parent, QString title,  int lineWidth = 2, double circleRadius = .5);
-	~CustomLineGraph();
-	void CustomLineGraph::paintEvent(QPaintEvent* event);
-	int lineWidth;
-	double circleRadius;
+	GraphView(QWidget* parent, QString title);
+	~GraphView();
 	QString title;
 private:
+	void GraphView::paintEvent(QPaintEvent* event);
 	//Data
-	std::vector<LineGraphSeries> seriesVec;
+	std::vector<GraphSeries> graphSeriesVec;
 	double minGraphX = 0, maxGraphX = 0, minGraphY = 0, maxGraphY = 0, rangeGraphX = 0, rangeGraphY = 0;
+	
+	
 	//Visualization
 	QString xAxisNumbers[11];
 	QString yAxisNumbers[11];
 	double hueoffset;
 	QPen linePen, rectPen, axisPen;
-	QPointF transformPoint(QPointF& point, double stregth_factorX, double stregth_factorY);
-	void generateAxisNumberStrings();
-	void calculateMinMaxGraphXY();
-	void CustomLineGraph::popullateLineGraphSeries(std::vector<QPointF>& line, LineGraphSeries& lgs);
-	void addSeries(std::vector<QPointF>& line, QColor color, LineGraphSeries::SeriesType type);
-	QColor generateNextColorForGraph();
+
+
+
+
 public:
 	void generateAndAddRandomLine();
 	void addLine(std::vector<QPointF>& line);
 	void addLine(std::vector<QPointF>& line, QColor color);
 	void addDots(std::vector<QPointF>& dots);
 	void addDots(std::vector<QPointF>& dots, QColor color);
+private:
+	void generateAxisNumberStrings();
+	void calculateMinMaxGraphXY();
+	void GraphView::calculateMinMaxXY(std::vector<QPointF>& line, GraphSeries& lgs);
+	void addSeries(std::vector<QPointF>& line, QColor color, GraphSeries::SeriesType type);
+	QColor generateNextColorForGraph();
+	QPointF transformPoint(QPointF& point, double stregth_factorX, double stregth_factorY);
+
 };
 

+ 0 - 45
metavis/LineGraph.cpp

@@ -1,45 +0,0 @@
-#include "LineGraph.h"
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QDebug>
-
-LineGraph::LineGraph(QWidget *parent)
-	: QWidget(parent)
-{
-	series = new QtCharts::QLineSeries();
-    std::random_device rd;  //Will be used to obtain a seed for the random number engine
-    std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
-    std::uniform_int_distribution<> dis(1, 100);
-
-    for (int i = 0; i < 100; i++) {
-        series->append(i, dis(gen));
-    }
-    //*series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
-    QtCharts::QLineSeries* ser2 = new QtCharts::QLineSeries();
-
-    for (int i = 0; i < 100; i++) {
-        ser2->append(i, dis(gen));
-    }
-    chart = new QtCharts::QChart();
-    chart->legend()->hide();
-    chart->addSeries(series);
-    chart->addSeries(ser2);
-    chart->createDefaultAxes();
-    chart->setTitle("Simple line chart example");
-    chartView = new QtCharts::QChartView(chart);
-    chartView->setRenderHint(QPainter::Antialiasing);
-    //chartView->setMinimumSize(200, 200);
-    QVBoxLayout* layout = new QVBoxLayout();
-    layout->addWidget(chartView);
-    this->setLayout(layout);
-
-}
-
-LineGraph::~LineGraph()
-{
-}
-
-void LineGraph::mouseMoveEvent(QMouseEvent* event)
-{
-    qDebug() << "MouseMoveEvent";
-}

+ 0 - 21
metavis/LineGraph.h

@@ -1,21 +0,0 @@
-#pragma once
-
-#include <QWidget>
-#include <QtCharts/QLineSeries>
-#include <QtCharts/QtCharts>
-#include <QtCharts/QChartView>
-
-class LineGraph : public QWidget
-{
-	Q_OBJECT
-
-private:
-	QtCharts::QLineSeries* series;
-	QtCharts::QChart* chart;
-	QtCharts::QChartView* chartView;
-public:
-	LineGraph(QWidget *parent);
-	~LineGraph();
-protected:
-	void mouseMoveEvent(QMouseEvent* event);
-};

+ 0 - 12
metavis/LineGraphZwei.h

@@ -1,12 +0,0 @@
-#pragma once
-
-#include <QWidget>
-
-class LineGraphZwei : public QWidget
-{
-	Q_OBJECT
-
-public:
-	LineGraphZwei(QWidget *parent);
-	~LineGraphZwei();
-};

+ 3 - 16
metavis/RunData.cpp

@@ -1,3 +1,4 @@
+#include "pch.h"
 #include "RunData.h"
 #include <QDebug>
 #include <QString>
@@ -72,8 +73,8 @@ void RunData::calculateBestAndAverageIter()
     double minObjectiveFunctionInIter = solutionVec[0].objectiveFunction;
     double maxObjectiveFunctionInIter = solutionVec[0].objectiveFunction;
     double bestObjectiveFunctionFound = solutionVec[0].objectiveFunction;
-    int actualIter = solutionVec[0].iteration;
     double actualIterObjectiveFunctionAggregate = solutionVec[0].objectiveFunction;
+    int actualIter = solutionVec[0].iteration;
     int foundSolutionInIteration = 1; 
     for(int i = 1; i < solutionVec.size(); i++) {
         SolutionPointData nextData = solutionVec[i];
@@ -141,21 +142,7 @@ void RunData::calculateParticleSolution()
 
 void RunData::calculateDotsForDistribution()
 {
-
     for (SolutionPointData sol : solutionVec) {
-        QPointF point((double)sol.iteration, sol.objectiveFunction);
-        dotsForDistribution.push_back(point);
+        dotsForDistribution.push_back(QPointF((double)sol.iteration, sol.objectiveFunction));
     }
-
-    ////check code:
-    //int count = 0;
-    //int actualIter = (int)dotsForDistribution[0].x();
-    //for (int i = 0; i < dotsForDistribution.size(); i++) {
-    //    if (actualIter != (int)dotsForDistribution[i].x()) {
-    //        actualIter = (int)dotsForDistribution[i].x();
-    //        qDebug() << "[" << actualIter << "]Min:" << minSolutionPerItertion[count].y() << " Max: " << maxSolutionPerItertion[count].y();
-    //        count++;
-    //    }
-    //    qDebug() << dotsForDistribution[i];
-    //}
 }

+ 2 - 1
metavis/SettingDialog.cpp

@@ -1,5 +1,6 @@
+#include "pch.h"
 #include "SettingDialog.h"
-#include <qdebug.h>
+#include <QDebug>
 SettingDialog::SettingDialog(QSettings* settings, QWidget* parent)
 	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint), settings(settings)
 {

+ 2 - 3
metavis/SettingDialog.h

@@ -1,9 +1,8 @@
 #pragma once
-
 #include <QDialog>
-#include <qsettings.h>
+#include <QSettings>
 #include "ui_SettingDialog.h"
-#include <qabstractbutton.h>
+#include <QAbstractButton>
 
 /**
  * A dialog to change the Setting for the main program.

File diff suppressed because it is too large
+ 0 - 1
metavis/d3.v5.min.js


+ 1 - 0
metavis/dataTest.cpp

@@ -1,3 +1,4 @@
+#include "pch.h"
 #include "dataTest.h"
 #include <QDebug>
 #include <sstream>

+ 1 - 0
metavis/main.cpp

@@ -1,3 +1,4 @@
+#include "pch.h"
 #include "metavis.h"
 #include <QtWidgets/QApplication>
 #include <QtGui>

+ 4 - 50
metavis/metavis.cpp

@@ -1,3 +1,4 @@
+#include "pch.h"
 #include "metavis.h"
 #include "SettingDialog.h"
 #include <QStandardPaths>
@@ -11,7 +12,6 @@
 #include <QFileDialog>
 #include <QDir>
 #include <map>
-#include "LineGraph.h"
 
 
 metavis::metavis(QWidget* parent)
@@ -23,15 +23,6 @@ metavis::metavis(QWidget* parent)
 	setStyleSheet(styleSheet() + "QMainWindow::separator {background: rgb(200, 200, 200);width: 1px;height: 1px;}");
 	setStyleSheet(styleSheet() + "QTabBar::tab:selected {color: rgb(0, 122, 204);}");
 	setStyleSheet(styleSheet() + "QTabWidget::pane {border-top: 2px solid #C2C7CB;}");
-	
-	
-	/*CustomLineGraph* random = createCustomWidget(QString("Random"));
-	random->generateAndAddRandomLine();
-	random->generateAndAddRandomLine();
-	random->generateAndAddRandomLine();*/
-	/*createCustomWidget();
-	createCustomWidget();
-	createCustomWidget();*/
 
 	readMainWindowSettings();
 }
@@ -49,50 +40,12 @@ metavis::~metavis()
 }
 
 
-
-void metavis::createChartWidget()
-{
-	QDockWidget* dock = new QDockWidget("Customers", this);
-	dock->setObjectName("TestWidget");
-	dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-	LineGraph* widget = new LineGraph(dock);
-	
-	widget->setMinimumSize(100, 100);
-	dock->setBaseSize(300, 300);
-	QPalette pal;
-	pal.setColor(QPalette::Background, Qt::lightGray);
-	dock->setPalette(pal);
-	//widget->setPalette(pal);
-	dock->setWidget(widget);
-	addDockWidget(Qt::RightDockWidgetArea, dock);
-}
-
-void metavis::createWebEngineWidget()
-{
-
-	QDockWidget* dock = new QDockWidget("Customers", this);
-	dock->setObjectName("TestWidget");
-	dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-	QWebEngineView* view = new QWebEngineView(dock);
-	view->load(QUrl("file:///web.html"));
-	//view->load(QUrl("http://youtube.de/"));
-	view->show();
-	view->setMinimumSize(200, 200);
-	dock->setBaseSize(300, 300);
-	QPalette pal;
-	pal.setColor(QPalette::Background, Qt::lightGray);
-	dock->setPalette(pal);
-	view->setPalette(pal);
-	dock->setWidget(view);
-	addDockWidget(Qt::LeftDockWidgetArea, dock);
-}
-
-CustomLineGraph* metavis::createCustomWidget(QString titleString)
+GraphView* metavis::createCustomWidget(QString titleString)
 {
 	QDockWidget* dock = new QDockWidget(titleString, this);
 	dock->setObjectName(titleString);
 	dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-	CustomLineGraph* bestGraph = new CustomLineGraph(dock, titleString);
+	GraphView* bestGraph = new GraphView(dock, titleString);
 	bestGraph->setMinimumSize(200, 200);
 	bestGraph->show();
 	bestGraph->repaint();
@@ -146,6 +99,7 @@ void metavis::openFile()
 	bestGraph->addLine(runVec[0].bestSolutionPerIteration, QColor(255, 0, 0));
 	bestGraph->addLine(runVec[0].averageSolutionPerItertion, QColor(0, 0, 255));
 
+	
 	minMaxGraph->addLine(runVec[0].minSolutionPerItertion, QColor(255, 0, 0));
 	minMaxGraph->addLine(runVec[0].maxSolutionPerItertion, QColor(0, 0, 255));
 	minMaxGraph->addDots(runVec[0].dotsForDistribution, QColor(255, 165, 0, 100));

+ 5 - 8
metavis/metavis.h

@@ -1,11 +1,10 @@
 #pragma once
-
 #include <QtWidgets/QMainWindow>
 #include "ui_metavis.h"
 #include <QSettings>
 #include <vector>
 #include "RunData.h"
-#include "CustomLineGraph.h"
+#include "GraphView.h"
 
 /**
  * Main class of the GUI.
@@ -17,9 +16,9 @@ class metavis : public QMainWindow
 public:
 	metavis(QWidget *parent = Q_NULLPTR);
 	~metavis();
-	CustomLineGraph* bestGraph;
-	CustomLineGraph* particleGraph;
-	CustomLineGraph* minMaxGraph;
+	GraphView* bestGraph;
+	GraphView* particleGraph;
+	GraphView* minMaxGraph;
 private:
 	Ui::metavisClass ui;
 	QSettings* settings;
@@ -28,9 +27,7 @@ private:
 
 private:
 	/* Widget functions */
-	void createChartWidget();
-	void createWebEngineWidget();
-	CustomLineGraph* createCustomWidget(QString titleString);
+	GraphView* createCustomWidget(QString titleString);
 
 
 	/* Setting functions*/

+ 11 - 4
metavis/metavis.vcxproj

@@ -69,6 +69,8 @@
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -84,6 +86,8 @@
       <DebugInformationFormat />
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -94,11 +98,14 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="CustomLineGraph.cpp" />
+    <ClCompile Include="GraphView.cpp" />
     <ClCompile Include="dataTest.cpp" />
-    <ClCompile Include="LineGraph.cpp" />
     <ClCompile Include="main.cpp" />
     <ClCompile Include="metavis.cpp" />
+    <ClCompile Include="pch.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+    </ClCompile>
     <ClCompile Include="RunData.cpp" />
     <ClCompile Include="SettingDialog.cpp" />
   </ItemGroup>
@@ -119,10 +126,10 @@
     <QtMoc Include="SettingDialog.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="pch.h" />
     <ClInclude Include="RunData.h" />
-    <QtMoc Include="CustomLineGraph.h" />
+    <QtMoc Include="GraphView.h" />
     <ClInclude Include="dataTest.h" />
-    <QtMoc Include="LineGraph.h" />
   </ItemGroup>
   <ItemGroup>
     <None Include="web.html" />

+ 7 - 7
metavis/metavis.vcxproj.filters

@@ -37,13 +37,13 @@
     <ClCompile Include="dataTest.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="LineGraph.cpp">
+    <ClCompile Include="RunData.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="CustomLineGraph.cpp">
+    <ClCompile Include="GraphView.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="RunData.cpp">
+    <ClCompile Include="pch.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
@@ -54,10 +54,7 @@
     <QtMoc Include="SettingDialog.h">
       <Filter>Header Files</Filter>
     </QtMoc>
-    <QtMoc Include="LineGraph.h">
-      <Filter>Header Files</Filter>
-    </QtMoc>
-    <QtMoc Include="CustomLineGraph.h">
+    <QtMoc Include="GraphView.h">
       <Filter>Header Files</Filter>
     </QtMoc>
   </ItemGroup>
@@ -84,6 +81,9 @@
     <ClInclude Include="RunData.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="pch.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="web.html">

+ 1 - 0
metavis/pch.cpp

@@ -0,0 +1 @@
+#include "pch.h"

+ 35 - 0
metavis/pch.h

@@ -0,0 +1,35 @@
+#pragma once
+//QT
+#include <QWidget>
+#include <QPaintEvent>
+#include <QPen>
+#include <QPainter>
+#include <QSettings>
+#include <QPoint>
+#include <QDialog>
+#include <QAbstractButton>
+#include <QDebug>
+#include <QBrush>
+#include <QtWidgets/QApplication>
+#include <QtGui>
+#include <QStandardPaths>
+#include <QDockwidget>
+#include <QLabel>
+#include <QLayout>
+#include <QStyleFactory>
+#include <QFileDialog>
+#include <QDir>
+#include <QString>
+
+
+
+//Std
+#include <vector>
+#include <bitset>
+#include <string>
+#include <fstream>
+#include <map>
+#include <random>
+#include <algorithm>
+#include <sstream>
+#include <regex>

+ 0 - 135
metavis/web.html

@@ -1,135 +0,0 @@
-
-<!--
-<html>
-<body>
-
-sdasdasd
-</body>
-</html>
--->
-
- 
-<meta charset="utf-8">
-<html>
-<header><title>This is title</title></header>
-
-<style type="text/css">
-/* 13. Basic Styling with CSS */
-
-/* Style the lines by removing the fill and applying a stroke */
-.line {
-    fill: none;
-    stroke: #ffab00;
-    stroke-width: 3;
-}
-  
-.overlay {
-  fill: none;
-  pointer-events: all;
-}
-
-/* Style the dots by assigning a fill and stroke */
-.dot {
-    fill: #ffab00;
-    stroke: #fff;
-}
-  
-  .focus circle {
-  fill: none;
-  stroke: steelblue;
-}
-
-.dot-focus{
-  fill: #ffffff;
-  stroke: steelblue;
-}
-
-</style>
-
-
-<body>
-<script src="d3.v5.min.js"></script>
-<script>
-
-var margin = {top: 10, right: 50, bottom: 50, left: 50}
-  , width = window.innerWidth - margin.left - margin.right // Use the window's width 
-  , height = window.innerHeight - margin.top - margin.bottom; // Use the window's height
-
-// The number of datapoints
-var n = 101;
-
-// 5. X scale will use the index of our data
-var xScale = d3.scaleLinear()
-    .domain([0, n-1]) // input
-    .range([0, width]); // output
-
-// 6. Y scale will use the randomly generate number 
-var yScale = d3.scaleLinear()
-    .domain([0, 1]) // input 
-    .range([height, 0]); // output 
-
-// 7. d3's line generator
-var line = d3.line()
-    .x(function(d, i) { return xScale(i); }) // set the x values for the line generator
-    .y(function(d) { return yScale(d.y); }) // set the y values for the line generator 
-    .curve(d3.curveMonotoneX) // apply smoothing to the line
-
-// 8. An array of objects of length N. Each object has key -> value pair, the key being "y" and the value is a random number
-var dataset = d3.range(n).map(function(d) { return {"y": d3.randomUniform(1)() } })
-
-// 1. Add the SVG to the page and employ #2
-var svg = d3.select("body").append("svg")
-    .attr("width", width + margin.left + margin.right  -25)
-    .attr("height", height + margin.top + margin.bottom -25)
-	//.attr("preserveAspectRatio", "xMinYMin meet")
-	//.attr("viewBox", "0 0 " + width + " " + height)
-  .append("g")
-    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
-// 3. Call the x axis in a group tag
-svg.append("g")
-    .attr("class", "x axis")
-    .attr("transform", "translate(0," + height + ")")
-    .call(d3.axisBottom(xScale)); // Create an axis component with d3.axisBottom
-
-// 4. Call the y axis in a group tag
-svg.append("g")
-    .attr("class", "y axis")
-    .call(d3.axisLeft(yScale)); // Create an axis component with d3.axisLeft
-
-// 9. Append the path, bind the data, and call the line generator 
-var path = svg.append("path")
-    .datum(dataset) // 10. Binds data to the line 
-    .attr("class", "line") // Assign a class for styling 
-    .attr("d", line); // 11. Calls the line generator 
-
-// 12. Appends a circle for each datapoint 
-svg.selectAll(".dot")
-    .data(dataset)
-  .enter().append("circle") // Uses the enter().append() method
-    .attr("class", "dot") // Assign a class for styling
-    .attr("cx", function(d, i) { return xScale(i) })
-    .attr("cy", function(d) { return yScale(d.y) })
-    .attr("r", 5)
-      .on("mouseover", function(a, b, c) { 
-  			console.log(a) 
-        d3.select(this).attr('class', 'dot-focus')
-		})
-	  .on("mouseout", function(a, b, c) { 
-  			console.log(a) 
-        d3.select(this).attr('class', 'dot')
-		})
-function redraw(){
-	width = window.innerWidth - margin.left - margin.right;
-	height = window.innerHeight - margin.top - margin.bottom;
-	console.log("redraw w:" + width + " h:" + height);
-	//path.attr("d", line)
-	//.attr("transform", null)
-	//.transition()
-	//.attr("transform", "translate(" + "0" + ",100)")
-	//.duration(300);
-}
-window.addEventListener("resize", redraw);
-</script>
-</body>
-</html>

Some files were not shown because too many files changed in this diff