Skip to content

Commit

Permalink
3D mouse axes, save icon for presets, some updates to mac build.
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Nov 17, 2023
2 parents bfb7317 + c31806e commit cb19d69
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 26 deletions.
40 changes: 29 additions & 11 deletions deps/TIFF/TIFF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@ find_package(OpenGL QUIET REQUIRED)

if (APPLE)
message(STATUS "Compiling TIFF for macos ${CMAKE_SYSTEM_VERSION}.")
prusaslicer_add_cmake_project(TIFF
URL https://gitlab.com/libtiff/libtiff/-/archive/v4.3.0/libtiff-v4.3.0.zip
URL_HASH SHA256=4fca1b582c88319f3ad6ecd5b46320eadaf5eb4ef6f6c32d44caaae4a03d0726
DEPENDS ${ZLIB_PKG} ${PNG_PKG} dep_JPEG
CMAKE_ARGS
-Dlzma:BOOL=OFF
-Dwebp:BOOL=OFF
-Djbig:BOOL=OFF
-Dzstd:BOOL=OFF
-Dpixarlog:BOOL=OFF
)
if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm")
prusaslicer_add_cmake_project(TIFF
URL https://gitlab.com/libtiff/libtiff/-/archive/v4.3.0/libtiff-v4.3.0.zip
URL_HASH SHA256=a1db6826ea1b8b08eaf168973abb29b8a143fb744c1b24cc6967cb12f5e6e81f
DEPENDS ${ZLIB_PKG} ${PNG_PKG} dep_JPEG
CMAKE_ARGS
-Dlzma:BOOL=OFF
-Dwebp:BOOL=OFF
-Djbig:BOOL=OFF
-Dzstd:BOOL=OFF
-Dpixarlog:BOOL=OFF
)

else()

prusaslicer_add_cmake_project(TIFF
URL https://gitlab.com/libtiff/libtiff/-/archive/v4.3.0/libtiff-v4.3.0.zip
URL_HASH SHA256=4fca1b582c88319f3ad6ecd5b46320eadaf5eb4ef6f6c32d44caaae4a03d0726
DEPENDS ${ZLIB_PKG} ${PNG_PKG} dep_JPEG
CMAKE_ARGS
-Dlzma:BOOL=OFF
-Dwebp:BOOL=OFF
-Djbig:BOOL=OFF
-Dzstd:BOOL=OFF
-Dpixarlog:BOOL=OFF
)

endif()

else()

prusaslicer_add_cmake_project(TIFF
Expand Down
34 changes: 34 additions & 0 deletions resources/icons/save_as.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ void AppConfig::set_recent_projects(const std::vector<std::string>& recent_proje
}

void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone,
float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz)
float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz, bool invert_x, bool invert_y, bool invert_z, bool invert_yaw, bool invert_pitch, bool invert_roll)
{
std::string key = std::string("mouse_device:") + name;
auto it = m_storage.find(key);
Expand All @@ -1098,6 +1098,12 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe
it->second["rotation_deadzone"] = float_to_string_decimal_point(rotation_deadzone);
it->second["zoom_speed"] = float_to_string_decimal_point(zoom_speed);
it->second["swap_yz"] = swap_yz ? "1" : "0";
it->second["invert_x"] = invert_x ? "1" : "0";
it->second["invert_y"] = invert_y ? "1" : "0";
it->second["invert_z"] = invert_z ? "1" : "0";
it->second["invert_yaw"] = invert_yaw ? "1" : "0";
it->second["invert_pitch"] = invert_pitch ? "1" : "0";
it->second["invert_roll"] = invert_roll ? "1" : "0";
}

std::vector<std::string> AppConfig::get_mouse_device_names() const
Expand Down
14 changes: 13 additions & 1 deletion src/libslic3r/AppConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class AppConfig
std::vector<std::string> get_recent_projects() const;
void set_recent_projects(const std::vector<std::string>& recent_projects);

