Scale correction revert in case of exception.
This commit is contained in:
parent
478dd2a93f
commit
ec571aec44
2 changed files with 30 additions and 23 deletions
|
@ -322,6 +322,21 @@ void PrintController::slice_to_png()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Turn back the correction scaling on the model.
|
||||||
|
auto scale_back = [&]() {
|
||||||
|
if(correction) { // scale the model back
|
||||||
|
print_->invalidate_all_steps();
|
||||||
|
for(auto po : print_->objects) {
|
||||||
|
po->model_object()->scale(
|
||||||
|
Pointf3(1.0/exd.corr_x, 1.0/exd.corr_y, 1.0/exd.corr_z)
|
||||||
|
);
|
||||||
|
po->model_object()->invalidate_bounding_box();
|
||||||
|
po->reload_model_instances();
|
||||||
|
po->invalidate_all_steps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto print_bb = print_->bounding_box();
|
auto print_bb = print_->bounding_box();
|
||||||
|
|
||||||
// If the print does not fit into the print area we should cry about it.
|
// If the print does not fit into the print area we should cry about it.
|
||||||
|
@ -333,7 +348,10 @@ void PrintController::slice_to_png()
|
||||||
<< _(L("Width needed: ")) << unscale(print_bb.size().x) << " mm\n"
|
<< _(L("Width needed: ")) << unscale(print_bb.size().x) << " mm\n"
|
||||||
<< _(L("Height needed: ")) << unscale(print_bb.size().y) << " mm\n";
|
<< _(L("Height needed: ")) << unscale(print_bb.size().y) << " mm\n";
|
||||||
|
|
||||||
report_issue(IssueType::WARN, ss.str(), "Warning");
|
if(!report_issue(IssueType::WARN_Q, ss.str(), _(L("Warning")))) {
|
||||||
|
scale_back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pri = create_progress_indicator(
|
auto pri = create_progress_indicator(
|
||||||
|
@ -343,8 +361,9 @@ void PrintController::slice_to_png()
|
||||||
pri->update(0, _(L("Slicing...")));
|
pri->update(0, _(L("Slicing...")));
|
||||||
slice(pri);
|
slice(pri);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
report_issue(IssueType::ERR, e.what(), _(L("Exception occured")));
|
|
||||||
pri->cancel();
|
pri->cancel();
|
||||||
|
report_issue(IssueType::ERR, e.what(), _(L("Exception occured")));
|
||||||
|
scale_back();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,24 +377,12 @@ void PrintController::slice_to_png()
|
||||||
exd.exp_time_s, exd.exp_time_first_s);
|
exd.exp_time_s, exd.exp_time_first_s);
|
||||||
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
report_issue(IssueType::ERR, e.what(), _(L("Exception occured")));
|
|
||||||
pri->cancel();
|
pri->cancel();
|
||||||
|
print_->progressindicator = pbak;
|
||||||
|
report_issue(IssueType::ERR, e.what(), _(L("Exception occured")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(correction) { // scale the model back
|
scale_back();
|
||||||
print_->invalidate_all_steps();
|
|
||||||
for(auto po : print_->objects) {
|
|
||||||
po->model_object()->scale(
|
|
||||||
Pointf3(1.0/exd.corr_x, 1.0/exd.corr_y, 1.0/exd.corr_z)
|
|
||||||
);
|
|
||||||
po->model_object()->invalidate_bounding_box();
|
|
||||||
po->reload_model_instances();
|
|
||||||
po->invalidate_all_steps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_->progressindicator = pbak;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IProgressIndicator::message_fmt(
|
void IProgressIndicator::message_fmt(
|
||||||
|
|
|
@ -212,6 +212,12 @@ protected:
|
||||||
// The previous export data, to pre-populate the dialog
|
// The previous export data, to pre-populate the dialog
|
||||||
PngExportData prev_expdata_;
|
PngExportData prev_expdata_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slice one pront object.
|
||||||
|
* @param pobj The print object.
|
||||||
|
*/
|
||||||
|
void slice(PrintObject *pobj);
|
||||||
|
|
||||||
void slice(ProgresIndicatorPtr pri);
|
void slice(ProgresIndicatorPtr pri);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -228,12 +234,6 @@ public:
|
||||||
return PrintController::Ptr( new PrintController(print) );
|
return PrintController::Ptr( new PrintController(print) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Slice one pront object.
|
|
||||||
* @param pobj The print object.
|
|
||||||
*/
|
|
||||||
void slice(PrintObject *pobj);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slice the loaded print scene.
|
* @brief Slice the loaded print scene.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue