From 4e74249511f68ec394d8ddb3b2c074550b584bc9 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 29 Apr 2018 18:02:48 -0500 Subject: [PATCH] Staged the 2D plater on its tab. --- src/GUI/Plater.cpp | 1 + src/GUI/Plater/Plate2D.cpp | 58 ++++++++++++++++++++++++++++++++++++++ src/GUI/Plater/Plate2D.hpp | 31 ++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index 2fb6d323d..fa8b596c1 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -56,6 +56,7 @@ Plater::Plater(wxWindow* parent, const wxString& title, std::shared_ptrAddPage(canvas2D, _("2D")); /* # Initialize 2D preview canvas diff --git a/src/GUI/Plater/Plate2D.cpp b/src/GUI/Plater/Plate2D.cpp index c5015b5d2..13ebb43f6 100644 --- a/src/GUI/Plater/Plate2D.cpp +++ b/src/GUI/Plater/Plate2D.cpp @@ -1,4 +1,5 @@ #include "Plater/Plate2D.hpp" +#include "Log.hpp" #include @@ -7,6 +8,63 @@ namespace Slic3r { namespace GUI { Plate2D::Plate2D(wxWindow* parent, const wxSize& size, std::vector& _objects, std::shared_ptr _model, std::shared_ptr _config, std::shared_ptr _settings) : wxPanel(parent, wxID_ANY, wxDefaultPosition, size, wxTAB_TRAVERSAL), objects(_objects), model(_model), config(_config), settings(_settings) { + + this->Bind(wxEVT_PAINT, [=](wxPaintEvent &e) { this->repaint(e); }); + this->Bind(wxEVT_MOTION, [=](wxMouseEvent &e) { this->mouse_drag(e); }); + if (user_drawn_background) { + this->Bind(wxEVT_ERASE_BACKGROUND, [=](wxEraseEvent& e){ }); + } + + // Bind the varying mouse events + + // Set the brushes + set_colors(); +} + +void Plate2D::repaint(wxPaintEvent& e) { +} + +void Plate2D::mouse_drag(wxMouseEvent& e) { + if (e.Dragging()) { + Slic3r::Log::info(LogChannel, L"Mouse dragging"); + } else { + Slic3r::Log::info(LogChannel, L"Mouse moving"); + } +} + +void Plate2D::set_colors() { + + this->SetBackgroundColour(settings->color->BACKGROUND255()); + + this->objects_brush.SetColour(settings->color->BED_OBJECTS()); + this->objects_brush.SetStyle(wxBRUSHSTYLE_SOLID); + this->instance_brush.SetColour(settings->color->BED_INSTANCE()); + this->instance_brush.SetStyle(wxBRUSHSTYLE_SOLID); + this->selected_brush.SetColour(settings->color->BED_SELECTED()); + this->selected_brush.SetStyle(wxBRUSHSTYLE_SOLID); + this->dragged_brush.SetColour(settings->color->BED_DRAGGED()); + this->dragged_brush.SetStyle(wxBRUSHSTYLE_SOLID); + this->bed_brush.SetColour(settings->color->BED_COLOR()); + this->bed_brush.SetStyle(wxBRUSHSTYLE_SOLID); + this->transparent_brush.SetColour(wxColour(0,0,0)); + this->transparent_brush.SetStyle(wxBRUSHSTYLE_TRANSPARENT); + + this->grid_pen.SetColour(settings->color->BED_GRID()); + this->grid_pen.SetWidth(1); + this->grid_pen.SetStyle(wxPENSTYLE_SOLID); + this->print_center_pen.SetColour(settings->color->BED_CENTER()); + this->print_center_pen.SetWidth(1); + this->print_center_pen.SetStyle(wxPENSTYLE_SOLID); + this->clearance_pen.SetColour(settings->color->BED_CLEARANCE()); + this->clearance_pen.SetWidth(1); + this->clearance_pen.SetStyle(wxPENSTYLE_SOLID); + this->skirt_pen.SetColour(settings->color->BED_SKIRT()); + this->skirt_pen.SetWidth(1); + this->skirt_pen.SetStyle(wxPENSTYLE_SOLID); + this->dark_pen.SetColour(settings->color->BED_DARK()); + this->dark_pen.SetWidth(1); + this->dark_pen.SetStyle(wxPENSTYLE_SOLID); + } } } // Namespace Slic3r::GUI diff --git a/src/GUI/Plater/Plate2D.hpp b/src/GUI/Plater/Plate2D.hpp index 3c82f1a10..07ae3451a 100644 --- a/src/GUI/Plater/Plate2D.hpp +++ b/src/GUI/Plater/Plate2D.hpp @@ -4,11 +4,16 @@ #ifndef WX_PRECOMP #include #endif + #include #include "Plater.hpp" #include "ColorScheme.hpp" #include "Settings.hpp" #include "Plater/Plater2DObject.hpp" +#include "misc_ui.hpp" + + +#include "Log.hpp" namespace Slic3r { namespace GUI { @@ -22,7 +27,33 @@ private: std::shared_ptr config; std::shared_ptr settings; + // Different brushes to draw with wxBrush objects_brush {}; + wxBrush instance_brush {}; + wxBrush selected_brush {}; + wxBrush bed_brush {}; + wxBrush dragged_brush {}; + wxBrush transparent_brush {}; + + wxPen grid_pen {}; + wxPen print_center_pen {}; + wxPen clearance_pen {}; + wxPen skirt_pen {}; + wxPen dark_pen {}; + + bool user_drawn_background {(the_os == OS::Mac ? false : true)}; + Plater2DObject selected_instance; + + /// Handle mouse-move events + void mouse_drag(wxMouseEvent& e); + + /// Handle repaint events + void repaint(wxPaintEvent& e); + + /// Set/Update all of the colors used by the various brushes in the panel. + void set_colors(); + + const std::string LogChannel {"GUI_2D"}; }; } } // Namespace Slic3r::GUI