void set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz);
void set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed, bool swap_yz, bool invert_x, bool invert_y, bool invert_z, bool invert_yaw, bool invert_pitch, bool invert_roll);
std::vector<std::string> get_mouse_device_names() const;
bool get_mouse_device_translation_speed(const std::string& name, double& speed) const
{ return get_3dmouse_device_numeric_value(name, "translation_speed", speed); }
Expand All @@ -228,6 +228,18 @@ class AppConfig
{ return get_3dmouse_device_numeric_value(name, "zoom_speed", speed); }
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
bool get_mouse_device_invert_x(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_x", invert); }
bool get_mouse_device_invert_y(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_y", invert); }
bool get_mouse_device_invert_z(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_z", invert); }
bool get_mouse_device_invert_yaw(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_yaw", invert); }
bool get_mouse_device_invert_pitch(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_pitch", invert); }
bool get_mouse_device_invert_roll(const std::string& name, bool& invert) const
{ return get_3dmouse_device_numeric_value(name, "invert_roll", invert); }

static const std::string SECTION_FILAMENTS;
static const std::string SECTION_MATERIALS;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("But on first layer");
def->full_label = L("Don't check crossings for retraction on first layer");
def->category = OptionCategory::extruders;
def->tooltip = L("let the retraction happens on the first alyer even if the travel path does not exceed the upper layer's perimeters.");
def->tooltip = L("let the retraction happens on the first layer even if the travel path does not exceed the upper layer's perimeters.");
def->mode = comExpert | comPrusa;
def->set_default_value(new ConfigOptionBool(true));

Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ void MainFrame::init_menubar_as_editor()
#else
append_menu_item(fileMenu, wxID_ANY, _L("Save Project &as") + dots + "\tCtrl+Alt+S", _L("Save current project file as"),
#endif // __APPLE__
[this](wxCommandEvent&) { save_project_as(); }, "save", nullptr,
[this](wxCommandEvent&) { save_project_as(); }, "save_as", nullptr,
[this](){return m_plater != nullptr && can_save_as(); }, this);

fileMenu->AppendSeparator();
Expand Down
70 changes: 67 additions & 3 deletions src/slic3r/GUI/Mouse3DController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Ca
if (! wxGetApp().IsActive())
return false;

int xmult = params.invert_x ? -1 : 1;
int ymult = params.invert_y ? -1 : 1;
int zmult = params.invert_z ? -1 : 1;
int yawmult = params.invert_yaw ? -1 : 1;
int pitchmult = params.invert_pitch ? -1 : 1;
int rollmult = params.invert_roll ? -1 : 1;

std::deque<QueueItem> input_queue;
{
// Atomically move m_input_queue to input_queue.
Expand All @@ -332,7 +339,7 @@ bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Ca

for (const QueueItem &input_queue_item : input_queue) {
if (input_queue_item.is_translation()) {
Vec3d translation = params.swap_yz ? Vec3d(input_queue_item.vector.x(), - input_queue_item.vector.z(), input_queue_item.vector.y()) : input_queue_item.vector;
Vec3d translation = params.swap_yz ? Vec3d(input_queue_item.vector.x() * xmult, - input_queue_item.vector.z() * zmult, input_queue_item.vector.y() * ymult) : Vec3d(input_queue_item.vector.x() * xmult, input_queue_item.vector.y() * ymult, input_queue_item.vector.z() * zmult);
double zoom_factor = camera.min_zoom() / camera.get_zoom();
camera.set_target(camera.get_target() + zoom_factor * params.translation.scale * (translation.x() * camera.get_dir_right() + translation.z() * camera.get_dir_up()));
if (translation.y() != 0.0)
Expand All @@ -341,6 +348,7 @@ bool Mouse3DController::State::apply(const Mouse3DController::Params &params, Ca
Vec3d rot = params.rotation.scale * input_queue_item.vector * (PI / 180.);
if (params.swap_yz)
rot = Vec3d(rot.x(), -rot.z(), rot.y());
rot = Vec3d(rot.x() * pitchmult, rot.y() * yawmult, rot.z() * rollmult);
camera.rotate_local_around_target(Vec3d(rot.x(), - rot.z(), rot.y()));
} else {
assert(input_queue_item.is_buttons());
Expand Down Expand Up @@ -369,12 +377,24 @@ void Mouse3DController::load_config(const AppConfig &appconfig)
float rotation_deadzone = Params::DefaultRotationDeadzone;
double zoom_speed = 2.0;
bool swap_yz = false;
bool invert_x = false;
bool invert_y = false;
bool invert_z = false;
bool invert_yaw = false;
bool invert_pitch = false;
bool invert_roll = false;
appconfig.get_mouse_device_translation_speed(device_name, translation_speed);
appconfig.get_mouse_device_translation_deadzone(device_name, translation_deadzone);
appconfig.get_mouse_device_rotation_speed(device_name, rotation_speed);
appconfig.get_mouse_device_rotation_deadzone(device_name, rotation_deadzone);
appconfig.get_mouse_device_zoom_speed(device_name, zoom_speed);
appconfig.get_mouse_device_swap_yz(device_name, swap_yz);
appconfig.get_mouse_device_invert_x(device_name, invert_x);
appconfig.get_mouse_device_invert_y(device_name, invert_y);
appconfig.get_mouse_device_invert_z(device_name, invert_z);
appconfig.get_mouse_device_invert_yaw(device_name, invert_yaw);
appconfig.get_mouse_device_invert_pitch(device_name, invert_pitch);
appconfig.get_mouse_device_invert_roll(device_name, invert_roll);
// clamp to valid values
Params params;
params.translation.scale = Params::DefaultTranslationScale * std::clamp(translation_speed, Params::MinTranslationScale, Params::MaxTranslationScale);
Expand All @@ -383,6 +403,12 @@ void Mouse3DController::load_config(const AppConfig &appconfig)
params.rotation.deadzone = std::clamp(rotation_deadzone, 0.0f, Params::MaxRotationDeadzone);
params.zoom.scale = Params::DefaultZoomScale * std::clamp(zoom_speed, 0.1, 10.0);
params.swap_yz = swap_yz;
params.invert_x = invert_x;
params.invert_y = invert_x;
params.invert_z = invert_x;
params.invert_yaw = invert_yaw;
params.invert_pitch = invert_pitch;
params.invert_roll = invert_roll;
m_params_by_device[device_name] = std::move(params);
}
}
Expand All @@ -398,7 +424,8 @@ void Mouse3DController::save_config(AppConfig &appconfig) const
const Params &params = key_value_pair.second;
// Store current device parameters into the config
appconfig.set_mouse_device(device_name, params.translation.scale / Params::DefaultTranslationScale, params.translation.deadzone,
params.rotation.scale / Params::DefaultRotationScale, params.rotation.deadzone, params.zoom.scale / Params::DefaultZoomScale, params.swap_yz);
params.rotation.scale / Params::DefaultRotationScale, params.rotation.deadzone, params.zoom.scale / Params::DefaultZoomScale,
params.swap_yz, params.invert_x, params.invert_y, params.invert_z, params.invert_yaw, params.invert_pitch, params.invert_roll);
}
}

Expand Down Expand Up @@ -511,6 +538,36 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
params_copy.swap_yz = swap_yz;
params_changed = true;
}
bool invert_x = params_copy.invert_x;
if (imgui.checkbox(_L("Invert X axis"), invert_x)) {
params_copy.invert_x = invert_x;
params_changed = true;
}
bool invert_y = params_copy.invert_y;
if (imgui.checkbox(_L("Invert Y axis"), invert_y)) {
params_copy.invert_y = invert_y;
params_changed = true;
}
bool invert_z = params_copy.invert_z;
if (imgui.checkbox(_L("Invert Z axis"), invert_z)) {
params_copy.invert_z = invert_z;
params_changed = true;
}
bool invert_yaw = params_copy.invert_yaw;
if (imgui.checkbox(_L("Invert Yaw axis"), invert_yaw)) {
params_copy.invert_yaw = invert_yaw;
params_changed = true;
}
bool invert_pitch = params_copy.invert_pitch;
if (imgui.checkbox(_L("Invert Pitch axis"), invert_pitch)) {
params_copy.invert_pitch = invert_pitch;
params_changed = true;
}
bool invert_roll = params_copy.invert_roll;
if (imgui.checkbox(_L("Invert Roll axis"), invert_roll)) {
params_copy.invert_roll = invert_roll;
params_changed = true;
}

#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
ImGui::Separator();
Expand Down Expand Up @@ -711,14 +768,21 @@ void Mouse3DController::run()
return;
}
m_connected = true;
m_device_str = "spacenavd";
if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
m_params = m_params_ui = it_params->second;
} else {
m_params = m_params_ui = m_params_by_device[m_device_str] = Params();
}

for (;;) {
{
std::scoped_lock lock(m_params_ui_mutex);
if (m_stop)
break;
if (m_params_ui_changed) {
m_params = m_params_ui;
m_params = m_params_by_device[m_device_str] = m_params_ui;
m_params_ui_changed = false;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/slic3r/GUI/Mouse3DController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class Mouse3DController
size_t input_queue_max_size { 15 };
// Whether to swap Y/Z axes or not.
bool swap_yz{ false };
// Invert varius axes...
bool invert_x{ false };
bool invert_y{ false };
bool invert_z{ false };
bool invert_yaw{ false };
bool invert_pitch{ false };
bool invert_roll{ false };
};

// Queue of the 3DConnexion input events (translations, rotations, button presses).
Expand Down
25 changes: 17 additions & 8 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void Tab::create_preset_tab()

add_scaled_button(panel, &m_btn_compare_preset, "compare");
add_scaled_button(panel, &m_btn_save_preset, "save");
add_scaled_button(panel, &m_btn_save_preset_as, "save_as");
add_scaled_button(panel, &m_btn_delete_preset, "cross");
if (m_type == Preset::Type::TYPE_PRINTER)
add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
Expand All @@ -228,8 +229,10 @@ void Tab::create_preset_tab()
m_btn_compare_preset->SetToolTip(_L("Compare this preset with some another"));
// TRN "Save current Settings"
m_btn_save_preset->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s"))) % m_title).str()));
m_btn_save_preset_as->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s as new preset"))) % m_title).str()));

m_btn_delete_preset->SetToolTip(_(L("Delete this preset")));
m_btn_delete_preset->Hide();
m_btn_delete_preset->Enable(false);

add_scaled_button(panel, &m_question_btn, "question");
m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n"
Expand Down Expand Up @@ -280,6 +283,8 @@ void Tab::create_preset_tab()
m_hsizer->AddSpacer(int(4*scale_factor));
m_hsizer->Add(m_btn_save_preset, 0, wxALIGN_CENTER_VERTICAL);
m_hsizer->AddSpacer(int(4 * scale_factor));
m_hsizer->Add(m_btn_save_preset_as, 0, wxALIGN_CENTER_VERTICAL);
m_hsizer->AddSpacer(int(4 * scale_factor));
m_hsizer->Add(m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL);
if (m_btn_edit_ph_printer) {
m_hsizer->AddSpacer(int(4 * scale_factor));
Expand Down Expand Up @@ -370,7 +375,10 @@ void Tab::create_preset_tab()
m_hsizer->Add(m_page_view, 1, wxEXPAND | wxLEFT, 5);

m_btn_compare_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { compare_preset(); }));
m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
save_preset(this->get_presets()->get_selected_preset_name());
}));
m_btn_save_preset_as->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { delete_preset(); }));
m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
toggle_show_hide_incompatible();
Expand Down Expand Up @@ -957,6 +965,7 @@ void Tab::update_changed_tree_ui()
cur_item = next_item;
}
update_undo_buttons();
update_btns_enabling();
}

