Some code review

This commit is contained in:
YuSanka 2018-10-31 12:56:08 +01:00
parent d2844bc39d
commit 7f08f460f1
25 changed files with 548 additions and 522 deletions

View file

@ -151,12 +151,14 @@ void Bed_2D::repaint()
}
// convert G - code coordinates into pixels
Point Bed_2D::to_pixels(Vec2d point){
Point Bed_2D::to_pixels(Vec2d point)
{
auto p = point * m_scale_factor + m_shift;
return Point(p(0), GetSize().GetHeight() - p(1));
}
void Bed_2D::mouse_event(wxMouseEvent event){
void Bed_2D::mouse_event(wxMouseEvent event)
{
if (!m_interactive) return;
if (!m_painted) return;
@ -170,11 +172,13 @@ void Bed_2D::mouse_event(wxMouseEvent event){
}
// convert pixels into G - code coordinates
Vec2d Bed_2D::to_units(Point point){
Vec2d Bed_2D::to_units(Point point)
{
return (Vec2d(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor);
}
void Bed_2D::set_pos(Vec2d pos){
void Bed_2D::set_pos(Vec2d pos)
{
m_pos = pos;
Refresh();
}

View file

@ -115,7 +115,8 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
// Called from the constructor.
// Create a panel for a rectangular / circular / custom bed shape.
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title){
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title)
{
auto panel = new wxPanel(m_shape_options_book);
ConfigOptionsGroupShp optgroup;

View file

@ -76,9 +76,10 @@ namespace Slic3r { namespace GUI {
if (m_on_kill_focus!=nullptr)
m_on_kill_focus();
}
void Field::on_change_field()
{
// std::cerr << "calling Field::_on_change \n";
std::cerr << "calling Field::_on_change \n";
if (m_on_change != nullptr && !m_disable_change_event)
m_on_change(m_opt_id, get_value());
}
@ -631,7 +632,8 @@ void ColourPicker::BUILD()
temp->SetToolTip(get_tooltip_text(clr_str));
}
boost::any& ColourPicker::get_value(){
boost::any& ColourPicker::get_value()
{
// boost::any m_value;
auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour();

View file

@ -239,22 +239,26 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
}
}
void show_error(wxWindow* parent, const wxString& message) {
void show_error(wxWindow* parent, const wxString& message)
{
ErrorDialog msg(parent, message);
msg.ShowModal();
}
void show_error_id(int id, const std::string& message) {
void show_error_id(int id, const std::string& message)
{
auto *parent = id != 0 ? wxWindow::FindWindowById(id) : nullptr;
show_error(parent, wxString::FromUTF8(message.data()));
}
void show_info(wxWindow* parent, const wxString& message, const wxString& title){
void show_info(wxWindow* parent, const wxString& message, const wxString& title)
{
wxMessageDialog msg_wingow(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION);
msg_wingow.ShowModal();
}
void warning_catcher(wxWindow* parent, const wxString& message){
void warning_catcher(wxWindow* parent, const wxString& message)
{
if (message == "GLUquadricObjPtr | " + _(L("Attempt to free unreferenced scalar")) )
return;
wxMessageDialog msg(parent, message, _(L("Warning")), wxOK | wxICON_WARNING);

View file

@ -267,7 +267,8 @@ void GUI_App::system_info()
// static method accepting a wxWindow object as first parameter
bool GUI_App::catch_error(std::function<void()> cb,
// wxMessageDialog* message_dialog,
const std::string& err /*= ""*/){
const std::string& err /*= ""*/)
{
if (!err.empty()) {
if (cb)
cb();
@ -280,14 +281,16 @@ bool GUI_App::catch_error(std::function<void()> cb,
}
// static method accepting a wxWindow object as first parameter
void fatal_error(wxWindow* parent){
void fatal_error(wxWindow* parent)
{
show_error(parent, "");
// exit 1; // #ys_FIXME
}
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void GUI_App::update_ui_from_settings(){
void GUI_App::update_ui_from_settings()
{
mainframe->update_ui_from_settings();
}

View file

@ -209,7 +209,8 @@ void ObjectList::update_extruder_in_config(const wxString& selection)
wxGetApp().plater()->update();
}
void ObjectList::init_icons(){
void ObjectList::init_icons()
{
m_bmp_modifiermesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG);
m_bmp_solidmesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG);

View file

@ -171,7 +171,8 @@ LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent,
// Called from the constructor.
// Create a panel for a rectangular / circular / custom bed shape.
ConfigOptionsGroupShp LambdaObjectDialog::init_modificator_options_page(const wxString& title){
ConfigOptionsGroupShp LambdaObjectDialog::init_modificator_options_page(const wxString& title)
{
if (!m_type_name.IsEmpty() && m_type_name != title)
return nullptr;

View file

@ -369,14 +369,16 @@ void MainFrame::init_menubar()
}
}
void MainFrame::slice_to_png(){
void MainFrame::slice_to_png()
{
// m_plater->stop_background_process();
// m_plater->async_apply_config();
m_appController->print_ctl()->slice_to_png();
}
// To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
void MainFrame::quick_slice(const int qs){
void MainFrame::quick_slice(const int qs)
{
// my $progress_dialog;
wxString input_file;
// eval

View file

@ -537,7 +537,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
return ret;
}
Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index){
Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index)
{
Field* field = get_field(opt_key);
if (field != nullptr)
return field;

View file

@ -598,7 +598,8 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
// Update the combo box label of the selected preset based on its "dirty" state,
// comparing the selected preset config with $self->{config}.
void Tab::update_dirty(){
void Tab::update_dirty()
{
m_presets->update_dirty_ui(m_presets_choice);
on_presets_changed();
update_changed_ui();
@ -627,7 +628,8 @@ void Tab::load_config(const DynamicPrintConfig& config)
}
// Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
void Tab::reload_config(){
void Tab::reload_config()
{
Freeze();
for (auto page : m_pages)
page->reload_config();
@ -1059,7 +1061,8 @@ void TabPrint::build()
}
// Reload current config (aka presets->edited_preset->config) into the UI fields.
void TabPrint::reload_config(){
void TabPrint::reload_config()
{
reload_compatible_printers_widget();
Tab::reload_config();
}
@ -1425,7 +1428,8 @@ void TabFilament::build()
}
// Reload current config (aka presets->edited_preset->config) into the UI fields.
void TabFilament::reload_config(){
void TabFilament::reload_config()
{
reload_compatible_printers_widget();
Tab::reload_config();
}
@ -1850,13 +1854,15 @@ void TabPrinter::build_sla()
optgroup->append_line(line);
}
void TabPrinter::update_serial_ports(){
void TabPrinter::update_serial_ports()
{
Field *field = get_field("serial_port");
Choice *choice = static_cast<Choice *>(field);
choice->set_values(Utils::scan_serial_ports());
}
void TabPrinter::extruders_count_changed(size_t extruders_count){
void TabPrinter::extruders_count_changed(size_t extruders_count)
{
m_extruders_count = extruders_count;
m_preset_bundle->printers.get_edited_preset().set_num_extruders(extruders_count);
m_preset_bundle->update_multi_material_filament_presets();
@ -2174,7 +2180,8 @@ void TabPrinter::update_fff()
Thaw();
}
void TabPrinter::update_sla(){ ; }
void TabPrinter::update_sla()
{ ; }
// Initialize the UI from the current preset
void Tab::load_current_preset()