Skip to content

Commit

Permalink
feat: error graph
Browse files Browse the repository at this point in the history
  • Loading branch information
iffse committed May 16, 2023
1 parent e08820b commit 6a193c8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 35 deletions.
119 changes: 85 additions & 34 deletions src-qml/Graphs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,98 @@ import QtQuick.Controls.Material 2.15


Item {
ChartView {
anchors.fill: parent
antialiasing: true
id: chart
theme: Material.theme === Material.Dark ? ChartView.ChartThemeDark : ChartView.ChartThemeLight
backgroundColor: Material.theme === Material.Dark ? Material.color(Material.Grey, Material.Shade900) : Material.color(Material.Grey, Material.Shade50)

// set backgroundcolor to match the theme
legend.visible: false

ValueAxis {
id: xAxis
min: 0
max: 1
}
Row {
width: parent.width
height: parent.height
spacing: 10
ChartView{
height: parent.height
width: (parent.width - parent.spacing) / 2
antialiasing: true
theme: Material.theme === Material.Dark ? ChartView.ChartThemeDark : ChartView.ChartThemeLight
backgroundColor: Material.theme === Material.Dark ? Material.color(Material.Grey, Material.Shade900) : Material.color(Material.Grey, Material.Shade50)

ValueAxis {
id: yAxis
min: 0
max: 1
}
legend.visible: false
title: "Burning Area with Time"

ValueAxis {
id: xAxis
min: 0
max: 1
}

ValueAxis {
id: yAxis
min: 0
max: 1
}


LineSeries {
id: series
axisX: xAxis
axisY: yAxis
LineSeries {
id: series
axisX: xAxis
axisY: yAxis

XYPoint { x: 0; y: 0 }
XYPoint { x: 0; y: 0 }

}

Connections {
target: actions
function onGraphBurningArea(points, xMax, yMax) {
series.clear();
xAxis.max = xMax * 1.05;
yAxis.max = yMax * 1.05;
for (var i = 0; i < points.length; ++i) {
var point = points[i];
series.append(point.x, point.y);
}
}
}
}

Connections {
target: actions
function onGraphBurningArea(points, xMax, yMax) {
series.clear();
xAxis.max = xMax * 1.05;
yAxis.max = yMax * 1.05;
for (var i = 0; i < points.length; ++i) {
var point = points[i];
series.append(point.x, point.y);
ChartView{
height: parent.height
width: (parent.width - parent.spacing) / 2
antialiasing: true
theme: Material.theme === Material.Dark ? ChartView.ChartThemeDark : ChartView.ChartThemeLight
backgroundColor: Material.theme === Material.Dark ? Material.color(Material.Grey, Material.Shade900) : Material.color(Material.Grey, Material.Shade50)

legend.visible: false
title: "Error with Iteration"

ValueAxis {
id: errorXAxis
min: 0
max: 1
}

ValueAxis {
id: errorYAxis
min: 0
max: 1
}


LineSeries {
id: errorSeries
axisX: errorXAxis
axisY: errorYAxis

XYPoint { x: 0; y: 0 }

}

Connections {
target: actions
function onGraphErrorIter(points, errorMax) {
errorSeries.clear();
errorYAxis.max = errorMax * 1.05;
errorXAxis.max = Math.ceil(points.length * 1.05);

for (var i = 0; i < points.length; ++i) {
errorSeries.append(i+1,points[i]);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/headers/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ inline uint minIter;
inline uint maxIter;
inline uint currentIter;
inline double tolerance;
inline std::vector<double> errorIter;

inline std::vector<int> meshData;
inline std::vector<double> x;
Expand Down
1 change: 1 addition & 0 deletions src/headers/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Actions: public QObject {
void clearCanvas();
void setCanvasSize(uint width, uint height);
void graphBurningArea(QVariant points, double xMax, double yMax);
void graphErrorIter(std::vector<double> points, double errorMax);
void updateProgress(uint progress, uint total);
void finished();
void readFinished(bool success);
Expand Down
5 changes: 4 additions & 1 deletion src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ void Actions::worker() {
eps = vector<double>(numNodes);
currentIter = 0;
}
errorIter.resize(maxIter);

double error = tolerance + 1;
QString linesToPrint = "";
Expand All @@ -228,7 +229,8 @@ void Actions::worker() {
}
++currentIter;
Iterations::subIteration();
error = getError();
errorIter[currentIter - 1] = getError();
error = errorIter[currentIter - 1];

if (linesToPrint != "")
linesToPrint += "\n";
Expand Down Expand Up @@ -269,6 +271,7 @@ void Actions::afterWorker() {
double &burningAreaMax = *max_element(burningArea.begin(), burningArea.end());

emit graphBurningArea(plotData::burningAreaData(), burningWayMax, burningAreaMax);
emit graphErrorIter(errorIter, *max_element(errorIter.begin(), errorIter.end()));
drawIsocontourLines(isocontourSize, numIsocontourLines);
}

Expand Down

0 comments on commit 6a193c8

Please sign in to comment.