2018-10-04 14:43:10 +00:00
|
|
|
#ifndef slic3r_GUI_ObjectList_hpp_
|
|
|
|
#define slic3r_GUI_ObjectList_hpp_
|
|
|
|
|
|
|
|
#include <wx/bitmap.h>
|
2018-10-08 14:27:38 +00:00
|
|
|
#include <wx/dataview.h>
|
2018-10-05 21:29:15 +00:00
|
|
|
#include <map>
|
2018-10-22 13:18:05 +00:00
|
|
|
#include <vector>
|
2018-11-01 11:33:56 +00:00
|
|
|
#include "Event.hpp"
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
class wxBoxSizer;
|
|
|
|
class PrusaObjectDataViewModel;
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
class ConfigOptionsGroup;
|
2018-10-05 21:29:15 +00:00
|
|
|
class DynamicPrintConfig;
|
|
|
|
class ModelObject;
|
|
|
|
class ModelVolume;
|
|
|
|
|
|
|
|
namespace GUI {
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-11-01 13:02:38 +00:00
|
|
|
wxDECLARE_EVENT(EVT_OBJ_LIST_OBJECT_SELECT, SimpleEvent);
|
2018-11-01 11:33:56 +00:00
|
|
|
|
2018-10-08 14:27:38 +00:00
|
|
|
class ObjectList : public wxDataViewCtrl
|
2018-10-04 14:43:10 +00:00
|
|
|
{
|
2018-10-05 21:29:15 +00:00
|
|
|
wxBoxSizer *m_sizer {nullptr};
|
|
|
|
|
|
|
|
DynamicPrintConfig *m_default_config {nullptr};
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-10-16 09:08:37 +00:00
|
|
|
wxBitmap m_bmp_modifiermesh;
|
|
|
|
wxBitmap m_bmp_solidmesh;
|
2018-11-02 11:35:26 +00:00
|
|
|
wxBitmap m_bmp_support_enforcer;
|
|
|
|
wxBitmap m_bmp_support_blocker;
|
2018-10-16 09:08:37 +00:00
|
|
|
wxBitmap m_bmp_manifold_warning;
|
2018-10-04 14:43:10 +00:00
|
|
|
wxBitmap m_bmp_cog;
|
|
|
|
wxBitmap m_bmp_split;
|
|
|
|
|
2018-11-02 11:35:26 +00:00
|
|
|
std::vector<wxBitmap*> m_bmp_vector;
|
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
int m_selected_object_id = -1;
|
2018-10-05 21:29:15 +00:00
|
|
|
bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select()
|
|
|
|
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
|
|
|
|
// calls this method again and again and again
|
|
|
|
#ifdef __WXOSX__
|
|
|
|
wxString m_selected_extruder = "";
|
|
|
|
#endif //__WXOSX__
|
|
|
|
bool m_parts_changed = false;
|
|
|
|
bool m_part_settings_changed = false;
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ObjectList(wxWindow* parent);
|
2018-10-05 21:29:15 +00:00
|
|
|
~ObjectList();
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::string, wxBitmap> CATEGORY_ICON;
|
|
|
|
|
|
|
|
PrusaObjectDataViewModel *m_objects_model{ nullptr };
|
|
|
|
DynamicPrintConfig *m_config {nullptr};
|
|
|
|
|
2018-10-08 14:27:38 +00:00
|
|
|
std::vector<ModelObject*> *m_objects{ nullptr };
|
2018-10-05 21:29:15 +00:00
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
void create_objects_ctrl();
|
|
|
|
wxDataViewColumn* create_objects_list_extruder_column(int extruders_count);
|
|
|
|
void update_objects_list_extruder_column(int extruders_count);
|
2018-10-05 21:29:15 +00:00
|
|
|
// show/hide "Extruder" column for Objects List
|
|
|
|
void set_extruder_column_hidden(bool hide);
|
|
|
|
// update extruder in current config
|
|
|
|
void update_extruder_in_config(const wxString& selection);
|
|
|
|
|
|
|
|
void init_icons();
|
2018-10-04 14:43:10 +00:00
|
|
|
|
|
|
|
void set_tooltip_for_item(const wxPoint& pt);
|
|
|
|
|
2018-10-11 13:57:09 +00:00
|
|
|
void selection_changed();
|
|
|
|
void context_menu();
|
2018-10-05 21:29:15 +00:00
|
|
|
void show_context_menu();
|
2018-10-11 13:57:09 +00:00
|
|
|
void key_event(wxKeyEvent& event);
|
|
|
|
void item_value_change(wxDataViewEvent& event);
|
2018-10-05 21:29:15 +00:00
|
|
|
|
|
|
|
void on_begin_drag(wxDataViewEvent &event);
|
|
|
|
void on_drop_possible(wxDataViewEvent &event);
|
|
|
|
void on_drop(wxDataViewEvent &event);
|
|
|
|
|
|
|
|
void get_settings_choice(wxMenu *menu, int id, bool is_part);
|
2018-11-06 14:34:44 +00:00
|
|
|
void menu_item_add_generic(wxMenuItem* &menu, int id, const int type);
|
2018-10-05 21:29:15 +00:00
|
|
|
wxMenuItem* menu_item_split(wxMenu* menu, int id);
|
|
|
|
wxMenuItem* menu_item_settings(wxMenu* menu, int id, const bool is_part);
|
|
|
|
wxMenu* create_add_part_popupmenu();
|
|
|
|
wxMenu* create_part_settings_popupmenu();
|
|
|
|
wxMenu* create_add_settings_popupmenu(bool is_part);
|
|
|
|
|
2018-11-02 11:35:26 +00:00
|
|
|
void load_subobject(int type);
|
|
|
|
void load_part(ModelObject* model_object, wxArrayString& part_names, int type);
|
2018-11-06 14:34:44 +00:00
|
|
|
void load_generic_subobject(const std::string& type_name, const int type);
|
2018-10-12 10:00:37 +00:00
|
|
|
void del_subobject_item(wxDataViewItem& item);
|
2018-10-05 21:29:15 +00:00
|
|
|
void del_settings_from_config();
|
2018-10-16 09:08:37 +00:00
|
|
|
void del_instances_from_object(const int obj_idx);
|
|
|
|
bool del_subobject_from_object(const int obj_idx, const int idx, const int type);
|
2018-10-05 21:29:15 +00:00
|
|
|
void split(const bool split_part);
|
|
|
|
bool get_volume_by_item(const bool split_part, const wxDataViewItem& item, ModelVolume*& volume);
|
|
|
|
bool is_splittable_object(const bool split_part);
|
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
wxPoint get_mouse_position_in_control();
|
2018-10-31 11:56:08 +00:00
|
|
|
wxBoxSizer* get_sizer() {return m_sizer;}
|
2018-10-12 10:00:37 +00:00
|
|
|
int get_selected_obj_idx() const;
|
2018-10-31 11:56:08 +00:00
|
|
|
bool is_parts_changed() const { return m_parts_changed; }
|
|
|
|
bool is_part_settings_changed() const { return m_part_settings_changed; }
|
2018-10-31 14:41:27 +00:00
|
|
|
void part_settings_changed();
|
2018-10-05 21:29:15 +00:00
|
|
|
|
|
|
|
void parts_changed(int obj_idx);
|
|
|
|
void part_selection_changed();
|
|
|
|
|
|
|
|
// Add object to the list
|
2018-10-08 14:27:38 +00:00
|
|
|
void add_object_to_list(size_t obj_idx);
|
2018-10-05 21:29:15 +00:00
|
|
|
// Delete object from the list
|
|
|
|
void delete_object_from_list();
|
2018-10-12 10:00:37 +00:00
|
|
|
void delete_object_from_list(const size_t obj_idx);
|
|
|
|
void delete_volume_from_list(const size_t obj_idx, const size_t vol_idx);
|
2018-11-13 12:34:31 +00:00
|
|
|
void delete_instance_from_list(const size_t obj_idx, const size_t inst_idx);
|
2018-10-05 21:29:15 +00:00
|
|
|
// Delete all objects from the list
|
|
|
|
void delete_all_objects_from_list();
|
2018-10-18 08:40:26 +00:00
|
|
|
// Increase instances count
|
|
|
|
void increase_object_instances(const size_t obj_idx, const size_t num);
|
|
|
|
// Decrease instances count
|
|
|
|
void decrease_object_instances(const size_t obj_idx, const size_t num);
|
2018-10-11 13:57:09 +00:00
|
|
|
|
|
|
|
// #ys_FIXME_to_delete
|
2018-10-05 21:29:15 +00:00
|
|
|
// Unselect all objects in the list on c++ side
|
|
|
|
void unselect_objects();
|
|
|
|
// Select current object in the list on c++ side
|
|
|
|
void select_current_object(int idx);
|
|
|
|
// Select current volume in the list on c++ side
|
|
|
|
void select_current_volume(int idx, int vol_idx);
|
2018-10-11 13:57:09 +00:00
|
|
|
|
2018-10-05 21:29:15 +00:00
|
|
|
// Remove objects/sub-object from the list
|
|
|
|
void remove();
|
|
|
|
|
|
|
|
void init_objects();
|
2018-10-10 14:22:20 +00:00
|
|
|
bool multiple_selection() const ;
|
2018-10-11 13:57:09 +00:00
|
|
|
void update_selections();
|
|
|
|
void update_selections_on_canvas();
|
|
|
|
void select_item(const wxDataViewItem& item);
|
|
|
|
void select_items(const wxDataViewItemArray& sels);
|
2018-10-12 10:00:37 +00:00
|
|
|
void select_all();
|
2018-11-08 14:45:55 +00:00
|
|
|
void select_item_all_children();
|
2018-10-11 13:57:09 +00:00
|
|
|
// correct current selections to avoid of the possible conflicts
|
|
|
|
void fix_multiselection_conflicts();
|
2018-11-02 22:27:31 +00:00
|
|
|
|
|
|
|
ModelVolume* get_selected_model_volume();
|
|
|
|
void change_part_type();
|
2018-11-12 12:47:24 +00:00
|
|
|
|
|
|
|
void last_volume_is_deleted(const int obj_idx);
|
2018-10-04 14:43:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif //slic3r_GUI_ObjectList_hpp_
|