This commit is contained in:
enricoturri1966 2021-09-23 09:25:31 +02:00
commit bc4650d174
7 changed files with 49 additions and 24 deletions

View file

@ -352,10 +352,16 @@ bool instance_check(int argc, char** argv, bool app_config_single_instance)
if (instance_check_internal::get_lock(lock_name + ".lock", data_dir() + "/cache/") && *cla.should_send) { if (instance_check_internal::get_lock(lock_name + ".lock", data_dir() + "/cache/") && *cla.should_send) {
#endif #endif
instance_check_internal::send_message(cla.cl_string, lock_name); instance_check_internal::send_message(cla.cl_string, lock_name);
BOOST_LOG_TRIVIAL(info) << "instance check: Another instance found. This instance will terminate."; BOOST_LOG_TRIVIAL(error) << "Instance check: Another instance found. This instance will terminate. Lock file of current running instance is located at " << data_dir() <<
#ifdef _WIN32
"\\cache\\"
#else // mac & linx
"/cache/"
#endif
<< lock_name << ".lock";
return true; return true;
} }
BOOST_LOG_TRIVIAL(info) << "instance check: Another instance not found or single-instance not set."; BOOST_LOG_TRIVIAL(info) << "Instance check: Another instance not found or single-instance not set.";
return false; return false;
} }

View file

@ -435,8 +435,9 @@ void MainFrame::update_layout()
{ {
m_plater->Reparent(m_tabpanel); m_plater->Reparent(m_tabpanel);
#ifdef _MSW_DARK_MODE #ifdef _MSW_DARK_MODE
m_plater->Layout();
if (!wxGetApp().tabs_as_menu()) if (!wxGetApp().tabs_as_menu())
dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater, _L("Plater"), std::string("plater")); dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater, _L("Plater"), std::string("plater"), true);
else else
#endif #endif
m_tabpanel->InsertPage(0, m_plater, _L("Plater")); m_tabpanel->InsertPage(0, m_plater, _L("Plater"));
@ -461,7 +462,7 @@ void MainFrame::update_layout()
m_plater_page = new wxPanel(m_tabpanel); m_plater_page = new wxPanel(m_tabpanel);
#ifdef _MSW_DARK_MODE #ifdef _MSW_DARK_MODE
if (!wxGetApp().tabs_as_menu()) if (!wxGetApp().tabs_as_menu())
dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater_page, _L("Plater"), std::string("plater")); dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater_page, _L("Plater"), std::string("plater"), true);
else else
#endif #endif
m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */ m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */

View file

