mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-28 19:31:22 +00:00
Merge branch 'main' into cad-mainline
This commit is contained in:
@@ -97,6 +97,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/CloneDialog.hpp
|
||||
GUI/ConfigManipulation.cpp
|
||||
GUI/ConfigManipulation.hpp
|
||||
GUI/ConfigValueFormatter.cpp
|
||||
GUI/ConfigValueFormatter.hpp
|
||||
GUI/ConfigWizard.cpp
|
||||
GUI/ConfigWizard.hpp
|
||||
GUI/ConfigWizard_private.hpp
|
||||
@@ -451,6 +453,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/Project.hpp
|
||||
GUI/PublishDialog.cpp
|
||||
GUI/PublishDialog.hpp
|
||||
GUI/PublishSettingsDialog.cpp
|
||||
GUI/PublishSettingsDialog.hpp
|
||||
GUI/PurgeModeDialog.cpp
|
||||
GUI/PurgeModeDialog.hpp
|
||||
GUI/RammingChart.cpp
|
||||
@@ -676,6 +680,10 @@ set(SLIC3R_GUI_SOURCES
|
||||
Utils/bambu_networking.hpp
|
||||
Utils/Bonjour.cpp
|
||||
Utils/Bonjour.hpp
|
||||
Utils/MeshInspect.cpp
|
||||
Utils/MeshInspect.hpp
|
||||
Utils/PaintCLI.cpp
|
||||
Utils/PaintCLI.hpp
|
||||
Utils/CalibUtils.cpp
|
||||
Utils/CalibUtils.hpp
|
||||
Utils/ColorSpaceConvert.cpp
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/ClipperUtils.hpp"
|
||||
#include "libslic3r/GCode/WipeTower.hpp"
|
||||
#include "libslic3r/GCode/WipeTowerEstimate.hpp"
|
||||
#include "libslic3r/Tesselate.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
@@ -919,6 +921,21 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||
GUI::PartPlateList& ppl = GUI::wxGetApp().plater()->get_partplate_list();
|
||||
std::vector<int> plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true);
|
||||
TriangleMesh wipe_tower_shell = make_cube(width, depth, height);
|
||||
// The brim is part of the printed footprint: draw it and fold it into the shell so the
|
||||
// outside-bed shader and the drag clamp react to the true first-layer extent.
|
||||
const bool show_brim = brim_width > 0.f;
|
||||
const float brim_height = 0.2f; // one first layer, visual only
|
||||
TriangleMesh brim_slab;
|
||||
if (show_brim) {
|
||||
// The brim follows the real first-layer outline: a Type2 cone-wall tower's base bulges
|
||||
// past the body box. The wall type and angle are print settings, the planner a printer one.
|
||||
const DynamicPrintConfig &print_cfg = GUI::wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
const DynamicPrintConfig &printer_cfg = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
const Polygon outline = estimate_wipe_tower_first_layer_outline(print_cfg, resolve_wipe_tower_type(printer_cfg), width, depth, height);
|
||||
const Polygons brim_outline = offset(outline, scaled(brim_width));
|
||||
brim_slab = WipeTower::its_make_rib_brim(brim_outline.empty() ? outline : brim_outline.front(), brim_height);
|
||||
wipe_tower_shell.merge(brim_slab);
|
||||
}
|
||||
for (int extruder_id : plate_extruders) {
|
||||
if (extruder_id <= extruder_colors.size())
|
||||
colors.push_back(extruder_colors[extruder_id - 1]);
|
||||
@@ -929,14 +946,19 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
||||
// Orca: make it transparent
|
||||
for(auto& color : colors)
|
||||
color.a(0.66f);
|
||||
const size_t slab_count = colors.size(); // per-filament body slabs; the brim part comes after
|
||||
if (show_brim && !colors.empty())
|
||||
colors.push_back(colors.front());
|
||||
volumes.emplace_back(new GLWipeTowerVolume(colors));
|
||||
GLWipeTowerVolume& v = *dynamic_cast<GLWipeTowerVolume*>(volumes.back());
|
||||
v.model_per_colors.resize(colors.size());
|
||||
for (int i = 0; i < colors.size(); i++) {
|
||||
TriangleMesh color_part = make_cube(width, depth / colors.size(), height);
|
||||
color_part.translate({ 0.f, depth * i / colors.size(), 0. });
|
||||
for (size_t i = 0; i < slab_count; i++) {
|
||||
TriangleMesh color_part = make_cube(width, depth / slab_count, height);
|
||||
color_part.translate({ 0.f, depth * i / slab_count, 0. });
|
||||
v.model_per_colors[i].init_from(color_part);
|
||||
}
|
||||
if (show_brim && !colors.empty())
|
||||
v.model_per_colors[slab_count].init_from(brim_slab);
|
||||
v.model.init_from(wipe_tower_shell);
|
||||
v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(wipe_tower_shell));
|
||||
v.set_convex_hull(wipe_tower_shell);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "AMSDryControl.hpp"
|
||||
#include "slic3r/GUI/DeviceCore/DevFilaSystem.h"
|
||||
#include "GUI_App.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include "slic3r/GUI/DeviceCore/DevExtruderSystem.h"
|
||||
@@ -1196,11 +1197,11 @@ void AMSDryCtrWin::update_normal_description(DevAms* dev_ams)
|
||||
for (const auto& lim : ams_limits) {
|
||||
if (dev_ams->GetAmsType() == lim.type) {
|
||||
if (temp_val > lim.max_temp) {
|
||||
wxString msg = wxString(lim.name) + _L(" maximum drying temperature is ") + wxString::Format(wxT("%d"), lim.max_temp) + wxString::FromUTF8("°C.");
|
||||
wxString msg = wxString::Format(_L("%s maximum drying temperature is %d°C."), wxString(lim.name), lim.max_temp);
|
||||
warning_text += msg + "\n";
|
||||
can_enable_button = false;
|
||||
} else if (temp_val < lim.min_temp) {
|
||||
wxString msg = wxString(lim.name) + _L(" minimum drying temperature is ") + wxString::Format(wxT("%d"), lim.min_temp) + wxString::FromUTF8("°C.");
|
||||
wxString msg = wxString::Format(_L("%s minimum drying temperature is %d°C."), wxString(lim.name), lim.min_temp);
|
||||
warning_text += msg + "\n";
|
||||
can_enable_button = false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
//Previous defintions
|
||||
class wxGrid;
|
||||
class ProgressBar;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@@ -97,12 +98,6 @@ private:
|
||||
wxSimplebook* m_main_simplebook{nullptr};
|
||||
wxPanel* m_original_page{nullptr};
|
||||
|
||||
wxWindow* m_amswin{nullptr};
|
||||
wxBoxSizer* m_sizer_ams_items{nullptr};
|
||||
wxScrolledWindow* m_panel_prv_left {nullptr};
|
||||
wxScrolledWindow* m_panel_prv_right{nullptr};
|
||||
wxBoxSizer* m_sizer_prv_left{nullptr};
|
||||
wxBoxSizer* m_sizer_prv_right{nullptr};
|
||||
|
||||
// left panel related members
|
||||
ScalableBitmap m_humidity_image;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "ExtrusionCalibration.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "format.hpp"
|
||||
#include "Widgets/ProgressDialog.hpp"
|
||||
#include <wx/tooltip.h>
|
||||
#include "Widgets/RoundedRectangle.hpp"
|
||||
#include "Widgets/StaticBox.hpp"
|
||||
|
||||
|
||||
@@ -457,7 +457,6 @@ private:
|
||||
ScalableBitmap close_img;
|
||||
|
||||
wxStaticBitmap* curr_humidity_img;
|
||||
wxStaticBitmap* m_img;
|
||||
|
||||
Label* m_staticText;;
|
||||
Label* m_staticText_note;
|
||||
|
||||
@@ -406,7 +406,7 @@ void AmsMapingPopup::update_ams_data_multi_machines()
|
||||
int ams_type = 1;
|
||||
int nozzle_id = 0;
|
||||
|
||||
if (ams_type >= 1 || ams_type <= 3) { // 1:ams 2:ams-lite 3:n3f
|
||||
if (ams_type >= 1 && ams_type <= 3) { // 1:ams 2:ams-lite 3:n3f
|
||||
|
||||
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0 ? m_right_marea_panel : m_left_marea_panel, "AMS-1", 4);
|
||||
|
||||
@@ -93,7 +93,6 @@ private:
|
||||
CenteredTitle* m_title_ctrl { nullptr };
|
||||
wxString m_titleText;
|
||||
|
||||
wxAuiToolBarItem* m_model_store_item;
|
||||
|
||||
//wxAuiToolBarItem *m_publish_item;
|
||||
wxAuiToolBarItem* m_undo_item;
|
||||
|
||||
@@ -848,7 +848,9 @@ void BackgroundSlicingProcess::finalize_gcode()
|
||||
case CopyFileResult::SUCCESS: break; // no error
|
||||
case CopyFileResult::FAIL_COPY_FILE:
|
||||
throw Slic3r::ExportError(GUI::format(
|
||||
_L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%"),
|
||||
m_export_path_on_removable_media ?
|
||||
_L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%") :
|
||||
_L("Copying of the temporary G-code to the output G-code failed.\nError message: %1%"),
|
||||
error_message));
|
||||
break;
|
||||
case CopyFileResult::FAIL_FILES_DIFFERENT:
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#include <thread>
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include <wx/timer.h>
|
||||
|
||||
class Button;
|
||||
class Label;
|
||||
class CheckBox;
|
||||
namespace Slic3r { namespace GUI {
|
||||
class CapsuleButton;
|
||||
|
||||
@@ -65,18 +65,10 @@ private:
|
||||
wxPanel* request_bind_panel;
|
||||
wxPanel* binding_panel;
|
||||
|
||||
wxScrolledWindow* m_sw_bind_failed_info;
|
||||
Label* m_bind_failed_info;
|
||||
Label* m_st_txt_error_code{ nullptr };
|
||||
Label* m_st_txt_error_desc{ nullptr };
|
||||
Label* m_st_txt_extra_info{ nullptr };
|
||||
HyperLink* m_link_network_state{ nullptr };
|
||||
wxString m_result_info;
|
||||
wxString m_result_extra;
|
||||
wxString m_ping_code_wiki;
|
||||
bool m_show_error_info_state = true;
|
||||
|
||||
int m_result_code;
|
||||
std::shared_ptr<BBLStatusBarBind> m_status_bar;
|
||||
|
||||
public:
|
||||
@@ -110,7 +102,6 @@ private:
|
||||
wxBitmap m_bitmap_show_error_close;
|
||||
wxBitmap m_bitmap_show_error_open;
|
||||
wxScrolledWindow* m_sw_bind_failed_info;
|
||||
Label* m_bind_failed_info;
|
||||
Label* m_st_txt_error_code{ nullptr };
|
||||
Label* m_st_txt_error_desc{ nullptr };
|
||||
Label* m_st_txt_extra_info{ nullptr };
|
||||
|
||||
@@ -70,11 +70,7 @@ public:
|
||||
|
||||
private:
|
||||
int m_my_devices_count{ 0 };
|
||||
int m_other_devices_count{ 0 };
|
||||
bool m_dismiss{ false };
|
||||
wxWindow* m_placeholder_panel { nullptr };
|
||||
wxWindow* m_panel_body{ nullptr };
|
||||
wxBoxSizer* m_sizer_body{ nullptr };
|
||||
wxBoxSizer* m_sizer_my_devices{ nullptr };
|
||||
wxScrolledWindow* m_scrolledWindow{ nullptr };
|
||||
wxTimer* m_refresh_timer{ nullptr };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CalibrationWizard.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "CalibrationWizardPage.hpp"
|
||||
#include "../../libslic3r/calib.hpp"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <regex>
|
||||
#include "CalibrationWizardPresetPage.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
@@ -360,7 +362,7 @@ void CaliPresetCustomRangePanel::create_panel(wxWindow* parent)
|
||||
int max_decimal_length;
|
||||
if (i <= 1)
|
||||
max_decimal_length = 3;
|
||||
else if (i >= 2)
|
||||
else
|
||||
max_decimal_length = 4;
|
||||
if (decimal_number > max_decimal_length) {
|
||||
int allowed_length = number.length() - decimal_number + max_decimal_length;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CalibrationWizardSavePage.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
|
||||
@@ -72,8 +72,10 @@ private:
|
||||
SwitchButton* m_switch_recording;
|
||||
wxStaticText* m_text_vcamera;
|
||||
SwitchButton* m_switch_vcamera;
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
wxStaticText* m_text_liveview_retry;
|
||||
SwitchButton* m_switch_liveview_retry;
|
||||
#endif //BBL_RELEASE_TO_PUBLIC
|
||||
wxStaticText* m_custom_camera_hint;
|
||||
TextInput* m_custom_camera_input;
|
||||
Button* m_custom_camera_input_confirm;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "GUI_App.hpp"
|
||||
#include "CapsuleButton.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
#include <wx/dcbuffer.h>
|
||||
#include "wx/graphics.h"
|
||||
#include "Widgets/Label.hpp"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ColorDecomposeSupport.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "MixedFilamentDialog.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
@@ -394,8 +395,9 @@ bool confirm_create_decompose_missing_components(wxWindow* parent, const std::ve
|
||||
missing_text += missing[i].display_name;
|
||||
}
|
||||
|
||||
wxString message = _L("The current filament list does not contain ") + missing_text +
|
||||
_L(". A project filament required by the mixed filament will be created automatically after decomposition.");
|
||||
wxString message = wxString::Format(_L("The current filament list does not contain %s. A project filament required by "
|
||||
"the mixed filament will be created automatically after decomposition."),
|
||||
missing_text);
|
||||
|
||||
MessageDialog dlg(parent, message, _L("Tip"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
||||
dlg.show_dsa_button();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ConfigManipulation.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "DeviceCore/DevConfigUtil.h"
|
||||
#include "format.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
@@ -1040,10 +1041,12 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
|
||||
for (auto el : {"wipe_tower_rotation_angle", "wipe_tower_cone_angle",
|
||||
"wipe_tower_extra_spacing", "wipe_tower_max_purge_speed",
|
||||
"wipe_tower_bridging", "wipe_tower_extra_flow",
|
||||
"wipe_tower_no_sparse_layers"})
|
||||
"wipe_tower_bridging", "wipe_tower_extra_flow"})
|
||||
toggle_line(el, have_prime_tower && supports_wipe_tower_2);
|
||||
|
||||
// Orca: both tower generators skip sparse layers, so this is not a wipe tower 2 exclusive.
|
||||
toggle_line("wipe_tower_no_sparse_layers", have_prime_tower);
|
||||
|
||||
WipeTowerWallType wipe_tower_wall_type = config->opt_enum<WipeTowerWallType>("wipe_tower_wall_type");
|
||||
bool have_rib_wall = (wipe_tower_wall_type == WipeTowerWallType::wtwRib)&&have_prime_tower;
|
||||
toggle_line("wipe_tower_cone_angle", have_prime_tower && supports_wipe_tower_2 && wipe_tower_wall_type == WipeTowerWallType::wtwCone);
|
||||
@@ -1054,6 +1057,10 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
|
||||
toggle_line("single_extruder_multi_material_priming", !bSEMM && have_prime_tower && supports_wipe_tower_2);
|
||||
|
||||
bool use_cyclic_ordering = config->opt_enum<ToolChangeOrderingType>("toolchange_ordering") == ToolChangeOrderingType::Cyclic;
|
||||
toggle_line("toolchange_cyclic_order", use_cyclic_ordering);
|
||||
toggle_line("toolchange_cyclic_first_layer", use_cyclic_ordering);
|
||||
|
||||
toggle_line("prime_volume",have_prime_tower && (!purge_in_primetower || !bSEMM));
|
||||
|
||||
for (auto el : {"flush_into_infill", "flush_into_support", "flush_into_objects"})
|
||||
@@ -1103,6 +1110,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
auto is_role_based_wipe_speed = config->opt_bool("role_based_wipe_speed");
|
||||
toggle_field("wipe_speed",!is_role_based_wipe_speed);
|
||||
|
||||
const bool have_wipe_inward = config->opt_bool("wipe_inward");
|
||||
toggle_line("wipe_inward_distance", have_wipe_inward);
|
||||
|
||||
for (auto el : {"accel_to_decel_enable", "accel_to_decel_factor"})
|
||||
toggle_line(el, gcf_is_klipper);
|
||||
if(gcf_is_klipper)
|
||||
@@ -1124,6 +1134,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
bool has_detect_overhang_wall = config->opt_bool("detect_overhang_wall");
|
||||
bool has_overhang_reverse = config->opt_bool("overhang_reverse");
|
||||
bool allow_overhang_reverse = !has_spiral_vase;
|
||||
toggle_line("unsupported_wall_last", has_detect_overhang_wall);
|
||||
toggle_line("overhang_reverse", allow_overhang_reverse);
|
||||
toggle_line("overhang_reverse_internal_only", allow_overhang_reverse && has_overhang_reverse);
|
||||
bool has_overhang_reverse_internal_only = config->opt_bool("overhang_reverse_internal_only");
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "ConfigValueFormatter.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
#include "I18N.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "Field.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
std::string get_pure_opt_key(const std::string& opt_key)
|
||||
{
|
||||
std::string pure_key = opt_key;
|
||||
const int pos = pure_key.find("#");
|
||||
if (pos > 0)
|
||||
boost::erase_tail(pure_key, pure_key.size() - pos);
|
||||
return pure_key;
|
||||
}
|
||||
|
||||
wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill, int idx)
|
||||
{
|
||||
const ConfigOptionDef& def = config.def()->options.at(opt_key);
|
||||
const std::vector<std::string>& names = def.enum_labels;//ConfigOptionEnum<T>::get_enum_names();
|
||||
int val = 0;
|
||||
|
||||
if (idx >= 0)
|
||||
val = dynamic_cast<const ConfigOptionInts*>(config.option(opt_key))->get_at(idx);
|
||||
else
|
||||
val = config.option(opt_key)->getInt();
|
||||
|
||||
// Each infill doesn't use all list of infill declared in PrintConfig.hpp.
|
||||
// So we should "convert" val to the correct one
|
||||
if (is_infill) {
|
||||
for (auto key_val : *def.enum_keys_map)
|
||||
if (int(key_val.second) == val) {
|
||||
auto it = std::find(def.enum_values.begin(), def.enum_values.end(), key_val.first);
|
||||
if (it == def.enum_values.end())
|
||||
return "";
|
||||
return from_u8(_utf8(names[it - def.enum_values.begin()]));
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
return from_u8(_utf8(names[val]));
|
||||
}
|
||||
|
||||
wxString get_full_label(const std::string& opt_key, const DynamicPrintConfig& config)
|
||||
{
|
||||
const std::string pure_key = get_pure_opt_key(opt_key);
|
||||
auto option = config.option(pure_key);
|
||||
|
||||
if (!option || option->is_nil())
|
||||
return _L("N/A");
|
||||
|
||||
const ConfigOptionDef* opt = config.def()->get(pure_key);
|
||||
return opt->full_label.empty() ? opt->label : opt->full_label;
|
||||
}
|
||||
|
||||
wxString get_string_value(const std::string& opt_key, const DynamicPrintConfig& config)
|
||||
{
|
||||
int orig_opt_idx = -1;
|
||||
int opt_idx = -1;
|
||||
int pos = opt_key.find("#");
|
||||
std::string temp_str = opt_key;
|
||||
if (pos > 0) {
|
||||
boost::erase_head(temp_str, pos + 1);
|
||||
orig_opt_idx = std::atoi(temp_str.c_str());
|
||||
}
|
||||
opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0;
|
||||
const std::string pure_key = get_pure_opt_key(opt_key);
|
||||
auto option = config.option(pure_key);
|
||||
if (!option) {
|
||||
return _L("N/A");
|
||||
}
|
||||
auto opt_vector = dynamic_cast<const ConfigOptionVectorBase *>(option);
|
||||
|
||||
if ((option->is_scalar() && option->is_nil()) ||
|
||||
(option->is_vector() && opt_vector && opt_idx >= 0 && opt_idx < opt_vector->size() && opt_vector->is_nil(opt_idx)))
|
||||
return _L("N/A");
|
||||
|
||||
wxString out;
|
||||
|
||||
const ConfigOptionDef* opt = config.def()->get(pure_key);
|
||||
bool is_nullable = opt->nullable;
|
||||
|
||||
switch (opt->type) {
|
||||
case coInt:
|
||||
return from_u8((boost::format("%1%") % config.opt_int(pure_key)).str());
|
||||
case coInts: {
|
||||
if (is_nullable) {
|
||||
auto values = config.opt<ConfigOptionIntsNullable>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str());
|
||||
}
|
||||
else {
|
||||
auto values = config.opt<ConfigOptionInts>(pure_key);
|
||||
if (orig_opt_idx >= 0 && orig_opt_idx < values->size()) {
|
||||
return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str());
|
||||
}
|
||||
else {
|
||||
std::string value_str;
|
||||
for (int i = 0; i < values->size(); i++) {
|
||||
value_str += std::to_string(values->get_at(i));
|
||||
if (i != values->size() - 1) {
|
||||
value_str += ",";
|
||||
}
|
||||
}
|
||||
return from_u8(value_str);
|
||||
}
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coBool:
|
||||
return config.opt_bool(pure_key) ? "true" : "false";
|
||||
case coBools: {
|
||||
if (is_nullable) {
|
||||
auto values = config.opt<ConfigOptionBoolsNullable>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return values->get_at(opt_idx) ? "true" : "false";
|
||||
}
|
||||
else {
|
||||
auto values = config.opt<ConfigOptionBools>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return values->get_at(opt_idx) ? "true" : "false";
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coPercent:
|
||||
return from_u8((boost::format("%1%%%") % int(config.optptr(pure_key)->getFloat())).str());
|
||||
case coPercents: {
|
||||
if (is_nullable) {
|
||||
auto values = config.opt<ConfigOptionPercentsNullable>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str());
|
||||
}
|
||||
else {
|
||||
auto values = config.opt<ConfigOptionPercents>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str());
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coFloat:
|
||||
return double_to_string(config.opt_float(pure_key));
|
||||
case coFloats: {
|
||||
if (is_nullable) {
|
||||
auto values = config.opt<ConfigOptionFloatsNullable>(pure_key);
|
||||
if (opt_idx < values->size())
|
||||
return double_to_string(values->get_at(opt_idx));
|
||||
}
|
||||
else {
|
||||
auto values = config.opt<ConfigOptionFloats>(pure_key);
|
||||
if (values && opt_idx < values->size())
|
||||
return double_to_string(values->get_at(opt_idx));
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coString:
|
||||
return from_u8(config.opt_string(pure_key));
|
||||
case coStrings: {
|
||||
const ConfigOptionStrings* strings = config.opt<ConfigOptionStrings>(pure_key);
|
||||
if (strings) {
|
||||
if (pure_key == "compatible_printers" || pure_key == "compatible_prints") {
|
||||
if (strings->empty())
|
||||
return _L("All");
|
||||
for (size_t id = 0; id < strings->size(); id++)
|
||||
out += from_u8(strings->get_at(id)) + "\n";
|
||||
out.RemoveLast(1);
|
||||
return out;
|
||||
}
|
||||
if (!strings->empty() && opt_idx < strings->values.size())
|
||||
return from_u8(strings->get_at(opt_idx));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case coFloatOrPercent: {
|
||||
const ConfigOptionFloatOrPercent* opt = config.opt<ConfigOptionFloatOrPercent>(pure_key);
|
||||
if (opt)
|
||||
out = double_to_string(opt->value) + (opt->percent ? "%" : "");
|
||||
return out;
|
||||
}
|
||||
case coFloatsOrPercents: {
|
||||
const auto* values = static_cast<const ConfigOptionVector<FloatOrPercent>*>(option);
|
||||
// Orca: Preset comparison may request the entire vector instead of an indexed entry.
|
||||
if (orig_opt_idx < 0)
|
||||
return from_u8(option->serialize());
|
||||
if (opt_idx < values->size()) {
|
||||
const FloatOrPercent& value = values->get_at(opt_idx);
|
||||
return double_to_string(value.value) + (value.percent ? "%" : "");
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coEnum: {
|
||||
return get_string_from_enum(pure_key, config,
|
||||
pure_key == "top_surface_pattern" ||
|
||||
pure_key == "bottom_surface_pattern" ||
|
||||
pure_key == "internal_solid_infill_pattern" ||
|
||||
pure_key == "sparse_infill_pattern" ||
|
||||
pure_key == "ironing_pattern" ||
|
||||
pure_key == "support_ironing_pattern" ||
|
||||
pure_key == "support_pattern" ||
|
||||
pure_key == "support_interface_pattern")
|
||||
;
|
||||
}
|
||||
case coEnums: {
|
||||
return get_string_from_enum(pure_key, config,
|
||||
pure_key == "top_surface_pattern" ||
|
||||
pure_key == "bottom_surface_pattern" ||
|
||||
pure_key == "internal_solid_infill_pattern" ||
|
||||
pure_key == "sparse_infill_pattern" ||
|
||||
pure_key == "ironing_pattern" ||
|
||||
pure_key == "support_ironing_pattern" ||
|
||||
pure_key == "support_pattern" ||
|
||||
pure_key == "support_interface_pattern"
|
||||
, opt_idx);
|
||||
}
|
||||
case coPoint: {
|
||||
Vec2d val = config.opt<ConfigOptionPoint>(pure_key)->value;
|
||||
return from_u8((boost::format("[%1%]") % ConfigOptionPoint(val).serialize()).str());
|
||||
}
|
||||
case coPoints: {
|
||||
//BBS: add bed_exclude_area
|
||||
if (pure_key == "printable_area" || pure_key == "thumbnails") {
|
||||
ConfigOptionPoints points = *config.option<ConfigOptionPoints>(pure_key);
|
||||
//BuildVolume build_volume = {points.values, 0.};
|
||||
return get_thumbnails_string(points.values);
|
||||
}
|
||||
else if (pure_key == "bed_exclude_area") {
|
||||
return get_thumbnails_string(config.option<ConfigOptionPoints>(pure_key)->values);
|
||||
}
|
||||
else if (pure_key == "head_wrap_detect_zone") {
|
||||
return get_thumbnails_string(config.option<ConfigOptionPoints>(pure_key)->values);
|
||||
}
|
||||
else if (pure_key == "wrapping_exclude_area") {
|
||||
return get_thumbnails_string(config.option<ConfigOptionPoints>(pure_key)->values);
|
||||
}
|
||||
Vec2d val = config.opt<ConfigOptionPoints>(pure_key)->get_at(opt_idx);
|
||||
return from_u8((boost::format("[%1%]") % ConfigOptionPoint(val).serialize()).str());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <wx/string.h>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class DynamicPrintConfig;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
// Human-readable value of opt_key (may carry a "#<index>" suffix) in config.
|
||||
wxString get_string_value(const std::string& opt_key, const DynamicPrintConfig& config);
|
||||
|
||||
// Full label of opt_key; "N/A" when the option is not set.
|
||||
wxString get_full_label(const std::string& opt_key, const DynamicPrintConfig& config);
|
||||
|
||||
// Strip the "#<index>" suffix (if any) from the option key.
|
||||
std::string get_pure_opt_key(const std::string& opt_key);
|
||||
|
||||
// Localized label of the currently selected value of an enum option.
|
||||
wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill = false, int idx = -1);
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
@@ -74,7 +74,6 @@ private:
|
||||
std::unordered_set<std::string> m_system_filament_types_set;
|
||||
std::set<std::string> m_visible_printers;
|
||||
CreateType m_create_type;
|
||||
Button * m_button_cancel = nullptr;
|
||||
ComboBox * m_filament_vendor_combobox = nullptr;
|
||||
::CheckBox * m_can_not_find_vendor_checkbox = nullptr;
|
||||
ComboBox * m_filament_type_combobox = nullptr;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "DailyTips.hpp"
|
||||
#include "slic3r/GUI/Widgets/Label.hpp"
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
@@ -245,7 +246,6 @@ DailyTipsPanel::DailyTipsPanel(bool can_expand, DailyTipsLayout layout)
|
||||
m_width(0),
|
||||
m_height(0),
|
||||
m_can_expand(can_expand),
|
||||
m_layout(layout),
|
||||
m_uid(DailyTipsPanel::uid++),
|
||||
m_dailytips_renderer(std::make_unique<DailyTipsDataRenderer>(layout))
|
||||
{
|
||||
|
||||
@@ -51,7 +51,6 @@ private:
|
||||
int m_uid;
|
||||
bool m_first_enter{ false };
|
||||
bool m_is_dark{ false };
|
||||
DailyTipsLayout m_layout{ DailyTipsLayout::Vertical };
|
||||
float m_fade_opacity{ 1.0f };
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
|
||||
#include "slic3r/GUI/UserNotification.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void ParseCalibrationConfig(const json& print_json); //cali
|
||||
|
||||
private:
|
||||
MachineObject* m_obj;
|
||||
[[maybe_unused]] MachineObject* m_obj;
|
||||
|
||||
/*configure vals*/
|
||||
// chamber
|
||||
|
||||
@@ -31,7 +31,7 @@ protected:
|
||||
DevExtensionTool(MachineObject* obj);
|
||||
|
||||
private:
|
||||
MachineObject* m_owner = nullptr;
|
||||
[[maybe_unused]] MachineObject* m_owner = nullptr;
|
||||
|
||||
enum MountState
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void SetAutoRefillEnabled(bool enable) { m_enable_auto_refill = enable; }
|
||||
|
||||
private:
|
||||
DevFilaSystem* m_owner = nullptr;
|
||||
[[maybe_unused]] DevFilaSystem* m_owner = nullptr;
|
||||
|
||||
std::optional<bool> m_enable_detect_on_insert = false;
|
||||
bool m_enable_detect_on_powerup = false;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <set>
|
||||
|
||||
#include "DevFilaBlackList.h"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
#include "DevFilaSystem.h"
|
||||
#include "DevManager.h"
|
||||
#include "DevConfigUtil.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "DevFilaSystem.h"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "DevNozzleSystem.h" // DevNozzle / DevNozzleSystem for GetNozzleFlowStringByAmsId
|
||||
|
||||
// TODO: remove this include
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
const std::vector<DevHMSItem>& GetHMSItems() const { return m_hms_list; };
|
||||
|
||||
private:
|
||||
MachineObject* m_object = nullptr;
|
||||
[[maybe_unused]] MachineObject* m_object = nullptr;
|
||||
|
||||
// all hms for this machine
|
||||
std::vector<DevHMSItem> m_hms_list;
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
//std::string m_connect_type;
|
||||
//std::string m_bind_state;
|
||||
|
||||
MachineObject* m_owner = nullptr;
|
||||
[[maybe_unused]] MachineObject* m_owner = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -872,7 +872,7 @@ namespace Slic3r
|
||||
obj->m_is_online = elem["dev_online"].get<bool>();
|
||||
if (elem.contains("dev_model_name") && !elem["dev_model_name"].is_null()) {
|
||||
auto printer_type = elem["dev_model_name"].get<std::string>();
|
||||
for (const std::pair<std::string, std::vector<std::string>> &pair : device_subseries) {
|
||||
for (const auto &pair : device_subseries) {
|
||||
auto it = std::find(pair.second.begin(), pair.second.end(), printer_type);
|
||||
if (it != pair.second.end())
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <limits>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "DevMapping.h"
|
||||
#include "DevFilaSystem.h"
|
||||
@@ -270,7 +272,7 @@ namespace Slic3r
|
||||
std::set<int> picked_tar;
|
||||
for (int k = 0; k < distance_map.size(); k++)
|
||||
{
|
||||
float min_val = INT_MAX;
|
||||
float min_val = std::numeric_limits<float>::max();
|
||||
int picked_src_idx = -1;
|
||||
int picked_tar_idx = -1;
|
||||
for (int i = 0; i < distance_map.size(); i++)
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void ParseStatus(const nlohmann::json& print_jj);
|
||||
|
||||
private:
|
||||
MachineObject *m_owner = nullptr;
|
||||
[[maybe_unused]] MachineObject *m_owner = nullptr;
|
||||
std::optional<DevJobState> m_job_state; // could be nullopt for some old firmware
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
bool is_timelapse_storage_low(const std::string& storage) const;
|
||||
|
||||
private:
|
||||
MachineObject *m_owner;
|
||||
[[maybe_unused]] MachineObject *m_owner;
|
||||
SdcardState m_sdcard_state { NO_SDCARD };
|
||||
// timelapse storage space info (from device push cam data)
|
||||
int tl_internal_free_kb{-1};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "libslic3r/Time.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "wgtMsgPanel.h"
|
||||
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/GUI/Widgets/Label.hpp"
|
||||
#include "slic3r/GUI/Widgets/StateColor.hpp"
|
||||
#include "slic3r/GUI/wxExtensions.hpp"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "DragCanvas.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include "EncodedFilament.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace Slic3r
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ExportPresetBundleDialog.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "I18N.hpp"
|
||||
@@ -12,7 +13,11 @@
|
||||
#include <libslic3r/PresetBundle.hpp>
|
||||
#include <wx/string.h>
|
||||
#include <miniz.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <slic3r/GUI/MsgDialog.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
ExportPresetBundleDialog::ExportPresetBundleDialog(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "ExtraRenderers.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "BitmapComboBox.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ExtrusionCalibration.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
+111
-123
@@ -11,6 +11,7 @@
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <regex>
|
||||
#include <utility>
|
||||
#include <cstdint>
|
||||
@@ -540,51 +541,95 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
||||
case coStrings:
|
||||
case coFloatOrPercent:
|
||||
case coFloatsOrPercents: {
|
||||
if ((m_opt.type == coFloatOrPercent || m_opt.type == coFloatsOrPercents) && !str.IsEmpty() && str.Last() != '%')
|
||||
{
|
||||
if ((m_opt.type == coFloatOrPercent || m_opt.type == coFloatsOrPercents) && !str.IsEmpty() &&
|
||||
!(m_opt.nullable && str == m_na_value)) {
|
||||
bool update_control = false;
|
||||
wxString numeric_str = str;
|
||||
double val = 0.;
|
||||
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number.
|
||||
if (str.Replace(dec_sep_alt, dec_sep, false) != 0)
|
||||
set_value(str, false);
|
||||
// Orca: normalize the decimal separator and optional unit before
|
||||
// detecting the percentage suffix and parsing the numeric part.
|
||||
update_control |= numeric_str.Replace(dec_sep_alt, dec_sep, false) != 0;
|
||||
update_control |= numeric_str.Replace(" ", "", true) != 0;
|
||||
const bool has_literal_unit = numeric_str.EndsWith("mm");
|
||||
if (has_literal_unit) {
|
||||
numeric_str.RemoveLast(2);
|
||||
update_control = true;
|
||||
}
|
||||
bool is_percent = !numeric_str.IsEmpty() && numeric_str.Last() == '%';
|
||||
if (is_percent)
|
||||
numeric_str.RemoveLast();
|
||||
|
||||
|
||||
// remove space and "mm" substring, if any exists
|
||||
str.Replace(" ", "", true);
|
||||
str.Replace("m", "", true);
|
||||
|
||||
if (!str.ToDouble(&val))
|
||||
{
|
||||
if ((has_literal_unit && is_percent) || !numeric_str.ToDouble(&val) || !std::isfinite(val)) {
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
break;
|
||||
}
|
||||
show_error(m_parent, _L("Invalid numeric."));
|
||||
set_value(double_to_string(val), true);
|
||||
}
|
||||
else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
|
||||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) &&
|
||||
(m_value.empty() || into_u8(str) != boost::any_cast<std::string>(m_value)))
|
||||
{
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
break;
|
||||
numeric_str = double_to_string(std::clamp(0., double(m_opt.min), double(m_opt.max)));
|
||||
is_percent = false;
|
||||
update_control = true;
|
||||
} else {
|
||||
const bool looks_like_missing_percent = !is_percent && !has_literal_unit &&
|
||||
((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
|
||||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > m_opt.max_literal));
|
||||
// Orca: validate explicit percentages and literal values before
|
||||
// asking whether an otherwise valid literal was meant as a percentage.
|
||||
const bool out_of_range = !m_opt.is_value_valid(val);
|
||||
if (out_of_range) {
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
break;
|
||||
}
|
||||
show_error(m_parent, _L("Value is out of range."));
|
||||
val = std::clamp(val, double(m_opt.min), double(m_opt.max));
|
||||
// Orca: retain the inferred percent unit when clamping a
|
||||
// suspicious unitless value, so 2000 becomes 100%, not 100 mm.
|
||||
is_percent |= looks_like_missing_percent;
|
||||
numeric_str = double_to_string(val);
|
||||
update_control = true;
|
||||
} else {
|
||||
const bool value_changed = m_value.empty() || into_u8(str) != boost::any_cast<std::string>(m_value);
|
||||
if (looks_like_missing_percent && value_changed) {
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
|
||||
const wxString stVal = numeric_str;
|
||||
const wxString msg_text = from_u8((boost::format(_utf8(L("Is it %s%% or %s %s?"))) %
|
||||
stVal % stVal % sidetext).str());
|
||||
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
|
||||
dialog.SetButtonLabel(wxID_YES, stVal + _L("%"));
|
||||
dialog.SetButtonLabel(wxID_NO, stVal + " " + _L(sidetext));
|
||||
dialog.GetSizer()->SetSizeHints(&dialog);
|
||||
dialog.Fit();
|
||||
dialog.CenterOnParent();
|
||||
is_percent = dialog.ShowModal() == wxID_YES;
|
||||
update_control = true;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
|
||||
const wxString stVal = double_to_string(val, 2);
|
||||
const wxString msg_text = from_u8((boost::format(_utf8(L("Is it %s%% or %s %s?\n"
|
||||
"YES for %s%%, \n"
|
||||
"NO for %s %s."))) %
|
||||
stVal % stVal % sidetext % stVal % stVal % sidetext)
|
||||
.str());
|
||||
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
|
||||
if ((val > 100) && dialog.ShowModal() == wxID_YES) {
|
||||
set_value(from_u8((boost::format("%s%%") % stVal).str()), false /*true*/);
|
||||
str += "%%";
|
||||
} else
|
||||
set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
|
||||
// Orca: also enforce the literal limit after clamping an explicit mm input.
|
||||
if (!is_percent && m_opt.sidetext.rfind("mm ") != std::string::npos && val > m_opt.max_literal) {
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
break;
|
||||
}
|
||||
if (!out_of_range)
|
||||
show_error(m_parent, _L("Value is out of range."));
|
||||
val = m_opt.max_literal;
|
||||
numeric_str = double_to_string(val);
|
||||
update_control = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update_control) {
|
||||
str = numeric_str + (is_percent ? "%" : "");
|
||||
set_value(str, true);
|
||||
}
|
||||
}
|
||||
if (m_opt.opt_key == "thumbnails") {
|
||||
@@ -2154,6 +2199,7 @@ void PrinterAgentChoice::msw_rescale()
|
||||
void PluginField::BUILD()
|
||||
{
|
||||
auto* panel = new wxPanel(m_parent, wxID_ANY);
|
||||
panel->SetBackgroundColour(*wxWHITE);
|
||||
wxGetApp().UpdateDarkUI(panel);
|
||||
window = panel;
|
||||
|
||||
@@ -2196,9 +2242,8 @@ void PluginField::rebuild_ui()
|
||||
m_rows.clear();
|
||||
m_standalone_add_btn = nullptr;
|
||||
|
||||
if (m_values.empty()) {
|
||||
add_empty_state_row();
|
||||
} else {
|
||||
add_empty_state_row();
|
||||
if (!m_values.empty()) {
|
||||
for (size_t i = 0; i < m_values.size(); ++i)
|
||||
add_plugin_row(display_name_for_value(m_values[i]), i == m_values.size() - 1);
|
||||
}
|
||||
@@ -2215,94 +2260,43 @@ void PluginField::rebuild_ui()
|
||||
|
||||
void PluginField::add_empty_state_row()
|
||||
{
|
||||
const auto button_size = wxSize(def_width_thinner() * m_em_unit, -1);
|
||||
auto row_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxTextCtrl* display = new wxTextCtrl(window, wxID_ANY, _L("No plugin selected"),
|
||||
wxDefaultPosition, wxSize(def_width_wider() * m_em_unit, wxDefaultCoord),
|
||||
wxTE_READONLY);
|
||||
display->SetEditable(false);
|
||||
wxGetApp().UpdateDarkUI(display);
|
||||
display->SetToolTip(_L("No plugin selected"));
|
||||
|
||||
auto add_btn = new ScalableButton(window, wxID_ANY, "param_add", wxEmptyString,
|
||||
button_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 16);
|
||||
wxGetApp().UpdateDarkUI(add_btn);
|
||||
add_btn->SetToolTip(_L("Add plugin"));
|
||||
auto add_btn = new Button(window, _L("Add plugin"), "param_add", 0, 16);
|
||||
add_btn->SetStyle(ButtonStyle::Regular, ButtonType::Parameter);
|
||||
|
||||
add_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { on_add_clicked(); });
|
||||
|
||||
row_sizer->Add(display, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
row_sizer->Add(add_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_main_sizer->Add(row_sizer, 0, wxEXPAND);
|
||||
|
||||
PluginRow row;
|
||||
row.display = display;
|
||||
row.add_btn = add_btn;
|
||||
row.sizer = row_sizer;
|
||||
m_rows.push_back(row);
|
||||
m_main_sizer->Add(add_btn, 0, wxEXPAND | wxBOTTOM, window->FromDIP(SidebarProps::ContentMarginV()));
|
||||
|
||||
m_standalone_add_btn = add_btn;
|
||||
}
|
||||
|
||||
void PluginField::add_plugin_row(const wxString& value, bool is_last)
|
||||
{
|
||||
const auto button_size = wxSize(def_width_thinner() * m_em_unit, -1);
|
||||
auto row_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
ScalableButton* select_btn = new ScalableButton(window, wxID_ANY, "search", wxEmptyString,
|
||||
button_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 16);
|
||||
wxGetApp().UpdateDarkUI(select_btn);
|
||||
select_btn->SetToolTip(_L("Select plugin"));
|
||||
|
||||
wxTextCtrl* display = new wxTextCtrl(window, wxID_ANY, value,
|
||||
wxDefaultPosition, wxSize(def_width_wider() * m_em_unit, wxDefaultCoord),
|
||||
wxTE_READONLY);
|
||||
display->SetEditable(false);
|
||||
wxGetApp().UpdateDarkUI(display);
|
||||
ComboBox* display = new ComboBox(window, wxID_ANY, value, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | CB_NO_DROP_ICON);
|
||||
display->SetIcon("edit");
|
||||
display->SetToolTip(get_tooltip_text(value));
|
||||
|
||||
ScalableButton* remove_btn = nullptr;
|
||||
if (!m_opt.readonly) {
|
||||
remove_btn = new ScalableButton(window, wxID_ANY, "cross", wxEmptyString,
|
||||
button_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 16);
|
||||
wxGetApp().UpdateDarkUI(remove_btn);
|
||||
remove_btn->SetToolTip(_L("Remove plugin"));
|
||||
}
|
||||
ScalableButton* remove_btn = new ScalableButton(window, wxID_ANY, "cross", wxEmptyString,
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 16);
|
||||
remove_btn->SetToolTip(_L("Remove plugin"));
|
||||
|
||||
ScalableButton* add_btn = nullptr;
|
||||
if (is_last && !m_opt.readonly) {
|
||||
add_btn = new ScalableButton(window, wxID_ANY, "param_add", wxEmptyString,
|
||||
button_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 16);
|
||||
wxGetApp().UpdateDarkUI(add_btn);
|
||||
add_btn->SetToolTip(_L("Add plugin"));
|
||||
add_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { on_add_clicked(); });
|
||||
}
|
||||
if (m_opt.readonly)
|
||||
remove_btn->Disable();
|
||||
|
||||
const size_t row_index = m_rows.size();
|
||||
select_btn->Bind(wxEVT_BUTTON, [this, row_index](wxCommandEvent&) { on_select_clicked(row_index); });
|
||||
if (remove_btn)
|
||||
remove_btn->Bind(wxEVT_BUTTON, [this, row_index](wxCommandEvent&) { on_remove_clicked(row_index); });
|
||||
display->Bind(wxEVT_LEFT_DOWN, [this, row_index](wxMouseEvent& ) { on_select_clicked(row_index); });
|
||||
remove_btn->Bind(wxEVT_BUTTON, [this, row_index](wxCommandEvent&) { on_remove_clicked(row_index); });
|
||||
|
||||
row_sizer->Add(select_btn, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
row_sizer->Add(display, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
if (remove_btn)
|
||||
row_sizer->Add(remove_btn, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
if (add_btn)
|
||||
row_sizer->Add(add_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
else if (!m_opt.readonly) {
|
||||
// Reserve space equal to the add button so all rows align.
|
||||
row_sizer->Add(button_size.GetWidth(), button_size.GetHeight(), 0, wxALIGN_CENTER_VERTICAL);
|
||||
}
|
||||
row_sizer->Add(display , 1, wxALIGN_CENTER_VERTICAL);
|
||||
row_sizer->Add(remove_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, window->FromDIP(SidebarProps::ElementSpacing()));
|
||||
|
||||
const int bottom_gap = is_last ? 0 : 4;
|
||||
m_main_sizer->Add(row_sizer, 0, wxEXPAND | (bottom_gap > 0 ? wxBOTTOM : 0), bottom_gap);
|
||||
m_main_sizer->Add(row_sizer, 0, wxEXPAND | wxBOTTOM, window->FromDIP(is_last ? SidebarProps::ContentMarginV() : 4));
|
||||
|
||||
PluginRow row;
|
||||
row.select_btn = select_btn;
|
||||
row.display = display;
|
||||
row.remove_btn = remove_btn;
|
||||
row.add_btn = add_btn;
|
||||
row.sizer = row_sizer;
|
||||
m_rows.push_back(row);
|
||||
}
|
||||
@@ -2354,9 +2348,9 @@ void PluginField::on_add_clicked()
|
||||
m_values.push_back(selected);
|
||||
m_value = m_values;
|
||||
|
||||
rebuild_ui();
|
||||
|
||||
on_change_field();
|
||||
// Defer: don't destroy the clicked button from inside its own handler.
|
||||
if(window)
|
||||
window->CallAfter([this]() {rebuild_ui(); on_change_field();});
|
||||
}
|
||||
|
||||
void PluginField::on_remove_clicked(size_t index)
|
||||
@@ -2367,8 +2361,9 @@ void PluginField::on_remove_clicked(size_t index)
|
||||
m_values.erase(m_values.begin() + index);
|
||||
m_value = m_values;
|
||||
|
||||
rebuild_ui();
|
||||
on_change_field();
|
||||
// Defer: don't destroy the clicked button from inside its own handler.
|
||||
if(window)
|
||||
window->CallAfter([this]() {rebuild_ui(); on_change_field();});
|
||||
}
|
||||
|
||||
wxString PluginField::get_row_value(size_t index) const
|
||||
@@ -2382,7 +2377,7 @@ void PluginField::set_row_value(size_t index, const wxString& value)
|
||||
{
|
||||
if (index >= m_rows.size() || !m_rows[index].display)
|
||||
return;
|
||||
m_rows[index].display->ChangeValue(value);
|
||||
m_rows[index].display->SetValue(value);
|
||||
m_rows[index].display->SetToolTip(get_tooltip_text(value));
|
||||
}
|
||||
|
||||
@@ -2425,14 +2420,10 @@ boost::any& PluginField::get_value()
|
||||
void PluginField::enable()
|
||||
{
|
||||
for (auto& row : m_rows) {
|
||||
if (row.select_btn)
|
||||
row.select_btn->Enable();
|
||||
if (row.display)
|
||||
row.display->Enable();
|
||||
if (row.remove_btn)
|
||||
row.remove_btn->Enable();
|
||||
if (row.add_btn)
|
||||
row.add_btn->Enable();
|
||||
}
|
||||
if (m_standalone_add_btn)
|
||||
m_standalone_add_btn->Enable();
|
||||
@@ -2441,14 +2432,10 @@ void PluginField::enable()
|
||||
void PluginField::disable()
|
||||
{
|
||||
for (auto& row : m_rows) {
|
||||
if (row.select_btn)
|
||||
row.select_btn->Disable();
|
||||
if (row.display)
|
||||
row.display->Disable();
|
||||
if (row.remove_btn)
|
||||
row.remove_btn->Disable();
|
||||
if (row.add_btn)
|
||||
row.add_btn->Disable();
|
||||
}
|
||||
if (m_standalone_add_btn)
|
||||
m_standalone_add_btn->Disable();
|
||||
@@ -2711,7 +2698,8 @@ void ColourPicker::set_value(const boost::any& value, bool change_event)
|
||||
auto field = dynamic_cast<wxColourPickerCtrl*>(window);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxColour clr = (clr_str.IsEmpty() || !clr.IsOk()) ? wxTransparentColour : clr_str;
|
||||
const wxColour parsed_clr(clr_str);
|
||||
wxColour clr = (clr_str.IsEmpty() || !parsed_clr.IsOk()) ? wxTransparentColour : parsed_clr;
|
||||
field->SetColour(clr);
|
||||
draw_bmp_btn(field, clr);
|
||||
#else
|
||||
@@ -2862,11 +2850,11 @@ void PointCtrl::BUILD()
|
||||
//temp->Add(static_text_y, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
temp->Add(y_input);
|
||||
|
||||
x_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(y_textctrl); }), y_textctrl->GetId());
|
||||
x_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_input_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_input_value(y_textctrl); }), y_textctrl->GetId());
|
||||
|
||||
x_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_value(y_textctrl); }), y_textctrl->GetId());
|
||||
x_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_input_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_input_value(y_textctrl); }), y_textctrl->GetId());
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(x_input);
|
||||
@@ -2915,7 +2903,7 @@ bool PointCtrl::value_was_changed(wxTextCtrl* win)
|
||||
return boost::any_cast<Vec2d>(m_value) != boost::any_cast<Vec2d>(val);
|
||||
}
|
||||
|
||||
void PointCtrl::propagate_value(wxTextCtrl* win)
|
||||
void PointCtrl::propagate_input_value(wxTextCtrl* win)
|
||||
{
|
||||
if (win->GetValue().empty())
|
||||
on_kill_focus();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "wxExtensions.hpp"
|
||||
#include "Widgets/SpinInput.hpp"
|
||||
#include "Widgets/TextInput.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define wxMSW true
|
||||
@@ -532,10 +533,8 @@ public:
|
||||
|
||||
private:
|
||||
struct PluginRow {
|
||||
ScalableButton* select_btn { nullptr };
|
||||
wxTextCtrl* display { nullptr };
|
||||
ComboBox* display { nullptr };
|
||||
ScalableButton* remove_btn { nullptr };
|
||||
ScalableButton* add_btn { nullptr };
|
||||
wxBoxSizer* sizer { nullptr };
|
||||
};
|
||||
|
||||
@@ -553,7 +552,7 @@ private:
|
||||
wxBoxSizer* m_main_sizer { nullptr };
|
||||
std::vector<PluginRow> m_rows;
|
||||
std::vector<std::string> m_values;
|
||||
ScalableButton* m_standalone_add_btn { nullptr };
|
||||
Button* m_standalone_add_btn { nullptr };
|
||||
std::function<std::string()> m_selector;
|
||||
};
|
||||
|
||||
@@ -628,8 +627,10 @@ private:
|
||||
void on_button_click(wxCommandEvent &WXUNUSED(ev));
|
||||
void save_colors_to_config();
|
||||
private:
|
||||
#if !defined(__linux__) && !defined(__LINUX__)
|
||||
wxColourData* m_clrData{nullptr};
|
||||
wxColourPickerWidget* m_picker_widget{nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
class PointCtrl : public Field {
|
||||
@@ -649,7 +650,7 @@ public:
|
||||
void BUILD() override;
|
||||
bool value_was_changed(wxTextCtrl* win);
|
||||
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
|
||||
void propagate_value(wxTextCtrl* win);
|
||||
void propagate_input_value(wxTextCtrl* win);
|
||||
void set_value(const Vec2d& value, bool change_event = false);
|
||||
void set_value(const boost::any& value, bool change_event = false) override;
|
||||
boost::any& get_value() override;
|
||||
|
||||
@@ -1,16 +1,66 @@
|
||||
#include <wx/dcmemory.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/graphics.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/window.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "EncodedFilament.hpp"
|
||||
#include "FilamentBitmapUtils.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GuiColor.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
#include "libslic3r/FilamentMixer.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
// Barycentric utilities for a ternary (triangle) ratio picker.
|
||||
double tri_signed_area2(TriPoint a, TriPoint b, TriPoint c)
|
||||
{
|
||||
return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
|
||||
}
|
||||
|
||||
bool tri_contains(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2)
|
||||
{
|
||||
double total = tri_signed_area2(v0, v1, v2);
|
||||
if (std::abs(total) < 1e-9) return false;
|
||||
double s0 = tri_signed_area2(p, v1, v2) / total;
|
||||
double s1 = tri_signed_area2(v0, p, v2) / total;
|
||||
double s2 = 1.0 - s0 - s1;
|
||||
return s0 >= -0.001 && s1 >= -0.001 && s2 >= -0.001;
|
||||
}
|
||||
|
||||
void tri_barycentric(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2,
|
||||
double& w0, double& w1, double& w2)
|
||||
{
|
||||
double total = std::abs(tri_signed_area2(v0, v1, v2));
|
||||
if (total < 1e-9) { w0 = w1 = w2 = 1.0 / 3.0; return; }
|
||||
w0 = std::abs(tri_signed_area2(p, v1, v2)) / total;
|
||||
w1 = std::abs(tri_signed_area2(v0, p, v2)) / total;
|
||||
w2 = 1.0 - w0 - w1;
|
||||
w0 = std::clamp(w0, 0.0, 1.0);
|
||||
w1 = std::clamp(w1, 0.0, 1.0);
|
||||
w2 = std::clamp(w2, 0.0, 1.0);
|
||||
double s = w0 + w1 + w2;
|
||||
if (s > 0) { w0 /= s; w1 /= s; w2 /= s; }
|
||||
}
|
||||
|
||||
TriPoint tri_clamp(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2)
|
||||
{
|
||||
double w0, w1, w2;
|
||||
tri_barycentric(p, v0, v1, v2, w0, w1, w2);
|
||||
return {w0 * v0.x + w1 * v1.x + w2 * v2.x,
|
||||
w0 * v0.y + w1 * v1.y + w2 * v2.y};
|
||||
}
|
||||
|
||||
void fill_gradient_rect_east(wxDC& dc, const wxRect& rect, const wxColour& from, const wxColour& to)
|
||||
{
|
||||
if (rect.width <= 0 || rect.height <= 0) return;
|
||||
@@ -73,7 +123,7 @@ std::vector<wxColour> sample_gradient_ramp(const wxColour& first,
|
||||
// Resolve the curve a gradient slot is sampled with, mirroring the slicer's fallback in
|
||||
// ToolOrdering: a custom curve wins, otherwise a straight line between gradient_range's
|
||||
// endpoints, otherwise the 0.10 -> 0.90 default.
|
||||
static Slic3r::GradientCurve mixed_gradient_curve(const Slic3r::DynamicPrintConfig& cfg, size_t slot)
|
||||
Slic3r::GradientCurve mixed_gradient_curve(const Slic3r::DynamicPrintConfig& cfg, size_t slot)
|
||||
{
|
||||
const auto* curve_opt = cfg.option<ConfigOptionStrings>("filament_mixed_gradient_curve");
|
||||
if (curve_opt && slot < curve_opt->values.size() && !curve_opt->values[slot].empty()) {
|
||||
@@ -449,4 +499,378 @@ void recompute_mixed_slot_colors(std::vector<wxColour>& colors,
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Layout ratios of the gradient plot rect, copied from GradientCurveEditor so the read-only
|
||||
// preview and the interactive editor stay pixel-identical. Plot rect is square 1:1; the
|
||||
// right/bottom margins host the axis arrows and labels.
|
||||
constexpr double kPlotLeftRatio = 0.0316;
|
||||
constexpr double kPlotRightRatio = 0.6766;
|
||||
constexpr double kPlotTopRatio = 0.1529;
|
||||
constexpr double kPlotBottomRatio = 0.8474;
|
||||
constexpr int kGridDivisions = 9; // 10 grid lines including the outer borders.
|
||||
constexpr int kStrokeAxis = 2; // axis line width (px, no DPI scaling)
|
||||
constexpr int kAxisArrowHalf = 5; // half-base of the axis arrow triangle (DIP)
|
||||
constexpr int kAxisArrowLen = 10; // length of the axis arrow triangle (DIP)
|
||||
constexpr int kPointRadius = 4; // anchor outer radius (DIP)
|
||||
constexpr float kBgSimilarThreshold = 15.0f;
|
||||
constexpr int kOutlineExtraDip = 2;
|
||||
constexpr double kTriangleMarginDip = 20.0;
|
||||
|
||||
// Quadratic blend that never goes out of gamut, matching MixedFilamentDialog::blend_colors.
|
||||
wxColour lerp_blend(const wxColour& a, const wxColour& b, double ratio_a)
|
||||
{
|
||||
unsigned char r, g, bl;
|
||||
Slic3r::filament_mixer_lerp(a.Red(), a.Green(), a.Blue(),
|
||||
b.Red(), b.Green(), b.Blue(),
|
||||
static_cast<float>(1.0 - ratio_a), &r, &g, &bl);
|
||||
return wxColour(r, g, bl);
|
||||
}
|
||||
|
||||
// DIP conversion for these free functions: unlike the wxWindow member FromDIP, it needs the
|
||||
// window parameter explicitly; nullptr picks the app's default DPI like the Publish dialog does.
|
||||
int dip_px(int v) { return wxWindow::FromDIP(v, nullptr); }
|
||||
|
||||
} // namespace
|
||||
|
||||
wxRect mixed_gradient_plot_rect(const wxSize& sz)
|
||||
{
|
||||
const int x = static_cast<int>(std::lround(sz.x * kPlotLeftRatio));
|
||||
const int y = static_cast<int>(std::lround(sz.y * kPlotTopRatio));
|
||||
const int x2 = static_cast<int>(std::lround(sz.x * kPlotRightRatio));
|
||||
const int y2 = static_cast<int>(std::lround(sz.y * kPlotBottomRatio));
|
||||
const int side = std::max(1, std::min(x2 - x, y2 - y));
|
||||
return wxRect(x, y, side, side);
|
||||
}
|
||||
|
||||
void draw_mixed_gradient_plot(wxDC& raw_dc, const wxSize& canvas,
|
||||
const std::vector<MixedGradientCurve>& curves,
|
||||
const std::vector<wxPoint2DDouble>& anchors,
|
||||
const MixedGradientTheme& theme)
|
||||
{
|
||||
// Draw into an internal opaque buffer so wxGCDC text/curves anti-alias against a solid
|
||||
// background (never a transparent one), then blit the finished image onto the caller's
|
||||
// buffered paint DC. wxGCDC cannot wrap a generic wxDC&, so the buffer is always a
|
||||
// wxMemoryDC -- the one type wxGCDC accepts on every platform.
|
||||
if (canvas.x <= 0 || canvas.y <= 0)
|
||||
return;
|
||||
const wxRect rc = mixed_gradient_plot_rect(canvas);
|
||||
if (rc.width <= 0 || rc.height <= 0)
|
||||
return;
|
||||
|
||||
wxBitmap buf(canvas);
|
||||
wxMemoryDC memdc(buf);
|
||||
memdc.SetBackground(wxBrush(theme.background));
|
||||
memdc.Clear();
|
||||
wxGCDC dc(memdc);
|
||||
wxGraphicsContext* gc = dc.GetGraphicsContext();
|
||||
|
||||
// 10x10 light grid (10 lines including outer borders, 9 equal divisions).
|
||||
dc.SetPen(wxPen(theme.grid, 1));
|
||||
for (int i = 0; i <= kGridDivisions; ++i) {
|
||||
const int x = rc.x + rc.width * i / kGridDivisions;
|
||||
const int y = rc.y + rc.height * i / kGridDivisions;
|
||||
dc.DrawLine(x, rc.y, x, rc.y + rc.height);
|
||||
dc.DrawLine(rc.x, y, rc.x + rc.width, y);
|
||||
}
|
||||
|
||||
// Set the label font first so text width measurements drive arrow / label placement.
|
||||
wxFont label_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
label_font.SetPointSize(std::max(7, label_font.GetPointSize() - 1));
|
||||
dc.SetFont(label_font);
|
||||
|
||||
const wxString axis_y_title = _L("Material Ratio");
|
||||
const wxString axis_x_title = _L("Model Height");
|
||||
const wxString pct_text = wxT("100%");
|
||||
const wxSize x_title_sz = dc.GetTextExtent(axis_x_title);
|
||||
const wxSize y_title_sz = dc.GetTextExtent(axis_y_title);
|
||||
|
||||
wxFont strong_font = label_font;
|
||||
strong_font.SetWeight(wxFONTWEIGHT_SEMIBOLD);
|
||||
dc.SetFont(strong_font);
|
||||
const wxSize pct_text_sz = dc.GetTextExtent(pct_text);
|
||||
dc.SetFont(label_font);
|
||||
|
||||
// Axes (grey 700) with filled triangle arrows. Y-axis extends above the plot top to the
|
||||
// canvas top edge; X-axis extends past the plot right toward the canvas right edge.
|
||||
const int arrow_half = dip_px(kAxisArrowHalf);
|
||||
const int arrow_len = dip_px(kAxisArrowLen);
|
||||
dc.SetPen(wxPen(theme.axis, kStrokeAxis));
|
||||
dc.SetBrush(wxBrush(theme.axis));
|
||||
|
||||
const int y_axis_x = rc.x;
|
||||
const int y_title_pct_gap = dip_px(1);
|
||||
const int y_title_bottom_pad = dip_px(2);
|
||||
const int y_title_y = std::max(0, rc.y - y_title_sz.y - y_title_pct_gap - pct_text_sz.y - y_title_bottom_pad);
|
||||
const int y_arrow_tip_y = y_title_y;
|
||||
const int y_arrow_ty = y_arrow_tip_y + arrow_len;
|
||||
dc.DrawLine(y_axis_x, y_arrow_ty, y_axis_x, rc.y + rc.height);
|
||||
{
|
||||
wxPoint tri[3] = {
|
||||
wxPoint(y_axis_x, y_arrow_tip_y),
|
||||
wxPoint(y_axis_x - arrow_half, y_arrow_ty),
|
||||
wxPoint(y_axis_x + arrow_half, y_arrow_ty),
|
||||
};
|
||||
dc.DrawPolygon(3, tri);
|
||||
}
|
||||
|
||||
const int x_axis_y = rc.y + rc.height;
|
||||
const int x_label_gap = dip_px(4);
|
||||
const int x_edge_pad = dip_px(6);
|
||||
const int x_arrow_ideal = rc.x + rc.width + dip_px(10);
|
||||
const int x_arrow_max = canvas.x - x_title_sz.x - x_label_gap - x_edge_pad - arrow_len;
|
||||
const int x_arrow_tx = std::max(rc.x + rc.width + arrow_len, std::min(x_arrow_ideal, x_arrow_max));
|
||||
const int x_arrow_tip_x = x_arrow_tx + arrow_len;
|
||||
const int x_title_x = x_arrow_tip_x + x_label_gap;
|
||||
dc.DrawLine(rc.x, x_axis_y, x_arrow_tx, x_axis_y);
|
||||
{
|
||||
wxPoint tri[3] = {
|
||||
wxPoint(x_arrow_tip_x, x_axis_y),
|
||||
wxPoint(x_arrow_tx, x_axis_y - arrow_half),
|
||||
wxPoint(x_arrow_tx, x_axis_y + arrow_half),
|
||||
};
|
||||
dc.DrawPolygon(3, tri);
|
||||
}
|
||||
|
||||
// Labels: "Material Ratio" and the leading "100%" share the same left x; the trailing
|
||||
// "Model Height" follows the X-axis arrow tip (already clamped to make room).
|
||||
const int label_left_x = y_axis_x + dip_px(10);
|
||||
dc.SetTextForeground(theme.label);
|
||||
dc.DrawText(axis_y_title, label_left_x, y_title_y);
|
||||
|
||||
dc.SetFont(strong_font);
|
||||
dc.SetTextForeground(theme.label_strong);
|
||||
dc.DrawText(pct_text, label_left_x, y_title_y + y_title_sz.y + y_title_pct_gap);
|
||||
|
||||
dc.DrawText(pct_text, rc.x + rc.width - pct_text_sz.x, x_axis_y);
|
||||
dc.SetFont(label_font);
|
||||
dc.SetTextForeground(theme.label);
|
||||
dc.DrawText(axis_x_title, x_title_x, x_axis_y - x_title_sz.y / 2);
|
||||
|
||||
if (!gc)
|
||||
return;
|
||||
|
||||
// Outline only when the curve colour is perceptually close to the background; otherwise the
|
||||
// plain filament colour reads fine and the extra stroke would look heavy.
|
||||
auto needs_outline = [&](const wxColour& c) {
|
||||
return calc_color_distance(c, theme.background) < kBgSimilarThreshold;
|
||||
};
|
||||
|
||||
// Only the geometry goes through the graphics context: dc.DrawLines() takes integer wxPoint
|
||||
// and would quantize the curve back to whole pixels. The pen is still set on the dc, which
|
||||
// forwards it here while keeping its own cached state in sync for later dc drawing.
|
||||
auto draw_polyline = [&](const MixedGradientCurve& curve) {
|
||||
if (curve.points.size() < 2)
|
||||
return;
|
||||
dc.SetPen(wxPen(curve.colour, dip_px(curve.stroke_dip)));
|
||||
gc->StrokeLines(curve.points.size(), curve.points.data());
|
||||
};
|
||||
|
||||
for (const MixedGradientCurve& curve : curves) {
|
||||
if (needs_outline(curve.colour))
|
||||
draw_polyline({curve.points, theme.outline, curve.stroke_dip + kOutlineExtraDip});
|
||||
draw_polyline(curve);
|
||||
}
|
||||
|
||||
// Control points: hollow circle with axis-colour border, theme-aware fill, drawn with a
|
||||
// sub-pixel centre so the ring stays centred on the curve.
|
||||
if (!anchors.empty()) {
|
||||
const double r = dip_px(kPointRadius);
|
||||
dc.SetPen(wxPen(theme.axis, 1));
|
||||
dc.SetBrush(wxBrush(theme.point_fill));
|
||||
for (const wxPoint2DDouble& p : anchors)
|
||||
gc->DrawEllipse(p.m_x - r, p.m_y - r, r * 2, r * 2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
raw_dc.DrawBitmap(buf, 0, 0);
|
||||
}
|
||||
|
||||
void draw_mixed_ratio_blend_bar(wxDC& dc, const wxRect& rect, const wxColour& first,
|
||||
const wxColour& second, double second_fraction)
|
||||
{
|
||||
if (rect.width <= 0 || rect.height <= 0)
|
||||
return;
|
||||
for (int x = 0; x < rect.width; ++x) {
|
||||
const double t = rect.width > 1 ? double(x) / rect.width : 0.0;
|
||||
const wxColour c = lerp_blend(first, second, 1.0 - t);
|
||||
dc.SetPen(wxPen(c));
|
||||
dc.DrawLine(rect.x + x, rect.y, rect.x + x, rect.y + rect.height);
|
||||
}
|
||||
|
||||
// Fixed in both themes, like the triangle picker's drag handle: the divider is drawn over
|
||||
// blended filament colour, so it has to keep its contrast against data rather than chrome.
|
||||
const int div_x = rect.x + static_cast<int>(second_fraction * rect.width);
|
||||
dc.SetPen(wxPen(wxColour(80, 80, 80), dip_px(4)));
|
||||
dc.DrawLine(div_x, rect.y, div_x, rect.y + rect.height);
|
||||
dc.SetPen(wxPen(*wxWHITE, dip_px(2)));
|
||||
dc.DrawLine(div_x, rect.y, div_x, rect.y + rect.height);
|
||||
}
|
||||
|
||||
void draw_mixed_ratio_segments(wxDC& dc, const wxRect& rect, const std::vector<wxColour>& colours,
|
||||
const std::vector<double>& shares)
|
||||
{
|
||||
const size_t n = std::min(colours.size(), shares.size());
|
||||
if (n == 0 || rect.width <= 0 || rect.height <= 0)
|
||||
return;
|
||||
std::vector<double> norm = shares;
|
||||
double total = 0.0;
|
||||
for (double s : norm)
|
||||
total += s;
|
||||
if (total <= 0.0) {
|
||||
norm.assign(n, 1.0 / n);
|
||||
total = 1.0;
|
||||
}
|
||||
auto share_to_px = [&](double share_sum) { return rect.x + int(std::lround(share_sum / total * double(rect.width))); };
|
||||
int x0 = rect.x;
|
||||
std::vector<wxRect> segs(n);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
int x1 = rect.x + rect.width;
|
||||
if (i + 1 < n)
|
||||
x1 = share_to_px(std::accumulate(norm.begin(), norm.begin() + i + 1, 0.0));
|
||||
segs[i] = wxRect(x0, rect.y, std::max(1, x1 - x0), rect.height);
|
||||
x0 = segs[i].GetRight() + 1;
|
||||
}
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(colours[i]));
|
||||
dc.DrawRectangle(segs[i]);
|
||||
}
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#ACACAC")), 1));
|
||||
dc.DrawRectangle(rect);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct TriCacheKey
|
||||
{
|
||||
int w, h;
|
||||
int c0r, c0g, c0b, c1r, c1g, c1b, c2r, c2g, c2b;
|
||||
int bg_r, bg_g, bg_b, ol_r, ol_g, ol_b;
|
||||
bool operator<(const TriCacheKey& o) const
|
||||
{
|
||||
return std::tie(w, h, c0r, c0g, c0b, c1r, c1g, c1b, c2r, c2g, c2b, bg_r, bg_g, bg_b, ol_r, ol_g, ol_b) <
|
||||
std::tie(o.w, o.h, o.c0r, o.c0g, o.c0b, o.c1r, o.c1g, o.c1b, o.c2r, o.c2g, o.c2b, o.bg_r, o.bg_g, o.bg_b, o.ol_r, o.ol_g, o.ol_b);
|
||||
}
|
||||
};
|
||||
|
||||
std::map<TriCacheKey, wxBitmap>& tri_cache()
|
||||
{
|
||||
static std::map<TriCacheKey, wxBitmap> cache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::array<TriPoint, 3> mixed_triangle_vertices(const wxSize& size, double margin_dip)
|
||||
{
|
||||
const double pw = size.GetWidth(), ph = size.GetHeight();
|
||||
const double margin = dip_px(int(margin_dip));
|
||||
const double avail = std::min(pw, ph) - 2.0 * margin;
|
||||
const double side = avail;
|
||||
const double tri_h = side * std::sqrt(3.0) / 2.0;
|
||||
const double cx = pw / 2.0;
|
||||
const double top_y = (ph - tri_h) / 2.0;
|
||||
return {{{cx, top_y}, {cx - side / 2.0, top_y + tri_h}, {cx + side / 2.0, top_y + tri_h}}};
|
||||
}
|
||||
|
||||
void draw_mixed_triangle_picker(wxDC& dc, const wxSize& size, const std::array<wxColour, 3>& colours,
|
||||
const std::array<double, 3>& weights, const MixedTriangleTheme& theme)
|
||||
{
|
||||
if (size.GetWidth() <= 0 || size.GetHeight() <= 0)
|
||||
return;
|
||||
const std::array<TriPoint, 3> v = mixed_triangle_vertices(size, kTriangleMarginDip);
|
||||
|
||||
dc.SetBrush(wxBrush(theme.background));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(0, 0, size.GetWidth(), size.GetHeight());
|
||||
|
||||
const wxColour& c0 = colours[0];
|
||||
const wxColour& c1 = colours[1];
|
||||
const wxColour& c2 = colours[2];
|
||||
const TriCacheKey key{size.GetWidth(), size.GetHeight(),
|
||||
c0.Red(), c0.Green(), c0.Blue(),
|
||||
c1.Red(), c1.Green(), c1.Blue(),
|
||||
c2.Red(), c2.Green(), c2.Blue(),
|
||||
theme.background.Red(), theme.background.Green(), theme.background.Blue(),
|
||||
theme.outline.Red(), theme.outline.Green(), theme.outline.Blue()};
|
||||
|
||||
wxBitmap& bmp = tri_cache()[key];
|
||||
if (!bmp.IsOk()) {
|
||||
bmp = wxBitmap(size.GetWidth(), size.GetHeight(), 24);
|
||||
wxMemoryDC mdc(bmp);
|
||||
mdc.SetBrush(wxBrush(theme.background));
|
||||
mdc.SetPen(*wxTRANSPARENT_PEN);
|
||||
mdc.DrawRectangle(0, 0, size.GetWidth(), size.GetHeight());
|
||||
|
||||
const int min_y = int(std::min({v[0].y, v[1].y, v[2].y}));
|
||||
const int max_y = int(std::max({v[0].y, v[1].y, v[2].y}));
|
||||
const int min_x = int(std::min({v[0].x, v[1].x, v[2].x}));
|
||||
const int max_x = int(std::max({v[0].x, v[1].x, v[2].x}));
|
||||
for (int py = min_y; py <= max_y; ++py) {
|
||||
for (int px = min_x; px <= max_x; ++px) {
|
||||
const TriPoint p = {double(px), double(py)};
|
||||
if (!tri_contains(p, v[0], v[1], v[2]))
|
||||
continue;
|
||||
double w0, w1, w2;
|
||||
tri_barycentric(p, v[0], v[1], v[2], w0, w1, w2);
|
||||
unsigned char mr, mg, mb;
|
||||
if (w0 + w1 > 1e-6) {
|
||||
float t01 = float(w1 / (w0 + w1));
|
||||
Slic3r::filament_mixer_lerp(c0.Red(), c0.Green(), c0.Blue(), c1.Red(), c1.Green(), c1.Blue(), t01, &mr, &mg, &mb);
|
||||
Slic3r::filament_mixer_lerp(mr, mg, mb, c2.Red(), c2.Green(), c2.Blue(), float(w2), &mr, &mg, &mb);
|
||||
} else {
|
||||
mr = c2.Red(); mg = c2.Green(); mb = c2.Blue();
|
||||
}
|
||||
mdc.SetPen(wxPen(wxColour(mr, mg, mb)));
|
||||
mdc.DrawPoint(px, py);
|
||||
}
|
||||
}
|
||||
|
||||
mdc.SetPen(wxPen(theme.outline, 1));
|
||||
mdc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
const wxPoint pts[3] = {{int(v[0].x), int(v[0].y)}, {int(v[1].x), int(v[1].y)}, {int(v[2].x), int(v[2].y)}};
|
||||
mdc.DrawPolygon(3, pts);
|
||||
mdc.SelectObject(wxNullBitmap);
|
||||
|
||||
// Keep the cache from growing without bound across DPI/size changes.
|
||||
if (tri_cache().size() > 6) {
|
||||
auto& cache = tri_cache();
|
||||
cache.erase(cache.begin());
|
||||
}
|
||||
}
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
|
||||
// Published-ratio marker (read-only twin of the editor's drag handle).
|
||||
const double w0 = weights[0], w1 = weights[1], w2 = weights[2];
|
||||
const int hx = int(w0 * v[0].x + w1 * v[1].x + w2 * v[2].x);
|
||||
const int hy = int(w0 * v[0].y + w1 * v[1].y + w2 * v[2].y);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.SetPen(wxPen(theme.ring, dip_px(2)));
|
||||
dc.DrawCircle(hx, hy, dip_px(5));
|
||||
}
|
||||
|
||||
void draw_mixed_triangle_labels(wxDC& dc, const wxSize& size, const std::array<double, 3>& weights,
|
||||
const MixedTriangleTheme& theme)
|
||||
{
|
||||
const std::array<TriPoint, 3> v = mixed_triangle_vertices(size, kTriangleMarginDip);
|
||||
dc.SetFont(::Label::Body_12);
|
||||
dc.SetTextForeground(theme.label);
|
||||
|
||||
// "Ratio" title, sitting above the top vertex.
|
||||
const wxString title = _L("Ratio");
|
||||
dc.DrawText(title, dip_px(2), std::max(0, int(v[0].y - dc.GetTextExtent(title).GetHeight() - dip_px(4))));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const wxString text = wxString::Format("%d%%", int(std::lround(weights[i] * 100.0)));
|
||||
const wxSize tsz = dc.GetTextExtent(text);
|
||||
int lx = int(v[i].x - tsz.GetWidth() / 2.0);
|
||||
int ly = (i == 0) ? int(v[i].y - tsz.GetHeight() - dip_px(4)) : int(v[i].y + dip_px(3));
|
||||
ly = std::clamp(ly, 0, size.GetHeight() - tsz.GetHeight());
|
||||
lx = std::clamp(lx, 0, size.GetWidth() - tsz.GetWidth());
|
||||
dc.DrawText(text, lx, ly);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <wx/colour.h>
|
||||
#include <wx/dc.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/geometry.h>
|
||||
#include <wx/graphics.h>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
// Orca: forward-declare so the header is self-contained outside libslic3r_gui's
|
||||
@@ -13,6 +16,16 @@ namespace Slic3r { class DynamicPrintConfig; struct GradientCurve; }
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
// Barycentric utilities for a ternary (triangle) ratio picker, shared by the mixed-filament
|
||||
// editor and the Publish dialog's read-only definition preview.
|
||||
struct TriPoint { double x, y; };
|
||||
|
||||
double tri_signed_area2(TriPoint a, TriPoint b, TriPoint c);
|
||||
bool tri_contains(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2);
|
||||
void tri_barycentric(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2,
|
||||
double& w0, double& w1, double& w2);
|
||||
TriPoint tri_clamp(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2);
|
||||
|
||||
// Fills a rect with a west->east linear gradient by drawing solid 1px columns.
|
||||
// Use instead of wxDC::GradientFillLinear, whose CoreGraphics (CGShading) backend
|
||||
// fails to render on some macOS builds; solid fills are unaffected.
|
||||
@@ -51,6 +64,12 @@ std::vector<wxColour> sample_gradient_ramp(const wxColour& first,
|
||||
// destination's height in pixels.
|
||||
std::vector<wxColour> mixed_gradient_ramp(const Slic3r::DynamicPrintConfig& cfg, size_t slot, int steps);
|
||||
|
||||
// Resolve the curve a gradient slot is sampled with: the custom curve wins when it has at
|
||||
// least two points, otherwise a straight line between gradient_range's endpoints, otherwise
|
||||
// the 0.10 -> 0.90 default. Mirrors the slicer's ToolOrdering fallback so every preview
|
||||
// agrees with what gets sliced. Always returns a two-point curve.
|
||||
Slic3r::GradientCurve mixed_gradient_curve(const Slic3r::DynamicPrintConfig& cfg, size_t slot);
|
||||
|
||||
// Fill rect with a ramp, ramp.front() along the bottom edge.
|
||||
void fill_gradient_ramp_rect(wxDC& dc, const wxRect& rect, const std::vector<wxColour>& ramp);
|
||||
|
||||
@@ -63,6 +82,81 @@ wxBitmap create_gradient_ramp_bitmap(const std::vector<wxColour>& ramp, const wx
|
||||
void recompute_mixed_slot_colors(std::vector<wxColour>& colors,
|
||||
const Slic3r::DynamicPrintConfig& cfg);
|
||||
|
||||
// --- Gradient plot (shared by GradientCurveEditor and the Publish dialog's read-only
|
||||
// preview). The plot is a square 1:1 rect laid out with the editor's ratios so both
|
||||
// render identically; curves are drawn as sub-pixel anti-aliased polylines through
|
||||
// wxGCDC so they never quantize to whole pixels.
|
||||
|
||||
// One curve of the plot: screen-space sub-pixel points already mapped into the plot
|
||||
// rect, the stroke colour and the stroke width in DIP.
|
||||
struct MixedGradientCurve
|
||||
{
|
||||
std::vector<wxPoint2DDouble> points;
|
||||
wxColour colour;
|
||||
int stroke_dip;
|
||||
};
|
||||
|
||||
// Theme tokens, resolved by the caller through StateColor::darkModeColorFor.
|
||||
struct MixedGradientTheme
|
||||
{
|
||||
wxColour background; // for near-background outline detection
|
||||
wxColour grid; // grid line
|
||||
wxColour axis; // axis + arrow fill
|
||||
wxColour label; // "Material Ratio" / "Model Height"
|
||||
wxColour label_strong; // "100%"
|
||||
wxColour outline; // near-background curve lift
|
||||
wxColour point_fill; // anchor fill
|
||||
};
|
||||
|
||||
// Square 1:1 plot rect inside `canvas`, using the editor's plot ratios.
|
||||
wxRect mixed_gradient_plot_rect(const wxSize& canvas);
|
||||
|
||||
// Draw the whole plot (grid, axes + arrowheads, axis labels, each curve with an optional
|
||||
// near-background outline, and anchor circles). `anchors` are empty when the caller has
|
||||
// none to show. `dc` is the caller's buffered paint DC; a wxGCDC is created inside so the
|
||||
// geometry gets anti-aliased.
|
||||
void draw_mixed_gradient_plot(wxDC& dc, const wxSize& canvas,
|
||||
const std::vector<MixedGradientCurve>& curves,
|
||||
const std::vector<wxPoint2DDouble>& anchors,
|
||||
const MixedGradientTheme& theme);
|
||||
|
||||
// --- Ratio bar (2-component continuous blend + divider, matching MixedFilamentDialog).
|
||||
// Colours blend first->second across the rect; the divider marks `second_fraction` of the
|
||||
// rect's width (the second component's share, 0..1).
|
||||
void draw_mixed_ratio_blend_bar(wxDC& dc, const wxRect& rect, const wxColour& first,
|
||||
const wxColour& second, double second_fraction);
|
||||
|
||||
// Fallback ratio bar for N>2 non-gradient slots: one solid segment per component,
|
||||
// widths proportional to shares. Label text (the "NN%" inside wide-enough segments) is
|
||||
// the caller's concern.
|
||||
void draw_mixed_ratio_segments(wxDC& dc, const wxRect& rect, const std::vector<wxColour>& colours,
|
||||
const std::vector<double>& shares);
|
||||
|
||||
// --- Triangle picker (3-component), shared by MixedFilamentDialog and the Publish preview.
|
||||
struct MixedTriangleTheme
|
||||
{
|
||||
wxColour background;
|
||||
wxColour outline; // triangle border
|
||||
wxColour ring; // drag-handle ring
|
||||
wxColour label; // "Ratio" title + per-vertex labels
|
||||
};
|
||||
|
||||
// The three vertices of the read-only/miniature triangle inside a `size` square panel,
|
||||
// with `margin_dip` inset. Order: top, bottom-left, bottom-right.
|
||||
std::array<TriPoint, 3> mixed_triangle_vertices(const wxSize& size, double margin_dip = 20.0);
|
||||
|
||||
// Draw background, the cached barycentric fill, the outline and the drag-handle marker.
|
||||
// `weights` are the three barycentric shares (sum 1). The "Ratio" title and per-vertex
|
||||
// percentage labels are drawn by the caller so the interactive editor can keep its own
|
||||
// live child labels while the read-only preview draws them as text.
|
||||
void draw_mixed_triangle_picker(wxDC& dc, const wxSize& size, const std::array<wxColour, 3>& colours,
|
||||
const std::array<double, 3>& weights, const MixedTriangleTheme& theme);
|
||||
|
||||
// Draw the "Ratio" title plus one "NN%" label per vertex (used by the read-only preview;
|
||||
// the interactive editor positions its own live labels instead).
|
||||
void draw_mixed_triangle_labels(wxDC& dc, const wxSize& size, const std::array<double, 3>& weights,
|
||||
const MixedTriangleTheme& theme);
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif // slic3r_GUI_FilamentBitmapUtils_hpp_
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "FilamentMapPanel.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Widgets/MultiNozzleSync.hpp" // manuallySetNozzleCount producer for extruder_nozzle_stats
|
||||
#include <algorithm>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Plater.hpp"
|
||||
#include "Camera.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "format.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
@@ -3436,16 +3437,18 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Whole sentences: the bare "up to"/"above"/"from"/"to" these used to be glued from gave a
|
||||
// translator no context, and left the unit and the numbers stuck in English word order.
|
||||
auto upto_label = [](double z) {
|
||||
char buf[64];
|
||||
::sprintf(buf, "%.2f", z);
|
||||
return _u8L("up to") + " " + std::string(buf) + " " + _u8L("mm");
|
||||
return format(_u8L("up to %1% mm"), buf);
|
||||
};
|
||||
|
||||
auto above_label = [](double z) {
|
||||
char buf[64];
|
||||
::sprintf(buf, "%.2f", z);
|
||||
return _u8L("above") + " " + std::string(buf) + " " + _u8L("mm");
|
||||
return format(_u8L("above %1% mm"), buf);
|
||||
};
|
||||
|
||||
auto fromto_label = [](double z1, double z2) {
|
||||
@@ -3453,7 +3456,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
::sprintf(buf1, "%.2f", z1);
|
||||
char buf2[64];
|
||||
::sprintf(buf2, "%.2f", z2);
|
||||
return _u8L("from") + " " + std::string(buf1) + " " + _u8L("to") + " " + std::string(buf2) + " " + _u8L("mm");
|
||||
return format(_u8L("from %1% to %2% mm"), buf1, buf2);
|
||||
};
|
||||
|
||||
auto role_time_and_percent = [this, total_estimated_time](libvgcode::EGCodeExtrusionRole role) {
|
||||
|
||||
+196
-121
@@ -1081,56 +1081,36 @@ const double GLCanvas3D::DefaultCameraZoomToPlateMarginFactor = 1.25;
|
||||
|
||||
void GLCanvas3D::load_arrange_settings()
|
||||
{
|
||||
std::string dist_fff_str =
|
||||
wxGetApp().app_config->get("arrange", "min_object_distance_fff");
|
||||
// Each key must match what _render_arrange_menu writes, which appends a per-mode
|
||||
// postfix to the base name.
|
||||
auto load_float = [](const char *key, float &out) {
|
||||
// The menu writes these with float_to_string_decimal_point, so parse them back
|
||||
// the same way rather than with anything locale-dependent.
|
||||
std::string value = wxGetApp().app_config->get("arrange", key);
|
||||
size_t parsed = 0;
|
||||
double number = string_to_double_decimal_point(value, &parsed);
|
||||
if (parsed > 0)
|
||||
out = float(number);
|
||||
};
|
||||
auto load_bool = [](const char *key, bool &out) {
|
||||
std::string value = wxGetApp().app_config->get("arrange", key);
|
||||
if (!value.empty())
|
||||
out = (value == "1" || value == "true");
|
||||
};
|
||||
|
||||
std::string dist_fff_seq_print_str =
|
||||
wxGetApp().app_config->get("arrange", "min_object_distance_seq_print_fff");
|
||||
load_float("min_object_distance_fff", m_arrange_settings_fff.distance);
|
||||
load_float("min_object_distance_fff_seq_print", m_arrange_settings_fff_seq_print.distance);
|
||||
load_float("min_object_distance_sla", m_arrange_settings_sla.distance);
|
||||
|
||||
std::string dist_sla_str =
|
||||
wxGetApp().app_config->get("arrange", "min_object_distance_sla");
|
||||
load_bool("enable_rotation_fff", m_arrange_settings_fff.enable_rotation);
|
||||
load_bool("enable_rotation_fff_seq_print", m_arrange_settings_fff_seq_print.enable_rotation);
|
||||
load_bool("enable_rotation_sla", m_arrange_settings_sla.enable_rotation);
|
||||
|
||||
std::string en_rot_fff_str =
|
||||
wxGetApp().app_config->get("arrange", "enable_rotation_fff");
|
||||
|
||||
std::string en_rot_fff_seqp_str =
|
||||
wxGetApp().app_config->get("arrange", "enable_rotation_seq_print");
|
||||
|
||||
std::string en_rot_sla_str =
|
||||
wxGetApp().app_config->get("arrange", "enable_rotation_sla");
|
||||
|
||||
std::string en_allow_multiple_materials_str =
|
||||
wxGetApp().app_config->get("arrange", "allow_multi_materials_on_same_plate");
|
||||
|
||||
std::string en_avoid_region_str =
|
||||
wxGetApp().app_config->get("arrange", "avoid_extrusion_cali_region");
|
||||
|
||||
|
||||
|
||||
if (!dist_fff_str.empty())
|
||||
m_arrange_settings_fff.distance = std::stof(dist_fff_str);
|
||||
|
||||
if (!dist_fff_seq_print_str.empty())
|
||||
m_arrange_settings_fff_seq_print.distance = std::stof(dist_fff_seq_print_str);
|
||||
|
||||
if (!dist_sla_str.empty())
|
||||
m_arrange_settings_sla.distance = std::stof(dist_sla_str);
|
||||
|
||||
if (!en_rot_fff_str.empty())
|
||||
m_arrange_settings_fff.enable_rotation = (en_rot_fff_str == "1" || en_rot_fff_str == "true");
|
||||
|
||||
if (!en_allow_multiple_materials_str.empty())
|
||||
m_arrange_settings_fff.allow_multi_materials_on_same_plate = (en_allow_multiple_materials_str == "1" || en_allow_multiple_materials_str == "true");
|
||||
|
||||
|
||||
if (!en_rot_fff_seqp_str.empty())
|
||||
m_arrange_settings_fff_seq_print.enable_rotation = (en_rot_fff_seqp_str == "1" || en_rot_fff_seqp_str == "true");
|
||||
|
||||
if(!en_avoid_region_str.empty())
|
||||
m_arrange_settings_fff.avoid_extrusion_cali_region = (en_avoid_region_str == "1" || en_avoid_region_str == "true");
|
||||
|
||||
if (!en_rot_sla_str.empty())
|
||||
m_arrange_settings_sla.enable_rotation = (en_rot_sla_str == "1" || en_rot_sla_str == "true");
|
||||
// These two keys carry no postfix, so the one stored value covers both FFF modes.
|
||||
load_bool("allow_multi_materials_on_same_plate", m_arrange_settings_fff.allow_multi_materials_on_same_plate);
|
||||
load_bool("allow_multi_materials_on_same_plate", m_arrange_settings_fff_seq_print.allow_multi_materials_on_same_plate);
|
||||
load_bool("avoid_extrusion_cali_region", m_arrange_settings_fff.avoid_extrusion_cali_region);
|
||||
load_bool("avoid_extrusion_cali_region", m_arrange_settings_fff_seq_print.avoid_extrusion_cali_region);
|
||||
|
||||
//BBS: add specific arrange settings
|
||||
m_arrange_settings_fff_seq_print.is_seq_print = true;
|
||||
@@ -2141,12 +2121,6 @@ void GLCanvas3D::render(bool only_init)
|
||||
_render_selection_center();
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
||||
// we need to set the mouse's scene position here because the depth buffer
|
||||
// could be invalidated by the following gizmo render methods
|
||||
// this position is used later into on_mouse() to drag the objects
|
||||
if (m_picking_enabled)
|
||||
m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast<coord_t>());
|
||||
|
||||
// sidebar hints need to be rendered before the gizmos because the depth buffer
|
||||
// could be invalidated by the following gizmo render methods
|
||||
_render_selection_sidebar_hints();
|
||||
@@ -2221,7 +2195,7 @@ void GLCanvas3D::render(bool only_init)
|
||||
|
||||
// Negative coordinate means out of the window, likely because the window was deactivated.
|
||||
// In that case the tooltip should be hidden.
|
||||
if (m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0. || has_mouse_capture()) { // ORCA continue to capture mouse pos mid drag
|
||||
if ((m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0.) || has_mouse_capture()) { // ORCA continue to capture mouse pos mid drag
|
||||
if (tooltip.empty())
|
||||
tooltip = m_layers_editing.get_tooltip(*this);
|
||||
|
||||
@@ -2921,23 +2895,37 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||
DynamicPrintConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
float x = dynamic_cast<const ConfigOptionFloats*>(proj_cfg.option("wipe_tower_x"))->get_at(plate_id);
|
||||
float y = dynamic_cast<const ConfigOptionFloats*>(proj_cfg.option("wipe_tower_y"))->get_at(plate_id);
|
||||
float w = dynamic_cast<const ConfigOptionFloat*>(m_config->option("prime_tower_width"))->value;
|
||||
float a = dynamic_cast<const ConfigOptionFloat*>(m_config->option("wipe_tower_rotation_angle"))->value;
|
||||
// BBS
|
||||
float v = dynamic_cast<const ConfigOptionFloat*>(m_config->option("prime_volume"))->value;
|
||||
Vec3d plate_origin = ppl.get_plate(plate_id)->get_origin();
|
||||
|
||||
const Print* print = m_process->fff_print();
|
||||
const Print* current_print = part_plate->fff_print();
|
||||
if (!need_wipe_tower && part_plate->get_extruders(true).size() < 2) continue;
|
||||
if (part_plate->get_objects_on_this_plate().empty()) continue;
|
||||
|
||||
float brim_width = print->wipe_tower_data(filaments_count).brim_width;
|
||||
int nozzle_nums = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||
Vec3d wipe_tower_size = ppl.get_plate(plate_id)->estimate_wipe_tower_size(full_config, w, v, nozzle_nums, 0, false, dynamic_cast<const ConfigOptionBool*>(dconfig.option("enable_wrapping_detection"))->value);
|
||||
// Body and brim from this plate's own estimate: m_process->fff_print() is the
|
||||
// selected plate's, so an auto brim drew every tower with that plate's brim.
|
||||
const WipeTowerFootprint footprint = part_plate->estimate_wipe_tower_footprint(full_config);
|
||||
// The estimate is also the answer to whether this plate prints a tower;
|
||||
// deciding it here as well only gave the two room to drift.
|
||||
if (footprint.depth <= 0.) continue;
|
||||
float brim_width = float(footprint.brim_width);
|
||||
Vec3d wipe_tower_size(footprint.width, footprint.depth, footprint.height);
|
||||
|
||||
// set_default_wipe_tower_pos_for_plate doesn't rerun when painting changes the
|
||||
// filament count, so redo its clamp here on every reload — unconditionally: a
|
||||
// paint-triggered reload can arrive before the background process invalidates
|
||||
// psWipeTower, so gating on it would skip the clamp exactly when it is needed.
|
||||
{
|
||||
Vec3d clamped_pos, clamped_size;
|
||||
part_plate->estimate_wipe_tower_polygon(full_config, plate_id, clamped_pos, clamped_size);
|
||||
if (std::abs(x - (float) clamped_pos(0)) > EPSILON || std::abs(y - (float) clamped_pos(1)) > EPSILON) {
|
||||
x = (float) clamped_pos(0);
|
||||
y = (float) clamped_pos(1);
|
||||
ConfigOptionFloat wt_x_opt(x), wt_y_opt(y);
|
||||
dynamic_cast<ConfigOptionFloats*>(proj_cfg.option("wipe_tower_x"))->set_at(&wt_x_opt, plate_id, 0);
|
||||
dynamic_cast<ConfigOptionFloats*>(proj_cfg.option("wipe_tower_y"))->set_at(&wt_y_opt, plate_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// The stored position is already clamped onto the bed, by
|
||||
// set_default_wipe_tower_pos_for_plate and again on every drag.
|
||||
if (!current_print->is_step_done(psWipeTower) || !current_print->wipe_tower_data().wipe_tower_mesh_data) {
|
||||
// update for wipe tower position
|
||||
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(1000 + plate_id, x + plate_origin(0), y + plate_origin(1),
|
||||
@@ -4451,6 +4439,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
if (can_sequential_clearance_show_in_gizmo())
|
||||
update_sequential_clearance();
|
||||
} else {
|
||||
// Orca: by-layer counterpart, for a prime tower compacted by "No sparse layers".
|
||||
if (current_printer_technology() == ptFFF && can_sequential_clearance_show_in_gizmo())
|
||||
update_compacted_wipe_tower_clearance();
|
||||
if (c == GLGizmosManager::EType::Move ||
|
||||
c == GLGizmosManager::EType::Scale ||
|
||||
c == GLGizmosManager::EType::Rotate)
|
||||
@@ -4620,12 +4611,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
BoundingBoxf3 volume_bbox = m_volumes.volumes[volume_idx]->transformed_bounding_box();
|
||||
volume_bbox.offset(1.0);
|
||||
const bool is_cut_connector_selected = m_selection.is_any_connector();
|
||||
if ((!any_gizmo_active || !evt.CmdDown()) && volume_bbox.contains(m_mouse.scene_position) && !is_cut_connector_selected) {
|
||||
const Vec3d scene_position = _mouse_to_3d(pos);
|
||||
if ((!any_gizmo_active || !evt.CmdDown()) && volume_bbox.contains(scene_position) && !is_cut_connector_selected) {
|
||||
m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None;
|
||||
// The dragging operation is initiated.
|
||||
m_mouse.drag.move_volume_idx = volume_idx;
|
||||
m_selection.setup_cache();
|
||||
m_mouse.drag.start_position_3D = m_mouse.scene_position;
|
||||
m_mouse.drag.start_position_3D = scene_position;
|
||||
m_sequential_print_clearance_first_displacement = true;
|
||||
m_moving = true;
|
||||
|
||||
@@ -4683,8 +4675,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D, trafo_type);
|
||||
if (current_printer_technology() == ptFFF && (fff_print()->config().print_sequence == PrintSequence::ByObject))
|
||||
update_sequential_clearance();
|
||||
if (current_printer_technology() == ptFFF) {
|
||||
if (fff_print()->config().print_sequence == PrintSequence::ByObject)
|
||||
update_sequential_clearance();
|
||||
else
|
||||
update_compacted_wipe_tower_clearance();
|
||||
}
|
||||
// BBS
|
||||
//wxGetApp().obj_manipul()->set_dirty();
|
||||
m_dirty = true;
|
||||
@@ -5172,7 +5168,21 @@ void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
}
|
||||
|
||||
//BBS: notify instance updates to part plater list
|
||||
m_selection.notify_instance_update(-1, 0);
|
||||
// Only what moved: the selected instances, or every instance of an object one of whose
|
||||
// parts moved. Notifying a plate about an instance that stayed put invalidates its slice
|
||||
// result, and notifying instance 0 alone left a moved copy unregistered on its new plate.
|
||||
{
|
||||
std::set<std::pair<int, int>> notified;
|
||||
for (unsigned int i : m_selection.get_volume_idxs()) {
|
||||
const GLVolume* v = m_volumes.volumes[i];
|
||||
const int object_idx = v->object_idx();
|
||||
if (object_idx < 0 || object_idx >= static_cast<int>(m_model->objects.size()))
|
||||
continue;
|
||||
const std::pair<int, int> key(object_idx, selection_mode == Selection::Volume ? -1 : v->instance_idx());
|
||||
if (notified.insert(key).second)
|
||||
m_selection.notify_instance_update(key.first, key.second);
|
||||
}
|
||||
}
|
||||
|
||||
// Fixes sinking/flying instances (snaps object to buildplate)
|
||||
for (const std::pair<int, int>& i : done) {
|
||||
@@ -5738,6 +5748,101 @@ bool GLCanvas3D::can_sequential_clearance_show_in_gizmo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Live preview of the compacted prime tower clearance, the by-layer counterpart of
|
||||
// update_sequential_clearance(). Called while the user drags a volume / gizmo; idle visibility
|
||||
// matches sequential print (hidden when valid, filled when Print::validate reports a collision).
|
||||
// Print::compacted_wipe_tower_clearance_valid() answers the same question authoritatively, but it
|
||||
// reads the tower position from the config, which only catches up once do_move() writes it back on
|
||||
// mouse release. Recomputing from the volumes here is what makes the keep-out zone follow the tower
|
||||
// while it is still under the cursor.
|
||||
void GLCanvas3D::update_compacted_wipe_tower_clearance()
|
||||
{
|
||||
if (current_printer_technology() != ptFFF)
|
||||
return;
|
||||
const Print *print = fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
const PrintConfig &config = print->config();
|
||||
if (config.print_sequence != PrintSequence::ByLayer || ! wipe_tower_sparse_layers_skipped(config) || ! print->has_wipe_tower())
|
||||
return;
|
||||
|
||||
PartPlateList &plate_list = wxGetApp().plater()->get_partplate_list();
|
||||
PartPlate *plate = plate_list.get_curr_plate();
|
||||
if (plate == nullptr)
|
||||
return;
|
||||
const int plate_id = plate_list.get_curr_plate_index();
|
||||
|
||||
// Once the tower has been generated the scene shows its real mesh with the brim merged in,
|
||||
// otherwise it is a bare estimated cube with no brim at all. Only the latter needs the brim added
|
||||
// here, and the width comes from WipeTowerData, the same source the preview box is sized from, so
|
||||
// the zone cannot be padded against a brim the preview was not built with.
|
||||
const bool preview_carries_brim = print->is_step_done(psWipeTower) && print->wipe_tower_data().wipe_tower_mesh_data.has_value();
|
||||
const double brim = preview_carries_brim ? 0. : double(print->wipe_tower_data(print->extruders().size()).brim_width);
|
||||
const double padding = compacted_tower_footprint_padding(config, brim);
|
||||
|
||||
// Tower footprint straight from the volume the user sees, so that dragging either the tower or an
|
||||
// object updates the zone on the very next frame.
|
||||
Polygon tower_footprint;
|
||||
for (const GLVolume *v : m_volumes.volumes) {
|
||||
if (! v->is_wipe_tower || v->object_idx() - 1000 != plate_id)
|
||||
continue;
|
||||
const BoundingBoxf3 bbox = v->transformed_convex_hull_bounding_box();
|
||||
tower_footprint = Polygon({ Point(scale_(bbox.min.x() - padding), scale_(bbox.min.y() - padding)),
|
||||
Point(scale_(bbox.max.x() + padding), scale_(bbox.min.y() - padding)),
|
||||
Point(scale_(bbox.max.x() + padding), scale_(bbox.max.y() + padding)),
|
||||
Point(scale_(bbox.min.x() - padding), scale_(bbox.max.y() + padding)) });
|
||||
break;
|
||||
}
|
||||
|
||||
const CompactedTowerZone zone = compacted_wipe_tower_zone(config, tower_footprint);
|
||||
if (zone.empty()) {
|
||||
reset_sequential_print_clearance();
|
||||
return;
|
||||
}
|
||||
|
||||
// While dragging, outline every on-plate instance next to the tower ring, the way sequential print
|
||||
// outlines every object. Both carry half of the clearance, so the two outlines meeting is precisely
|
||||
// the moment that object goes over its limit - which is what makes the pair worth drawing at all.
|
||||
// The tier is per object, so a short object gets the narrow nozzle outline rather than the wide
|
||||
// body one it is not subject to; without that, a 3 mm object parked beside the tower would be drawn
|
||||
// deep inside the keep-out ring while passing the check. Only the instances that already exceed
|
||||
// allowed_rise also get a height limit plane.
|
||||
Polygons outlines;
|
||||
std::vector<std::pair<Polygon, float>> height_polygons;
|
||||
bool body_tier_used = false;
|
||||
const BoundingBox plate_bb = plate->get_bounding_box_crd();
|
||||
for (const ModelObject *model_object : m_model->objects) {
|
||||
for (size_t i = 0; i < model_object->instances.size(); ++i) {
|
||||
Geometry::Transformation trafo(model_object->instances[i]->get_transformation());
|
||||
const Vec3d offset = trafo.get_offset();
|
||||
trafo.set_offset(Vec3d(offset.x(), offset.y(), 0.0));
|
||||
const Polygon inst_hull = model_object->convex_hull_2d(trafo.get_matrix());
|
||||
if (inst_hull.points.empty() || ! plate_bb.overlap(inst_hull.bounding_box()))
|
||||
continue;
|
||||
|
||||
// Same tiers and the same rise measured from the plate as
|
||||
// Print::compacted_wipe_tower_clearance_valid(), so that the preview and the validation
|
||||
// that follows it never contradict each other.
|
||||
const double object_top = model_object->get_instance_max_z(i);
|
||||
const CompactedTowerClearance clearance = compacted_wipe_tower_clearance(config, zone, inst_hull, object_top);
|
||||
body_tier_used = body_tier_used || compacted_tower_body_tier(clearance);
|
||||
|
||||
const Polygon outline = compacted_wipe_tower_offender_outline(inst_hull, clearance.body_clearance);
|
||||
outlines.emplace_back(outline);
|
||||
if (object_top <= clearance.allowed_rise + EPSILON)
|
||||
continue;
|
||||
height_polygons.emplace_back(outline, float(clearance.allowed_rise));
|
||||
}
|
||||
}
|
||||
|
||||
Polygons polygons = compacted_wipe_tower_rings(zone, body_tier_used);
|
||||
append(polygons, outlines);
|
||||
|
||||
set_sequential_print_clearance_visible(true);
|
||||
set_sequential_print_clearance_render_fill(false);
|
||||
set_sequential_print_clearance_polygons(polygons, height_polygons);
|
||||
}
|
||||
|
||||
void GLCanvas3D::update_sequential_clearance()
|
||||
{
|
||||
if (current_printer_technology() != ptFFF || (fff_print()->config().print_sequence == PrintSequence::ByLayer))
|
||||
@@ -6058,7 +6163,7 @@ bool GLCanvas3D::_render_orient_menu(float left, float right, float bottom, floa
|
||||
}
|
||||
|
||||
//BBS: GUI refactor: adjust main toolbar position
|
||||
bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, float top)
|
||||
void GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, float top)
|
||||
{
|
||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||
|
||||
@@ -6083,7 +6188,6 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
|
||||
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
|
||||
|
||||
ArrangeSettings settings = get_arrange_settings();
|
||||
ArrangeSettings &settings_out = get_arrange_settings();
|
||||
const float slider_icon_width = imgui->get_slider_icon_size().x;
|
||||
const float cursor_slider_left = imgui->calc_text_size(_L("Spacing")).x + imgui->scaled(1.5f);
|
||||
@@ -6092,13 +6196,9 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
auto &appcfg = wxGetApp().app_config;
|
||||
PrinterTechnology ptech = current_printer_technology();
|
||||
|
||||
bool settings_changed = false;
|
||||
float dist_min = 0.f; // 0 means auto
|
||||
std::string dist_key = "min_object_distance", rot_key = "enable_rotation";
|
||||
std::string bed_shrink_x_key = "bed_shrink_x", bed_shrink_y_key = "bed_shrink_y";
|
||||
std::string multi_material_key = "allow_multi_materials_on_same_plate";
|
||||
std::string avoid_extrusion_key = "avoid_extrusion_cali_region";
|
||||
std::string align_to_y_axis_key = "align_to_y_axis";
|
||||
std::string postfix;
|
||||
//BBS:
|
||||
bool seq_print = false;
|
||||
@@ -6106,59 +6206,41 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
if (ptech == ptSLA) {
|
||||
postfix = "_sla";
|
||||
} else if (ptech == ptFFF) {
|
||||
seq_print = &settings == &m_arrange_settings_fff_seq_print;
|
||||
if (seq_print) {
|
||||
postfix = "_fff_seq_print";
|
||||
} else {
|
||||
postfix = "_fff";
|
||||
}
|
||||
seq_print = wxGetApp().global_print_sequence() == PrintSequence::ByObject;
|
||||
postfix = seq_print ? "_fff_seq_print" : "_fff";
|
||||
}
|
||||
|
||||
dist_key += postfix;
|
||||
rot_key += postfix;
|
||||
bed_shrink_x_key += postfix;
|
||||
bed_shrink_y_key += postfix;
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui->text(_L("Spacing"));
|
||||
ImGui::SameLine(1.2 * cursor_slider_left);
|
||||
ImGui::PushItemWidth(window_width - slider_icon_width);
|
||||
bool b_Spacing = imgui->bbl_slider_float_style("##Spacing", &settings.distance, dist_min, 100.0f, "%5.2f") || dist_min > settings.distance;
|
||||
bool b_Spacing = imgui->bbl_slider_float_style("##Spacing", &settings_out.distance, 0.f, 100.0f, "%5.2f", 1.0f, /*clamp=*/false);
|
||||
ImGui::SameLine(window_width - slider_icon_width + 1.3 * cursor_slider_left);
|
||||
ImGui::PushItemWidth(1.5 * slider_icon_width);
|
||||
bool b_spacing_input = ImGui::BBLDragFloat("##spacing_input", &settings.distance, 0.05f, 0.0f, 0.0f, "%.2f");
|
||||
if (b_Spacing || b_spacing_input)
|
||||
{
|
||||
settings.distance = std::max(dist_min, settings.distance);
|
||||
settings_out.distance = settings.distance;
|
||||
bool b_spacing_input = ImGui::BBLDragFloat("##spacing_input", &settings_out.distance, 0.05f, 0.0f, 0.0f, "%.2f");
|
||||
if (b_Spacing || b_spacing_input) {
|
||||
settings_out.distance = std::max(0.f, settings_out.distance);
|
||||
appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance));
|
||||
settings_changed = true;
|
||||
}
|
||||
imgui->text(_L("0 means auto spacing."));
|
||||
|
||||
ImGui::Separator();
|
||||
if (imgui->bbl_checkbox(_L("Auto rotate for arrangement"), settings.enable_rotation)) {
|
||||
settings_out.enable_rotation = settings.enable_rotation;
|
||||
if (imgui->bbl_checkbox(_L("Auto rotate for arrangement"), settings_out.enable_rotation))
|
||||
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation);
|
||||
settings_changed = true;
|
||||
}
|
||||
|
||||
if (imgui->bbl_checkbox(_L("Allow multiple materials on same plate"), settings.allow_multi_materials_on_same_plate)) {
|
||||
settings_out.allow_multi_materials_on_same_plate = settings.allow_multi_materials_on_same_plate;
|
||||
appcfg->set("arrange", multi_material_key.c_str(), settings_out.allow_multi_materials_on_same_plate );
|
||||
settings_changed = true;
|
||||
}
|
||||
if (imgui->bbl_checkbox(_L("Allow multiple materials on same plate"), settings_out.allow_multi_materials_on_same_plate))
|
||||
appcfg->set("arrange", multi_material_key.c_str(), settings_out.allow_multi_materials_on_same_plate);
|
||||
|
||||
// only show this option if the printer has micro Lidar and can do first layer scan
|
||||
DynamicPrintConfig ¤t_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
const bool has_lidar = wxGetApp().preset_bundle->is_bbl_vendor();
|
||||
auto op = current_config.option("scan_first_layer");
|
||||
if (has_lidar && op && op->getBool()) {
|
||||
if (imgui->bbl_checkbox(_L("Avoid extrusion calibration region"), settings.avoid_extrusion_cali_region)) {
|
||||
settings_out.avoid_extrusion_cali_region = settings.avoid_extrusion_cali_region;
|
||||
appcfg->set("arrange", avoid_extrusion_key.c_str(), settings_out.avoid_extrusion_cali_region ? "1" : "0");
|
||||
settings_changed = true;
|
||||
}
|
||||
if (imgui->bbl_checkbox(_L("Avoid extrusion calibration region"), settings_out.avoid_extrusion_cali_region))
|
||||
appcfg->set("arrange", avoid_extrusion_key.c_str(), settings_out.avoid_extrusion_cali_region);
|
||||
} else {
|
||||
settings_out.avoid_extrusion_cali_region = false;
|
||||
}
|
||||
@@ -6170,11 +6252,7 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
settings_out.align_to_y_axis = false;
|
||||
}
|
||||
|
||||
if (imgui->bbl_checkbox(_L("Align to Y axis"), settings.align_to_y_axis)) {
|
||||
settings_out.align_to_y_axis = settings.align_to_y_axis;
|
||||
appcfg->set("arrange", align_to_y_axis_key, settings_out.align_to_y_axis ? "1" : "0");
|
||||
settings_changed = true;
|
||||
}
|
||||
imgui->bbl_checkbox(_L("Align to Y axis"), settings_out.align_to_y_axis);
|
||||
|
||||
if (settings_out.enable_rotation == true) { imgui->disabled_end(); }
|
||||
}
|
||||
@@ -6190,7 +6268,6 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
|
||||
if (imgui->button(_L("Reset"))) {
|
||||
settings_out = ArrangeSettings{};
|
||||
settings_out.distance = std::max(dist_min, settings_out.distance);
|
||||
//BBS: add specific arrange settings
|
||||
if (seq_print) settings_out.is_seq_print = true;
|
||||
|
||||
@@ -6200,18 +6277,16 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
||||
else
|
||||
settings_out.align_to_y_axis = false;
|
||||
|
||||
appcfg->set("arrange", dist_key, float_to_string_decimal_point(settings_out.distance));
|
||||
appcfg->set("arrange", rot_key, settings_out.enable_rotation ? "1" : "0");
|
||||
appcfg->set("arrange", align_to_y_axis_key, settings_out.align_to_y_axis ? "1" : "0");
|
||||
settings_changed = true;
|
||||
appcfg->erase("arrange", dist_key);
|
||||
appcfg->erase("arrange", rot_key);
|
||||
appcfg->erase("arrange", multi_material_key);
|
||||
appcfg->erase("arrange", avoid_extrusion_key);
|
||||
}
|
||||
ImGui::PopStyleVar(1);
|
||||
imgui->end();
|
||||
|
||||
//BBS
|
||||
ImGuiWrapper::pop_toolbar_style();
|
||||
|
||||
return settings_changed;
|
||||
}
|
||||
|
||||
static const float cameraProjection[16] = {1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f};
|
||||
@@ -9996,18 +10071,18 @@ void GLCanvas3D::_render_paint_toolbar() const
|
||||
ImVec2 number_label_size = ImGui::CalcTextSize(std::to_string(i + 1).c_str());
|
||||
ImGui::SetCursorPosY(cursor_y + text_offset_y);
|
||||
ImGui::SetCursorPosX(spacing + i * (spacing + button_size.x) + (button_size.x - number_label_size.x) / 2);
|
||||
ImGui::TextColored(text_color, std::to_string(i + 1).c_str());
|
||||
ImGui::TextColored(text_color, "%s", std::to_string(i + 1).c_str());
|
||||
imgui.pop_bold_font();
|
||||
|
||||
ImVec2 filament_first_line_label_size = ImGui::CalcTextSize(filament_text_first_line[i].c_str());
|
||||
ImGui::SetCursorPosY(cursor_y + text_offset_y + number_label_size.y);
|
||||
ImGui::SetCursorPosX(spacing + i * (spacing + button_size.x) + (button_size.x - filament_first_line_label_size.x) / 2);
|
||||
ImGui::TextColored(text_color, filament_text_first_line[i].c_str());
|
||||
ImGui::TextColored(text_color, "%s", filament_text_first_line[i].c_str());
|
||||
|
||||
ImVec2 filament_second_line_label_size = ImGui::CalcTextSize(filament_text_second_line[i].c_str());
|
||||
ImGui::SetCursorPosY(cursor_y + text_offset_y + number_label_size.y + filament_first_line_label_size.y);
|
||||
ImGui::SetCursorPosX(spacing + i * (spacing + button_size.x) + (button_size.x - filament_second_line_label_size.x) / 2);
|
||||
ImGui::TextColored(text_color, filament_text_second_line[i].c_str());
|
||||
ImGui::TextColored(text_color, "%s", filament_text_second_line[i].c_str());
|
||||
}
|
||||
|
||||
if (ImGui::GetWindowWidth() == constraint_window_width) {
|
||||
@@ -10234,9 +10309,9 @@ void GLCanvas3D::_render_assemble_info() const
|
||||
double size1 = m_selection.get_bounding_box().size()(1);
|
||||
double size2 = m_selection.get_bounding_box().size()(2);
|
||||
if (!m_selection.is_empty()) {
|
||||
ImGui::Text(_L("Volume:").ToUTF8()); ImGui::SameLine(caption_max);
|
||||
ImGui::Text("%s", _L("Volume:").ToUTF8().data()); ImGui::SameLine(caption_max);
|
||||
ImGui::Text("%.2f", size0 * size1 * size2);
|
||||
ImGui::Text(_L("Size:").ToUTF8()); ImGui::SameLine(caption_max);
|
||||
ImGui::Text("%s", _L("Size:").ToUTF8().data()); ImGui::SameLine(caption_max);
|
||||
ImGui::Text("%.2f x %.2f x %.2f", size0, size1, size2);
|
||||
}
|
||||
imgui->end();
|
||||
|
||||
@@ -340,7 +340,6 @@ class GLCanvas3D
|
||||
|
||||
bool dragging{ false };
|
||||
Vec2d position{ DBL_MAX, DBL_MAX };
|
||||
Vec3d scene_position{ DBL_MAX, DBL_MAX, DBL_MAX };
|
||||
bool ignore_left_up{ false };
|
||||
Drag drag;
|
||||
bool ignore_right_up;
|
||||
@@ -684,11 +683,7 @@ public:
|
||||
}
|
||||
|
||||
void load_arrange_settings();
|
||||
ArrangeSettings& get_arrange_settings();// { return get_arrange_settings(this); }
|
||||
ArrangeSettings& get_arrange_settings(PrintSequence print_seq) {
|
||||
return (print_seq == PrintSequence::ByObject) ? m_arrange_settings_fff_seq_print
|
||||
: m_arrange_settings_fff;
|
||||
}
|
||||
ArrangeSettings& get_arrange_settings();
|
||||
|
||||
class SequentialPrintClearance
|
||||
{
|
||||
@@ -1201,17 +1196,6 @@ public:
|
||||
void highlight_toolbar_item(const std::string& item_name);
|
||||
void highlight_gizmo(const std::string& gizmo_name);
|
||||
|
||||
ArrangeSettings get_arrange_settings() const {
|
||||
const ArrangeSettings &settings = get_arrange_settings();
|
||||
ArrangeSettings ret = settings;
|
||||
if (&settings == &m_arrange_settings_fff_seq_print) {
|
||||
ret.distance = std::max(ret.distance,
|
||||
float(min_object_distance(*m_config)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Timestamp for FPS calculation and notification fade-outs.
|
||||
static int64_t timestamp_now() {
|
||||
#ifdef _WIN32
|
||||
@@ -1245,6 +1229,8 @@ public:
|
||||
|
||||
bool can_sequential_clearance_show_in_gizmo();
|
||||
void update_sequential_clearance();
|
||||
// Orca: by-layer counterpart, for a prime tower compacted by "No sparse layers".
|
||||
void update_compacted_wipe_tower_clearance();
|
||||
|
||||
const Print* fff_print() const;
|
||||
const SLAPrint* sla_print() const;
|
||||
@@ -1350,7 +1336,7 @@ private:
|
||||
void _render_selection_sidebar_hints() { m_selection.render_sidebar_hints(m_sidebar_field, m_gizmos.get_uniform_scaling()); }
|
||||
//BBS: GUI refactor: adjust main toolbar position
|
||||
bool _render_orient_menu(float left, float right, float bottom, float top);
|
||||
bool _render_arrange_menu(float left, float right, float bottom, float top);
|
||||
void _render_arrange_menu(float left, float right, float bottom, float top);
|
||||
void _render_3d_navigator();
|
||||
|
||||
void _update_volumes_hover_state();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "3DScene.hpp"
|
||||
#include "OpenGLManager.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GLModel.hpp"
|
||||
|
||||
#include <glad/gl.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "GUI_App.hpp"
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/dcmemory.h>
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
+11
-224
@@ -3,6 +3,14 @@
|
||||
#include "libslic3r/Technologies.hpp"
|
||||
#include "libslic3r/Platform.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "BindDialog.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "PresetBundleDialog.hpp"
|
||||
#include "WebUserLoginDialog.hpp"
|
||||
#include "WebViewDialog.hpp"
|
||||
#include "slic3r/Utils/BBLCloudServiceAgent.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "GUI_Init.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/UserManager.hpp"
|
||||
@@ -598,7 +606,7 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
||||
|
||||
#ifdef WIN32
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
|
||||
|
||||
static void register_win32_device_notification_event()
|
||||
{
|
||||
@@ -6808,7 +6816,7 @@ bool GUI_App::check_preset_parent_available(const std::pair<std::string, std::ma
|
||||
|
||||
void GUI_App::add_pending_vendor_preset(const std::pair<std::string, std::map<std::string, std::string>>& preset_data)
|
||||
{
|
||||
Preset::Type type;
|
||||
Preset::Type type = Preset::Type::TYPE_INVALID;
|
||||
if (preset_data.second.at(BBL_JSON_KEY_TYPE) == PRESET_IOT_PRINT_TYPE)
|
||||
type = Preset::Type::TYPE_PRINT;
|
||||
else if (preset_data.second.at(BBL_JSON_KEY_TYPE) == PRESET_IOT_PRINTER_TYPE)
|
||||
@@ -7769,21 +7777,6 @@ void GUI_App::stop_http_server()
|
||||
m_http_server.stop();
|
||||
}
|
||||
|
||||
void GUI_App::switch_staff_pick(bool on)
|
||||
{
|
||||
mainframe->m_webview->SendDesignStaffpick(on);
|
||||
}
|
||||
|
||||
bool GUI_App::switch_language()
|
||||
{
|
||||
if (select_language()) {
|
||||
recreate_GUI(_L("Switching application language") + dots);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
static const wxLanguageInfo* linux_get_existing_locale_language(const wxLanguageInfo* language,
|
||||
const wxLanguageInfo* system_language)
|
||||
@@ -7878,72 +7871,6 @@ int GUI_App::GetSingleChoiceIndex(const wxString& message,
|
||||
#endif
|
||||
}
|
||||
|
||||
// select language from the list of installed languages
|
||||
bool GUI_App::select_language()
|
||||
{
|
||||
wxArrayString translations = wxTranslations::Get()->GetAvailableTranslations(SLIC3R_APP_KEY);
|
||||
std::vector<const wxLanguageInfo*> language_infos;
|
||||
language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH));
|
||||
for (size_t i = 0; i < translations.GetCount(); ++ i) {
|
||||
const wxLanguageInfo *langinfo = wxLocale::FindLanguageInfo(translations[i]);
|
||||
if (langinfo != nullptr)
|
||||
language_infos.emplace_back(langinfo);
|
||||
}
|
||||
sort_remove_duplicates(language_infos);
|
||||
std::sort(language_infos.begin(), language_infos.end(), [](const wxLanguageInfo* l, const wxLanguageInfo* r) { return l->Description < r->Description; });
|
||||
|
||||
wxArrayString names;
|
||||
names.Alloc(language_infos.size());
|
||||
|
||||
// Some valid language should be selected since the application start up.
|
||||
const wxString active_language_code = current_language_code();
|
||||
const wxLanguageInfo* active_language_info = wxLocale::FindLanguageInfo(active_language_code);
|
||||
const wxLanguage current_language = active_language_info != nullptr ? wxLanguage(active_language_info->Language) : wxLanguage(m_wxLocale->GetLanguage());
|
||||
const wxString active_lang_prefix = active_language_code.BeforeFirst('_');
|
||||
int init_selection = -1;
|
||||
int init_selection_alt = -1;
|
||||
int init_selection_default = -1;
|
||||
for (size_t i = 0; i < language_infos.size(); ++ i) {
|
||||
if (wxLanguage(language_infos[i]->Language) == current_language)
|
||||
// The dictionary matches the active language and country.
|
||||
init_selection = i;
|
||||
else if ((language_infos[i]->CanonicalName.BeforeFirst('_') == active_lang_prefix) ||
|
||||
// if the active language is Slovak, mark the Czech language as active.
|
||||
(language_infos[i]->CanonicalName.BeforeFirst('_') == "cs" && active_lang_prefix == "sk"))
|
||||
// The dictionary matches the active language, it does not necessarily match the country.
|
||||
init_selection_alt = i;
|
||||
if (language_infos[i]->CanonicalName.BeforeFirst('_') == "en")
|
||||
// This will be the default selection if the active language does not match any dictionary.
|
||||
init_selection_default = i;
|
||||
names.Add(language_infos[i]->Description);
|
||||
}
|
||||
if (init_selection == -1)
|
||||
// This is the dictionary matching the active language.
|
||||
init_selection = init_selection_alt;
|
||||
if (init_selection != -1)
|
||||
// This is the language to highlight in the choice dialog initially.
|
||||
init_selection_default = init_selection;
|
||||
|
||||
const long index = GetSingleChoiceIndex(_L("Select the language"), _L("Language"), names, init_selection_default);
|
||||
// Try to load a new language.
|
||||
if (index != -1 && (init_selection == -1 || init_selection != index)) {
|
||||
const wxLanguageInfo *new_language_info = language_infos[index];
|
||||
if (this->load_language(new_language_info->CanonicalName, false)) {
|
||||
// Save language at application config.
|
||||
// Which language to save as the selected dictionary language?
|
||||
// 1) Hopefully the language set to wxTranslations by this->load_language(), but that API is weird and we don't want to rely on its
|
||||
// stability in the future:
|
||||
// wxTranslations::Get()->GetBestTranslation(SLIC3R_APP_KEY, wxLANGUAGE_ENGLISH);
|
||||
// 2) Current locale language may not match the dictionary name, see GH issue #3901
|
||||
// m_wxLocale->GetCanonicalName()
|
||||
// 3) new_language_info->CanonicalName is a safe bet. It points to a valid dictionary name.
|
||||
app_config->set("language", new_language_info->CanonicalName.ToUTF8().data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load gettext translation files and activate them at the start of the application,
|
||||
// based on the "language" key stored in the application config.
|
||||
@@ -8330,146 +8257,6 @@ void GUI_App::show_ip_address_enter_dialog_handler(wxCommandEvent& evt)
|
||||
show_modal_ip_address_enter_dialog(mode == -1?false:true, title);
|
||||
}
|
||||
|
||||
//void GUI_App::add_config_menu(wxMenuBar *menu)
|
||||
//void GUI_App::add_config_menu(wxMenu *menu)
|
||||
//{
|
||||
// auto local_menu = new wxMenu();
|
||||
// wxWindowID config_id_base = wxWindow::NewControlId(int(ConfigMenuCnt));
|
||||
//
|
||||
// const auto config_wizard_name = _(ConfigWizard::name(true));
|
||||
// const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Open %s"))) % config_wizard_name).str());
|
||||
// // Cmd+, is standard on OS X - what about other operating systems?
|
||||
// if (is_editor()) {
|
||||
// local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip);
|
||||
// local_menu->Append(config_id_base + ConfigMenuUpdate, _L("Check for Configuration Updates"), _L("Check for configuration updates"));
|
||||
// local_menu->AppendSeparator();
|
||||
// }
|
||||
// local_menu->Append(config_id_base + ConfigMenuPreferences, _L("Preferences") + dots +
|
||||
//#ifdef __APPLE__
|
||||
// "\tCtrl+,",
|
||||
//#else
|
||||
// "\tCtrl+P",
|
||||
//#endif
|
||||
// _L("Application preferences"));
|
||||
// wxMenu* mode_menu = nullptr;
|
||||
// if (is_editor()) {
|
||||
// local_menu->AppendSeparator();
|
||||
// mode_menu = new wxMenu();
|
||||
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _L("Simple"), _L("Simple Mode"));
|
||||
// mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _L("Advanced"), _L("Advanced Mode"));
|
||||
// Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
|
||||
// Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if (get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
|
||||
//
|
||||
// local_menu->AppendSubMenu(mode_menu, _L("Mode"), wxString::Format(_L("%s Mode"), SLIC3R_APP_NAME));
|
||||
// }
|
||||
// local_menu->AppendSeparator();
|
||||
// local_menu->Append(config_id_base + ConfigMenuLanguage, _L("Language"));
|
||||
// if (is_editor()) {
|
||||
// local_menu->AppendSeparator();
|
||||
// }
|
||||
//
|
||||
// local_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent &event) {
|
||||
// switch (event.GetId() - config_id_base) {
|
||||
// case ConfigMenuWizard:
|
||||
// run_wizard(ConfigWizard::RR_USER);
|
||||
// break;
|
||||
// case ConfigMenuUpdate:
|
||||
// check_updates(true);
|
||||
// break;
|
||||
//#ifdef __linux__
|
||||
// case ConfigMenuDesktopIntegration:
|
||||
// show_desktop_integration_dialog();
|
||||
// break;
|
||||
//#endif
|
||||
// case ConfigMenuSnapshots:
|
||||
// //BBS do not support task snapshot
|
||||
// break;
|
||||
// case ConfigMenuPreferences:
|
||||
// {
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// //bool app_layout_changed = false;
|
||||
// {
|
||||
// // the dialog needs to be destroyed before the call to recreate_GUI()
|
||||
// // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // so we put it into an inner scope
|
||||
// PreferencesDialog dlg(mainframe);
|
||||
// dlg.ShowModal();
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// //app_layout_changed = dlg.settings_layout_changed();
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
// this->plater_->refresh_print();
|
||||
//
|
||||
// if (dlg.recreate_GUI()) {
|
||||
// recreate_GUI(_L("Restart application") + dots);
|
||||
// return;
|
||||
// }
|
||||
//#ifdef _WIN32
|
||||
// if (is_editor()) {
|
||||
// if (app_config->get("associate_3mf") == "true")
|
||||
// associate_3mf_files();
|
||||
// if (app_config->get("associate_stl") == "true")
|
||||
// associate_stl_files();
|
||||
// }
|
||||
// else {
|
||||
// if (app_config->get("associate_gcode") == "true")
|
||||
// associate_gcode_files();
|
||||
// }
|
||||
//#endif // _WIN32
|
||||
// }
|
||||
// //BBS GUI refactor: remove unuse layout logic
|
||||
// /*if (app_layout_changed) {
|
||||
// // hide full main_sizer for mainFrame
|
||||
// mainframe->GetSizer()->Show(false);
|
||||
// mainframe->update_layout();
|
||||
// mainframe->select_tab(size_t(0));
|
||||
// }*/
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuLanguage:
|
||||
// {
|
||||
// /* Before change application language, let's check unsaved changes on 3D-Scene
|
||||
// * and draw user's attention to the application restarting after a language change
|
||||
// */
|
||||
// {
|
||||
// // the dialog needs to be destroyed before the call to switch_language()
|
||||
// // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // so we put it into an inner scope
|
||||
// wxString title = is_editor() ? wxString(SLIC3R_APP_NAME) : wxString(GCODEVIEWER_APP_NAME);
|
||||
// title += " - " + _L("Choose language");
|
||||
// //wxMessageDialog dialog(nullptr,
|
||||
// MessageDialog dialog(nullptr,
|
||||
// _L("Switching the language requires application restart.\n") + "\n\n" +
|
||||
// _L("Do you want to continue?"),
|
||||
// title,
|
||||
// wxICON_QUESTION | wxOK | wxCANCEL);
|
||||
// if (dialog.ShowModal() == wxID_CANCEL)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// switch_language();
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuFlashFirmware:
|
||||
// //BBS FirmwareDialog::run(mainframe);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// using std::placeholders::_1;
|
||||
//
|
||||
// if (mode_menu != nullptr) {
|
||||
// auto modfn = [this](int mode, wxCommandEvent&) { if (get_mode() != mode) save_mode(mode); };
|
||||
// mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
|
||||
// mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
|
||||
// }
|
||||
//
|
||||
// // BBS
|
||||
// //menu->Append(local_menu, _L("Configuration"));
|
||||
// menu->AppendSubMenu(local_menu, _L("Configuration"));
|
||||
//}
|
||||
|
||||
void GUI_App::open_presetbundledialog(size_t open_on_tab, const std::string& highlight_option)
|
||||
{
|
||||
bool app_layout_changed = false;
|
||||
@@ -9418,7 +9205,7 @@ int GUI_App::filaments_cnt() const
|
||||
PrintSequence GUI_App::global_print_sequence() const
|
||||
{
|
||||
PrintSequence global_print_seq = PrintSequence::ByDefault;
|
||||
auto curr_preset_config = preset_bundle->prints.get_edited_preset().config;
|
||||
const auto &curr_preset_config = preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has("print_sequence"))
|
||||
global_print_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>("print_sequence")->value;
|
||||
return global_print_seq;
|
||||
|
||||
+10
-12
@@ -1,23 +1,17 @@
|
||||
#ifndef slic3r_GUI_App_hpp_
|
||||
#define slic3r_GUI_App_hpp_
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "ActionRegistry.hpp"
|
||||
#include "ImGuiWrapper.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "OpenGLManager.hpp"
|
||||
#include "PresetBundleDialog.hpp"
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
#include "slic3r/GUI/UserNotification.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "slic3r/Utils/BBLCloudServiceAgent.hpp"
|
||||
#include "slic3r/GUI/WebViewDialog.hpp"
|
||||
#include "slic3r/GUI/WebUserLoginDialog.hpp"
|
||||
#include "slic3r/GUI/BindDialog.hpp"
|
||||
#include "slic3r/GUI/HMS.hpp"
|
||||
#include "slic3r/Utils/CloudProvider.hpp"
|
||||
#include "slic3r/GUI/Jobs/UpgradeNetworkJob.hpp"
|
||||
#include "slic3r/GUI/HttpServer.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
@@ -64,9 +58,14 @@ class ModelObject;
|
||||
class Model;
|
||||
class UserManager;
|
||||
class DeviceManager;
|
||||
class MachineObject;
|
||||
class NetworkAgent;
|
||||
class IPrinterAgent;
|
||||
class TaskManager;
|
||||
|
||||
// Same typedef as in bambu_networking.hpp, so this header need not include it.
|
||||
typedef std::function<bool()> WasCancelledFn;
|
||||
|
||||
namespace GUI{
|
||||
|
||||
class RemovableDriveManager;
|
||||
@@ -85,6 +84,8 @@ class ParamsDialog;
|
||||
class HMSQuery;
|
||||
class ModelMallDialog;
|
||||
class PingCodeBindDialog;
|
||||
class PresetBundleDialog;
|
||||
class ZUserLogin;
|
||||
class NetworkErrorDialog;
|
||||
class PluginsDialog;
|
||||
class SpeedDialWebDialog;
|
||||
@@ -574,7 +575,6 @@ public:
|
||||
void start_http_server(const std::string& provider = ORCA_CLOUD_PROVIDER);
|
||||
void start_http_server(int port, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
||||
void stop_http_server();
|
||||
void switch_staff_pick(bool on);
|
||||
|
||||
void on_show_check_privacy_dlg(int online_login = 0, const std::string& provider = ORCA_CLOUD_PROVIDER);
|
||||
void show_check_privacy_dlg(wxCommandEvent& evt);
|
||||
@@ -588,7 +588,6 @@ public:
|
||||
void persist_window_geometry(wxTopLevelWindow *window, bool default_maximized = false);
|
||||
void update_ui_from_settings();
|
||||
|
||||
bool switch_language();
|
||||
bool load_language(wxString language, bool initial);
|
||||
|
||||
Tab* get_tab(Preset::Type type);
|
||||
@@ -806,7 +805,6 @@ private:
|
||||
bool window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
|
||||
void window_pos_sanitize(wxTopLevelWindow* window);
|
||||
void window_pos_center(wxTopLevelWindow *window);
|
||||
bool select_language();
|
||||
|
||||
// Dynamic printer agent selection - internal helpers for switch_printer_agent
|
||||
// and the plugin load/unload callbacks (init_plugin_gui_wiring).
|
||||
@@ -837,7 +835,7 @@ wxDECLARE_EVENT(EVT_UPDATE_BUNDLE_COMPLETE, wxCommandEvent);
|
||||
bool is_support_filament(int extruder_id, bool strict_check = true);
|
||||
bool is_soluble_filament(int extruder_id);
|
||||
// check if the filament for model is in the list
|
||||
bool has_filaments(const std::vector<string>& model_filaments);
|
||||
bool has_filaments(const std::vector<std::string>& model_filaments);
|
||||
} // namespace GUI
|
||||
} // Slic3r
|
||||
|
||||
|
||||
@@ -1392,7 +1392,7 @@ void MenuFactory::create_default_menu()
|
||||
{
|
||||
wxMenu* sub_menu_primitives = append_submenu_add_generic(&m_default_menu, ModelVolumeType::INVALID);
|
||||
wxMenu* sub_menu_handy = append_submenu_add_handy_model(&m_default_menu, ModelVolumeType::INVALID);
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
|
||||
[]() {return true; }, m_parent);
|
||||
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
|
||||
@@ -1400,15 +1400,6 @@ void MenuFactory::create_default_menu()
|
||||
append_menu_item(&m_default_menu, wxID_ANY, _L("Add Models"), "", // ORCA: Add Models
|
||||
[](wxCommandEvent&) { plater()->add_file(); }, "menu_add_part", &m_default_menu,
|
||||
[]() {return wxGetApp().plater()->can_add_model(); }, m_parent);
|
||||
#else
|
||||
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
|
||||
[]() {return true; }, m_parent);
|
||||
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
|
||||
[]() {return true; }, m_parent);
|
||||
append_menu_item(&m_default_menu, wxID_ANY, _L("Add Models"), "", // ORCA: Add Models
|
||||
[](wxCommandEvent&) { plater()->add_file(); }, "", &m_default_menu,
|
||||
[]() {return wxGetApp().plater()->can_add_model(); }, m_parent);
|
||||
#endif
|
||||
|
||||
m_default_menu.AppendSeparator();
|
||||
|
||||
@@ -1789,7 +1780,6 @@ void MenuFactory::create_plate_menu()
|
||||
wxMenu* sub_menu_primitives = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
|
||||
wxMenu* sub_menu_handy = append_submenu_add_handy_model(menu, ModelVolumeType::INVALID);
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
|
||||
[]() {return true; }, m_parent);
|
||||
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
|
||||
@@ -1797,15 +1787,7 @@ void MenuFactory::create_plate_menu()
|
||||
append_menu_item(menu, wxID_ANY, _L("Add Models"), "", // ORCA: Add Models
|
||||
[](wxCommandEvent&) { plater()->add_file(); }, "menu_add_part", menu,
|
||||
[]() {return wxGetApp().plater()->can_add_model(); }, m_parent);
|
||||
#else
|
||||
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
|
||||
[]() {return true; }, m_parent);
|
||||
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
|
||||
[]() {return true; }, m_parent);
|
||||
append_menu_item(menu, wxID_ANY, _L("Add Models"), "", // ORCA: Add Models
|
||||
[](wxCommandEvent&) { plater()->add_file(); }, "", menu,
|
||||
[]() {return wxGetApp().plater()->can_add_model(); }, m_parent);
|
||||
#endif
|
||||
|
||||
append_menu_item_replace_all_with_stl(menu);
|
||||
|
||||
|
||||
|
||||
@@ -2578,7 +2578,7 @@ void ObjectGridTable::OnSelectCell(int row, int col)
|
||||
return;
|
||||
m_panel->m_side_window->Freeze();
|
||||
if (row == 0 || col == col_filaments) {
|
||||
m_panel->m_object_settings->UpdateAndShow(row, false, false, false, nullptr, nullptr, std::string());
|
||||
m_panel->m_object_settings->UpdateAndShowRow(row, false, false, false, nullptr, nullptr, std::string());
|
||||
}
|
||||
else {
|
||||
ObjectGridRow* grid_row = m_grid_data[row - 1];
|
||||
@@ -2588,7 +2588,7 @@ void ObjectGridTable::OnSelectCell(int row, int col)
|
||||
|
||||
//m_panel->m_object_settings->get_og()->set_name(GUI::from_u8(grid_row->name.value));
|
||||
//m_panel->m_page_text->SetLabel(GUI::from_u8(grid_row->name.value));
|
||||
m_panel->m_object_settings->UpdateAndShow(row, true, is_object, false, object, grid_row->config, grid_col->category);
|
||||
m_panel->m_object_settings->UpdateAndShowRow(row, true, is_object, false, object, grid_row->config, grid_col->category);
|
||||
|
||||
std::vector<ObjectVolumeID> object_volume_ids;
|
||||
ObjectVolumeID object_volume_id;
|
||||
|
||||
@@ -591,16 +591,11 @@ private:
|
||||
wxColour m_hover_colour;
|
||||
wxBoxSizer* m_top_sizer{nullptr};
|
||||
wxBoxSizer* m_page_sizer{nullptr};
|
||||
wxBoxSizer* m_page_top_sizer{nullptr};
|
||||
wxTextCtrl* m_search_line{ nullptr };
|
||||
ObjectGrid* m_object_grid{nullptr};
|
||||
ObjectGridTable* m_object_grid_table{nullptr};
|
||||
wxStaticText* m_page_text{nullptr};
|
||||
ScalableButton* m_global_reset{nullptr};
|
||||
wxScrolledWindow* m_side_window{nullptr};
|
||||
ObjectTableSettings* m_object_settings{ nullptr };
|
||||
Model* m_model{nullptr};
|
||||
ModelConfig* m_config {nullptr};
|
||||
Plater* m_plater{nullptr};
|
||||
|
||||
int m_cur_row { -1 };
|
||||
@@ -625,8 +620,6 @@ class ObjectTableDialog : public GUI::DPIDialog
|
||||
const int POPUP_HEIGHT = FromDIP(1024);
|
||||
|
||||
//wxPanel* m_panel{ nullptr };
|
||||
wxBoxSizer* m_top_sizer{ nullptr };
|
||||
wxStaticText* m_static_title{ nullptr };
|
||||
//wxTimer* m_refresh_timer;
|
||||
ObjectTablePanel* m_obj_panel{ nullptr };
|
||||
Model* m_model{ nullptr };
|
||||
|
||||
@@ -463,7 +463,7 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje
|
||||
m_table->reload_cell_data(m_current_row, category);
|
||||
}
|
||||
|
||||
void ObjectTableSettings::UpdateAndShow(int row, const bool show, bool is_object, bool is_multiple_selection, ModelObject* object, ModelConfig* config, const std::string& category)
|
||||
void ObjectTableSettings::UpdateAndShowRow(int row, const bool show, bool is_object, bool is_multiple_selection, ModelObject* object, ModelConfig* config, const std::string& category)
|
||||
{
|
||||
m_current_row = row;
|
||||
m_current_category = category;
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
//return visible count
|
||||
int update_extra_column_visible_status(ConfigOptionsGroup* option_group, const std::vector<SimpleSettingData>& option_keys, ModelConfig* config);
|
||||
void update_config_values(bool is_object, ModelObject* object, ModelConfig* config, const std::string& category, const std::string& changed_opt_key = "");
|
||||
void UpdateAndShow(int row, const bool show, bool is_object, bool is_multiple_selection, ModelObject* object, ModelConfig* config, const std::string& category);
|
||||
void UpdateAndShowRow(int row, const bool show, bool is_object, bool is_multiple_selection, ModelObject* object, ModelConfig* config, const std::string& category);
|
||||
void ValueChanged(int row, bool is_object, ModelObject* object, ModelConfig* config, const std::string& category, const std::string& key);
|
||||
void resetAllValues(int row, bool is_object, ModelObject* object, ModelConfig* config, const std::string& category);
|
||||
void msw_rescale();
|
||||
|
||||
@@ -69,6 +69,8 @@ CopyFileResult copy_file_gui(const std::string &from, const std::string &to, std
|
||||
HANDLE handlesrc = nullptr;
|
||||
HANDLE handledst = nullptr;
|
||||
CopyFileResult ret = SUCCESS;
|
||||
DWORD size = 0;
|
||||
DWORD dwRead = 0, dwWrite = 0;
|
||||
|
||||
handlesrc = CreateFile(src.wc_str(),
|
||||
GENERIC_READ,
|
||||
@@ -96,13 +98,12 @@ CopyFileResult copy_file_gui(const std::string &from, const std::string &to, std
|
||||
goto __finished;
|
||||
}
|
||||
|
||||
DWORD size=GetFileSize(handlesrc,NULL);
|
||||
size = GetFileSize(handlesrc,NULL);
|
||||
buff = new char[size+1];
|
||||
DWORD dwRead=0,dwWrite;
|
||||
result = ReadFile(handlesrc, buff, size, &dwRead, NULL);
|
||||
if (!result) {
|
||||
DWORD errCode = GetLastError();
|
||||
error_message = "Error: " + errCode;
|
||||
error_message = "Error: " + std::to_string(errCode);
|
||||
ret = FAIL_COPY_FILE;
|
||||
goto __finished;
|
||||
}
|
||||
@@ -110,7 +111,7 @@ CopyFileResult copy_file_gui(const std::string &from, const std::string &to, std
|
||||
result = WriteFile(handledst,buff,size,&dwWrite,NULL);
|
||||
if (!result) {
|
||||
DWORD errCode = GetLastError();
|
||||
error_message = "Error: " + errCode;
|
||||
error_message = "Error: " + std::to_string(errCode);
|
||||
ret = FAIL_COPY_FILE;
|
||||
goto __finished;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro.
|
||||
#include "GLGizmoAdvancedCut.hpp"
|
||||
#include "slic3r/GUI/Widgets/ProgressDialog.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
|
||||
#include <glad/gl.h>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "GLGizmoBrimEars.hpp"
|
||||
#include <glad/gl.h>
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
@@ -342,7 +343,7 @@ bool GLGizmoBrimEars::on_mouse(const wxMouseEvent& mouse_event)
|
||||
// concludes that the event was not intended for it, it should return false.
|
||||
bool GLGizmoBrimEars::gizmo_event(SLAGizmoEventType action, const Vec2d &mouse_position, bool shift_down, bool alt_down, bool control_down)
|
||||
{
|
||||
if (action != SLAGizmoEventType::MouseWheelDown || action != SLAGizmoEventType::MouseWheelUp || action != SLAGizmoEventType::Moving) {
|
||||
if (action != SLAGizmoEventType::MouseWheelDown && action != SLAGizmoEventType::MouseWheelUp && action != SLAGizmoEventType::Moving) {
|
||||
apply_radius_change();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ class GLGizmoCut3D : public GLGizmoBase
|
||||
GLModel m_reference_radius;
|
||||
GLModel m_angle_arc;
|
||||
|
||||
Vec3d m_old_center;
|
||||
Vec3d m_cut_normal;
|
||||
|
||||
struct InvalidConnectorsStatistics
|
||||
|
||||
@@ -122,7 +122,7 @@ bool GLGizmoFdmSupports::on_init()
|
||||
{ctrl + _L("Mouse wheel"), _L("Gap area")}
|
||||
};
|
||||
|
||||
memset(&m_print_instance, 0, sizeof(m_print_instance));
|
||||
m_print_instance = PrintInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
|
||||
|
||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
||||
#include "libslic3r/LayOnFace.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
#include <numeric>
|
||||
@@ -45,10 +45,10 @@ void GLGizmoFlatten::data_changed(bool is_serializing)
|
||||
const ModelObject *model_object = nullptr;
|
||||
int instance_id = -1;
|
||||
if (selection.is_single_full_instance() ||
|
||||
selection.is_from_single_object() ) {
|
||||
selection.is_from_single_object() ) {
|
||||
model_object = selection.get_model()->objects[selection.get_object_idx()];
|
||||
instance_id = selection.get_instance_idx();
|
||||
}
|
||||
}
|
||||
set_flattening_data(model_object, instance_id);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void GLGizmoFlatten::on_render()
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
shader->start_using();
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
@@ -152,134 +152,18 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object, int in
|
||||
void GLGizmoFlatten::update_planes()
|
||||
{
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
TriangleMesh ch;
|
||||
for (const ModelVolume* vol : mo->volumes) {
|
||||
if (vol->type() != ModelVolumeType::MODEL_PART)
|
||||
continue;
|
||||
TriangleMesh vol_ch = vol->get_convex_hull();
|
||||
vol_ch.transform(vol->get_matrix());
|
||||
ch.merge(vol_ch);
|
||||
}
|
||||
ch = ch.convex_hull_3d();
|
||||
const Transform3d &inst_matrix = mo->instances.front()->get_matrix_no_offset();
|
||||
// The candidate faces are shared with the CLI --ground-* options, the rest only prepares them for rendering.
|
||||
std::vector<LayOnFacePlane> planes = lay_on_face_planes(*mo, inst_matrix);
|
||||
m_planes.clear();
|
||||
on_unregister_raycasters_for_picking();
|
||||
const Transform3d &inst_matrix = mo->instances.front()->get_matrix_no_offset();
|
||||
|
||||
// Following constants are used for discarding too small polygons.
|
||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||
const float minimal_side = 1.f; // mm
|
||||
const float minimal_angle = 1.f; // degree, initial value was 10, but cause bugs
|
||||
// We only keep the 254 largest planes (because of the picking pass limitations):
|
||||
planes.resize(std::min((int)planes.size(), 254));
|
||||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
const int num_of_facets = ch.facets_count();
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
|
||||
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(ch.its);
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
std::vector<bool> facet_visited(num_of_facets, false);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
int facet_idx = 0;
|
||||
while (1) {
|
||||
// Find next unvisited triangle:
|
||||
for (; facet_idx < num_of_facets; ++ facet_idx)
|
||||
if (!facet_visited[facet_idx]) {
|
||||
facet_queue[facet_queue_cnt ++] = facet_idx;
|
||||
facet_visited[facet_idx] = true;
|
||||
normal_ptr = &face_normals[facet_idx];
|
||||
m_planes.emplace_back();
|
||||
break;
|
||||
}
|
||||
if (facet_idx == num_of_facets)
|
||||
break; // Everything was visited already
|
||||
|
||||
while (facet_queue_cnt > 0) {
|
||||
int facet_idx = facet_queue[-- facet_queue_cnt];
|
||||
const stl_normal& this_normal = face_normals[facet_idx];
|
||||
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
|
||||
const Vec3i32 face = ch.its.indices[facet_idx];
|
||||
for (int j=0; j<3; ++j)
|
||||
m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>());
|
||||
|
||||
facet_visited[facet_idx] = true;
|
||||
for (int j = 0; j < 3; ++ j)
|
||||
if (int neighbor_idx = face_neighbors[facet_idx][j]; neighbor_idx >= 0 && ! facet_visited[neighbor_idx])
|
||||
facet_queue[facet_queue_cnt ++] = neighbor_idx;
|
||||
}
|
||||
}
|
||||
m_planes.back().normal = normal_ptr->cast<double>();
|
||||
|
||||
Pointf3s& verts = m_planes.back().vertices;
|
||||
// Now we'll transform all the points into world coordinates, so that the areas, angles and distances
|
||||
// make real sense.
|
||||
verts = transform(verts, inst_matrix);
|
||||
|
||||
// if this is a just a very small triangle, remove it to speed up further calculations (it would be rejected later anyway):
|
||||
if (verts.size() == 3 &&
|
||||
((verts[0] - verts[1]).norm() < minimal_side
|
||||
|| (verts[0] - verts[2]).norm() < minimal_side
|
||||
|| (verts[1] - verts[2]).norm() < minimal_side))
|
||||
m_planes.pop_back();
|
||||
}
|
||||
|
||||
// Let's prepare transformation of the normal vector from mesh to instance coordinates.
|
||||
const Matrix3d normal_matrix = inst_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
|
||||
// Now we'll go through all the polygons, transform the points into xy plane to process them:
|
||||
for (unsigned int polygon_id=0; polygon_id < m_planes.size(); ++polygon_id) {
|
||||
Pointf3s& polygon = m_planes[polygon_id].vertices;
|
||||
const Vec3d& normal = m_planes[polygon_id].normal;
|
||||
|
||||
// transform the normal according to the instance matrix:
|
||||
const Vec3d normal_transformed = normal_matrix * normal;
|
||||
|
||||
// We are going to rotate about z and y to flatten the plane
|
||||
Eigen::Quaterniond q;
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.matrix().block(0, 0, 3, 3) = q.setFromTwoVectors(normal_transformed, Vec3d::UnitZ()).toRotationMatrix();
|
||||
polygon = transform(polygon, m);
|
||||
|
||||
// Now to remove the inner points. We'll misuse Geometry::convex_hull for that, but since
|
||||
// it works in fixed point representation, we will rescale the polygon to avoid overflows.
|
||||
// And yes, it is a nasty thing to do. Whoever has time is free to refactor.
|
||||
Vec3d bb_size = BoundingBoxf3(polygon).size();
|
||||
float sf = std::min(1./bb_size(0), 1./bb_size(1));
|
||||
Transform3d tr = Geometry::scale_transform({ sf, sf, 1.f });
|
||||
polygon = transform(polygon, tr);
|
||||
polygon = Slic3r::Geometry::convex_hull(polygon);
|
||||
polygon = transform(polygon, tr.inverse());
|
||||
|
||||
// Calculate area of the polygons and discard ones that are too small
|
||||
float& area = m_planes[polygon_id].area;
|
||||
area = 0.f;
|
||||
for (unsigned int i = 0; i < polygon.size(); i++) // Shoelace formula
|
||||
area += polygon[i](0)*polygon[i + 1 < polygon.size() ? i + 1 : 0](1) - polygon[i + 1 < polygon.size() ? i + 1 : 0](0)*polygon[i](1);
|
||||
area = 0.5f * std::abs(area);
|
||||
|
||||
bool discard = false;
|
||||
if (area < minimal_area)
|
||||
discard = true;
|
||||
else {
|
||||
// We also check the inner angles and discard polygons with angles smaller than the following threshold
|
||||
const double angle_threshold = ::cos(minimal_angle * (double)PI / 180.0);
|
||||
|
||||
for (unsigned int i = 0; i < polygon.size(); ++i) {
|
||||
const Vec3d& prec = polygon[(i == 0) ? polygon.size() - 1 : i - 1];
|
||||
const Vec3d& curr = polygon[i];
|
||||
const Vec3d& next = polygon[(i == polygon.size() - 1) ? 0 : i + 1];
|
||||
|
||||
if ((prec - curr).normalized().dot((next - curr).normalized()) > angle_threshold) {
|
||||
discard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (discard) {
|
||||
m_planes[polygon_id--] = std::move(m_planes.back());
|
||||
m_planes.pop_back();
|
||||
continue;
|
||||
}
|
||||
for (LayOnFacePlane& plane : planes) {
|
||||
// The outline is convex and lies in the plane frame, where the plane is horizontal.
|
||||
Pointf3s& polygon = plane.outline;
|
||||
|
||||
// We will shrink the polygon a little bit so it does not touch the object edges:
|
||||
Vec3d centroid = std::accumulate(polygon.begin(), polygon.end(), Vec3d(0.0, 0.0, 0.0));
|
||||
@@ -332,13 +216,12 @@ void GLGizmoFlatten::update_planes()
|
||||
b(2) += 0.1f;
|
||||
|
||||
// Transform back to 3D (and also back to mesh coordinates)
|
||||
polygon = transform(polygon, inst_matrix.inverse() * m.inverse());
|
||||
m_planes.emplace_back();
|
||||
m_planes.back().normal = plane.normal;
|
||||
m_planes.back().area = plane.area;
|
||||
m_planes.back().vertices = transform(polygon, inst_matrix.inverse() * plane.to_plane_frame.inverse());
|
||||
}
|
||||
|
||||
// We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
|
||||
std::sort(m_planes.rbegin(), m_planes.rend(), [](const PlaneData& a, const PlaneData& b) { return a.area < b.area; });
|
||||
m_planes.resize(std::min((int)m_planes.size(), 254));
|
||||
|
||||
// Planes are finished - let's save what we calculated it from:
|
||||
m_volumes_matrices.clear();
|
||||
m_volumes_types.clear();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "libslic3r/Print.hpp"
|
||||
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "GLGizmoMeasure.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
|
||||
@@ -343,12 +343,12 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(10,20));
|
||||
if (is_worker_running) { // apply or preview
|
||||
// draw progress bar
|
||||
std::string progress_text = GUI::format("%1%", std::to_string(progress)) + "%%";
|
||||
std::string progress_text = GUI::format("%1%", std::to_string(progress)) + "%";
|
||||
ImVec2 progress_size(bottom_left_width - space_size, 0.0f);
|
||||
ImGui::BBLProgressBar2(progress / 100., progress_size);
|
||||
ImGui::SameLine();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextColored(ImVec4(0.42f, 0.42f, 0.42f, 1.00f), progress_text.c_str());
|
||||
ImGui::TextColored(ImVec4(0.42f, 0.42f, 0.42f, 1.00f), "%s", progress_text.c_str());
|
||||
ImGui::SameLine(bottom_left_width + slider_width + m_imgui->scaled(1.0f));
|
||||
} else {
|
||||
ImGui::Dummy(ImVec2(bottom_left_width - space_size, -1));
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
*/
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
namespace Slic3r::GUI::GLGizmoUtils {
|
||||
|
||||
void render_tooltip_button(
|
||||
|
||||
@@ -702,7 +702,7 @@ bool GizmoObjectManipulation::reset_zero_button(ImGuiWrapper *imgui_wrapper, bo
|
||||
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
char buf[3][64] = {0};
|
||||
char buf[3][64] = {};
|
||||
float buf_size[3] = {0};
|
||||
for (int j = 0; j < 3; j++) {
|
||||
ImGui::DataTypeFormatString(buf[j], IM_ARRAYSIZE(buf[j]), ImGuiDataType_Double, (void *) &vec[i][j], "%.2f");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "GradientCurveEditor.hpp"
|
||||
#include "FilamentBitmapUtils.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GuiColor.hpp"
|
||||
#include "I18N.hpp"
|
||||
@@ -19,23 +20,13 @@ namespace GUI {
|
||||
wxDEFINE_EVENT(wxEVT_GRADIENT_CURVE_CHANGED, wxCommandEvent);
|
||||
|
||||
namespace {
|
||||
// Layout ratios of the plot rect within the widget, taken from a 214 x 180 px reference drawing.
|
||||
// Plot rect occupies the upper-left region; right + bottom margins host axis arrows / labels.
|
||||
constexpr double kPlotLeftRatio = 0.0316;
|
||||
constexpr double kPlotRightRatio = 0.6766;
|
||||
constexpr double kPlotTopRatio = 0.1529;
|
||||
constexpr double kPlotBottomRatio = 0.8474;
|
||||
constexpr int kGridDivisions = 9; // 10 grid lines including the outer borders.
|
||||
|
||||
// Hit / stroke (DIP).
|
||||
// Hit / stroke (DIP). The plot-rect ratios, grid divisions, axis/arrow geometry and the
|
||||
// near-background outline threshold now live in FilamentBitmapUtils so the read-only Publish
|
||||
// preview and this editor stay pixel-identical.
|
||||
constexpr int kHitRadius = 6;
|
||||
constexpr int kCurveHitRadius = 5;
|
||||
constexpr int kPointRadius = 4; // anchor outer radius (DIP)
|
||||
constexpr int kStrokeUnselected = 2;
|
||||
constexpr int kStrokeSelected = 4;
|
||||
constexpr int kStrokeAxis = 2; // axis line width (px, no DPI scaling - matches kGridColor pen and 2DBed convention)
|
||||
constexpr int kAxisArrowHalf = 5; // half-base of the axis arrow triangle (DIP)
|
||||
constexpr int kAxisArrowLen = 10; // length of the axis arrow triangle (DIP)
|
||||
|
||||
// Light-mode design tokens. Resolved through StateColor::darkModeColorFor()
|
||||
// at paint time so the editor follows the app theme (#EEEEEE -> #4C4C55, #6B6B6B ->
|
||||
@@ -46,12 +37,6 @@ const wxColour kAxisColor (107, 107, 107); // #6B6B6B grey 700
|
||||
const wxColour kLabelMuted (107, 107, 107); // #6B6B6B grey 700
|
||||
const wxColour kLabelStrong ( 38, 46, 48); // #262E30 grey 900
|
||||
const wxColour kOutlineColor(172, 172, 172); // #ACACAC dimmed elements
|
||||
|
||||
// LAB (DeltaE76) threshold for "curve color is too close to the background": below it the curve
|
||||
// gets a subtle outline so it does not visually vanish, otherwise it is drawn plain. Looser than
|
||||
// the 5.0 of FlushPredict::is_similar_color, so a pastel pink on white still gets an outline.
|
||||
constexpr float kBgSimilarThreshold = 15.0f;
|
||||
constexpr int kOutlineExtraDip = 2;
|
||||
} // namespace
|
||||
|
||||
GradientCurveEditor::GradientCurveEditor(wxWindow* parent,
|
||||
@@ -177,15 +162,8 @@ void GradientCurveEditor::emit_changed()
|
||||
|
||||
wxRect GradientCurveEditor::plot_rect() const
|
||||
{
|
||||
const wxSize sz = GetClientSize();
|
||||
const int x = static_cast<int>(std::lround(sz.x * kPlotLeftRatio));
|
||||
const int y = static_cast<int>(std::lround(sz.y * kPlotTopRatio));
|
||||
const int x2 = static_cast<int>(std::lround(sz.x * kPlotRightRatio));
|
||||
const int y2 = static_cast<int>(std::lround(sz.y * kPlotBottomRatio));
|
||||
// Force square 1:1 so X/Y axes share the same scale and grid cells stay square. Anchor at
|
||||
// the top-left so the "100%" labels on the bottom/right still align with the plot edges.
|
||||
const int side = std::max(1, std::min(x2 - x, y2 - y));
|
||||
return wxRect(x, y, side, side);
|
||||
// Square 1:1 plot, shared with the Publish dialog's read-only preview.
|
||||
return mixed_gradient_plot_rect(GetClientSize());
|
||||
}
|
||||
|
||||
wxPoint2DDouble GradientCurveEditor::data_to_px_f(double x, double y) const
|
||||
@@ -330,171 +308,52 @@ void GradientCurveEditor::on_paint(wxPaintEvent& /*evt*/)
|
||||
raw_dc.SetBackground(wxBrush(bg));
|
||||
raw_dc.Clear();
|
||||
|
||||
// Render through wxGCDC so curves, arrows and anchor circles get anti-aliased; the buffered
|
||||
// DC is the actual back buffer that gets blitted to the window.
|
||||
wxGCDC dc(raw_dc);
|
||||
// The curve and its anchors are drawn straight on the graphics context so their
|
||||
// coordinates stay sub-pixel accurate (see data_to_px_f).
|
||||
wxGraphicsContext* gc = dc.GetGraphicsContext();
|
||||
|
||||
const wxRect rc = plot_rect();
|
||||
if (rc.width <= 0 || rc.height <= 0)
|
||||
return;
|
||||
|
||||
// 10x10 light grid (10 lines including outer borders, 9 equal divisions).
|
||||
dc.SetPen(wxPen(grid_color, 1));
|
||||
for (int i = 0; i <= kGridDivisions; ++i) {
|
||||
const int x = rc.x + rc.width * i / kGridDivisions;
|
||||
const int y = rc.y + rc.height * i / kGridDivisions;
|
||||
dc.DrawLine(x, rc.y, x, rc.y + rc.height);
|
||||
dc.DrawLine(rc.x, y, rc.x + rc.width, y);
|
||||
}
|
||||
|
||||
// Set the label font first so text width measurements drive arrow / label placement.
|
||||
wxFont label_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
label_font.SetPointSize(std::max(7, label_font.GetPointSize() - 1));
|
||||
dc.SetFont(label_font);
|
||||
|
||||
const wxString axis_y_title = _L("Material Ratio");
|
||||
const wxString axis_x_title = _L("Model Height");
|
||||
const wxString pct_text = wxT("100%");
|
||||
const wxSize x_title_sz = dc.GetTextExtent(axis_x_title);
|
||||
const wxSize y_title_sz = dc.GetTextExtent(axis_y_title);
|
||||
|
||||
wxFont strong_font = label_font;
|
||||
strong_font.SetWeight(wxFONTWEIGHT_SEMIBOLD);
|
||||
dc.SetFont(strong_font);
|
||||
const wxSize pct_text_sz = dc.GetTextExtent(pct_text);
|
||||
dc.SetFont(label_font);
|
||||
|
||||
// Axes (grey 700) with filled triangle arrows. Y-axis extends above the plot top to the
|
||||
// canvas top edge; X-axis extends past the plot right toward the canvas right edge.
|
||||
const int arrow_half = FromDIP(kAxisArrowHalf);
|
||||
const int arrow_len = FromDIP(kAxisArrowLen);
|
||||
const wxSize sz = GetClientSize();
|
||||
dc.SetPen(wxPen(axis_color, kStrokeAxis));
|
||||
dc.SetBrush(wxBrush(axis_color));
|
||||
|
||||
// Y-axis: vertical line at plot_left, from arrow tip near canvas top down to plot bottom.
|
||||
const int y_axis_x = rc.x;
|
||||
const int y_title_pct_gap = FromDIP(1);
|
||||
const int y_title_bottom_pad = FromDIP(2);
|
||||
const int y_title_y = std::max(0, rc.y - y_title_sz.y - y_title_pct_gap - pct_text_sz.y - y_title_bottom_pad);
|
||||
const int y_arrow_tip_y = y_title_y;
|
||||
const int y_arrow_ty = y_arrow_tip_y + arrow_len;
|
||||
dc.DrawLine(y_axis_x, y_arrow_ty, y_axis_x, rc.y + rc.height);
|
||||
{
|
||||
wxPoint tri[3] = {
|
||||
wxPoint(y_axis_x, y_arrow_tip_y),
|
||||
wxPoint(y_axis_x - arrow_half, y_arrow_ty),
|
||||
wxPoint(y_axis_x + arrow_half, y_arrow_ty),
|
||||
// Render the plot (grid, axes, labels, curves, anchors) through the shared painter so the
|
||||
// interactive editor and the Publish dialog's read-only preview stay pixel-identical. The
|
||||
// curves are handed over as sub-pixel polylines and anti-alias inside the helper.
|
||||
std::vector<MixedGradientCurve> curves;
|
||||
std::vector<wxPoint2DDouble> anchors;
|
||||
if (m_points.size() >= 2) {
|
||||
auto color_for_curve = [&](int curve_idx) -> wxColour {
|
||||
wxColour c = (curve_idx == 0) ? m_color_low : m_color_high;
|
||||
// Transparent filaments (alpha == 0, e.g. #FFFFFF00) would be invisible.
|
||||
if (c.Alpha() == 0)
|
||||
c.Set(c.Red(), c.Green(), c.Blue(), 150);
|
||||
return c;
|
||||
};
|
||||
dc.DrawPolygon(3, tri);
|
||||
}
|
||||
|
||||
// X-axis arrow tip: stays just past the plot ideally, but is clamped so the trailing
|
||||
// "Material Ratio" label still fits inside the canvas without overlapping the arrow.
|
||||
const int x_axis_y = rc.y + rc.height;
|
||||
const int x_label_gap = FromDIP(4);
|
||||
const int x_edge_pad = FromDIP(6);
|
||||
const int x_arrow_ideal = rc.x + rc.width + FromDIP(10);
|
||||
const int x_arrow_max = sz.x - x_title_sz.x - x_label_gap - x_edge_pad - arrow_len;
|
||||
const int x_arrow_tx = std::max(rc.x + rc.width + arrow_len,
|
||||
std::min(x_arrow_ideal, x_arrow_max));
|
||||
const int x_arrow_tip_x = x_arrow_tx + arrow_len;
|
||||
const int x_title_x = x_arrow_tip_x + x_label_gap;
|
||||
dc.DrawLine(rc.x, x_axis_y, x_arrow_tx, x_axis_y);
|
||||
{
|
||||
wxPoint tri[3] = {
|
||||
wxPoint(x_arrow_tip_x, x_axis_y),
|
||||
wxPoint(x_arrow_tx, x_axis_y - arrow_half),
|
||||
wxPoint(x_arrow_tx, x_axis_y + arrow_half),
|
||||
auto build_polyline = [&](int curve_idx) -> std::vector<wxPoint2DDouble> {
|
||||
const int samples = std::max(128, plot_rect().width * 2);
|
||||
std::vector<wxPoint2DDouble> poly;
|
||||
poly.reserve(samples + 1);
|
||||
for (int s = 0; s <= samples; ++s) {
|
||||
const double x = double(s) / samples;
|
||||
const double y0 = sample_curve_y(x);
|
||||
const double vy = to_visual_y(curve_idx, y0);
|
||||
poly.push_back(data_to_px_f(x, vy));
|
||||
}
|
||||
return poly;
|
||||
};
|
||||
dc.DrawPolygon(3, tri);
|
||||
}
|
||||
|
||||
// Labels.
|
||||
// "Model Height" and "100%" share the same left x; the gap is larger than the
|
||||
// axis-arrow half-base so the text never visually touches the Y-axis arrow.
|
||||
const int label_left_x = y_axis_x + FromDIP(10);
|
||||
dc.SetTextForeground(label_muted);
|
||||
dc.DrawText(axis_y_title, label_left_x, y_title_y);
|
||||
|
||||
dc.SetFont(strong_font);
|
||||
dc.SetTextForeground(label_strong);
|
||||
dc.DrawText(pct_text, label_left_x, y_title_y + y_title_sz.y + y_title_pct_gap);
|
||||
|
||||
// Bottom-right "100%" sits under the right end of the plot; "Material Ratio" follows the
|
||||
// X-axis arrow tip (placement was already clamped above to leave room).
|
||||
dc.DrawText(pct_text, rc.x + rc.width - pct_text_sz.x, x_axis_y);
|
||||
dc.SetFont(label_font);
|
||||
dc.SetTextForeground(label_muted);
|
||||
dc.DrawText(axis_x_title, x_title_x, x_axis_y - x_title_sz.y / 2);
|
||||
|
||||
if (m_points.size() < 2 || !gc)
|
||||
return;
|
||||
|
||||
auto color_for_curve = [&](int curve_idx) -> wxColour {
|
||||
wxColour c = (curve_idx == 0) ? m_color_low : m_color_high;
|
||||
// Transparent filaments (alpha == 0, e.g. #FFFFFF00) would be invisible.
|
||||
// Lift alpha so the curve stays visible while still hinting at transparency.
|
||||
if (c.Alpha() == 0)
|
||||
c.Set(c.Red(), c.Green(), c.Blue(), 150);
|
||||
return c;
|
||||
};
|
||||
|
||||
auto build_polyline = [&](int curve_idx) -> std::vector<wxPoint2DDouble> {
|
||||
const int samples = std::max(128, rc.width * 2);
|
||||
std::vector<wxPoint2DDouble> poly;
|
||||
poly.reserve(samples + 1);
|
||||
for (int s = 0; s <= samples; ++s) {
|
||||
const double x = double(s) / samples;
|
||||
const double y0 = sample_curve_y(x);
|
||||
const double vy = to_visual_y(curve_idx, y0);
|
||||
poly.push_back(data_to_px_f(x, vy));
|
||||
// Draw unselected first so the selected curve sits on top.
|
||||
const int other = 1 - m_selected_curve;
|
||||
for (const int idx : {other, m_selected_curve}) {
|
||||
std::vector<wxPoint2DDouble> pts = build_polyline(idx);
|
||||
if (pts.empty())
|
||||
continue;
|
||||
curves.push_back({std::move(pts), color_for_curve(idx), idx == m_selected_curve ? kStrokeSelected : kStrokeUnselected});
|
||||
}
|
||||
return poly;
|
||||
};
|
||||
|
||||
// Only the geometry goes through the graphics context: dc.DrawLines() takes integer wxPoint
|
||||
// and would quantize the curve back to whole pixels. The pen is still set on the dc, which
|
||||
// forwards it here while keeping its own cached state in sync for later dc drawing.
|
||||
auto draw_polyline = [&](const std::vector<wxPoint2DDouble>& poly, const wxColour& col, int stroke_dip) {
|
||||
dc.SetPen(wxPen(col, FromDIP(stroke_dip)));
|
||||
gc->StrokeLines(poly.size(), poly.data());
|
||||
};
|
||||
|
||||
// Outline only when the curve color is perceptually close to the background; otherwise
|
||||
// the plain filament color reads fine and the extra stroke would look heavy.
|
||||
auto needs_outline = [&](const wxColour& c) {
|
||||
return calc_color_distance(c, bg) < kBgSimilarThreshold;
|
||||
};
|
||||
|
||||
auto draw_one = [&](int curve_idx, int stroke_dip) {
|
||||
const auto poly = build_polyline(curve_idx);
|
||||
const wxColour col = color_for_curve(curve_idx);
|
||||
if (needs_outline(col))
|
||||
draw_polyline(poly, outline_color, stroke_dip + kOutlineExtraDip);
|
||||
draw_polyline(poly, col, stroke_dip);
|
||||
};
|
||||
|
||||
// Draw unselected first so the selected curve sits on top.
|
||||
const int other = 1 - m_selected_curve;
|
||||
draw_one(other, kStrokeUnselected);
|
||||
draw_one(m_selected_curve, kStrokeSelected);
|
||||
|
||||
// Control points (selected curve only): hollow circle with axis-color border, theme-aware fill.
|
||||
// Drawn on the graphics context with a sub-pixel center so the ring stays centered on the
|
||||
// curve instead of drifting up to half a pixel off it; pen and brush go through the dc for
|
||||
// the same reason as in draw_polyline above.
|
||||
const double r = FromDIP(kPointRadius);
|
||||
dc.SetPen(wxPen(axis_color, 1));
|
||||
dc.SetBrush(wxBrush(point_fill));
|
||||
for (size_t i = 0; i < m_points.size(); ++i) {
|
||||
const double vy = to_visual_y(m_selected_curve, m_points[i].y);
|
||||
const wxPoint2DDouble p = data_to_px_f(m_points[i].x, vy);
|
||||
gc->DrawEllipse(p.m_x - r, p.m_y - r, r * 2, r * 2);
|
||||
// Control points (selected curve only).
|
||||
anchors.reserve(m_points.size());
|
||||
for (size_t i = 0; i < m_points.size(); ++i) {
|
||||
const double vy = to_visual_y(m_selected_curve, m_points[i].y);
|
||||
anchors.push_back(data_to_px_f(m_points[i].x, vy));
|
||||
}
|
||||
}
|
||||
|
||||
const MixedGradientTheme theme{bg, grid_color, axis_color, label_muted, label_strong, outline_color, point_fill};
|
||||
draw_mixed_gradient_plot(raw_dc, GetClientSize(), curves, anchors, theme);
|
||||
}
|
||||
|
||||
void GradientCurveEditor::on_left_down(wxMouseEvent& evt)
|
||||
|
||||
@@ -25,7 +25,6 @@ class HMSNotifyItem : public wxPanel
|
||||
wxStaticBitmap *m_bitmap_notify;
|
||||
wxStaticBitmap *m_bitmap_arrow;
|
||||
wxStaticText * m_hms_content;
|
||||
wxHtmlWindow * m_html;
|
||||
wxPanel * m_staticline;
|
||||
|
||||
wxBitmap m_img_notify_lv1;
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "slic3r/Utils/BBLNetworkPlugin.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "IMSlider.hpp"
|
||||
#include "libslic3r/GCode.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
@@ -790,7 +791,7 @@ void IMSlider::draw_ticks(const ImRect& slideable_region) {
|
||||
|
||||
void IMSlider::show_tooltip(const std::string tooltip) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 6 * m_scale, 3 * m_scale });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, { 3 * m_scale });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3 * m_scale);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.00f, 1.00f, 1.00f, 1.00f));
|
||||
|
||||
@@ -216,7 +216,6 @@ private:
|
||||
long m_extra_style;
|
||||
float m_label_koef{1.0};
|
||||
|
||||
float m_zero_layer_height = 0.0f;
|
||||
std::vector<double> m_values;
|
||||
TickCodeInfo m_ticks;
|
||||
std::vector<double> m_layers_times;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
class wxStaticBitmap;
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
@@ -521,7 +521,7 @@ void ImageGrid::render(wxDC& dc)
|
||||
if (!m_status_msg.IsEmpty()) {
|
||||
auto si = m_status_icon.GetBmpSize();
|
||||
auto st = dc.GetMultiLineTextExtent(m_status_msg);
|
||||
auto rect = wxRect{0, 0, max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
|
||||
auto rect = wxRect{0, 0, std::max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
|
||||
dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
|
||||
dc.SetTextForeground(wxColor(0x909090));
|
||||
dc.DrawText(m_status_msg, rect.x + (rect.width - st.x) / 2, rect.GetBottom() - st.y);
|
||||
|
||||
@@ -114,7 +114,10 @@ namespace instance_check_internal
|
||||
if (my_instance_hash == other_instance_hash) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "win enum - found correct instance";
|
||||
orca_slicer_hwnd = hwnd;
|
||||
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
|
||||
// Do not alter the window state when opening a file in the existing instance.
|
||||
// A minimized window still needs restoring before it can receive focus.
|
||||
if (IsIconic(hwnd))
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
SetForegroundWindow(hwnd);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@ private:
|
||||
std::condition_variable m_thread_stop_condition;
|
||||
mutable std::mutex m_thread_stop_mutex;
|
||||
bool m_stop{ false };
|
||||
bool m_start{ true };
|
||||
|
||||
// background thread method
|
||||
void listen();
|
||||
|
||||
@@ -265,8 +265,7 @@ arrangement::ArrangePolygon estimate_wipe_tower_info(int plate_index, std::set<i
|
||||
int extruder_size = extruder_ids.size();
|
||||
|
||||
Vec3d wipe_tower_size, wipe_tower_pos;
|
||||
int nozzle_nums = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||
auto arrange_poly = ppl.get_plate(plate_index_valid)->estimate_wipe_tower_polygon(full_config, plate_index, wipe_tower_pos, wipe_tower_size, nozzle_nums, extruder_size);
|
||||
auto arrange_poly = ppl.get_plate(plate_index_valid)->estimate_wipe_tower_polygon(full_config, plate_index, wipe_tower_pos, wipe_tower_size, extruder_size);
|
||||
arrange_poly.bed_idx = plate_index;
|
||||
return arrange_poly;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
#include "slic3r/GUI/HMS.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
|
||||
#include "slic3r/GUI/DeviceCore/DevManager.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ class BindJob : public Job
|
||||
std::string m_sec_link;
|
||||
std::string m_ssdp_version;
|
||||
bool m_job_finished{ false };
|
||||
int m_print_job_completed_id = 0;
|
||||
bool m_improved{false};
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "SendJob.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "libslic3r/MTUtils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@@ -27,7 +27,6 @@ class UpgradeNetworkJob : public Job
|
||||
wxWindow * m_event_handle{nullptr};
|
||||
std::function<void()> m_success_fun{nullptr};
|
||||
bool m_job_finished{ false };
|
||||
int m_print_job_completed_id = 0;
|
||||
|
||||
InstallProgressFn pro_fn { nullptr };
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ void KBShortcutsDialog::fill_shortcuts()
|
||||
{ ctrl + "O", L("Open Project") },
|
||||
{ ctrl + "S", L("Save Project") },
|
||||
{ ctrl + shift + "S", L("Save Project as")},
|
||||
{ ctrl + shift + "E", L("Publish 3MF") },
|
||||
// File>Import
|
||||
{ ctrl + "I", L("Import geometry data from STL/STEP/3MF/OBJ/AMF files") },
|
||||
// File>Export
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#endif
|
||||
#include "WebViewDialog.hpp"
|
||||
#include "../Utils/Process.hpp"
|
||||
#include "format.hpp"
|
||||
// BBS
|
||||
#include "PartPlate.hpp"
|
||||
#include "Preferences.hpp"
|
||||
@@ -53,11 +52,9 @@
|
||||
#include "../Utils/NetworkAgentFactory.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <string_view>
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
#include "PublishSettingsDialog.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include "GUI_Factories.hpp"
|
||||
@@ -747,6 +744,10 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
||||
if (m_plater) { m_plater->add_file(); }
|
||||
return;
|
||||
}
|
||||
if (evt.CmdDown() && evt.ShiftDown() && evt.GetKeyCode() == 'E') {
|
||||
if (can_export_model()) publish_project();
|
||||
return;
|
||||
}
|
||||
evt.Skip();
|
||||
});
|
||||
|
||||
@@ -1646,7 +1647,7 @@ void MainFrame::register_win32_callbacks()
|
||||
//static GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED };
|
||||
//static GUID GUID_DEVINTERFACE_DISK = { 0x53f56307, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b };
|
||||
//static GUID GUID_DEVINTERFACE_VOLUME = { 0x71a27cdd, 0x812a, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f };
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } };
|
||||
|
||||
// Register USB HID (Human Interface Devices) notifications to trigger the 3DConnexion enumeration.
|
||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter = { 0 };
|
||||
@@ -1686,7 +1687,7 @@ void MainFrame::register_win32_callbacks()
|
||||
|
||||
{
|
||||
static constexpr int device_count = 1;
|
||||
RAWINPUTDEVICE devices[device_count] = { 0 };
|
||||
RAWINPUTDEVICE devices[device_count] = {};
|
||||
// multi-axis mouse (SpaceNavigator, etc.)
|
||||
devices[0].usUsagePage = 0x01;
|
||||
devices[0].usUsage = 0x08;
|
||||
@@ -1795,6 +1796,22 @@ bool MainFrame::save_project_as(const wxString& filename)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MainFrame::publish_project()
|
||||
{
|
||||
if (m_plater == nullptr)
|
||||
return;
|
||||
// Seed the dialog from the session selection (a remembered state or a freshly loaded
|
||||
// published 3MF); a null pointer means "fresh", keeping the dirty defaults.
|
||||
std::vector<std::string> pending_keys;
|
||||
std::vector<Slic3r::PublishedMaterialEntry> pending_material;
|
||||
const bool has_prior = m_plater->get_pending_published(pending_keys, pending_material);
|
||||
PublishSettingsDialog dlg(this, has_prior ? &pending_keys : nullptr, has_prior ? &pending_material : nullptr);
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
m_plater->set_pending_published(dlg.GetPublishedKeys(), dlg.GetPublishedMaterialKeys());
|
||||
m_plater->export_published_3mf(dlg.GetPublishedKeys(), dlg.GetPublishedMaterialKeys());
|
||||
}
|
||||
|
||||
bool MainFrame::can_upload() const
|
||||
{
|
||||
return true;
|
||||
@@ -2890,6 +2907,20 @@ void MainFrame::init_menubar_as_editor()
|
||||
[this](){return m_plater != nullptr && can_save_as(); }, this);
|
||||
#endif
|
||||
|
||||
// BBS: publish
|
||||
fileMenu->AppendSeparator();
|
||||
auto publish_handler = [this](wxCommandEvent&) { publish_project(); };
|
||||
|
||||
#ifndef __APPLE__
|
||||
append_menu_item(fileMenu, wxID_ANY, _L("Publish 3MF") + dots + "\t" + ctrl + shift + "E", _L("Export a 3MF file with the selected settings embedded"),
|
||||
publish_handler, "menu_publish", nullptr,
|
||||
[this](){return can_export_model(); }, this);
|
||||
#else
|
||||
append_menu_item(fileMenu, wxID_ANY, _L("Publish 3MF") + dots + "\t" + ctrl + shift + "E", _L("Export a 3MF file with the selected settings embedded"),
|
||||
publish_handler, "", nullptr,
|
||||
[this](){return can_export_model(); }, this);
|
||||
#endif
|
||||
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
@@ -3300,98 +3331,9 @@ void MainFrame::init_menubar_as_editor()
|
||||
auto preference_item = new wxMenuItem(parent_menu, ConfigMenuPreferences + config_id_base, _L("Preferences") + "\t" + ctrl + "P", "");
|
||||
|
||||
#endif
|
||||
//auto printer_item = new wxMenuItem(parent_menu, ConfigMenuPrinter + config_id_base, _L("Printer"), "");
|
||||
//auto language_item = new wxMenuItem(parent_menu, ConfigMenuLanguage + config_id_base, _L("Switch Language"), "");
|
||||
// parent_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
|
||||
// switch (event.GetId() - config_id_base) {
|
||||
// //case ConfigMenuLanguage:
|
||||
// //{
|
||||
// // /* Before change application language, let's check unsaved changes on 3D-Scene
|
||||
// // * and draw user's attention to the application restarting after a language change
|
||||
// // */
|
||||
// // {
|
||||
// // // the dialog needs to be destroyed before the call to switch_language()
|
||||
// // // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // // so we put it into an inner scope
|
||||
// // wxString title = _L("Language selection");
|
||||
// // wxMessageDialog dialog(nullptr,
|
||||
// // _L("Switching the language requires application restart.\n") + "\n\n" +
|
||||
// // _L("Do you want to continue?"),
|
||||
// // title,
|
||||
// // wxICON_QUESTION | wxOK | wxCANCEL);
|
||||
// // if (dialog.ShowModal() == wxID_CANCEL)
|
||||
// // return;
|
||||
// // }
|
||||
//
|
||||
// // wxGetApp().switch_language();
|
||||
// // break;
|
||||
// //}
|
||||
// //case ConfigMenuWizard:
|
||||
// //{
|
||||
// // wxGetApp().run_wizard(ConfigWizard::RR_USER);
|
||||
// // break;
|
||||
// //}
|
||||
// case ConfigMenuPrinter:
|
||||
// {
|
||||
// wxGetApp().params_dialog()->Popup();
|
||||
// wxGetApp().get_tab(Preset::TYPE_PRINTER)->restore_last_select_item();
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuPreferences:
|
||||
// {
|
||||
// CallAfter([this] {
|
||||
// PreferencesDialog dlg(this);
|
||||
// dlg.ShowModal();
|
||||
//#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
//#else
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
//#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// plater()->refresh_print();
|
||||
//#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
//#ifdef _WIN32
|
||||
// /*
|
||||
// if (wxGetApp().app_config()->get("associate_3mf") == "true")
|
||||
// wxGetApp().associate_3mf_files();
|
||||
// if (wxGetApp().app_config()->get("associate_stl") == "true")
|
||||
// wxGetApp().associate_stl_files();
|
||||
// /*if (wxGetApp().app_config()->get("associate_step") == "true")
|
||||
// wxGetApp().associate_step_files();*/
|
||||
//#endif // _WIN32
|
||||
//#endif
|
||||
// });
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
|
||||
#ifdef __APPLE__
|
||||
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
|
||||
//auto about_item = new wxMenuItem(parent_menu, OrcaSlicerMenuAbout + bambu_studio_id_base, about_title, "");
|
||||
//parent_menu->Bind(wxEVT_MENU, [this, bambu_studio_id_base](wxEvent& event) {
|
||||
// switch (event.GetId() - bambu_studio_id_base) {
|
||||
// case OrcaSlicerMenuAbout:
|
||||
// Slic3r::GUI::about();
|
||||
// break;
|
||||
// case OrcaSlicerMenuPreferences:
|
||||
// CallAfter([this] {
|
||||
// PreferencesDialog dlg(this);
|
||||
// dlg.ShowModal();
|
||||
//#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
//#else
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
//#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// plater()->refresh_print();
|
||||
// });
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//});
|
||||
//parent_menu->Insert(0, about_item);
|
||||
append_menu_item(
|
||||
parent_menu, wxID_ANY, _L(about_title), "",
|
||||
[](wxCommandEvent &) { Slic3r::GUI::about();},
|
||||
@@ -4268,15 +4210,23 @@ std::wstring MainFrame::FileHistory::GetThumbnailUrl(int index) const
|
||||
return wss.str();
|
||||
}
|
||||
|
||||
bool MainFrame::FileHistory::GetPublished(int index) const
|
||||
{
|
||||
return index >= 0 && index < static_cast<int>(m_published_files.size()) && m_published_files[index];
|
||||
}
|
||||
|
||||
void MainFrame::FileHistory::AddFileToHistory(const wxString &file)
|
||||
{
|
||||
if (this->m_fileMaxFiles == 0)
|
||||
return;
|
||||
wxFileHistory::AddFileToHistory(file);
|
||||
if (m_load_called)
|
||||
if (m_load_called) {
|
||||
m_thumbnails.push_front(bbs_3mf_get_thumbnail(into_u8(file).c_str()));
|
||||
else
|
||||
m_published_files.push_front(bbs_3mf_is_published(into_u8(file)));
|
||||
} else {
|
||||
m_thumbnails.push_front("");
|
||||
m_published_files.push_front(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainFrame::FileHistory::RemoveFileFromHistory(size_t i)
|
||||
@@ -4285,6 +4235,7 @@ void MainFrame::FileHistory::RemoveFileFromHistory(size_t i)
|
||||
return;
|
||||
wxFileHistory::RemoveFileFromHistory(i);
|
||||
m_thumbnails.erase(m_thumbnails.begin() + i);
|
||||
m_published_files.erase(m_published_files.begin() + i);
|
||||
}
|
||||
|
||||
size_t MainFrame::FileHistory::FindFileInHistory(const wxString & file)
|
||||
@@ -4300,6 +4251,7 @@ void MainFrame::FileHistory::LoadThumbnails()
|
||||
if (!thumbnail.empty()) {
|
||||
m_thumbnails[i] = thumbnail;
|
||||
}
|
||||
m_published_files[i] = bbs_3mf_is_published(into_u8(GetHistoryFile(i)));
|
||||
}
|
||||
});
|
||||
m_load_called = true;
|
||||
@@ -4320,6 +4272,7 @@ void MainFrame::get_recent_projects(boost::property_tree::wptree &tree, int imag
|
||||
std::wstring proj = m_recent_projects.GetHistoryFile(i).ToStdWstring();
|
||||
item.put(L"project_name", proj.substr(proj.find_last_of(L"/\\") + 1));
|
||||
item.put(L"path", proj);
|
||||
item.put(L"published", m_recent_projects.GetPublished(i) ? L"1" : L"0");
|
||||
boost::system::error_code ec;
|
||||
std::time_t t = boost::filesystem::last_write_time(proj, ec);
|
||||
if (!ec) {
|
||||
@@ -4544,10 +4497,9 @@ std::string MainFrame::get_dir_name(const wxString &full_name) const
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
||||
:DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog"),
|
||||
:DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog")
|
||||
//: DPIDialog(mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize,
|
||||
// wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
|
||||
m_main_frame(mainframe)
|
||||
{
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
return;
|
||||
|
||||
@@ -72,6 +72,7 @@ class Plater;
|
||||
class DesignPanel;
|
||||
#endif
|
||||
class MainFrame;
|
||||
class WebViewPanel;
|
||||
class ParamsDialog;
|
||||
#ifdef __WXGTK__
|
||||
class ResizeEdgePanel;
|
||||
@@ -100,7 +101,6 @@ class SettingsDialog : public DPIDialog//DPIDialog
|
||||
{
|
||||
//wxNotebook* m_tabpanel { nullptr };
|
||||
Notebook* m_tabpanel{ nullptr };
|
||||
MainFrame* m_main_frame { nullptr };
|
||||
wxMenuBar* m_menubar{ nullptr };
|
||||
public:
|
||||
SettingsDialog(MainFrame* mainframe);
|
||||
@@ -185,6 +185,7 @@ class MainFrame : public DPIFrame
|
||||
{
|
||||
FileHistory(int max) : wxFileHistory(max) {}
|
||||
std::wstring GetThumbnailUrl(int index) const;
|
||||
bool GetPublished(int index) const;
|
||||
|
||||
virtual void AddFileToHistory(const wxString &file);
|
||||
virtual void RemoveFileFromHistory(size_t i);
|
||||
@@ -195,6 +196,7 @@ class MainFrame : public DPIFrame
|
||||
void SetMaxFiles(int max);
|
||||
private:
|
||||
std::deque<std::string> m_thumbnails;
|
||||
std::deque<bool> m_published_files; // parallel to m_thumbnails: is it a published 3mf?
|
||||
bool m_load_called = false;
|
||||
};
|
||||
|
||||
@@ -348,6 +350,8 @@ public:
|
||||
bool can_upload() const;
|
||||
void save_project();
|
||||
bool save_project_as(const wxString& filename = wxString());
|
||||
// Open the Publish dialog and export the selected settings as a published 3MF.
|
||||
void publish_project();
|
||||
|
||||
void add_to_recent_projects(const wxString& filename);
|
||||
void get_recent_projects(boost::property_tree::wptree &tree, int images);
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include "ImageGrid.h"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/SwitchButton.hpp"
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "DeviceCore/DevConfigUtil.h"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
@@ -13,6 +18,7 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/nowide/cstdio.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/nowide/utf8_codecvt.hpp>
|
||||
#undef pid_t
|
||||
#include <boost/process.hpp>
|
||||
@@ -71,7 +77,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl3 *media_ctrl, const w
|
||||
auto ip = str.find(' ', ik);
|
||||
if (ip == wxString::npos) ip = str.Length();
|
||||
auto v = str.Mid(ik, ip - ik);
|
||||
if (k == "T:" && v.Length() == 8) {
|
||||
if (strcmp(k, "T:") == 0 && v.Length() == 8) {
|
||||
long h = 0,m = 0,s = 0;
|
||||
v.Left(2).ToLong(&h);
|
||||
v.Mid(3, 2).ToLong(&m);
|
||||
|
||||
@@ -297,7 +297,7 @@ void MeshClipper::recalculate_triangles()
|
||||
// it so it lies on our line. This will be the figure to subtract
|
||||
// from the cut. The coordinates must not overflow after the transform,
|
||||
// make the rectangle a bit smaller.
|
||||
const coord_t size = (std::numeric_limits<coord_t>::max()/2 - scale_(std::max(std::abs(e * a), std::abs(e * b)))) / 4;
|
||||
const coord_t size = (double(std::numeric_limits<coord_t>::max()/2) - scale_(std::max(std::abs(e * a), std::abs(e * b)))) / 4;
|
||||
Polygons ep {Polygon({Point(-size, 0), Point(size, 0), Point(size, 2*size), Point(-size, 2*size)})};
|
||||
ep.front().rotate(angle);
|
||||
ep.front().translate(scale_(-e * a), scale_(-e * b));
|
||||
@@ -352,7 +352,7 @@ void MeshClipper::recalculate_triangles()
|
||||
|
||||
// To prevent overflow after scaling, downscale the input if needed:
|
||||
double extra_scale = 1.;
|
||||
coord_t limit = coord_t(std::min(std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_x)), std::numeric_limits<coord_t>::max() / (2. * std::max(1., scale_y))));
|
||||
coord_t limit = coord_t(std::min(double(std::numeric_limits<coord_t>::max()) / (2. * std::max(1., scale_x)), double(std::numeric_limits<coord_t>::max()) / (2. * std::max(1., scale_y))));
|
||||
coord_t max_coord = 0;
|
||||
for (const Point& pt : exp.contour)
|
||||
max_coord = std::max(max_coord, std::max(std::abs(pt.x()), std::abs(pt.y())));
|
||||
|
||||
@@ -126,7 +126,6 @@ MixedFilamentDialog::MixedFilamentDialog(wxWindow* parent,
|
||||
const std::vector<std::string>& physical_types)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Add Mixed Filament"), wxDefaultPosition,
|
||||
wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
, m_edit_mode(false)
|
||||
, m_physical_colors(physical_colors)
|
||||
, m_physical_names(physical_names)
|
||||
, m_physical_types(physical_types)
|
||||
@@ -157,7 +156,6 @@ MixedFilamentDialog::MixedFilamentDialog(wxWindow* parent,
|
||||
: DPIDialog(parent, wxID_ANY, _L("Edit Mixed Filament"), wxDefaultPosition,
|
||||
wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
, m_result(existing)
|
||||
, m_edit_mode(true)
|
||||
, m_physical_colors(physical_colors)
|
||||
, m_physical_names(physical_names)
|
||||
, m_physical_types(physical_types)
|
||||
@@ -847,23 +845,8 @@ wxBoxSizer* MixedFilamentDialog::create_ratio_slider()
|
||||
m_ratio_bar->Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
|
||||
wxBufferedPaintDC dc(m_ratio_bar);
|
||||
wxSize sz = m_ratio_bar->GetClientSize();
|
||||
|
||||
wxColour col_a = comp_colour(0), col_b = comp_colour(1);
|
||||
|
||||
for (int x = 0; x < sz.GetWidth(); ++x) {
|
||||
double t = (double)x / sz.GetWidth();
|
||||
wxColour c = blend_colors(col_a, col_b, 1.0 - t);
|
||||
dc.SetPen(wxPen(c));
|
||||
dc.DrawLine(x, 0, x, sz.GetHeight());
|
||||
}
|
||||
|
||||
int div_x = (int)(ratio(1) / 100.0 * sz.GetWidth());
|
||||
// Fixed in both themes, like the triangle picker's drag handle: the divider is drawn over
|
||||
// blended filament colour, so it has to keep its contrast against data rather than chrome.
|
||||
dc.SetPen(wxPen(wxColour(80, 80, 80), FromDIP(4)));
|
||||
dc.DrawLine(div_x, 0, div_x, sz.GetHeight());
|
||||
dc.SetPen(wxPen(*wxWHITE, FromDIP(2)));
|
||||
dc.DrawLine(div_x, 0, div_x, sz.GetHeight());
|
||||
draw_mixed_ratio_blend_bar(dc, wxRect(0, 0, sz.GetWidth(), sz.GetHeight()),
|
||||
comp_colour(0), comp_colour(1), ratio(1) / 100.0);
|
||||
});
|
||||
|
||||
m_ratio_bar->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
@@ -919,52 +902,8 @@ wxBoxSizer* MixedFilamentDialog::create_ratio_slider()
|
||||
}
|
||||
|
||||
// ---- Triangle (ternary) ratio picker ----
|
||||
|
||||
// Barycentric coordinate utilities
|
||||
struct TriPoint { double x, y; };
|
||||
|
||||
static double tri_signed_area2(TriPoint a, TriPoint b, TriPoint c)
|
||||
{
|
||||
return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
|
||||
}
|
||||
|
||||
static bool tri_contains(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2)
|
||||
{
|
||||
double total = tri_signed_area2(v0, v1, v2);
|
||||
if (std::abs(total) < 1e-9) return false;
|
||||
double s0 = tri_signed_area2(p, v1, v2) / total;
|
||||
double s1 = tri_signed_area2(v0, p, v2) / total;
|
||||
double s2 = 1.0 - s0 - s1;
|
||||
return s0 >= -0.001 && s1 >= -0.001 && s2 >= -0.001;
|
||||
}
|
||||
|
||||
static void tri_barycentric(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2,
|
||||
double& w0, double& w1, double& w2)
|
||||
{
|
||||
double total = std::abs(tri_signed_area2(v0, v1, v2));
|
||||
if (total < 1e-9) { w0 = w1 = w2 = 1.0 / 3.0; return; }
|
||||
w0 = std::abs(tri_signed_area2(p, v1, v2)) / total;
|
||||
w1 = std::abs(tri_signed_area2(v0, p, v2)) / total;
|
||||
w2 = 1.0 - w0 - w1;
|
||||
w0 = std::clamp(w0, 0.0, 1.0);
|
||||
w1 = std::clamp(w1, 0.0, 1.0);
|
||||
w2 = std::clamp(w2, 0.0, 1.0);
|
||||
double s = w0 + w1 + w2;
|
||||
if (s > 0) { w0 /= s; w1 /= s; w2 /= s; }
|
||||
}
|
||||
|
||||
static TriPoint tri_clamp(TriPoint p, TriPoint v0, TriPoint v1, TriPoint v2)
|
||||
{
|
||||
double w0, w1, w2;
|
||||
tri_barycentric(p, v0, v1, v2, w0, w1, w2);
|
||||
w0 = std::clamp(w0, 0.0, 1.0);
|
||||
w1 = std::clamp(w1, 0.0, 1.0);
|
||||
w2 = std::clamp(w2, 0.0, 1.0);
|
||||
double s = w0 + w1 + w2;
|
||||
if (s > 0) { w0 /= s; w1 /= s; w2 /= s; }
|
||||
return {w0 * v0.x + w1 * v1.x + w2 * v2.x,
|
||||
w0 * v0.y + w1 * v1.y + w2 * v2.y};
|
||||
}
|
||||
// The barycentric utilities (TriPoint, tri_contains, tri_barycentric, tri_clamp) live in
|
||||
// FilamentBitmapUtils so the Publish dialog can mirror this picker read-only.
|
||||
|
||||
wxBoxSizer* MixedFilamentDialog::create_triangle_picker()
|
||||
{
|
||||
@@ -998,72 +937,15 @@ wxBoxSizer* MixedFilamentDialog::create_triangle_picker()
|
||||
wxSize sz = m_triangle_panel->GetClientSize();
|
||||
auto [v0, v1, v2] = get_vertices();
|
||||
|
||||
wxColour tri_bg = StateColor::darkModeColorFor(*wxWHITE);
|
||||
dc.SetBrush(wxBrush(tri_bg));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
|
||||
|
||||
wxColour c0 = comp_colour(0), c1 = comp_colour(1), c2 = comp_colour(2);
|
||||
|
||||
const bool cache_valid = m_tri_cache_bmp.IsOk() &&
|
||||
m_tri_cache_size == sz &&
|
||||
m_tri_cache_c0 == c0 && m_tri_cache_c1 == c1 && m_tri_cache_c2 == c2;
|
||||
|
||||
if (!cache_valid) {
|
||||
int min_y = (int)std::min({v0.y, v1.y, v2.y});
|
||||
int max_y = (int)std::max({v0.y, v1.y, v2.y});
|
||||
int min_x = (int)std::min({v0.x, v1.x, v2.x});
|
||||
int max_x = (int)std::max({v0.x, v1.x, v2.x});
|
||||
|
||||
m_tri_cache_bmp = wxBitmap(sz.GetWidth(), sz.GetHeight(), 24);
|
||||
wxMemoryDC mdc(m_tri_cache_bmp);
|
||||
mdc.SetBrush(wxBrush(tri_bg));
|
||||
mdc.SetPen(*wxTRANSPARENT_PEN);
|
||||
mdc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
|
||||
|
||||
for (int py = min_y; py <= max_y; ++py) {
|
||||
for (int px = min_x; px <= max_x; ++px) {
|
||||
TriPoint p = {(double)px, (double)py};
|
||||
if (!tri_contains(p, v0, v1, v2)) continue;
|
||||
double w0, w1, w2;
|
||||
tri_barycentric(p, v0, v1, v2, w0, w1, w2);
|
||||
unsigned char mr, mg, mb;
|
||||
if (w0 + w1 > 1e-6) {
|
||||
float t01 = static_cast<float>(w1 / (w0 + w1));
|
||||
Slic3r::filament_mixer_lerp(c0.Red(), c0.Green(), c0.Blue(),
|
||||
c1.Red(), c1.Green(), c1.Blue(),
|
||||
t01, &mr, &mg, &mb);
|
||||
float t2 = static_cast<float>(w2);
|
||||
Slic3r::filament_mixer_lerp(mr, mg, mb,
|
||||
c2.Red(), c2.Green(), c2.Blue(),
|
||||
t2, &mr, &mg, &mb);
|
||||
} else {
|
||||
mr = c2.Red(); mg = c2.Green(); mb = c2.Blue();
|
||||
}
|
||||
mdc.SetPen(wxPen(wxColour(mr, mg, mb)));
|
||||
mdc.DrawPoint(px, py);
|
||||
}
|
||||
}
|
||||
|
||||
mdc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#CECECE")), 1));
|
||||
mdc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
wxPoint pts[3] = {{(int)v0.x, (int)v0.y}, {(int)v1.x, (int)v1.y}, {(int)v2.x, (int)v2.y}};
|
||||
mdc.DrawPolygon(3, pts);
|
||||
|
||||
mdc.SelectObject(wxNullBitmap);
|
||||
m_tri_cache_c0 = c0; m_tri_cache_c1 = c1; m_tri_cache_c2 = c2;
|
||||
m_tri_cache_size = sz;
|
||||
}
|
||||
|
||||
dc.DrawBitmap(m_tri_cache_bmp, 0, 0);
|
||||
|
||||
// Drag handle (always redrawn on top of cached bitmap)
|
||||
double hx = m_tri_wx * v0.x + m_tri_wy * v1.x + m_tri_wz * v2.x;
|
||||
double hy = m_tri_wx * v0.y + m_tri_wy * v1.y + m_tri_wz * v2.y;
|
||||
int handle_r = FromDIP(5);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.SetPen(wxPen(wxColour("#262E30"), FromDIP(2)));
|
||||
dc.DrawCircle((int)hx, (int)hy, handle_r);
|
||||
// Draw the background, cached barycentric fill, outline and drag-handle marker through the
|
||||
// shared picker painter (same geometry the read-only Publish preview uses).
|
||||
draw_mixed_triangle_picker(dc, sz,
|
||||
{comp_colour(0), comp_colour(1), comp_colour(2)},
|
||||
{m_tri_wx, m_tri_wy, m_tri_wz},
|
||||
{StateColor::darkModeColorFor(*wxWHITE),
|
||||
StateColor::darkModeColorFor(wxColour("#CECECE")),
|
||||
StateColor::darkModeColorFor(wxColour("#262E30")),
|
||||
StateColor::darkModeColorFor(COLOR_LABEL_MUTED)});
|
||||
|
||||
if (m_result.ratios.size() >= 3) {
|
||||
dc.SetFont(::Label::Body_10);
|
||||
|
||||
@@ -115,7 +115,6 @@ private:
|
||||
wxColour comp_colour(size_t i) const;
|
||||
|
||||
MixedFilamentResult m_result;
|
||||
bool m_edit_mode{false};
|
||||
std::vector<std::string> m_physical_colors;
|
||||
std::vector<std::string> m_physical_names;
|
||||
std::vector<std::string> m_physical_types;
|
||||
@@ -170,10 +169,6 @@ private:
|
||||
// Triangle picker drag point (barycentric weights)
|
||||
double m_tri_wx{0.333}, m_tri_wy{0.333}, m_tri_wz{0.334};
|
||||
|
||||
// Cached triangle color bitmap (invalidated when colors or size change)
|
||||
wxBitmap m_tri_cache_bmp;
|
||||
wxColour m_tri_cache_c0, m_tri_cache_c1, m_tri_cache_c2;
|
||||
wxSize m_tri_cache_size;
|
||||
std::array<RatioLabelPanel*, 3> m_triangle_ratio_labels{nullptr, nullptr, nullptr};
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ private:
|
||||
Tabbook* m_tabpanel{ nullptr };
|
||||
wxSizer* m_main_sizer{ nullptr };
|
||||
|
||||
AddMachinePanel* m_status_add_machine_panel;
|
||||
StatusPanel* m_status_info_panel;
|
||||
MediaFilePanel* m_media_file_panel;
|
||||
UpgradePanel* m_upgrade_panel;
|
||||
@@ -86,8 +85,6 @@ private:
|
||||
|
||||
/* side tools */
|
||||
SideTools* m_side_tools{nullptr};
|
||||
wxStaticBitmap* m_bitmap_arrow;
|
||||
wxStaticBitmap* m_bitmap_wifi_signal;
|
||||
SelectMachinePopup m_select_machine;
|
||||
|
||||
/* images */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "Mouse3DController.hpp"
|
||||
#include "GUI.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
@@ -498,7 +499,7 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
|
||||
static ImVec2 last_win_size(0.0f, 0.0f);
|
||||
bool shown = true;
|
||||
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) {
|
||||
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) {
|
||||
if (shown) {
|
||||
ImVec2 win_size = ImGui::GetWindowSize();
|
||||
if (last_win_size.x != win_size.x || last_win_size.y != win_size.y) {
|
||||
|
||||
@@ -177,7 +177,6 @@ public:
|
||||
// Generic rich message dialog, used intead of wxRichMessageDialog
|
||||
class RichMessageDialog : public MsgDialog
|
||||
{
|
||||
wxCheckBox* m_checkBox{ nullptr };
|
||||
wxString m_checkBoxText;
|
||||
bool m_checkBoxValue{ false };
|
||||
|
||||
@@ -416,7 +415,6 @@ private:
|
||||
wxString m_new_keys;
|
||||
Button * m_update_btn = nullptr;
|
||||
Button * m_later_btn = nullptr;
|
||||
wxStaticText *m_msg_text = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ private:
|
||||
wxBoxSizer* m_main_sizer{nullptr};
|
||||
wxBoxSizer* m_sizer_machine_list{nullptr};
|
||||
wxScrolledWindow* m_machine_list{ nullptr };
|
||||
wxStaticText* m_selected_num{ nullptr };
|
||||
|
||||
// table head
|
||||
wxPanel* m_table_head_panel{ nullptr };
|
||||
@@ -99,8 +98,6 @@ private:
|
||||
int m_total_count{ 0 };
|
||||
int m_count_page_item{ 10 };
|
||||
|
||||
bool prev{ false };
|
||||
bool next{ false };
|
||||
Button* btn_last_page{ nullptr };
|
||||
Button* btn_next_page{ nullptr };
|
||||
wxStaticText* st_page_number{ nullptr };
|
||||
|
||||
@@ -81,7 +81,6 @@ private:
|
||||
AppConfig* app_config;
|
||||
Label* m_label{ nullptr };
|
||||
wxScrolledWindow* scroll_macine_list{ nullptr };
|
||||
wxBoxSizer* m_sizer_body{ nullptr };
|
||||
wxBoxSizer* sizer_machine_list{ nullptr };
|
||||
std::map<std::string, DevicePickItem*> m_device_items;
|
||||
int m_selected_count{0};
|
||||
|
||||
@@ -99,7 +99,6 @@ private:
|
||||
wxBoxSizer* page_sizer{ nullptr };
|
||||
wxBoxSizer* m_sizer_task_list{ nullptr };
|
||||
wxScrolledWindow* m_task_list{ nullptr };
|
||||
wxStaticText* m_selected_num{ nullptr };
|
||||
|
||||
// table head
|
||||
wxPanel* m_table_head_panel{ nullptr };
|
||||
@@ -113,7 +112,6 @@ private:
|
||||
Button* m_action{ nullptr };
|
||||
|
||||
// ctrl button for all
|
||||
int m_sel_number{0};
|
||||
wxPanel* m_ctrl_btn_panel{ nullptr };
|
||||
wxBoxSizer* m_btn_sizer{ nullptr };
|
||||
Button* btn_stop_all{ nullptr };
|
||||
@@ -160,15 +158,12 @@ private:
|
||||
wxBoxSizer* m_sizer_task_list{ nullptr };
|
||||
wxBoxSizer* m_main_sizer{ nullptr };
|
||||
wxScrolledWindow* m_task_list{ nullptr };
|
||||
wxStaticText* m_selected_num{ nullptr };
|
||||
|
||||
// Flipping pages
|
||||
int m_current_page{ 0 };
|
||||
int m_total_page{0};
|
||||
int m_total_count{ 0 };
|
||||
int m_count_page_item{ 10 };
|
||||
bool prev{ false };
|
||||
bool next{ false };
|
||||
Button* btn_last_page{ nullptr };
|
||||
Button* btn_next_page{ nullptr };
|
||||
wxStaticText* st_page_number{ nullptr };
|
||||
@@ -191,7 +186,6 @@ private:
|
||||
Button* m_action{ nullptr };
|
||||
|
||||
// ctrl button for all
|
||||
int m_sel_number;
|
||||
wxPanel* m_ctrl_btn_panel{ nullptr };
|
||||
wxBoxSizer* m_btn_sizer{ nullptr };
|
||||
Button* btn_pause_all{ nullptr };
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user