void Tab::update_undo_buttons()
Expand Down Expand Up @@ -3743,10 +3752,11 @@ void Tab::rebuild_page_tree()

void Tab::update_btns_enabling()
{
// we can delete any preset from the physical printer
// and any user preset
const Preset& preset = m_presets->get_edited_preset();
m_btn_delete_preset->Show((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
const Preset &preset = m_presets->get_edited_preset();
// we can save any preset taht is not default/system and is modified.
m_btn_save_preset->Enable(!preset.is_default && !preset.is_system && preset.is_dirty && !preset.name.empty());
// we can delete any preset from the physical printer and any user preset
m_btn_delete_preset->Enable((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
|| (!preset.is_default && !preset.is_system));

if (m_btn_edit_ph_printer)
Expand Down Expand Up @@ -4156,8 +4166,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
// Update the selection boxes at the plater.
on_presets_changed();
// If current profile is saved, "delete preset" button have to be enabled
m_btn_delete_preset->Show();
m_btn_delete_preset->GetParent()->Layout();
update_btns_enabling();

if (m_type == Preset::TYPE_PRINTER)
static_cast<TabPrinter*>(this)->m_initial_extruders_count = static_cast<TabPrinter*>(this)->m_extruders_count;
Expand Down
Loading

0 comments on commit cb19d69

Please sign in to comment.