PrusaSlicer-NonPlainar/src/slic3r/GUI/Plater.hpp

343 lines
10 KiB
C++
Raw Normal View History

2018-09-17 10:15:11 +00:00
#ifndef slic3r_Plater_hpp_
#define slic3r_Plater_hpp_
#include <memory>
2018-10-08 17:14:55 +00:00
#include <vector>
2018-10-04 09:12:55 +00:00
#include <boost/filesystem/path.hpp>
2018-09-17 10:15:11 +00:00
#include <wx/panel.h>
2018-10-09 10:41:05 +00:00
#include <wx/bmpcbox.h>
2018-09-17 10:15:11 +00:00
#include "Preset.hpp"
#include "3DScene.hpp"
#include "GLTexture.hpp"
#include "wxExtensions.hpp"
2018-10-04 09:12:55 +00:00
class wxButton;
class ScalableButton;
class wxBoxSizer;
class wxGLCanvas;
class wxScrolledWindow;
class wxString;
2018-10-04 09:12:55 +00:00
2018-09-17 10:15:11 +00:00
namespace Slic3r {
class Model;
class ModelObject;
2018-10-11 11:22:36 +00:00
class Print;
class SLAPrint;
enum SLAPrintObjectStep : unsigned int;
namespace UndoRedo {
class Stack;
struct Snapshot;
};
2018-09-17 10:15:11 +00:00
namespace GUI {
class MainFrame;
2018-10-03 13:14:52 +00:00
class ConfigOptionsGroup;
class ObjectManipulation;
class ObjectSettings;
class ObjectLayers;
2018-10-05 21:29:15 +00:00
class ObjectList;
class GLCanvas3D;
class Mouse3DController;
2018-10-03 13:14:52 +00:00
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
2018-09-17 10:15:11 +00:00
2018-10-04 09:12:55 +00:00
class Plater;
enum class ActionButtonType : int;
2018-10-04 09:12:55 +00:00
class PresetComboBox : public PresetBitmapComboBox
2018-10-09 10:41:05 +00:00
{
public:
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
~PresetComboBox();
ScalableButton* edit_btn { nullptr };
enum LabelItemType {
LABEL_ITEM_MARKER = 0xffffff01,
LABEL_ITEM_WIZARD_PRINTERS,
LABEL_ITEM_WIZARD_FILAMENTS,
LABEL_ITEM_WIZARD_MATERIALS,
LABEL_ITEM_MAX,
};
void set_label_marker(int item, LabelItemType label_item_type = LABEL_ITEM_MARKER);
void set_extruder_idx(const int extr_idx) { extruder_idx = extr_idx; }
int get_extruder_idx() const { return extruder_idx; }
int em_unit() const { return m_em_unit; }
2018-12-03 14:16:33 +00:00
void check_selection();
2018-10-09 10:41:05 +00:00
void msw_rescale();
2018-10-09 10:41:05 +00:00
private:
typedef std::size_t Marker;
Preset::Type preset_type;
int last_selected;
int extruder_idx = -1;
int m_em_unit;
2018-10-09 10:41:05 +00:00
};
2018-09-17 10:15:11 +00:00
class Sidebar : public wxPanel
{
ConfigOptionMode m_mode;
2018-09-17 10:15:11 +00:00
public:
2018-10-04 09:12:55 +00:00
Sidebar(Plater *parent);
2018-09-17 10:15:11 +00:00
Sidebar(Sidebar &&) = delete;
Sidebar(const Sidebar &) = delete;
Sidebar &operator=(Sidebar &&) = delete;
Sidebar &operator=(const Sidebar &) = delete;
~Sidebar();
void init_filament_combo(PresetComboBox **combo, const int extr_idx);
void remove_unused_filament_combos(const size_t current_extruder_count);
2019-04-10 07:56:32 +00:00
void update_all_preset_comboboxes();
2018-09-17 10:15:11 +00:00
void update_presets(Slic3r::Preset::Type preset_type);
void update_mode_sizer() const;
void update_reslice_btn_tooltip() const;
void msw_rescale();
2018-10-03 13:14:52 +00:00
2018-10-09 10:41:05 +00:00
ObjectManipulation* obj_manipul();
2018-10-05 21:29:15 +00:00
ObjectList* obj_list();
ObjectSettings* obj_settings();
ObjectLayers* obj_layers();
wxScrolledWindow* scrolled_panel();
wxPanel* presets_panel();
2018-10-03 13:14:52 +00:00
ConfigOptionsGroup* og_freq_chng_params(const bool is_fff);
2018-10-03 13:14:52 +00:00
wxButton* get_wiping_dialog_button();
void update_objects_list_extruder_column(size_t extruders_count);
void show_info_sizer();
void show_sliced_info_sizer(const bool show);
void update_sliced_info_sizer();
2018-10-08 17:14:55 +00:00
void enable_buttons(bool enable);
void set_btn_label(const ActionButtonType btn_type, const wxString& label) const;
bool show_reslice(bool show) const;
bool show_export(bool show) const;
bool show_send(bool show) const;
2019-12-10 16:31:27 +00:00
bool show_disconnect(bool show)const;
bool show_export_removable(bool show) const;
2018-10-09 10:41:05 +00:00
bool is_multifilament();
void update_mode();
std::vector<PresetComboBox*>& combos_filament();
2018-09-17 10:15:11 +00:00
private:
struct priv;
std::unique_ptr<priv> p;
};
class Plater: public wxPanel
{
public:
2018-12-11 09:33:11 +00:00
using fs_path = boost::filesystem::path;
2018-09-17 10:15:11 +00:00
Plater(wxWindow *parent, MainFrame *main_frame);
Plater(Plater &&) = delete;
Plater(const Plater &) = delete;
Plater &operator=(Plater &&) = delete;
Plater &operator=(const Plater &) = delete;
~Plater();
Sidebar& sidebar();
2018-10-11 11:22:36 +00:00
Model& model();
const Print& fff_print() const;
Print& fff_print();
const SLAPrint& sla_print() const;
SLAPrint& sla_print();
2018-09-17 10:15:11 +00:00
void new_project();
void load_project();
void load_project(const wxString& filename);
void add_model();
void extract_config_from_project();
std::vector<size_t> load_files(const std::vector<boost::filesystem::path>& input_files, bool load_model = true, bool load_config = true);
// To be called when providing a list of files to the GUI slic3r on command line.
std::vector<size_t> load_files(const std::vector<std::string>& input_files, bool load_model = true, bool load_config = true);
2018-09-17 10:15:11 +00:00
void update();
void stop_jobs();
2018-10-17 10:59:58 +00:00
void select_view(const std::string& direction);
void select_view_3D(const std::string& name);
bool is_preview_shown() const;
bool is_preview_loaded() const;
bool is_view3D_shown() const;
bool are_view3D_labels_shown() const;
void show_view3D_labels(bool show);
// 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();
2018-10-17 10:59:58 +00:00
2018-11-21 14:28:35 +00:00
void select_all();
void deselect_all();
2018-10-04 09:12:55 +00:00
void remove(size_t obj_idx);
2018-11-22 10:31:53 +00:00
void reset();
void reset_with_confirm();
void delete_object_from_model(size_t obj_idx);
2018-10-04 09:12:55 +00:00
void remove_selected();
void increase_instances(size_t num = 1);
void decrease_instances(size_t num = 1);
void set_number_of_copies(/*size_t num*/);
2018-11-21 14:47:41 +00:00
bool is_selection_empty() const;
void scale_selection_to_fit_print_volume();
2018-10-08 17:14:55 +00:00
2018-11-26 09:56:07 +00:00
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false);
2018-10-18 13:13:38 +00:00
void export_gcode(bool prefer_removable = true);
2019-05-02 11:46:39 +00:00
void export_stl(bool extended = false, bool selection_only = false);
2018-10-04 09:12:55 +00:00
void export_amf();
void export_3mf(const boost::filesystem::path& output_path = boost::filesystem::path());
void reload_from_disk();
void reload_all_from_disk();
bool has_toolpaths_to_export() const;
void export_toolpaths_to_obj() const;
void hollow();
2018-09-17 10:15:11 +00:00
void reslice();
void reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages = false);
void reslice_SLA_hollowing(const ModelObject &object, bool postpone_error_messages = false);
void reslice_SLA_until_step(SLAPrintObjectStep step, const ModelObject &object, bool postpone_error_messages = false);
2018-10-31 14:41:27 +00:00
void changed_object(int obj_idx);
void changed_objects(const std::vector<size_t>& object_idxs);
2019-06-26 07:48:52 +00:00
void schedule_background_process(bool schedule = true);
bool is_background_process_running() const;
void suppress_background_process(const bool stop_background_process) ;
void fix_through_netfabb(const int obj_idx, const int vol_idx = -1);
2018-10-04 09:12:55 +00:00
void send_gcode();
2019-12-11 11:28:51 +00:00
void eject_drive();
void drive_ejected_callback();
void take_snapshot(const std::string &snapshot_name);
void take_snapshot(const wxString &snapshot_name);
void undo();
void redo();
2019-07-09 18:45:00 +00:00
void undo_to(int selection);
void redo_to(int selection);
bool undo_redo_string_getter(const bool is_undo, int idx, const char** out_text);
void undo_redo_topmost_string_getter(const bool is_undo, std::string& out_text);
// For the memory statistics.
const Slic3r::UndoRedo::Stack& undo_redo_stack_main() const;
// Enter / leave the Gizmos specific Undo / Redo stack. To be used by the SLA support point editing gizmo.
void enter_gizmos_stack();
void leave_gizmos_stack();
void on_extruders_change(size_t extruders_count);
void on_config_change(const DynamicPrintConfig &config);
void force_filament_colors_update();
void force_print_bed_update();
// On activating the parent window.
void on_activate();
2019-09-30 12:03:50 +00:00
std::vector<std::string> get_extruder_colors_from_plater_config() const;
std::vector<std::string> get_colors_for_color_print() const;
void update_object_menu();
wxString get_project_filename(const wxString& extension = wxEmptyString) const;
void set_project_filename(const wxString& filename);
bool is_export_gcode_scheduled() const;
2018-11-01 11:33:56 +00:00
int get_selected_object_idx();
bool is_single_full_object_selection() const;
GLCanvas3D* canvas3D();
GLCanvas3D* get_current_canvas3D();
BoundingBoxf bed_shape_bb() const;
void set_current_canvas_as_dirty();
PrinterTechnology printer_technology() const;
void set_printer_technology(PrinterTechnology printer_technology);
void copy_selection_to_clipboard();
void paste_from_clipboard();
bool can_delete() const;
bool can_delete_all() const;
bool can_increase_instances() const;
bool can_decrease_instances() const;
bool can_set_instance_to_object() const;
bool can_fix_through_netfabb() const;
bool can_split_to_objects() const;
bool can_split_to_volumes() const;
bool can_arrange() const;
bool can_layers_editing() const;
bool can_paste_from_clipboard() const;
bool can_copy_to_clipboard() const;
2019-07-08 08:57:35 +00:00
bool can_undo() const;
bool can_redo() const;
bool can_reload_from_disk() const;
void msw_rescale();
bool init_view_toolbar();
const Camera& get_camera() const;
const Mouse3DController& get_mouse3d_controller() const;
Mouse3DController& get_mouse3d_controller();
void set_bed_shape() const;
// ROII wrapper for suppressing the Undo / Redo snapshot to be taken.
class SuppressSnapshots
{
public:
SuppressSnapshots(Plater *plater) : m_plater(plater)
{
m_plater->suppress_snapshots();
}
~SuppressSnapshots()
{
m_plater->allow_snapshots();
}
private:
Plater *m_plater;
};
// ROII wrapper for taking an Undo / Redo snapshot while disabling the snapshot taking by the methods called from inside this snapshot.
class TakeSnapshot
{
public:
TakeSnapshot(Plater *plater, const wxString &snapshot_name) : m_plater(plater)
{
m_plater->take_snapshot(snapshot_name);
m_plater->suppress_snapshots();
}
~TakeSnapshot()
{
m_plater->allow_snapshots();
}
private:
Plater *m_plater;
};
2018-09-17 10:15:11 +00:00
private:
struct priv;
std::unique_ptr<priv> p;
2019-06-26 07:48:52 +00:00
void suppress_snapshots();
void allow_snapshots();
2019-06-26 07:48:52 +00:00
friend class SuppressBackgroundProcessingUpdate;
2018-09-17 10:15:11 +00:00
};
2019-06-26 07:48:52 +00:00
class SuppressBackgroundProcessingUpdate
{
public:
SuppressBackgroundProcessingUpdate();
~SuppressBackgroundProcessingUpdate();
private:
bool m_was_running;
};
2018-09-17 10:15:11 +00:00
}}
#endif