Skip to content

Commit

Permalink
fix: graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
iffse committed May 16, 2023
1 parent 664f724 commit 89fbed3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
20 changes: 7 additions & 13 deletions src-qml/Graphs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ Item {
id: series
axisX: xAxis
axisY: yAxis

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;
xAxis.max = xMax;
yAxis.max = yMax;
for (var i = 0; i < points.length; ++i) {
var point = points[i];
series.append(point.x, point.y);
Expand All @@ -67,8 +64,8 @@ Item {

ValueAxis {
id: errorXAxis
min: 0
max: 1
min: 1
max: 5
labelFormat: "%i"
}

Expand All @@ -83,20 +80,17 @@ Item {
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);
errorYAxis.max = errorMax;
errorXAxis.max = points.length;

for (var i = 0; i < points.length; ++i) {
errorSeries.append(i+1,points[i]);
errorSeries.append(i+1, points[i]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src-qml/InputConf.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ScrollView {
LabelInput {
text: "Number of areas"
placeholderText: "Enter a number"
toolTipText: "Number of areas used to graph the burning area\n\nLeave empty to not graph the burning area"
toolTipText: "Number of areas used toa calculate the error with respect to the minimum distance function and the burning area area\n\nLeave empty to disable"
objName: "areas"
decimals: false
negative: false
Expand Down
1 change: 0 additions & 1 deletion src-qml/OutputConf.qml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ ScrollView {
}
}
}

}
}

15 changes: 10 additions & 5 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,20 @@ void Actions::worker() {

void Actions::afterWorker() {
root->findChild<QObject*>("runButton")->setProperty("text", "Run");
double &burningWayMax = *max_element(burningWay.begin(), burningWay.end());
double &burningAreaMax = *max_element(burningArea.begin(), burningArea.end());
drawIsocontourLines(isocontourSize, numIsocontourLines);

emit graphBurningArea(plotData::burningAreaData(), burningWayMax, burningAreaMax);
emit graphErrorIter(
vector<double>(errorIter.begin(), errorIter.begin() + currentIter),
*max_element(errorIter.begin(), errorIter.end())
*max_element(errorIter.begin(), errorIter.begin() + currentIter) * 1.05
);
drawIsocontourLines(isocontourSize, numIsocontourLines);

if (numberArea == 0)
emit graphBurningArea(QVariantList(), 1, 1);
else {
double &burningWayMax = *max_element(burningWay.begin(), burningWay.end());
double &burningAreaMax = *max_element(burningArea.begin(), burningArea.end());
emit graphBurningArea(plotData::burningAreaData(), burningWayMax * 1.05, burningAreaMax * 1.05);
}
}

void Actions::exportData(QString filepath, bool pretty) {
Expand Down
5 changes: 4 additions & 1 deletion src/iterations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void subIteration() {
}

tuple<double, double> mainLoop() {
double areaMDF = 0.0;
double areaGeometric = 0.0;

for (uint triangle = 0; triangle < numTriangles; ++triangle) {
Expand All @@ -34,6 +33,10 @@ tuple<double, double> mainLoop() {
areaGeometric += cellArea;
}

if (numberArea == 0)
return {areaGeometric, 0};

double areaMDF = 0.0;
for (uint area = 0; area < numberArea - 1; ++area)
areaMDF += 0.5 * (burningArea[area] + burningArea[area + 1]) * (burningWay[area + 1] - burningWay[area]);

Expand Down
3 changes: 3 additions & 0 deletions src/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ void setBoundary() {
void setBurningArea() {
burningArea = vector<double>(numberArea);
burningWay = vector<double>(numberArea);
if (numberArea == 0)
return;

auto epsilon = 0.001;
auto uMin = *min_element(uVertex.begin(), uVertex.end());
auto uMax = *max_element(uVertex.begin(), uVertex.end());
Expand Down

0 comments on commit 89fbed3

Please sign in to comment.