<commit_before>#ifndef PLATE2D_HPP
#define PLATE2D_HPP
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif
#include <wx/datetime.h>

#include <vector>
#include <functional>
#include "Plater.hpp"
#include "ColorScheme.hpp"
#include "Settings.hpp"
#include "Plater/PlaterObject.hpp"
#include "misc_ui.hpp"

#include "Log.hpp"


namespace Slic3r { namespace GUI {


// Setup for an Easter Egg with the canvas text.
const wxDateTime today_date {wxDateTime().GetDateOnly()}; 
const wxDateTime special_date {13, wxDateTime::Month::Sep, 2006, 0, 0, 0, 0};
const bool today_is_special = {today_date.GetDay() == special_date.GetDay() && today_date.GetMonth() == special_date.GetMonth()};

enum class MoveDirection {
    Up, Down, Left, Right
};

/// simple POD to make referencing this pair of identifiers easy
struct InstanceIdx {
    long obj;
    long inst;
};

class Plate2D : public wxPanel {
public:
    Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings);


    /// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
    void update_bed_size();

    std::function<void (const unsigned int obj_idx)> on_select_object {};
    std::function<void ()> on_double_click {};

    /// Do something on right-clicks.
    std::function<void (const wxPoint& pos)> on_right_click {};
    std::function<void ()> on_instances_moved {};


    void set_selected (long obj, long inst) { this->selected_instance = {obj, inst}; }

private:
    std::vector<PlaterObject>& objects; //< reference to parent vector
    std::shared_ptr<Slic3r::Model> model;
    std::shared_ptr<Slic3r::Config> config;
    std::shared_ptr<Settings> settings;

    // Different brushes to draw with, initialized from settings->Color during the constructor
    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)};

    /// The object id and selected 
    InstanceIdx selected_instance;
    InstanceIdx drag_object;

    /// Handle mouse-move events
    void mouse_drag(wxMouseEvent& e);
    void mouse_down(wxMouseEvent& e);
    void mouse_up(wxMouseEvent& e);
    void mouse_dclick(wxMouseEvent& e);

    wxPoint drag_start_pos {};


    /// Handle repaint events
    void repaint(wxPaintEvent& e);

    void nudge_key(wxKeyEvent& e);

    void nudge(MoveDirection dir);

    /// Set/Update all of the colors used by the various brushes in the panel.
    void set_colors();

    /// Convert a scale point array to a pixel polygon suitable for DrawPolygon<commit_msg>Set some default values.<commit_after>#ifndef PLATE2D_HPP
#define PLATE2D_HPP
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif
#include <wx/datetime.h>

#include <vector>
#include <functional>
#include "Plater.hpp"
#include "ColorScheme.hpp"
#include "Settings.hpp"
#include "Plater/PlaterObject.hpp"
#include "misc_ui.hpp"

#include "Log.hpp"


namespace Slic3r { namespace GUI {


// Setup for an Easter Egg with the canvas text.
const wxDateTime today_date {wxDateTime().GetDateOnly()}; 
const wxDateTime special_date {13, wxDateTime::Month::Sep, 2006, 0, 0, 0, 0};
const bool today_is_special = {today_date.GetDay() == special_date.GetDay() && today_date.GetMonth() == special_date.GetMonth()};

enum class MoveDirection {
    Up, Down, Left, Right
};

/// simple POD to make referencing this pair of identifiers easy
struct InstanceIdx {
    long obj;
    long inst;
};

class Plate2D : public wxPanel {
public:
    Plate2D(wxWindow* parent, const wxSize& size, std::vector<PlaterObject>& _objects, std::shared_ptr<Model> _model, std::shared_ptr<Config> _config, std::shared_ptr<Settings> _settings);


    /// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
    void update_bed_size();

    std::function<void (const unsigned int obj_idx)> on_select_object {};
    std::function<void ()> on_double_click {};

    /// Do something on right-clicks.
    std::function<void (const wxPoint& pos)> on_right_click {};
    std::function<void ()> on_instances_moved {};


    void set_selected (long obj, long inst) { this->selected_instance = {obj, inst}; }

private:
    std::vector<PlaterObject>& objects; //< reference to parent vector
    std::shared_ptr<Slic3r::Model> model;
    std::shared_ptr<Slic3r::Config> config;
    std::shared_ptr<Settings> settings;

    // Different brushes to draw with, initialized from settings->Color during the constructor
    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)};

    /// The object id and selected 
    InstanceIdx selected_instance {-1, -1};
    InstanceIdx drag_object {-1, -1};

    /// Handle mouse-move events
    void mouse_drag(wxMouseEvent& e);
    void mouse_down(wxMouseEvent& e);
    void mouse_up(wxMouseEvent& e);
    void mouse_dclick(wxMouseEvent& e);

    wxPoint drag_start_pos {wxPoint(-1, -1)};


    /// Handle repaint events
    void repaint(wxPaintEvent& e);

    void nudge_key(wxKeyEvent& e);

    void nudge(MoveDirection dir);

    /// Set/Update all of the colors used by the various brushes in the panel.
    void set_colors();

    /// Convert a scale point array to a pixel polygon suitable for DrawPolygon
{'fraction_non_alphanumeric': 0.1162007409902324, 'fraction_numerical': 0.006736274840013472, 'mean_word_length': 3.999158249158249, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7558586', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1810, 'n_words': 546}