From 4a51365ef268a79e21f2cd0b1f5b1936fb861598 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 6 Aug 2023 10:02:04 +0200 Subject: [PATCH] Implemented relative marker size for search & replace --- src/lay/lay/SearchReplaceConfigPage.ui | 94 ++++++++++++----------- src/lay/lay/laySearchReplaceConfigPage.cc | 13 ++-- src/lay/lay/laySearchReplaceDialog.cc | 13 ++-- src/lay/lay/laySearchReplaceDialog.h | 3 +- 4 files changed, 64 insertions(+), 59 deletions(-) diff --git a/src/lay/lay/SearchReplaceConfigPage.ui b/src/lay/lay/SearchReplaceConfigPage.ui index 10d32349e..aea0d8731 100644 --- a/src/lay/lay/SearchReplaceConfigPage.ui +++ b/src/lay/lay/SearchReplaceConfigPage.ui @@ -1,7 +1,8 @@ - + + SearchReplaceConfigPage - - + + 0 0 @@ -9,94 +10,87 @@ 158 - + Search Result Browser Configuration - - - 9 - - + + 6 + + 9 + - - + + Search Result Browser Configuration - - + + 9 - + 6 - - - + + + µm - - - - false - - - - - - + + + Maximum number of items to show - - - + + + Window - - + + - + Don't change - + Fit context cell - + Fit marker with margin .. - + Center marker - + Center marker with size .. - + - + Qt::Horizontal - + QSizePolicy::Minimum - + 10 21 @@ -104,18 +98,28 @@ - - + + + + + - + + + + lay::MarginWidget + QWidget +
layWidgets.h
+ 1 +
+
cbx_window - le_window le_max_items diff --git a/src/lay/lay/laySearchReplaceConfigPage.cc b/src/lay/lay/laySearchReplaceConfigPage.cc index 946ec0034..e0e93affb 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.cc +++ b/src/lay/lay/laySearchReplaceConfigPage.cc @@ -87,9 +87,9 @@ SearchReplaceConfigPage::setup (lay::Dispatcher *root) cbx_window->setCurrentIndex (int (wmode)); // window dimension - double wdim = 1.0; - root->config_get (cfg_sr_window_dim, wdim); - le_window->setText (tl::to_qstring (tl::to_string (wdim))); + std::string wdim_str; + root->config_get (cfg_sr_window_dim, wdim_str); + mrg_window->set_margin (lay::Margin::from_string (wdim_str)); // max. instance count unsigned int max_item_count = 1000; @@ -103,20 +103,19 @@ SearchReplaceConfigPage::setup (lay::Dispatcher *root) void SearchReplaceConfigPage::window_changed (int m) { - le_window->setEnabled (m == int (SearchReplaceDialog::FitMarker) || m == int (SearchReplaceDialog::CenterSize)); + mrg_window->setEnabled (m == int (SearchReplaceDialog::FitMarker) || m == int (SearchReplaceDialog::CenterSize)); } void SearchReplaceConfigPage::commit (lay::Dispatcher *root) { - double dim = 1.0; - tl::from_string_ext (tl::to_string (le_window->text ()), dim); + lay::Margin dim = mrg_window->get_margin (); unsigned int max_item_count = 1000; tl::from_string_ext (tl::to_string (le_max_items->text ()), max_item_count); root->config_set (cfg_sr_window_mode, SearchReplaceDialog::window_type (cbx_window->currentIndex ()), SearchReplaceWindowModeConverter ()); - root->config_set (cfg_sr_window_dim, dim); + root->config_set (cfg_sr_window_dim, dim.to_string ()); root->config_set (cfg_sr_max_item_count, max_item_count); } diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index dc856b88b..030b2b6a8 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -1125,9 +1125,8 @@ SearchReplaceDialog::configure (const std::string &name, const std::string &valu } else if (name == cfg_sr_window_dim) { - double wdim = m_window_dim; - tl::from_string (value, wdim); - if (fabs (wdim - m_window_dim) > 1e-6) { + lay::Margin wdim = lay::Margin::from_string (value); + if (wdim != m_window_dim) { m_window_dim = wdim; need_update = true; } @@ -1754,15 +1753,17 @@ SearchReplaceDialog::result_selection_changed () if (! dbox.empty ()) { + double window_dim = m_window_dim.get (dbox); + if (m_window == FitCell) { view ()->zoom_fit (); } else if (m_window == FitMarker) { - view ()->zoom_box (dbox.enlarged (db::DVector (m_window_dim, m_window_dim))); + view ()->zoom_box (dbox.enlarged (db::DVector (window_dim, window_dim))); } else if (m_window == Center) { view ()->pan_center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); } else if (m_window == CenterSize) { - double w = std::max (dbox.width (), m_window_dim); - double h = std::max (dbox.height (), m_window_dim); + double w = std::max (dbox.width (), window_dim); + double h = std::max (dbox.height (), window_dim); db::DPoint center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); db::DVector d (w * 0.5, h * 0.5); view ()->zoom_box (db::DBox (center - d, center + d)); diff --git a/src/lay/lay/laySearchReplaceDialog.h b/src/lay/lay/laySearchReplaceDialog.h index ed5f90183..1e942f2b5 100644 --- a/src/lay/lay/laySearchReplaceDialog.h +++ b/src/lay/lay/laySearchReplaceDialog.h @@ -27,6 +27,7 @@ #include "ui_SearchReplaceDialog.h" #include "layBrowser.h" +#include "layMargin.h" #include "rdb.h" #include "dbLayout.h" #include "dbShape.h" @@ -180,7 +181,7 @@ private: int m_current_mode; window_type m_window; - double m_window_dim; + lay::Margin m_window_dim; unsigned int m_max_item_count; std::vector mp_markers;