Skip to content

Ch. 3 ‐ Adding new parameters to the GUI

Alex Petsiuk edited this page Aug 14, 2024 · 2 revisions

commits 1641b2b, 72a5d34

Screenshot 2023-03-08 152545

To add a few variables to the PrusaSlicer GUI you have to modify the following files:

  • slic3r/GUI/Tab.cpp
  • libslic3r/PrintConfig.hpp
  • libslic3r/PrintConfig.cpp
  • libslic3r/Preset.cpp

----cpp

Example:

Screenshot 2023-03-07 182500

Tab.cpp

page = add_options_page(L("Tool Clustering"), "atc_tool_clustering.png"); // ../PrusaSlicer/resources/icons
    optgroup = page->new_optgroup(L("General parameters (experimental)"));
    optgroup->append_single_option_line("atc_enable_tool_clustering");

PrintConfig.hpp

PRINT_CONFIG_CLASS_DEFINE(
    PrintObjectConfig,
    ((ConfigOptionBool,                atc_enable_tool_clustering))

PrintConfig.cpp

// enable ATC tool clustering: bool checkbox
def = this->add("atc_enable_tool_clustering", coBool);
def->label = L("Enable tool clustering");
def->tooltip = L("This feature will enable the experimental ATC color layer batching algorithm.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));

Preset.cpp

static std::vector<std::string> s_Preset_print_options {..., "atc_enable_tool_clustering", ... }

Accessing new variables in code

Screenshot 2023-03-08 155706

m_print_config.option<ConfigOptionBool>("atc_enable_tool_clustering")->value = true;

if (m_print_config.option<ConfigOptionBool>("atc_enable_tool_clustering")->value) {...}

OR

double critical_intersection = print.m_objects[0]->config().atc_critical_intersection_area; // 0.5