@ -253,11 +253,10 @@ std::vector<unsigned> MeshRaycaster::get_unobscured_idxs(const Geometry::Transfo
std::vector<unsigned> out; std::vector<unsigned> out;
const Transform3d& instance_matrix_no_translation_no_scaling = trafo.get_matrix(true,false,true); const Transform3d& instance_matrix_no_translation_no_scaling = trafo.get_matrix(true,false,true);
Vec3f direction_to_camera = -camera.get_dir_forward().cast<float>(); Vec3d direction_to_camera = -camera.get_dir_forward();
Vec3f direction_to_camera_mesh = (instance_matrix_no_translation_no_scaling.inverse().cast<float>() * direction_to_camera).normalized().eval(); Vec3d direction_to_camera_mesh = (instance_matrix_no_translation_no_scaling.inverse() * direction_to_camera).normalized().eval();
Vec3f scaling = trafo.get_scaling_factor().cast<float>(); direction_to_camera_mesh = direction_to_camera_mesh.cwiseProduct(trafo.get_scaling_factor());
direction_to_camera_mesh = Vec3f(direction_to_camera_mesh(0)*scaling(0), direction_to_camera_mesh(1)*scaling(1), direction_to_camera_mesh(2)*scaling(2)); const Transform3d inverse_trafo = trafo.get_matrix().inverse();
const Transform3f inverse_trafo = trafo.get_matrix().inverse().cast<float>();
for (size_t i=0; i<points.size(); ++i) { for (size_t i=0; i<points.size(); ++i) {
const Vec3f& pt = points[i]; const Vec3f& pt = points[i];
@ -268,9 +267,8 @@ std::vector<unsigned> MeshRaycaster::get_unobscured_idxs(const Geometry::Transfo
// Cast a ray in the direction of the camera and look for intersection with the mesh: // Cast a ray in the direction of the camera and look for intersection with the mesh:
std::vector<sla::IndexedMesh::hit_result> hits; std::vector<sla::IndexedMesh::hit_result> hits;
// Offset the start of the ray by EPSILON to account for numerical inaccuracies. // Offset the start of the ray by EPSILON to account for numerical inaccuracies.
hits = m_emesh.query_ray_hits((inverse_trafo * pt + direction_to_camera_mesh * EPSILON).cast<double>(), hits = m_emesh.query_ray_hits((inverse_trafo * pt.cast<double>() + direction_to_camera_mesh * EPSILON),
direction_to_camera.cast<double>()); direction_to_camera_mesh);
if (! hits.empty()) { if (! hits.empty()) {
// If the closest hit facet normal points in the same direction as the ray, // If the closest hit facet normal points in the same direction as the ray,

View file

@ -165,8 +165,8 @@ public:
GetBtnsListCtrl()->InsertPage(n, text, bSelect, bmp_name); GetBtnsListCtrl()->InsertPage(n, text, bSelect, bmp_name);
if (!DoSetSelectionAfterInsertion(n, bSelect)) if (bSelect)
page->Hide(); SetSelection(n);
return true; return true;
} }
@ -174,7 +174,14 @@ public:
virtual int SetSelection(size_t n) override virtual int SetSelection(size_t n) override
{ {
GetBtnsListCtrl()->SetSelection(n); GetBtnsListCtrl()->SetSelection(n);
return DoSetSelection(n, SetSelection_SendEvent); int ret = DoSetSelection(n, SetSelection_SendEvent);
// check that only the selected page is visible and others are hidden:
for (size_t page = 0; page < m_pages.size(); page++)
if (page != n)
m_pages[page]->Hide();
return ret;
} }
virtual int ChangeSelection(size_t n) override virtual int ChangeSelection(size_t n) override

View file

@ -6536,12 +6536,7 @@ void Plater::search(bool plater_is_active)
canvas3D()->on_char(evt); canvas3D()->on_char(evt);
} }
else else
{ p->sidebar->get_searcher().show_dialog();
wxPoint pos = this->ClientToScreen(wxPoint(0, 0));
pos.x += em_unit(this) * 40;
pos.y += em_unit(this) * 4;
p->sidebar->get_searcher().search_dialog->Popup(pos);
}
} }
void Plater::msw_rescale() void Plater::msw_rescale()

View file

@ -289,7 +289,6 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
OptionsSearcher::OptionsSearcher() OptionsSearcher::OptionsSearcher()
{ {
search_dialog = new SearchDialog(this);
} }
OptionsSearcher::~OptionsSearcher() OptionsSearcher::~OptionsSearcher()
@ -386,6 +385,22 @@ Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& l
return create_option(opt_key, label, type, gc); return create_option(opt_key, label, type, gc);
} }
void OptionsSearcher::show_dialog()
{
if (!search_dialog) {
search_dialog = new SearchDialog(this);
auto parent = search_dialog->GetParent();
wxPoint pos = parent->ClientToScreen(wxPoint(0, 0));
pos.x += em_unit(parent) * 40;
pos.y += em_unit(parent) * 4;
search_dialog->SetPosition(pos);
}
search_dialog->Popup();
}
void OptionsSearcher::add_key(const std::string& opt_key, Preset::Type type, const wxString& group, const wxString& category) void OptionsSearcher::add_key(const std::string& opt_key, Preset::Type type, const wxString& group, const wxString& category)
{ {
groups_and_categories[get_key(opt_key, type)] = GroupAndCategory{group, category}; groups_and_categories[get_key(opt_key, type)] = GroupAndCategory{group, category};
@ -405,7 +420,7 @@ static const std::map<const char, int> icon_idxs = {
}; };
SearchDialog::SearchDialog(OptionsSearcher* searcher) SearchDialog::SearchDialog(OptionsSearcher* searcher)
: GUI::DPIDialog(NULL, wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), : GUI::DPIDialog(GUI::wxGetApp().tab_panel(), wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
searcher(searcher) searcher(searcher)
{ {
SetFont(GUI::wxGetApp().normal_font()); SetFont(GUI::wxGetApp().normal_font());
@ -506,7 +521,8 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/)
if (check_english) if (check_english)
check_english->SetValue(params.english); check_english->SetValue(params.english);
this->SetPosition(position); if (position != wxDefaultPosition)
this->SetPosition(position);
this->ShowModal(); this->ShowModal();
} }

View file

@ -134,6 +134,8 @@ public:
return o1.key < o2.key; }); return o1.key < o2.key; });
} }
void sort_options_by_label() { sort_options(); } void sort_options_by_label() { sort_options(); }
void show_dialog();
}; };