Fixed events OBJECT_SETTINGS_CHANGED_EVENT , OBJECT_REMOVE_EVENT and UPDATE_SCENE_EVENT
+ changed ctor of ObjList + deleted unusable code from Tab.cpp
This commit is contained in:
parent
04e193011c
commit
1006cd976e
@ -1,7 +1,7 @@
|
||||
#ifndef slic3r_Events_hpp_
|
||||
#define slic3r_Events_hpp_
|
||||
|
||||
|
||||
#include <array>
|
||||
#include <wx/event.h>
|
||||
|
||||
|
||||
|
@ -669,6 +669,11 @@ ObjectList* GUI_App::obj_list()
|
||||
return sidebar().obj_list();
|
||||
}
|
||||
|
||||
Plater* GUI_App::plater()
|
||||
{
|
||||
return mainframe->m_plater;
|
||||
}
|
||||
|
||||
ModelObjectPtrs* GUI_App::model_objects()
|
||||
{
|
||||
return &mainframe->m_plater->model().objects;
|
||||
|
@ -142,6 +142,7 @@ public:
|
||||
Sidebar& sidebar();
|
||||
ObjectManipulation* obj_manipul();
|
||||
ObjectList* obj_list();
|
||||
Plater* plater();
|
||||
std::vector<ModelObject*> *model_objects();
|
||||
|
||||
AppConfig* app_config{ nullptr };
|
||||
|
@ -18,7 +18,7 @@ namespace GUI
|
||||
{
|
||||
|
||||
ObjectList::ObjectList(wxWindow* parent) :
|
||||
m_parent(parent)
|
||||
wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
{
|
||||
// Fill CATEGORY_ICON
|
||||
{
|
||||
@ -39,24 +39,24 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||
create_objects_ctrl();
|
||||
|
||||
// describe control behavior
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxEvent& event) {
|
||||
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxEvent& event) {
|
||||
object_ctrl_selection_changed();
|
||||
#ifndef __WXMSW__
|
||||
set_tooltip_for_item(get_mouse_position_in_control());
|
||||
#endif //__WXMSW__
|
||||
});
|
||||
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, [this](wxDataViewEvent& event) {
|
||||
Bind(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, [this](wxDataViewEvent& event) {
|
||||
object_ctrl_context_menu();
|
||||
});
|
||||
|
||||
m_objects_ctrl->Bind(wxEVT_CHAR, [this](wxKeyEvent& event) { object_ctrl_key_event(event); }); // doesn't work on OSX
|
||||
Bind(wxEVT_CHAR, [this](wxKeyEvent& event) { object_ctrl_key_event(event); }); // doesn't work on OSX
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Extruder value changed
|
||||
m_objects_ctrl->Bind(wxEVT_CHOICE, [this](wxCommandEvent& event) { update_extruder_in_config(event.GetString()); });
|
||||
Bind(wxEVT_CHOICE, [this](wxCommandEvent& event) { update_extruder_in_config(event.GetString()); });
|
||||
|
||||
m_objects_ctrl->GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
|
||||
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
|
||||
set_tooltip_for_item(event.GetPosition());
|
||||
event.Skip();
|
||||
});
|
||||
@ -65,9 +65,9 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, [this](wxDataViewEvent& e) { object_ctrl_item_value_change(e); });
|
||||
#endif //__WXMSW__
|
||||
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, [this](wxDataViewEvent& e) {on_begin_drag(e); });
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, [this](wxDataViewEvent& e) {on_drop_possible(e); });
|
||||
m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_DROP, [this](wxDataViewEvent& e) {on_drop(e); });
|
||||
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, [this](wxDataViewEvent& e) {on_begin_drag(e); });
|
||||
Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, [this](wxDataViewEvent& e) {on_drop_possible(e); });
|
||||
Bind(wxEVT_DATAVIEW_ITEM_DROP, [this](wxDataViewEvent& e) {on_drop(e); });
|
||||
}
|
||||
|
||||
ObjectList::~ObjectList()
|
||||
@ -78,33 +78,32 @@ ObjectList::~ObjectList()
|
||||
|
||||
void ObjectList::create_objects_ctrl()
|
||||
{
|
||||
m_objects_ctrl = new wxDataViewCtrl(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_objects_ctrl->SetMinSize(wxSize(-1, 150)); // TODO - Set correct height according to the opened/closed objects
|
||||
SetMinSize(wxSize(-1, 150)); // TODO - Set correct height according to the opened/closed objects
|
||||
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer->Add(m_objects_ctrl, 1, wxGROW | wxLEFT, 20);
|
||||
m_sizer->Add(this, 1, wxGROW | wxLEFT, 20);
|
||||
|
||||
m_objects_model = new PrusaObjectDataViewModel;
|
||||
m_objects_ctrl->AssociateModel(m_objects_model);
|
||||
AssociateModel(m_objects_model);
|
||||
#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
||||
m_objects_ctrl->EnableDragSource(wxDF_UNICODETEXT);
|
||||
m_objects_ctrl->EnableDropTarget(wxDF_UNICODETEXT);
|
||||
EnableDragSource(wxDF_UNICODETEXT);
|
||||
EnableDropTarget(wxDF_UNICODETEXT);
|
||||
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
||||
|
||||
// column 0(Icon+Text) of the view control:
|
||||
// And Icon can be consisting of several bitmaps
|
||||
m_objects_ctrl->AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(),
|
||||
AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(),
|
||||
0, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
|
||||
|
||||
// column 1 of the view control:
|
||||
m_objects_ctrl->AppendTextColumn(_(L("Copy")), 1, wxDATAVIEW_CELL_INERT, 45,
|
||||
AppendTextColumn(_(L("Copy")), 1, wxDATAVIEW_CELL_INERT, 45,
|
||||
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
||||
|
||||
// column 2 of the view control:
|
||||
m_objects_ctrl->AppendColumn(create_objects_list_extruder_column(4));
|
||||
AppendColumn(create_objects_list_extruder_column(4));
|
||||
|
||||
// column 3 of the view control:
|
||||
m_objects_ctrl->AppendBitmapColumn(" ", 3, wxDATAVIEW_CELL_INERT, 25,
|
||||
AppendBitmapColumn(" ", 3, wxDATAVIEW_CELL_INERT, 25,
|
||||
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
||||
}
|
||||
|
||||
@ -112,11 +111,11 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
|
||||
{
|
||||
wxDataViewItem item;
|
||||
wxDataViewColumn* col;
|
||||
m_objects_ctrl->HitTest(pt, item, col);
|
||||
HitTest(pt, item, col);
|
||||
if (!item) return;
|
||||
|
||||
if (col->GetTitle() == " ")
|
||||
m_objects_ctrl->GetMainWindow()->SetToolTip(_(L("Right button click the icon to change the object settings")));
|
||||
GetMainWindow()->SetToolTip(_(L("Right button click the icon to change the object settings")));
|
||||
else if (col->GetTitle() == _("Name") &&
|
||||
m_objects_model->GetIcon(item).GetRefData() == m_icon_manifold_warning.GetRefData()) {
|
||||
int obj_idx = m_objects_model->GetIdByItem(item);
|
||||
@ -148,17 +147,17 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
|
||||
if (is_windows10())
|
||||
tooltip += _(L("Right button click the icon to fix STL through Netfabb"));
|
||||
|
||||
m_objects_ctrl->GetMainWindow()->SetToolTip(tooltip);
|
||||
GetMainWindow()->SetToolTip(tooltip);
|
||||
}
|
||||
else
|
||||
m_objects_ctrl->GetMainWindow()->SetToolTip(""); // hide tooltip
|
||||
GetMainWindow()->SetToolTip(""); // hide tooltip
|
||||
}
|
||||
|
||||
wxPoint ObjectList::get_mouse_position_in_control() {
|
||||
const wxPoint& pt = wxGetMousePosition();
|
||||
wxWindow* win = m_objects_ctrl->GetMainWindow();
|
||||
return wxPoint(pt.x - win->GetScreenPosition().x,
|
||||
pt.y - win->GetScreenPosition().y);
|
||||
// wxWindow* win = GetMainWindow();
|
||||
// wxPoint screen_pos = win->GetScreenPosition();
|
||||
return wxPoint(pt.x - /*win->*/GetScreenPosition().x, pt.y - /*win->*/GetScreenPosition().y);
|
||||
}
|
||||
|
||||
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count)
|
||||
@ -175,21 +174,21 @@ wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_
|
||||
|
||||
void ObjectList::update_objects_list_extruder_column(int extruders_count)
|
||||
{
|
||||
if (!m_objects_ctrl) return; // #ys_FIXME
|
||||
if (!this) return; // #ys_FIXME
|
||||
if (wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA)
|
||||
extruders_count = 1;
|
||||
|
||||
// delete old 3rd column
|
||||
m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumn(2));
|
||||
DeleteColumn(GetColumn(2));
|
||||
// insert new created 3rd column
|
||||
m_objects_ctrl->InsertColumn(2, create_objects_list_extruder_column(extruders_count));
|
||||
InsertColumn(2, create_objects_list_extruder_column(extruders_count));
|
||||
// set show/hide for this column
|
||||
set_extruder_column_hidden(extruders_count <= 1);
|
||||
}
|
||||
|
||||
void ObjectList::set_extruder_column_hidden(bool hide)
|
||||
{
|
||||
m_objects_ctrl->GetColumn(2)->SetHidden(hide);
|
||||
GetColumn(2)->SetHidden(hide);
|
||||
}
|
||||
|
||||
void ObjectList::update_extruder_in_config(const wxString& selection)
|
||||
@ -201,7 +200,7 @@ void ObjectList::update_extruder_in_config(const wxString& selection)
|
||||
m_config->set_key_value("extruder", new ConfigOptionInt(extruder));
|
||||
|
||||
// #ys_FIXME_events
|
||||
// call function to update the scene after extruder changing
|
||||
// wxGetApp().plater()->update();
|
||||
}
|
||||
|
||||
void ObjectList::init_icons(){
|
||||
@ -231,7 +230,7 @@ void ObjectList::object_ctrl_selection_changed()
|
||||
int obj_idx, vol_idx = -1;
|
||||
obj_idx = m_selected_object_id;
|
||||
|
||||
const wxDataViewItem item = m_objects_ctrl->GetSelection();
|
||||
const wxDataViewItem item = GetSelection();
|
||||
if (!item || m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||
vol_idx = -1;
|
||||
else {
|
||||
@ -250,11 +249,11 @@ void ObjectList::object_ctrl_context_menu()
|
||||
wxDataViewItem item;
|
||||
wxDataViewColumn* col;
|
||||
const wxPoint pt = get_mouse_position_in_control();
|
||||
m_objects_ctrl->HitTest(pt, item, col);
|
||||
HitTest(pt, item, col);
|
||||
if (!item)
|
||||
#ifdef __WXOSX__ // #ys_FIXME temporary workaround for OSX
|
||||
// after Yosemite OS X version, HitTest return undefined item
|
||||
item = m_objects_ctrl->GetSelection();
|
||||
item = GetSelection();
|
||||
if (item)
|
||||
show_context_menu();
|
||||
else
|
||||
@ -275,13 +274,13 @@ void ObjectList::object_ctrl_context_menu()
|
||||
/*fix_through_netfabb()*/;// #ys_FIXME
|
||||
}
|
||||
#ifndef __WXMSW__
|
||||
m_objects_ctrl->GetMainWindow()->SetToolTip(""); // hide tooltip
|
||||
GetMainWindow()->SetToolTip(""); // hide tooltip
|
||||
#endif //__WXMSW__
|
||||
}
|
||||
|
||||
void ObjectList::show_context_menu()
|
||||
{
|
||||
const auto item = m_objects_ctrl->GetSelection();
|
||||
const auto item = GetSelection();
|
||||
if (item)
|
||||
{
|
||||
if (m_objects_model->IsSettingsItem(item))
|
||||
@ -297,7 +296,7 @@ void ObjectList::show_context_menu()
|
||||
void ObjectList::object_ctrl_key_event(wxKeyEvent& event)
|
||||
{
|
||||
if (event.GetKeyCode() == WXK_TAB)
|
||||
m_objects_ctrl->Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
|
||||
Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
|
||||
else if (event.GetKeyCode() == WXK_DELETE
|
||||
#ifdef __WXOSX__
|
||||
|| event.GetKeyCode() == WXK_BACK
|
||||
@ -382,7 +381,7 @@ void ObjectList::on_drop(wxDataViewEvent &event)
|
||||
if (to_volume_id > from_volume_id) to_volume_id--;
|
||||
#endif // __WXGTK__
|
||||
|
||||
m_objects_ctrl->Select(m_objects_model->ReorganizeChildren(from_volume_id, to_volume_id,
|
||||
Select(m_objects_model->ReorganizeChildren(from_volume_id, to_volume_id,
|
||||
m_objects_model->GetParent(item)));
|
||||
|
||||
auto& volumes = (*m_objects)[m_selected_object_id]->volumes;
|
||||
@ -490,10 +489,10 @@ void ObjectList::get_settings_choice(wxMenu *menu, int id, bool is_part)
|
||||
|
||||
|
||||
// Add settings item for object
|
||||
const auto item = m_objects_ctrl->GetSelection();
|
||||
const auto item = GetSelection();
|
||||
if (item) {
|
||||
const auto settings_item = m_objects_model->HasSettings(item);
|
||||
m_objects_ctrl->Select(settings_item ? settings_item :
|
||||
Select(settings_item ? settings_item :
|
||||
m_objects_model->AddSettingsChild(item));
|
||||
#ifndef __WXOSX__
|
||||
part_selection_changed();
|
||||
@ -644,7 +643,7 @@ wxMenu* ObjectList::create_add_settings_popupmenu(bool is_part)
|
||||
// Load SubObjects (parts and modifiers)
|
||||
void ObjectList::load_subobject(bool is_modifier /*= false*/, bool is_lambda/* = false*/)
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
if (!item)
|
||||
return;
|
||||
int obj_idx = -1;
|
||||
@ -663,7 +662,7 @@ void ObjectList::load_subobject(bool is_modifier /*= false*/, bool is_lambda/* =
|
||||
parts_changed(obj_idx);
|
||||
|
||||
for (int i = 0; i < part_names.size(); ++i)
|
||||
m_objects_ctrl->Select(m_objects_model->AddChild(item, part_names.Item(i),
|
||||
Select(m_objects_model->AddChild(item, part_names.Item(i),
|
||||
is_modifier ? m_icon_modifiermesh : m_icon_solidmesh));
|
||||
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
|
||||
object_ctrl_selection_changed();
|
||||
@ -725,7 +724,7 @@ void ObjectList::load_lambda( ModelObject* model_object,
|
||||
wxArrayString& part_names,
|
||||
const bool is_modifier)
|
||||
{
|
||||
auto dlg = new LambdaObjectDialog(m_objects_ctrl->GetMainWindow());
|
||||
auto dlg = new LambdaObjectDialog(GetMainWindow());
|
||||
if (dlg->ShowModal() == wxID_CANCEL) {
|
||||
return;
|
||||
}
|
||||
@ -776,7 +775,7 @@ void ObjectList::load_lambda(const std::string& type_name)
|
||||
{
|
||||
if (m_selected_object_id < 0) return;
|
||||
|
||||
auto dlg = new LambdaObjectDialog(m_objects_ctrl->GetMainWindow(), type_name);
|
||||
auto dlg = new LambdaObjectDialog(GetMainWindow(), type_name);
|
||||
if (dlg->ShowModal() == wxID_CANCEL)
|
||||
return;
|
||||
|
||||
@ -808,7 +807,7 @@ void ObjectList::load_lambda(const std::string& type_name)
|
||||
m_parts_changed = true;
|
||||
parts_changed(m_selected_object_id);
|
||||
|
||||
m_objects_ctrl->Select(m_objects_model->AddChild(m_objects_ctrl->GetSelection(),
|
||||
Select(m_objects_model->AddChild(GetSelection(),
|
||||
name, m_icon_modifiermesh));
|
||||
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
|
||||
object_ctrl_selection_changed();
|
||||
@ -820,7 +819,7 @@ void ObjectList::load_lambda(const std::string& type_name)
|
||||
|
||||
void ObjectList::del_subobject()
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
if (!item) return;
|
||||
|
||||
const auto volume_id = m_objects_model->GetVolumeIdByItem(item);
|
||||
@ -832,7 +831,7 @@ void ObjectList::del_subobject()
|
||||
else if (!del_subobject_from_object(volume_id))
|
||||
return;
|
||||
|
||||
m_objects_ctrl->Select(m_objects_model->Delete(item));
|
||||
Select(m_objects_model->Delete(item));
|
||||
part_selection_changed();
|
||||
}
|
||||
|
||||
@ -875,7 +874,7 @@ bool ObjectList::del_subobject_from_object(const int volume_id)
|
||||
|
||||
void ObjectList::split(const bool split_part)
|
||||
{
|
||||
const auto item = m_objects_ctrl->GetSelection();
|
||||
const auto item = GetSelection();
|
||||
if (!item || m_selected_object_id < 0)
|
||||
return;
|
||||
ModelVolume* volume;
|
||||
@ -900,7 +899,7 @@ void ObjectList::split(const bool split_part)
|
||||
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value : 0,
|
||||
false);
|
||||
|
||||
m_objects_ctrl->Expand(parent);
|
||||
Expand(parent);
|
||||
}
|
||||
else {
|
||||
for (auto id = 0; id < model_object->volumes.size(); id++)
|
||||
@ -909,7 +908,7 @@ void ObjectList::split(const bool split_part)
|
||||
model_object->volumes[id]->config.has("extruder") ?
|
||||
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value : 0,
|
||||
false);
|
||||
m_objects_ctrl->Expand(item);
|
||||
Expand(item);
|
||||
}
|
||||
|
||||
m_parts_changed = true;
|
||||
@ -934,7 +933,7 @@ bool ObjectList::get_volume_by_item(const bool split_part, const wxDataViewItem&
|
||||
|
||||
bool ObjectList::is_splittable_object(const bool split_part)
|
||||
{
|
||||
const wxDataViewItem item = m_objects_ctrl->GetSelection();
|
||||
const wxDataViewItem item = GetSelection();
|
||||
if (!item) return false;
|
||||
|
||||
wxDataViewItemArray children;
|
||||
@ -956,18 +955,14 @@ bool ObjectList::is_splittable_object(const bool split_part)
|
||||
|
||||
void ObjectList::parts_changed(int obj_idx)
|
||||
{
|
||||
// #ys_FIXME_events
|
||||
// call function to update scene after some changes in ObjectList
|
||||
// auto event_str = wxString::Format("%d %d %d", obj_idx,
|
||||
// is_parts_changed() ? 1 : 0,
|
||||
// is_part_settings_changed() ? 1 : 0);
|
||||
wxGetApp().mainframe->m_plater->changed_object_settings(obj_idx);
|
||||
}
|
||||
|
||||
void ObjectList::part_selection_changed()
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
int obj_idx = -1;
|
||||
ConfigOptionsGroup* og = wxGetApp().obj_manipul()->get_og();// get_optgroup(ogFrequentlyObjectSettings);
|
||||
ConfigOptionsGroup* og = wxGetApp().obj_manipul()->get_og();
|
||||
m_config = nullptr;
|
||||
wxString object_name = wxEmptyString;
|
||||
if (item)
|
||||
@ -1022,21 +1017,22 @@ void ObjectList::part_selection_changed()
|
||||
|
||||
void ObjectList::update_manipulation_sizer(const bool is_simple_mode)
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
if (!item || !is_simple_mode)
|
||||
return;
|
||||
|
||||
if (m_objects_model->IsSettingsItem(item)) {
|
||||
m_objects_ctrl->Select(m_objects_model->GetParent(item));
|
||||
Select(m_objects_model->GetParent(item));
|
||||
part_selection_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::add_object_to_list(const std::string &name, ModelObject* model_object)
|
||||
void ObjectList::add_object_to_list(size_t obj_idx)
|
||||
{
|
||||
wxString item_name = name;
|
||||
auto model_object = (*m_objects)[obj_idx];
|
||||
wxString item_name = model_object->name;
|
||||
auto item = m_objects_model->Add(item_name, model_object->instances.size());
|
||||
m_objects_ctrl->Select(item);
|
||||
Select(item);
|
||||
|
||||
// Add error icon if detected auto-repaire
|
||||
auto stats = model_object->volumes[0]->mesh.stl.stats;
|
||||
@ -1056,7 +1052,7 @@ void ObjectList::add_object_to_list(const std::string &name, ModelObject* model_
|
||||
m_icon_solidmesh,
|
||||
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value,
|
||||
false);
|
||||
m_objects_ctrl->Expand(item);
|
||||
Expand(item);
|
||||
}
|
||||
|
||||
#ifndef __WXOSX__
|
||||
@ -1066,10 +1062,10 @@ void ObjectList::add_object_to_list(const std::string &name, ModelObject* model_
|
||||
|
||||
void ObjectList::delete_object_from_list()
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
if (!item || m_objects_model->GetParent(item) != wxDataViewItem(0))
|
||||
return;
|
||||
// m_objects_ctrl->Select(m_objects_model->Delete(item));
|
||||
// Select(m_objects_model->Delete(item));
|
||||
m_objects_model->Delete(item);
|
||||
|
||||
part_selection_changed();
|
||||
@ -1084,16 +1080,16 @@ void ObjectList::delete_all_objects_from_list()
|
||||
void ObjectList::set_object_count(int idx, int count)
|
||||
{
|
||||
m_objects_model->SetValue(wxString::Format("%d", count), idx, 1);
|
||||
m_objects_ctrl->Refresh();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ObjectList::unselect_objects()
|
||||
{
|
||||
if (!m_objects_ctrl->GetSelection())
|
||||
if (!GetSelection())
|
||||
return;
|
||||
|
||||
m_prevent_list_events = true;
|
||||
m_objects_ctrl->UnselectAll();
|
||||
UnselectAll();
|
||||
part_selection_changed();
|
||||
m_prevent_list_events = false;
|
||||
}
|
||||
@ -1101,9 +1097,9 @@ void ObjectList::unselect_objects()
|
||||
void ObjectList::select_current_object(int idx)
|
||||
{
|
||||
m_prevent_list_events = true;
|
||||
m_objects_ctrl->UnselectAll();
|
||||
UnselectAll();
|
||||
if (idx >= 0)
|
||||
m_objects_ctrl->Select(m_objects_model->GetItemById(idx));
|
||||
Select(m_objects_model->GetItemById(idx));
|
||||
part_selection_changed();
|
||||
m_prevent_list_events = false;
|
||||
}
|
||||
@ -1115,16 +1111,16 @@ void ObjectList::select_current_volume(int idx, int vol_idx)
|
||||
return;
|
||||
}
|
||||
m_prevent_list_events = true;
|
||||
m_objects_ctrl->UnselectAll();
|
||||
UnselectAll();
|
||||
if (idx >= 0)
|
||||
m_objects_ctrl->Select(m_objects_model->GetItemByVolumeId(idx, vol_idx));
|
||||
Select(m_objects_model->GetItemByVolumeId(idx, vol_idx));
|
||||
part_selection_changed();
|
||||
m_prevent_list_events = false;
|
||||
}
|
||||
|
||||
void ObjectList::remove()
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
auto item = GetSelection();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
#ifndef slic3r_GUI_ObjectList_hpp_
|
||||
#define slic3r_GUI_ObjectList_hpp_
|
||||
|
||||
#include <wx/panel.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <map>
|
||||
|
||||
class wxBoxSizer;
|
||||
class wxDataViewCtrl;
|
||||
class wxDataViewColumn;
|
||||
class wxDataViewEvent;
|
||||
class wxDataViewItem;
|
||||
class PrusaObjectDataViewModel;
|
||||
|
||||
namespace Slic3r {
|
||||
@ -20,10 +16,9 @@ class ModelVolume;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class ObjectList
|
||||
class ObjectList : public wxDataViewCtrl
|
||||
{
|
||||
wxBoxSizer *m_sizer {nullptr};
|
||||
wxWindow *m_parent{ nullptr };
|
||||
|
||||
DynamicPrintConfig *m_default_config {nullptr};
|
||||
|
||||
@ -50,11 +45,10 @@ public:
|
||||
|
||||
std::map<std::string, wxBitmap> CATEGORY_ICON;
|
||||
|
||||
wxDataViewCtrl *m_objects_ctrl{ nullptr };
|
||||
PrusaObjectDataViewModel *m_objects_model{ nullptr };
|
||||
DynamicPrintConfig *m_config {nullptr};
|
||||
|
||||
std::vector<ModelObject*> *m_objects{ nullptr };
|
||||
std::vector<ModelObject*> *m_objects{ nullptr };
|
||||
|
||||
|
||||
void create_objects_ctrl();
|
||||
@ -110,7 +104,7 @@ public:
|
||||
void update_manipulation_sizer(const bool is_simple_mode);
|
||||
|
||||
// Add object to the list
|
||||
void add_object_to_list(const std::string &name, ModelObject* model_object);
|
||||
void add_object_to_list(size_t obj_idx);
|
||||
// Delete object from the list
|
||||
void delete_object_from_list();
|
||||
// Delete all objects from the list
|
||||
|
@ -171,7 +171,7 @@ void ObjectManipulation::update_settings_list()
|
||||
m_settings_list_sizer->Clear(true);
|
||||
bool show_manipulations = true;
|
||||
|
||||
auto objects_ctrl = wxGetApp().obj_list()->m_objects_ctrl;
|
||||
auto objects_ctrl = wxGetApp().obj_list();
|
||||
auto objects_model = wxGetApp().obj_list()->m_objects_model;
|
||||
auto config = wxGetApp().obj_list()->m_config;
|
||||
|
||||
@ -259,7 +259,7 @@ void ObjectManipulation::update_settings_list()
|
||||
#endif
|
||||
|
||||
parent->Layout();
|
||||
/*wxGetApp().sidebar().*/parent->GetParent()->Layout();
|
||||
parent->GetParent()->Layout();
|
||||
}
|
||||
|
||||
void ObjectManipulation::update_values()
|
||||
|
@ -171,25 +171,6 @@ void MainFrame::init_tabpanel()
|
||||
// m_plater->select_object_from_cpp(obj_idx < 0 ? undef : obj_idx, vol_idx < 0 ? -1 : vol_idx);
|
||||
// });
|
||||
|
||||
// The following event is emited by the C++ GUI implementation on object settings change.
|
||||
// EVT_COMMAND($self, -1, $OBJECT_SETTINGS_CHANGED_EVENT, sub {
|
||||
// auto line = event->GetString();
|
||||
// my($obj_idx, $parts_changed, $part_settings_changed) = split('', $line);
|
||||
//
|
||||
// m_plater->changed_object_settings(obj_idx, parts_changed, part_settings_changed);
|
||||
// });
|
||||
|
||||
// The following event is emited by the C++ GUI implementation on object remove.
|
||||
// EVT_COMMAND($self, -1, $OBJECT_REMOVE_EVENT, sub {
|
||||
// m_plater->remove();
|
||||
// });
|
||||
//
|
||||
// // The following event is emited by the C++ GUI implementation on extruder change for object.
|
||||
// EVT_COMMAND($self, -1, $UPDATE_SCENE_EVENT, sub {
|
||||
// m_plater->update();
|
||||
// });
|
||||
|
||||
|
||||
create_preset_tabs();
|
||||
std::vector<std::string> tab_names = { "print", "filament", "sla_material", "printer" };
|
||||
for (auto tab_name : tab_names)
|
||||
|
@ -362,6 +362,9 @@ struct Sidebar::priv
|
||||
wxButton *btn_reslice;
|
||||
// wxButton *btn_print; // XXX: remove
|
||||
wxButton *btn_send_gcode;
|
||||
|
||||
bool show_manifold_warning_icon = false;
|
||||
bool show_print_info = false;
|
||||
};
|
||||
|
||||
|
||||
@ -537,8 +540,8 @@ int Sidebar::get_ol_selection()
|
||||
void Sidebar::show_info_sizers(const bool show)
|
||||
{
|
||||
p->object_info->Show(show);
|
||||
p->object_info->manifold_warning_icon->Show(show/* && g_show_manifold_warning_icon*/); // where is g_show_manifold_warning_icon updating? #ys_FIXME
|
||||
p->sliced_info->Show(show /*&& g_show_print_info*/); // where is g_show_print_info updating? #ys_FIXME
|
||||
p->object_info->manifold_warning_icon->Show(show && p->show_manifold_warning_icon); // where is g_show_manifold_warning_icon updating? #ys_FIXME
|
||||
p->sliced_info->Show(show && p->show_print_info); // where is g_show_print_info updating? #ys_FIXME
|
||||
}
|
||||
|
||||
void Sidebar::show_buttons(const bool show)
|
||||
@ -974,11 +977,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mod
|
||||
}
|
||||
|
||||
for (const size_t idx : obj_idxs) {
|
||||
const PlaterObject &object = objects[idx];
|
||||
ModelObject *model_object = model.objects[idx];
|
||||
|
||||
// FIXME: ObjetParts not initialized (via add_frequently_changed_parameters)
|
||||
// GUI::add_object_to_list(object.name, model_object);
|
||||
wxGetApp().obj_list()->add_object_to_list(idx);
|
||||
}
|
||||
|
||||
if (need_arrange) {
|
||||
@ -1155,5 +1154,37 @@ void Plater::reslice()
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Plater::changed_object_settings(int obj_idx)
|
||||
{
|
||||
if (obj_idx < 0)
|
||||
return;
|
||||
auto list = wxGetApp().obj_list();
|
||||
wxASSERT(list != nullptr);
|
||||
if (list == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if (list->is_parts_changed()) {
|
||||
// recenter and re - align to Z = 0
|
||||
auto model_object = p->model.objects[list->get_sel_obj_id()];
|
||||
model_object->center_around_origin();
|
||||
}
|
||||
|
||||
// update print
|
||||
if (list->is_parts_changed() || list->is_part_settings_changed()) {
|
||||
// stop_background_process();
|
||||
// $self->{print}->reload_object($obj_idx);
|
||||
// schedule_background_process();
|
||||
if (p->canvas3D) _3DScene::reload_scene(p->canvas3D, true);
|
||||
auto selections = p->collect_selections();
|
||||
_3DScene::set_objects_selections(p->canvas3D, selections);
|
||||
_3DScene::reload_scene(p->canvas3D, false);
|
||||
}
|
||||
else {
|
||||
// schedule_background_process();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
// Note: empty string means request default path
|
||||
std::string export_gcode(const std::string &output_path);
|
||||
void reslice();
|
||||
void changed_object_settings(int obj_idx);
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
@ -152,7 +152,6 @@ void Tab::create_preset_tab()
|
||||
m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_hsizer->AddSpacer(32);
|
||||
m_hsizer->Add(m_question_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
// m_hsizer->Add(m_cc_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
||||
|
||||
//Horizontal sizer to hold the tree and the selected page.
|
||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@ -518,7 +517,7 @@ void Tab::update_changed_tree_ui()
|
||||
break;
|
||||
}
|
||||
auto next_item = m_treectrl->GetNextVisible(cur_item);
|
||||
cur_item = !m_treectrl->IsVisible(cur_item) ? m_treectrl->GetNextVisible(cur_item) : nullptr;// next_item;
|
||||
cur_item = next_item;
|
||||
}
|
||||
update_undo_buttons();
|
||||
}
|
||||
@ -590,14 +589,11 @@ void Tab::update_dirty(){
|
||||
m_presets->update_dirty_ui(m_presets_choice);
|
||||
on_presets_changed();
|
||||
update_changed_ui();
|
||||
// update_dirty_presets(m_cc_presets_choice);
|
||||
}
|
||||
|
||||
void Tab::update_tab_ui()
|
||||
{
|
||||
m_selected_preset_item = m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets);
|
||||
// update_tab_presets(m_cc_presets_choice, m_show_incompatible_presets);
|
||||
// update_presetsctrl(m_presetctrl, m_show_incompatible_presets);
|
||||
}
|
||||
|
||||
// Load a provied DynamicConfig into the tab, modifying the active preset.
|
||||
@ -2611,173 +2607,6 @@ wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox
|
||||
return sizer;
|
||||
}
|
||||
|
||||
void Tab::update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible)
|
||||
{
|
||||
if (ui == nullptr)
|
||||
return;
|
||||
ui->Freeze();
|
||||
ui->DeleteAllItems();
|
||||
auto presets = m_presets->get_presets();
|
||||
auto idx_selected = m_presets->get_idx_selected();
|
||||
auto suffix_modified = m_presets->get_suffix_modified();
|
||||
int icon_compatible = 0;
|
||||
int icon_incompatible = 1;
|
||||
int cnt_items = 0;
|
||||
|
||||
auto root_sys = ui->AppendContainer(wxDataViewItem(0), _(L("System presets")));
|
||||
auto root_def = ui->AppendContainer(wxDataViewItem(0), _(L("Default presets")));
|
||||
|
||||
auto show_def = wxGetApp().app_config->get("no_defaults")[0] != '1';
|
||||
|
||||
for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) {
|
||||
const Preset &preset = presets[i];
|
||||
if (!preset.is_visible || (!show_incompatible && !preset.is_compatible && i != idx_selected))
|
||||
continue;
|
||||
|
||||
auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str());
|
||||
|
||||
wxDataViewItem item;
|
||||
if (preset.is_system)
|
||||
item = ui->AppendItem(root_sys, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else if (show_def && preset.is_default)
|
||||
item = ui->AppendItem(root_def, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else
|
||||
{
|
||||
auto parent = m_presets->get_preset_parent(preset);
|
||||
if (parent == nullptr)
|
||||
item = ui->AppendItem(root_def, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else
|
||||
{
|
||||
auto parent_name = parent->name;
|
||||
|
||||
wxDataViewTreeStoreContainerNode *node = ui->GetStore()->FindContainerNode(root_sys);
|
||||
if (node)
|
||||
{
|
||||
wxDataViewTreeStoreNodes::iterator iter;
|
||||
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++)
|
||||
{
|
||||
wxDataViewTreeStoreNode* child = *iter;
|
||||
auto child_item = child->GetItem();
|
||||
auto item_text = ui->GetItemText(child_item);
|
||||
if (item_text == parent_name)
|
||||
{
|
||||
auto added_child = ui->AppendItem(child->GetItem(), preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
if (!added_child){
|
||||
ui->DeleteItem(child->GetItem());
|
||||
auto new_parent = ui->AppendContainer(root_sys, parent_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
ui->AppendItem(new_parent, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cnt_items++;
|
||||
if (i == idx_selected){
|
||||
ui->Select(item);
|
||||
m_cc_presets_choice->SetText(preset_name);
|
||||
}
|
||||
}
|
||||
if (ui->GetStore()->GetChildCount(root_def) == 0)
|
||||
ui->DeleteItem(root_def);
|
||||
|
||||
ui->Thaw();
|
||||
}
|
||||
|
||||
void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible)
|
||||
{
|
||||
if (ui == nullptr)
|
||||
return;
|
||||
ui->Freeze();
|
||||
ui->Clear();
|
||||
auto presets = m_presets->get_presets();
|
||||
auto idx_selected = m_presets->get_idx_selected();
|
||||
auto suffix_modified = m_presets->get_suffix_modified();
|
||||
int icon_compatible = 0;
|
||||
int icon_incompatible = 1;
|
||||
int cnt_items = 0;
|
||||
|
||||
wxDataViewTreeCtrlComboPopup* popup = wxDynamicCast(m_cc_presets_choice->GetPopupControl(), wxDataViewTreeCtrlComboPopup);
|
||||
if (popup != nullptr)
|
||||
{
|
||||
popup->DeleteAllItems();
|
||||
|
||||
auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets")));
|
||||
auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets")));
|
||||
|
||||
auto show_def = wxGetApp().app_config->get("no_defaults")[0] != '1';
|
||||
|
||||
for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) {
|
||||
const Preset &preset = presets[i];
|
||||
if (!preset.is_visible || (!show_incompatible && !preset.is_compatible && i != idx_selected))
|
||||
continue;
|
||||
|
||||
auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str());
|
||||
|
||||
wxDataViewItem item;
|
||||
if (preset.is_system)
|
||||
item = popup->AppendItem(root_sys, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else if (show_def && preset.is_default)
|
||||
item = popup->AppendItem(root_def, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else
|
||||
{
|
||||
auto parent = m_presets->get_preset_parent(preset);
|
||||
if (parent == nullptr)
|
||||
item = popup->AppendItem(root_def, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
else
|
||||
{
|
||||
auto parent_name = parent->name;
|
||||
|
||||
wxDataViewTreeStoreContainerNode *node = popup->GetStore()->FindContainerNode(root_sys);
|
||||
if (node)
|
||||
{
|
||||
wxDataViewTreeStoreNodes::iterator iter;
|
||||
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++)
|
||||
{
|
||||
wxDataViewTreeStoreNode* child = *iter;
|
||||
auto child_item = child->GetItem();
|
||||
auto item_text = popup->GetItemText(child_item);
|
||||
if (item_text == parent_name)
|
||||
{
|
||||
auto added_child = popup->AppendItem(child->GetItem(), preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
if (!added_child){
|
||||
popup->DeleteItem(child->GetItem());
|
||||
auto new_parent = popup->AppendContainer(root_sys, parent_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
popup->AppendItem(new_parent, preset_name,
|
||||
preset.is_compatible ? icon_compatible : icon_incompatible);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cnt_items++;
|
||||
if (i == idx_selected){
|
||||
popup->Select(item);
|
||||
m_cc_presets_choice->SetText(preset_name);
|
||||
}
|
||||
}
|
||||
if (popup->GetStore()->GetChildCount(root_def) == 0)
|
||||
popup->DeleteItem(root_def);
|
||||
}
|
||||
ui->Thaw();
|
||||
}
|
||||
|
||||
void Tab::fill_icon_descriptions()
|
||||
{
|
||||
m_icon_descriptions.push_back(t_icon_description(&m_bmp_value_lock, L("LOCKED LOCK;"
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/event.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@ -126,8 +123,6 @@ protected:
|
||||
wxButton* m_undo_btn;
|
||||
wxButton* m_undo_to_sys_btn;
|
||||
wxButton* m_question_btn;
|
||||
wxComboCtrl* m_cc_presets_choice;
|
||||
wxDataViewTreeCtrl* m_presetctrl;
|
||||
wxImageList* m_preset_icons;
|
||||
|
||||
// Cached bitmaps.
|
||||
@ -218,7 +213,6 @@ public:
|
||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
|
||||
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
|
||||
|
||||
void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible);
|
||||
void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false);
|
||||
void reload_compatible_printers_widget();
|
||||
|
||||
@ -267,7 +261,6 @@ protected:
|
||||
void on_presets_changed();
|
||||
void update_preset_description_line();
|
||||
void update_frequently_changed_parameters();
|
||||
void update_tab_presets(wxComboCtrl* ui, bool show_incompatible);
|
||||
void fill_icon_descriptions();
|
||||
void set_tooltips_text();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user