NEW:[STUDIO-4121] Search object list
jira:STUDIO-4121 Change-Id: Ib0777fc19b8fd70c92fa1169dd1df8cd27a04b3f
This commit is contained in:
parent
eb417083e0
commit
bcc5450522
|
@ -782,6 +782,76 @@ void ObjectList::printable_state_changed(const std::vector<ObjectVolumeID>& ov_i
|
||||||
wxGetApp().plater()->update();
|
wxGetApp().plater()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::search_object_list() {
|
||||||
|
|
||||||
|
auto found_size = m_found_list.size();
|
||||||
|
|
||||||
|
if (cur_pos >= found_size) {
|
||||||
|
cur_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cur_pos < found_size) {
|
||||||
|
wxDataViewItem cur_item = m_found_list.Item(cur_pos);
|
||||||
|
select_item(cur_item);
|
||||||
|
cur_pos++;
|
||||||
|
ensure_current_item_visible();
|
||||||
|
selection_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::append_found_list(wxString current_search_text, wxDataViewItem item) {
|
||||||
|
|
||||||
|
wxString item_name = m_objects_model->GetName(item);
|
||||||
|
item_name = item_name.MakeLower();
|
||||||
|
|
||||||
|
if (item_name.find(current_search_text) != wxString::npos) {
|
||||||
|
m_found_list.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectDataViewModelNode* root = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||||
|
size_t child_count = root->GetChildCount();
|
||||||
|
for (size_t i = 0; i < child_count; ++i) {
|
||||||
|
append_found_list(current_search_text, wxDataViewItem(root->GetNthChild(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::set_found_list(wxString current_search_text) {
|
||||||
|
|
||||||
|
m_found_list.clear();
|
||||||
|
PartPlateList& ppl = wxGetApp().plater()->get_partplate_list();
|
||||||
|
current_search_text = current_search_text.MakeLower();
|
||||||
|
for (int i = 0; i < ppl.get_plate_count(); ++i) {
|
||||||
|
wxDataViewItem plate_item = m_objects_model->GetItemByPlateId(i);
|
||||||
|
append_found_list(current_search_text, plate_item);
|
||||||
|
}
|
||||||
|
if (current_search_text.empty()) {
|
||||||
|
if (ppl.get_plate_count() > 0) {
|
||||||
|
wxDataViewItem item = m_objects_model->GetItemByPlateId(0);
|
||||||
|
select_item(item);
|
||||||
|
ensure_current_item_visible();
|
||||||
|
selection_changed();
|
||||||
|
}
|
||||||
|
auto column = GetColumn(colName);
|
||||||
|
column->SetTitle(_L("Name"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto column = GetColumn(colName);
|
||||||
|
wxString match_num = wxString::Format("%d", m_found_list.size());
|
||||||
|
wxString match_message = " (" + match_num + _L(" research result") + ")";
|
||||||
|
wxString column_name = _L("Name") + match_message;
|
||||||
|
column->SetTitle(column_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::set_cur_pos(int value) {
|
||||||
|
cur_pos = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::searchbar_kill_focus() {
|
||||||
|
auto column = GetColumn(colName);
|
||||||
|
column->SetTitle(_L("Name"));
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectList::update_objects_list_filament_column(size_t filaments_count)
|
void ObjectList::update_objects_list_filament_column(size_t filaments_count)
|
||||||
{
|
{
|
||||||
assert(filaments_count >= 1);
|
assert(filaments_count >= 1);
|
||||||
|
|
|
@ -190,6 +190,8 @@ private:
|
||||||
// because it would turn off the gizmos (mainly a problem for the SLA gizmo)
|
// because it would turn off the gizmos (mainly a problem for the SLA gizmo)
|
||||||
|
|
||||||
wxDataViewItem m_last_selected_item {nullptr};
|
wxDataViewItem m_last_selected_item {nullptr};
|
||||||
|
|
||||||
|
wxDataViewItemArray m_found_list;
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
||||||
int m_last_selected_column = -1;
|
int m_last_selected_column = -1;
|
||||||
|
@ -220,6 +222,8 @@ public:
|
||||||
std::vector<ModelObject*>* objects() const { return m_objects; }
|
std::vector<ModelObject*>* objects() const { return m_objects; }
|
||||||
|
|
||||||
ModelObject* object(const int obj_idx) const ;
|
ModelObject* object(const int obj_idx) const ;
|
||||||
|
wxDataViewItemArray get_found_list() const { return m_found_list; }
|
||||||
|
|
||||||
|
|
||||||
void create_objects_ctrl();
|
void create_objects_ctrl();
|
||||||
// BBS
|
// BBS
|
||||||
|
@ -462,6 +466,12 @@ public:
|
||||||
bool is_dragging() const { return m_dragged_data.type() != itUndef; }
|
bool is_dragging() const { return m_dragged_data.type() != itUndef; }
|
||||||
void cancel_drag();
|
void cancel_drag();
|
||||||
|
|
||||||
|
// search objectlist
|
||||||
|
void search_object_list();
|
||||||
|
void append_found_list(wxString current_search_text, wxDataViewItem item);
|
||||||
|
void set_found_list(wxString current_search_text);
|
||||||
|
void set_cur_pos(int value);
|
||||||
|
void searchbar_kill_focus();
|
||||||
private:
|
private:
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
// void OnChar(wxKeyEvent& event);
|
// void OnChar(wxKeyEvent& event);
|
||||||
|
@ -489,6 +499,7 @@ private:
|
||||||
|
|
||||||
std::vector<int> m_columns_width;
|
std::vector<int> m_columns_width;
|
||||||
wxSize m_last_size;
|
wxSize m_last_size;
|
||||||
|
int cur_pos = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,7 @@ struct Sidebar::priv
|
||||||
wxPanel* m_panel_project_title;
|
wxPanel* m_panel_project_title;
|
||||||
ScalableButton* m_filament_icon = nullptr;
|
ScalableButton* m_filament_icon = nullptr;
|
||||||
Button * m_flushing_volume_btn = nullptr;
|
Button * m_flushing_volume_btn = nullptr;
|
||||||
|
wxSearchCtrl* m_search_bar = nullptr;
|
||||||
|
|
||||||
// BBS printer config
|
// BBS printer config
|
||||||
StaticBox* m_panel_printer_title = nullptr;
|
StaticBox* m_panel_printer_title = nullptr;
|
||||||
|
@ -348,7 +349,9 @@ struct Sidebar::priv
|
||||||
~priv();
|
~priv();
|
||||||
|
|
||||||
void show_preset_comboboxes();
|
void show_preset_comboboxes();
|
||||||
|
void on_search_enter();
|
||||||
|
void on_search_update();
|
||||||
|
void on_kill_focus();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
wxString btn_reslice_tip;
|
wxString btn_reslice_tip;
|
||||||
void show_rich_tip(const wxString& tooltip, wxButton* btn);
|
void show_rich_tip(const wxString& tooltip, wxButton* btn);
|
||||||
|
@ -388,6 +391,23 @@ void Sidebar::priv::show_preset_comboboxes()
|
||||||
scrolled->Refresh();
|
scrolled->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sidebar::priv::on_search_enter() {
|
||||||
|
|
||||||
|
m_object_list->search_object_list();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sidebar::priv::on_search_update() {
|
||||||
|
|
||||||
|
wxString search_text = m_search_bar->GetValue();
|
||||||
|
m_object_list->set_found_list(search_text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sidebar::priv::on_kill_focus() {
|
||||||
|
m_object_list->searchbar_kill_focus();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
using wxRichToolTipPopup = wxCustomBackgroundWindow<wxPopupTransientWindow>;
|
using wxRichToolTipPopup = wxCustomBackgroundWindow<wxPopupTransientWindow>;
|
||||||
static wxRichToolTipPopup* get_rtt_popup(wxButton* btn)
|
static wxRichToolTipPopup* get_rtt_popup(wxButton* btn)
|
||||||
|
@ -910,11 +930,30 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
|
|
||||||
//add project content
|
//add project content
|
||||||
p->sizer_params = new wxBoxSizer(wxVERTICAL);
|
p->sizer_params = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
p->m_search_bar = new wxSearchCtrl(p->scrolled, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||||
|
p->m_search_bar->ShowSearchButton(true);
|
||||||
|
p->m_search_bar->ShowCancelButton(true);
|
||||||
|
p->m_search_bar->SetDescriptiveText(_L("Search plater, object and part."));
|
||||||
|
p->m_search_bar->Bind(wxEVT_SET_FOCUS, [this](wxFocusEvent&) {
|
||||||
|
this->p->on_search_update();});
|
||||||
|
p->m_search_bar->Bind(wxEVT_COMMAND_TEXT_UPDATED, [this](wxCommandEvent&) {
|
||||||
|
this->p->m_object_list->set_cur_pos(0);
|
||||||
|
this->p->on_search_update();
|
||||||
|
});
|
||||||
|
p->m_search_bar->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& e) {
|
||||||
|
this->p->on_kill_focus();
|
||||||
|
e.Skip();
|
||||||
|
});
|
||||||
|
p->m_search_bar->Bind(wxEVT_SEARCH, [this](wxCommandEvent&) {this->p->on_search_enter();});
|
||||||
|
|
||||||
p->m_object_list = new ObjectList(p->scrolled);
|
p->m_object_list = new ObjectList(p->scrolled);
|
||||||
|
|
||||||
|
p->sizer_params->Add(p->m_search_bar, 0, wxALL | wxEXPAND, 0);
|
||||||
p->sizer_params->Add(p->m_object_list, 1, wxEXPAND | wxTOP, 0);
|
p->sizer_params->Add(p->m_object_list, 1, wxEXPAND | wxTOP, 0);
|
||||||
scrolled_sizer->Add(p->sizer_params, 2, wxEXPAND | wxLEFT, 0);
|
scrolled_sizer->Add(p->sizer_params, 2, wxEXPAND | wxLEFT, 0);
|
||||||
p->m_object_list->Hide();
|
p->m_object_list->Hide();
|
||||||
|
p->m_search_bar->Hide();
|
||||||
// Frequently Object Settings
|
// Frequently Object Settings
|
||||||
p->object_settings = new ObjectSettings(p->scrolled);
|
p->object_settings = new ObjectSettings(p->scrolled);
|
||||||
#if !NEW_OBJECT_SETTING
|
#if !NEW_OBJECT_SETTING
|
||||||
|
@ -1679,6 +1718,7 @@ void Sidebar::update_ui_from_settings()
|
||||||
|
|
||||||
bool Sidebar::show_object_list(bool show) const
|
bool Sidebar::show_object_list(bool show) const
|
||||||
{
|
{
|
||||||
|
p->m_search_bar->Show(show);
|
||||||
if (!p->m_object_list->Show(show))
|
if (!p->m_object_list->Show(show))
|
||||||
return false;
|
return false;
|
||||||
if (!show)
|
if (!show)
|
||||||
|
|
Loading…
Reference in New Issue