mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 04:25:54 +08:00
more work on repaint() event handler. Now draws grid based on bed polygon in config.
This commit is contained in:
parent
fb3250997b
commit
2116dfa178
@ -35,7 +35,7 @@ void Plate2D::repaint(wxPaintEvent& e) {
|
|||||||
this->SetFocus();
|
this->SetFocus();
|
||||||
|
|
||||||
auto dc {new wxAutoBufferedPaintDC(this)};
|
auto dc {new wxAutoBufferedPaintDC(this)};
|
||||||
const auto& size = this->GetSize();
|
const auto& size {wxSize(this->GetSize().GetWidth(), this->GetSize().GetHeight())};
|
||||||
|
|
||||||
|
|
||||||
if (this->user_drawn_background) {
|
if (this->user_drawn_background) {
|
||||||
@ -55,8 +55,38 @@ void Plate2D::repaint(wxPaintEvent& e) {
|
|||||||
{
|
{
|
||||||
dc->SetPen(this->print_center_pen);
|
dc->SetPen(this->print_center_pen);
|
||||||
dc->SetBrush(this->bed_brush);
|
dc->SetBrush(this->bed_brush);
|
||||||
|
auto tmp {scaled_points_to_pixel(this->bed_polygon, true)};
|
||||||
|
dc->DrawPolygon(this->bed_polygon.points.size(), tmp.data(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
dc->DrawPolygon(scaled_points_to_pixel(this->bed_polygon, true), 0, 0);
|
// draw print center
|
||||||
|
{
|
||||||
|
if (this->objects.size() > 0 && settings->autocenter) {
|
||||||
|
const auto center = this->unscaled_point_to_pixel(this->print_center);
|
||||||
|
dc->SetPen(print_center_pen);
|
||||||
|
dc->DrawLine(center.x, 0, center.x, size.y);
|
||||||
|
dc->DrawLine(0, center.y, size.x, center.y);
|
||||||
|
dc->SetTextForeground(wxColor(0,0,0));
|
||||||
|
dc->SetFont(wxFont(10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
|
|
||||||
|
dc->DrawLabel("X = ", wxRect(0,0, center.x*2, this->GetSize().GetHeight()), wxALIGN_CENTER_HORIZONTAL | wxALIGN_BOTTOM);
|
||||||
|
dc->DrawRotatedText("Y = ", 0, center.y + 15, 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw text if plate is empty
|
||||||
|
if (this->objects.size() == 0) {
|
||||||
|
dc->SetTextForeground(settings->color->BED_OBJECTS());
|
||||||
|
dc->SetFont(wxFont(14, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
|
dc->DrawLabel(CANVAS_TEXT, wxRect(0,0, this->GetSize().GetWidth(), this->GetSize().GetHeight()), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
|
||||||
|
} else {
|
||||||
|
// draw grid
|
||||||
|
dc->SetPen(grid_pen);
|
||||||
|
// Assumption: grid of lines is arranged
|
||||||
|
// as adjacent pairs of wxPoints
|
||||||
|
for (auto i = 0U; i < grid.size(); i+=2) {
|
||||||
|
dc->DrawLine(grid[i], grid[i+1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +90,10 @@ private:
|
|||||||
const std::string LogChannel {"GUI_2D"};
|
const std::string LogChannel {"GUI_2D"};
|
||||||
|
|
||||||
wxPoint bed_origin {};
|
wxPoint bed_origin {};
|
||||||
|
wxPoint print_center {};
|
||||||
Slic3r::Polygon bed_polygon {};
|
Slic3r::Polygon bed_polygon {};
|
||||||
|
std::vector<wxPoint> grid {};
|
||||||
|
|
||||||
/// Set up the 2D canvas blank canvas text.
|
/// Set up the 2D canvas blank canvas text.
|
||||||
/// Easter egg: Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap.
|
/// Easter egg: Sept. 13, 2006. The first part ever printed by a RepRap to make another RepRap.
|
||||||
const wxString CANVAS_TEXT { today_is_special ? _(L"What do you want to print today?™") : _("Drag your objects here") };
|
const wxString CANVAS_TEXT { today_is_special ? _(L"What do you want to print today?™") : _("Drag your objects here") };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user