Skip to content

Commit

Permalink
DiffPresetDialog : improvements
Browse files Browse the repository at this point in the history
* This dialog is non-modal now
* "Compare presets" menu item is moved from "View" to the "Window" menu group
* Added info tooltips for the bitmap buttons between presets
* Added "Show all presets" checkbox
* Show full difference between printer presets with different count of extruders
  • Loading branch information
YuSanka committed Jan 19, 2021
1 parent 3d38b62 commit 01171c8
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 61 deletions.
12 changes: 4 additions & 8 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,14 +1152,6 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F",
_L("Search in settings"), [this](wxCommandEvent&) { m_plater->search(/*m_tabpanel->GetCurrentPage() == */m_plater->IsShown()); },
"search", nullptr, []() {return true; }, this);

editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _L("Compare presets")/* + "\tCtrl+F"*/,
_L("Compare presets"), [this](wxCommandEvent&) {
DiffPresetDialog dlg;
dlg.ShowModal();
},
"compare", nullptr, []() {return true; }, this);
}

// Window menu
Expand Down Expand Up @@ -1199,6 +1191,10 @@ void MainFrame::init_menubar_as_editor()
windowMenu->AppendSeparator();
append_menu_item(windowMenu, wxID_ANY, _L("Open new instance") + "\tCtrl+Shift+I", _L("Open a new PrusaSlicer instance"),
[this](wxCommandEvent&) { start_new_slicer(); }, "", nullptr, [this]() {return m_plater != nullptr && wxGetApp().app_config->get("single_instance") != "1"; }, this);

windowMenu->AppendSeparator();
append_menu_item(windowMenu, wxID_ANY, _L("Compare presets")/* + "\tCtrl+F"*/, _L("Compare presets"),
[this](wxCommandEvent&) { diff_dialog.show();}, "compare", nullptr, []() {return true; }, this);
}

// View menu
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/MainFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "GUI_Utils.hpp"
#include "Event.hpp"
#include "UnsavedChangesDialog.hpp"

class wxNotebook;
class wxProgressDialog;
Expand Down Expand Up @@ -190,6 +191,7 @@ class MainFrame : public DPIFrame
Plater* m_plater { nullptr };
wxNotebook* m_tabpanel { nullptr };
SettingsDialog m_settings_dialog;
DiffPresetDialog diff_dialog;
wxWindow* m_plater_page{ nullptr };
wxProgressDialog* m_progress_dialog { nullptr };
PrintHostQueueDialog* m_printhost_queue_dlg;
Expand Down
8 changes: 7 additions & 1 deletion src/slic3r/GUI/PresetComboBoxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void PresetComboBox::update(std::string select_preset_name)
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
const Preset& preset = presets[i];
if (!preset.is_visible || !preset.is_compatible)
if (!m_show_all && (!preset.is_visible || !preset.is_compatible))
continue;

// marker used for disable incompatible printer models for the selected physical printer
Expand Down Expand Up @@ -344,6 +344,12 @@ bool PresetComboBox::del_physical_printer(const wxString& note_string/* = wxEmpt
return true;
}

void PresetComboBox::show_all(bool show_all)
{
m_show_all = show_all;
update();
}

void PresetComboBox::update()
{
this->update(into_u8(this->GetString(this->GetSelection())));
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/PresetComboBoxes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BitmapCache;
// BitmapComboBox used to presets list on Sidebar and Tabs
class PresetComboBox : public wxBitmapComboBox
{
bool m_show_all { false };
public:
PresetComboBox(wxWindow* parent, Preset::Type preset_type, const wxSize& size = wxDefaultSize);
~PresetComboBox();
Expand Down Expand Up @@ -65,6 +66,7 @@ class PresetComboBox : public wxBitmapComboBox

virtual wxString get_preset_name(const Preset& preset);
Preset::Type get_type() { return m_type; }
void show_all(bool show_all);
virtual void update();
virtual void msw_rescale();

Expand Down
46 changes: 34 additions & 12 deletions src/slic3r/GUI/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,8 @@ const Option& OptionsSearcher::get_option(const std::string& opt_key) const
return options[it - options.begin()];
}

Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& label, Preset::Type type) const
static Option create_option(const std::string& opt_key, const wxString& label, Preset::Type type, const GroupAndCategory& gc)
{
auto it = std::lower_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) }));
if(it->opt_key == boost::nowide::widen(opt_key) ||
groups_and_categories.find(opt_key) == groups_and_categories.end())
return options[it - options.begin()];

const GroupAndCategory& gc = groups_and_categories.at(opt_key);
if (gc.group.IsEmpty() || gc.category.IsEmpty())
return options[it - options.begin()];

wxString suffix;
wxString suffix_local;
if (gc.category == "Machine limits") {
Expand All @@ -348,10 +339,41 @@ Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& l
suffix = " " + suffix;
}

return Option{boost::nowide::widen(opt_key), type,
wxString category = gc.category;
if (type == Preset::TYPE_PRINTER && category.Contains("Extruder ")) {
std::string opt_idx = opt_key.substr(opt_key.find("#") + 1);
category = wxString::Format("%s %d", "Extruder", atoi(opt_idx.c_str()) + 1);
}

return Option{ boost::nowide::widen(opt_key), type,
(label + suffix).ToStdWstring(), (_(label) + suffix_local).ToStdWstring(),
gc.group.ToStdWstring(), _(gc.group).ToStdWstring(),
gc.category.ToStdWstring(), GUI::Tab::translate_category(gc.category, type).ToStdWstring() };
gc.category.ToStdWstring(), GUI::Tab::translate_category(category, type).ToStdWstring() };
}

Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& label, Preset::Type type) const
{
auto it = std::lower_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) }));
if(it->opt_key == boost::nowide::widen(opt_key))
return options[it - options.begin()];
if (groups_and_categories.find(opt_key) == groups_and_categories.end()) {
size_t pos = opt_key.find('#');
if (pos == std::string::npos)
return options[it - options.begin()];

std::string zero_opt_key = opt_key.substr(0, pos + 1) + "0";

if(groups_and_categories.find(zero_opt_key) == groups_and_categories.end())
return options[it - options.begin()];

return create_option(opt_key, label, type, groups_and_categories.at(zero_opt_key));
}

const GroupAndCategory& gc = groups_and_categories.at(opt_key);
if (gc.group.IsEmpty() || gc.category.IsEmpty())
return options[it - options.begin()];

return create_option(opt_key, label, type, gc);
}

void OptionsSearcher::add_key(const std::string& opt_key, const wxString& group, const wxString& category)
Expand Down
3 changes: 1 addition & 2 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3379,8 +3379,7 @@ void Tab::OnKeyDown(wxKeyEvent& event)

void Tab::compare_preset()
{
DiffPresetDialog dlg(m_type);
dlg.ShowModal();
wxGetApp().mainframe->diff_dialog.show(m_type);
}

// Save the current preset into file.
Expand Down
Loading

0 comments on commit 01171c8

Please sign in to comment.