Fixed updates of the "Slice now" and "Export G-code buttons"

based on the object inside / outside the work space condition.

Removed TabIface.cpp/hpp Perl bindings.

Fixed reset of the status bar / cancel button after the last object
is removed from the plater.
This commit is contained in:
bubnikv 2018-12-04 11:14:39 +01:00
parent 86e6f8bf33
commit 160aa6c78c
6 changed files with 33 additions and 99 deletions

View File

@ -64,8 +64,6 @@ add_library(libslic3r_gui STATIC
GUI/LambdaObjectDialog.hpp
GUI/Tab.cpp
GUI/Tab.hpp
GUI/TabIface.cpp
GUI/TabIface.hpp
GUI/Field.cpp
GUI/Field.hpp
GUI/OptionsGroup.cpp

View File

@ -43,6 +43,13 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
SetIcon(wxIcon(Slic3r::var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
#endif // _WIN32
// initialize status bar
m_statusbar = new ProgressStatusBar(this);
m_statusbar->embed(this);
m_statusbar->set_status_text(_(L("Version ")) +
SLIC3R_VERSION +
_(L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases")));
// initialize tabpanel and menubar
init_tabpanel();
init_menubar();
@ -52,13 +59,6 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
// (SetAutoPop is not available on GTK.)
wxToolTip::SetAutoPop(32767);
// initialize status bar
m_statusbar = new ProgressStatusBar(this);
m_statusbar->embed(this);
m_statusbar->set_status_text(_(L("Version ")) +
SLIC3R_VERSION +
_(L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases")));
m_loaded = true;
// initialize layout
@ -767,13 +767,12 @@ void MainFrame::on_value_changed(wxCommandEvent& event)
void MainFrame::update_ui_from_settings()
{
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
// if (m_plater) m_plater->update_ui_from_settings();
if (m_plater)
m_plater->update_ui_from_settings();
for (auto tab: wxGetApp().tabs_list)
tab->update_ui_from_settings();
}
std::string MainFrame::get_base_name(const wxString full_name) const
{
return boost::filesystem::path(full_name).filename().string();

View File

@ -1005,8 +1005,6 @@ struct Plater::priv
void on_process_completed(wxCommandEvent&);
void on_layer_editing_toggled(bool enable);
void on_schedule_background_process(SimpleEvent&);
void on_action_add(SimpleEvent&);
void on_action_split_objects(SimpleEvent&);
void on_action_split_volumes(SimpleEvent&);
@ -1015,9 +1013,7 @@ struct Plater::priv
void on_object_select(SimpleEvent&);
void on_viewport_changed(SimpleEvent&);
void on_right_click(Vec2dEvent&);
void on_model_update(SimpleEvent&);
void on_wipetower_moved(Vec3dEvent&);
void on_enable_action_buttons(Event<bool>&);
void on_update_geometry(Vec3dsEvent<2>&);
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
@ -1137,20 +1133,20 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
sidebar->Bind(wxEVT_COMBOBOX, &priv::on_select_preset, this);
sidebar->Bind(EVT_OBJ_LIST_OBJECT_SELECT, [this](wxEvent&) { priv::selection_changed(); });
sidebar->Bind(EVT_SCHEDULE_BACKGROUND_PROCESS, &priv::on_schedule_background_process, this);
sidebar->Bind(EVT_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); });
// 3DScene events:
canvas3Dwidget->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, &priv::on_schedule_background_process, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_VIEWPORT_CHANGED, &priv::on_viewport_changed, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_MODEL_UPDATE, &priv::on_model_update, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_MODEL_UPDATE, [this](SimpleEvent&) { this->schedule_background_process(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent&) { arrange(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_INCREASE_INSTANCES, [q](Event<int> &evt) { evt.data == 1 ? q->increase_instances() : q->decrease_instances(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_INSTANCE_MOVED, [this](SimpleEvent&) { update(); });
canvas3Dwidget->Bind(EVT_GLCANVAS_WIPETOWER_MOVED, &priv::on_wipetower_moved, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, &priv::on_enable_action_buttons, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, [this](Event<bool> &evt) { this->sidebar->enable_buttons(evt.data); });
canvas3Dwidget->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
canvas3Dwidget->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
// 3DScene/Toolbar:
@ -1213,6 +1209,8 @@ void Plater::priv::select_view(const std::string& direction)
}
}
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void Plater::priv::update_ui_from_settings()
{
// TODO: (?)
@ -1843,7 +1841,15 @@ unsigned int Plater::priv::update_background_process()
}
}
if (! this->background_process.empty()) {
if (this->background_process.empty()) {
if (invalidated != Print::APPLY_STATUS_UNCHANGED) {
// The background processing will not be restarted, because the Print / SLAPrint is empty.
// Simulate a "canceled" callback message.
wxCommandEvent evt;
evt.SetInt(-1); // canceled
this->on_process_completed(evt);
}
} else {
std::string err = this->background_process.validate();
if (err.empty()) {
if (invalidated != Print::APPLY_STATUS_UNCHANGED)
@ -2057,8 +2063,10 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
this->sidebar->show_sliced_info_sizer(success);
// this updates buttons status
//$self->object_list_changed;
// This updates the "Slice now", "Export G-code", "Arrange" buttons status.
// Namely, it refreshes the "Out of print bed" property of all the ModelObjects, and it enables
// the "Slice now" and "Export G-code" buttons based on their "out of bed" status.
this->object_list_changed();
// refresh preview
switch (this->printer_technology) {
@ -2086,11 +2094,6 @@ void Plater::priv::on_layer_editing_toggled(bool enable)
canvas3Dwidget->Update();
}
void Plater::priv::on_schedule_background_process(SimpleEvent&)
{
schedule_background_process();
}
void Plater::priv::on_action_add(SimpleEvent&)
{
if (q != nullptr)
@ -2140,11 +2143,6 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
q->PopupMenu(&object_menu, (int)evt.data.x(), (int)evt.data.y());
}
void Plater::priv::on_model_update(SimpleEvent&)
{
// TODO
}
void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
{
DynamicPrintConfig cfg;
@ -2153,11 +2151,6 @@ void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg);
}
void Plater::priv::on_enable_action_buttons(Event<bool>&)
{
// TODO
}
void Plater::priv::on_update_geometry(Vec3dsEvent<2>&)
{
// TODO
@ -2352,6 +2345,8 @@ void Plater::load_files(const std::vector<fs::path>& input_files, bool load_mode
void Plater::update() { p->update(); }
void Plater::update_ui_from_settings() { p->update_ui_from_settings(); }
void Plater::select_view(const std::string& direction) { p->select_view(direction); }
void Plater::select_all() { p->select_all(); }

View File

@ -125,6 +125,9 @@ public:
void update();
void select_view(const std::string& direction);
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void update_ui_from_settings();
void select_all();
void remove(size_t obj_idx);

View File

@ -1,20 +0,0 @@
#include "TabIface.hpp"
#include "Tab.hpp"
namespace Slic3r {
void TabIface::load_current_preset() { m_tab->load_current_preset(); }
void TabIface::update_tab_ui() { m_tab->update_tab_ui(); }
void TabIface::update_ui_from_settings() { m_tab->update_ui_from_settings();}
void TabIface::select_preset(char* name) { m_tab->select_preset(name);}
void TabIface::load_config(DynamicPrintConfig* config) { m_tab->load_config(*config);}
void TabIface::load_key_value(char* opt_key, char* value){ m_tab->load_key_value(opt_key, static_cast<std::string>(value)); }
bool TabIface::current_preset_is_dirty() { return m_tab->current_preset_is_dirty();}
void TabIface::OnActivate() { return m_tab->OnActivate();}
size_t TabIface::get_selected_preset_item() { return m_tab->get_selected_preset_item(); }
std::string TabIface::title() { return m_tab->title().ToUTF8().data(); }
DynamicPrintConfig* TabIface::get_config() { return m_tab->get_config(); }
PresetCollection* TabIface::get_presets() { return m_tab!=nullptr ? m_tab->get_presets() : nullptr; }
std::vector<std::string> TabIface::get_dependent_tabs() { return m_tab->get_dependent_tabs(); }
}; // namespace Slic3r

View File

@ -1,41 +0,0 @@
#ifndef slic3r_TabIface_hpp_
#define slic3r_TabIface_hpp_
#include <vector>
#include <string>
namespace Slic3r {
class DynamicPrintConfig;
class PresetCollection;
namespace GUI {
class Tab;
}
class TabIface {
public:
TabIface() : m_tab(nullptr) {}
TabIface(GUI::Tab *tab) : m_tab(tab) {}
// TabIface(const TabIface &rhs) : m_tab(rhs.m_tab) {}
void load_current_preset();
void update_tab_ui();
void update_ui_from_settings();
void select_preset(char* name);
std::string title();
void load_config(DynamicPrintConfig* config);
void load_key_value(char* opt_key, char* value);
bool current_preset_is_dirty();
void OnActivate();
DynamicPrintConfig* get_config();
PresetCollection* get_presets();
std::vector<std::string> get_dependent_tabs();
size_t get_selected_preset_item();
protected:
GUI::Tab *m_tab;
}; // namespace GUI
}; // namespace Slic3r
#endif /* slic3r_TabIface_hpp_ */