Skip to content

Commit

Permalink
#598 disable autocenter for calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Nov 2, 2020
1 parent ef53b16 commit 2f8cb3b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/slic3r/GUI/CalibrationBedDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CalibrationBedDialog.hpp"
#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "AppConfig.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "Tab.hpp"
Expand Down Expand Up @@ -31,6 +32,12 @@ void CalibrationBedDialog::create_geometry(wxCommandEvent& event_args) {
Plater* plat = this->main_frame->plater();
Model& model = plat->model();
plat->reset();
bool autocenter = gui_app->app_config->get("autocenter") == "1";
if(autocenter) {
//disable aut-ocenter for this calibration.
gui_app->app_config->set("autocenter", "0");
}

std::vector<size_t> objs_idx = plat->load_files(std::vector<std::string>{
Slic3r::resources_dir()+"/calibration/bed_leveling/patch.amf",
Slic3r::resources_dir()+"/calibration/bed_leveling/patch.amf",
Expand Down Expand Up @@ -133,7 +140,10 @@ void CalibrationBedDialog::create_geometry(wxCommandEvent& event_args) {
// plat->schedule_background_process();
plat->reslice();
plat->select_view_3D("Preview");

if (autocenter) {
//re-enable auto-center after this calibration.
gui_app->app_config->set("autocenter", "1");
}
}

} // namespace GUI
Expand Down
18 changes: 15 additions & 3 deletions src/slic3r/GUI/CalibrationBridgeDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CalibrationBridgeDialog.hpp"
#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "AppConfig.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "Tab.hpp"
Expand Down Expand Up @@ -51,6 +52,12 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool
Model& model = plat->model();
plat->reset();

bool autocenter = gui_app->app_config->get("autocenter") == "1";
if (autocenter) {
//disable auto-center for this calibration.
gui_app->app_config->set("autocenter", "0");
}

int idx_steps = steps->GetSelection();
int idx_nb = nb_tests->GetSelection();
size_t step = 5 + (idx_steps == wxNOT_FOUND ? 0 : idx_steps * 5);
Expand Down Expand Up @@ -89,15 +96,15 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool
}

/// --- translate ---;
const float brim_width = std::max(print_config->option<ConfigOptionFloat>("brim_width")->value, nozzle_diameter * 5.);
const ConfigOptionFloat* extruder_clearance_radius = print_config->option<ConfigOptionFloat>("extruder_clearance_radius");
const ConfigOptionPoints* bed_shape = printer_config->option<ConfigOptionPoints>("bed_shape");
const float brim_width = std::max(print_config->option<ConfigOptionFloat>("brim_width")->value, nozzle_diameter * 5.);
Vec2d bed_size = BoundingBoxf(bed_shape->values).size();
Vec2d bed_min = BoundingBoxf(bed_shape->values).min;
float offsety = 2 + 10 * 1 + extruder_clearance_radius->value + brim_width + (brim_width> extruder_clearance_radius->value ? brim_width - extruder_clearance_radius->value :0);
float offsety = 2 + 10 * 1 + extruder_clearance_radius->value + brim_width + (brim_width > extruder_clearance_radius->value ? brim_width - extruder_clearance_radius->value : 0);
model.objects[objs_idx[0]]->translate({ bed_min.x() + bed_size.x() / 2, bed_min.y() + bed_size.y() / 2, 0 });
for (int i = 1; i < nb_items; i++) {
model.objects[objs_idx[i]]->translate({ bed_min.x() + bed_size.x() / 2, bed_min.y() + bed_size.y() / 2 + (i%2==0?-1:1) * offsety * ((i+1)/2), 0 });
model.objects[objs_idx[i]]->translate({ bed_min.x() + bed_size.x() / 2, bed_min.y() + bed_size.y() / 2 + (i % 2 == 0 ? -1 : 1) * offsety * ((i + 1) / 2), 0 });
}
//TODO: if not enough space, forget about complete_objects

Expand Down Expand Up @@ -135,6 +142,11 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool

plat->reslice();
plat->select_view_3D("Preview");

if (autocenter) {
//re-enable auto-center after this calibration.
gui_app->app_config->set("autocenter", "1");
}
}

} // namespace GUI
Expand Down
13 changes: 13 additions & 0 deletions src/slic3r/GUI/CalibrationFlowDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CalibrationFlowDialog.hpp"
#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "AppConfig.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "Tab.hpp"
Expand Down Expand Up @@ -35,6 +36,13 @@ void CalibrationFlowDialog::create_geometry(float start, float delta) {
Plater* plat = this->main_frame->plater();
Model& model = plat->model();
plat->reset();

bool autocenter = gui_app->app_config->get("autocenter") == "1";
if (autocenter) {
//disable auto-center for this calibration.
gui_app->app_config->set("autocenter", "0");
}

std::vector<size_t> objs_idx = plat->load_files(std::vector<std::string>{
Slic3r::resources_dir()+"/calibration/filament_flow/filament_flow_test_cube.amf",
Slic3r::resources_dir()+"/calibration/filament_flow/filament_flow_test_cube.amf",
Expand Down Expand Up @@ -150,6 +158,11 @@ void CalibrationFlowDialog::create_geometry(float start, float delta) {

plat->reslice();
plat->select_view_3D("Preview");

if (autocenter) {
//re-enable auto-center after this calibration.
gui_app->app_config->set("autocenter", "1");
}
}

} // namespace GUI
Expand Down
12 changes: 12 additions & 0 deletions src/slic3r/GUI/CalibrationOverBridgeDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CalibrationOverBridgeDialog.hpp"
#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "AppConfig.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "Tab.hpp"
Expand Down Expand Up @@ -31,6 +32,12 @@ void CalibrationOverBridgeDialog::create_geometry(wxCommandEvent& event_args) {
Plater* plat = this->main_frame->plater();
Model& model = plat->model();
plat->reset();
bool autocenter = gui_app->app_config->get("autocenter") == "1";
if (autocenter) {
//disable aut-ocenter for this calibration.
gui_app->app_config->set("autocenter", "0");
}

std::vector<size_t> objs_idx = plat->load_files(std::vector<std::string>{
Slic3r::resources_dir()+"/calibration/over-bridge_tuning/over-bridge_flow_ratio_test.amf",
Slic3r::resources_dir()+"/calibration/over-bridge_tuning/over-bridge_flow_ratio_test.amf",
Expand Down Expand Up @@ -117,6 +124,11 @@ void CalibrationOverBridgeDialog::create_geometry(wxCommandEvent& event_args) {

plat->reslice();
plat->select_view_3D("Preview");

if (autocenter) {
//re-enable auto-center after this calibration.
gui_app->app_config->set("autocenter", "1");
}
}

} // namespace GUI
Expand Down
12 changes: 8 additions & 4 deletions src/slic3r/GUI/CalibrationTempDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CalibrationTempDialog.hpp"
#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "AppConfig.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "Tab.hpp"
Expand Down Expand Up @@ -107,10 +108,13 @@ void CalibrationTempDialog::create_geometry(wxCommandEvent& event_args) {


/// --- translate ---
const ConfigOptionPoints* bed_shape = printerConfig->option<ConfigOptionPoints>("bed_shape");
Vec2d bed_size = BoundingBoxf(bed_shape->values).size();
Vec2d bed_min = BoundingBoxf(bed_shape->values).min;
model.objects[objs_idx[0]]->translate({ bed_min.x() + bed_size.x() / 2, bed_min.y() + bed_size.y() / 2, 0 });
bool autocenter = gui_app->app_config->get("autocenter") == "1";
if (!autocenter) {
const ConfigOptionPoints* bed_shape = printerConfig->option<ConfigOptionPoints>("bed_shape");
Vec2d bed_size = BoundingBoxf(bed_shape->values).size();
Vec2d bed_min = BoundingBoxf(bed_shape->values).min;
model.objects[objs_idx[0]]->translate({ bed_min.x() + bed_size.x() / 2, bed_min.y() + bed_size.y() / 2, 0 });
}

/// --- main config, please modify object config when possible ---
DynamicPrintConfig new_print_config = *printConfig; //make a copy
Expand Down

0 comments on commit 2f8cb3b

Please sign in to comment.