Implemented relative margin for shape and instance browser

This commit is contained in:
Matthias Koefferlein 2023-08-06 10:25:35 +02:00
parent 4a51365ef2
commit 29e1bf9860
9 changed files with 200 additions and 213 deletions

View File

@ -26,32 +26,27 @@
<string>Search Result Browser Configuration</string> <string>Search Result Browser Configuration</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout">
<property name="margin" stdset="0">
<number>9</number>
</property>
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="4"> <item row="0" column="2">
<widget class="QLabel" name="textLabel2"> <spacer>
<property name="text"> <property name="orientation">
<string>µm</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>21</height>
</size>
</property>
</spacer>
</item> </item>
<item row="1" column="0" colspan="3"> <item row="1" column="3">
<widget class="QLabel" name="label"> <widget class="QLineEdit" name="le_max_items"/>
<property name="text">
<string>Maximum number of items to show</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="textLabel1_2">
<property name="text">
<string>Window </string>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="cbx_window"> <widget class="QComboBox" name="cbx_window">
@ -82,28 +77,23 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="0">
<spacer> <widget class="QLabel" name="textLabel1_2">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Window </string>
</property> </property>
<property name="sizeType"> </widget>
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_max_items"/>
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="lay::MarginWidget" name="mrg_window" native="true"/> <widget class="lay::MarginWidget" name="mrg_window" native="true"/>
</item> </item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum number of items to show</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -1,53 +1,52 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BrowseInstancesConfigPage</class> <class>BrowseInstancesConfigPage</class>
<widget class="QFrame" name="BrowseInstancesConfigPage" > <widget class="QFrame" name="BrowseInstancesConfigPage">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>499</width> <width>499</width>
<height>148</height> <height>151</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Browse Cell Instances</string> <string>Browse Cell Instances</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<property name="margin" > <property name="spacing">
<number>9</number>
</property>
<property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" stdset="0">
<number>9</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBox" > <widget class="QGroupBox" name="groupBox">
<property name="title" > <property name="title">
<string>Instance Browser Setup</string> <string>Instance Browser Setup</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="margin" stdset="0">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="2" > <item row="0" column="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Minimum</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>16</width> <width>16</width>
<height>27</height> <height>27</height>
@ -55,62 +54,62 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="3" colspan="2" > <item row="0" column="3" colspan="2">
<widget class="QLineEdit" name="le_cell_name" > <widget class="QLineEdit" name="le_cell_name">
<property name="enabled" > <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3" > <item row="2" column="0" colspan="3">
<widget class="QLabel" name="label" > <widget class="QLabel" name="label">
<property name="text" > <property name="text">
<string>Maximum number of instances to show</string> <string>Maximum number of instances to show</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QComboBox" name="cbx_context" > <widget class="QComboBox" name="cbx_context">
<item> <item>
<property name="text" > <property name="text">
<string>Show in context of cell ..</string> <string>Show in context of cell ..</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Show in context of any top cell</string> <string>Show in context of any top cell</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Show in parent cell</string> <string>Show in parent cell</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="textLabel1" > <widget class="QLabel" name="textLabel1">
<property name="text" > <property name="text">
<string>Context </string> <string>Context </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QLabel" name="textLabel1_2" > <widget class="QLabel" name="textLabel1_2">
<property name="text" > <property name="text">
<string>Window</string> <string>Window</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2" > <item row="1" column="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Minimum</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>16</width> <width>16</width>
<height>25</height> <height>25</height>
@ -118,58 +117,55 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QComboBox" name="cbx_window" > <widget class="QComboBox" name="cbx_window">
<item> <item>
<property name="text" > <property name="text">
<string>Don't change</string> <string>Don't change</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Fit whole context cell</string> <string>Fit whole context cell</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Fit marker with margin ..</string> <string>Fit marker with margin ..</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Center marker</string> <string>Center marker</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Center marker with size ..</string> <string>Center marker with size ..</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="3" > <item row="1" column="3" colspan="2">
<widget class="QLineEdit" name="le_window" > <widget class="lay::MarginWidget" name="mrg_window" native="true"/>
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item> </item>
<item row="2" column="3" > <item row="2" column="3" colspan="2">
<widget class="QLineEdit" name="le_max_count" /> <widget class="QLineEdit" name="le_max_count"/>
</item>
<item row="1" column="4" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>µm</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>lay::MarginWidget</class>
<extends>QWidget</extends>
<header>layWidgets.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,7 +1,8 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BrowseShapesConfigPage</class> <class>BrowseShapesConfigPage</class>
<widget class="QFrame" name="BrowseShapesConfigPage" > <widget class="QFrame" name="BrowseShapesConfigPage">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,61 +10,44 @@
<height>194</height> <height>194</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Browse Shapes</string> <string>Browse Shapes</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<property name="margin" > <property name="spacing">
<number>9</number>
</property>
<property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin" stdset="0">
<number>9</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBox" > <widget class="QGroupBox" name="groupBox">
<property name="title" > <property name="title">
<string>Shape Browser Setup</string> <string>Shape Browser Setup</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="margin" stdset="0">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="4" > <item row="0" column="3" colspan="2">
<widget class="QLabel" name="textLabel2" > <widget class="QLineEdit" name="le_cell_name">
<property name="text" > <property name="enabled">
<string>µm</string>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QLineEdit" name="le_window" >
<property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3" colspan="2" > <item row="0" column="2">
<widget class="QLineEdit" name="le_cell_name" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="3" >
<widget class="QLineEdit" name="le_max_shapes" />
</item>
<item row="0" column="2" >
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Minimum</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>10</width> <width>10</width>
<height>21</height> <height>21</height>
@ -71,15 +55,15 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="2" > <item row="1" column="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Minimum</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>10</width> <width>10</width>
<height>20</height> <height>20</height>
@ -87,91 +71,105 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QComboBox" name="cbx_context" > <widget class="QComboBox" name="cbx_context">
<item> <item>
<property name="text" > <property name="text">
<string>Show in context of cell ..</string> <string>Show in context of cell ..</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Show in context of any top cell</string> <string>Show in context of any top cell</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Show in context of local cell</string> <string>Show in context of local cell</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="3" > <item row="2" column="0" colspan="2">
<widget class="QLineEdit" name="le_max_inst" /> <widget class="QLabel" name="label">
</item> <property name="text">
<item row="2" column="0" colspan="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Maximum number of shapes to show</string> <string>Maximum number of shapes to show</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="textLabel1" > <widget class="QLabel" name="textLabel1">
<property name="text" > <property name="text">
<string>Context </string> <string>Context </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QComboBox" name="cbx_window" > <widget class="QComboBox" name="cbx_window">
<item> <item>
<property name="text" > <property name="text">
<string>Don't change</string> <string>Don't change</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Fit context cell</string> <string>Fit context cell</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Fit marker with margin ..</string> <string>Fit marker with margin ..</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Center marker</string> <string>Center marker</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text" > <property name="text">
<string>Center marker with size ..</string> <string>Center marker with size ..</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2" > <item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2">
<property name="text" > <property name="text">
<string>Maximum number of instances to show</string> <string>Maximum number of instances to show</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QLabel" name="textLabel1_2" > <widget class="QLabel" name="textLabel1_2">
<property name="text" > <property name="text">
<string>Window </string> <string>Window </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3" colspan="2">
<widget class="lay::MarginWidget" name="mrg_window" native="true"/>
</item>
<item row="2" column="3" colspan="2">
<widget class="QLineEdit" name="le_max_shapes"/>
</item>
<item row="3" column="3" colspan="2">
<widget class="QLineEdit" name="le_max_inst"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>lay::MarginWidget</class>
<extends>QWidget</extends>
<header>layWidgets.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -200,9 +200,9 @@ BrowseInstancesConfigPage::setup (lay::Dispatcher *root)
cbx_window->setCurrentIndex (int (wmode)); cbx_window->setCurrentIndex (int (wmode));
// window dimension // window dimension
double wdim = 1.0; std::string wdim_str;
root->config_get (cfg_cib_window_dim, wdim); root->config_get (cfg_cib_window_dim, wdim_str);
le_window->setText (tl::to_qstring (tl::to_string (wdim))); mrg_window->set_margin (lay::Margin::from_string (wdim_str));
// max. instance count // max. instance count
unsigned int max_inst_count = 1000; unsigned int max_inst_count = 1000;
@ -223,22 +223,19 @@ BrowseInstancesConfigPage::context_changed (int m)
void void
BrowseInstancesConfigPage::window_changed (int m) BrowseInstancesConfigPage::window_changed (int m)
{ {
le_window->setEnabled (m == int (BrowseInstancesForm::FitMarker) || m == int (BrowseInstancesForm::CenterSize)); mrg_window->setEnabled (m == int (BrowseInstancesForm::FitMarker) || m == int (BrowseInstancesForm::CenterSize));
} }
void void
BrowseInstancesConfigPage::commit (lay::Dispatcher *root) BrowseInstancesConfigPage::commit (lay::Dispatcher *root)
{ {
double dim = 1.0;
tl::from_string_ext (tl::to_string (le_window->text ()), dim);
unsigned int max_inst_count = 1000; unsigned int max_inst_count = 1000;
tl::from_string_ext (tl::to_string (le_max_count->text ()), max_inst_count); tl::from_string_ext (tl::to_string (le_max_count->text ()), max_inst_count);
root->config_set (cfg_cib_context_cell, tl::to_string (le_cell_name->text ())); root->config_set (cfg_cib_context_cell, tl::to_string (le_cell_name->text ()));
root->config_set (cfg_cib_context_mode, BrowseInstancesForm::mode_type (cbx_context->currentIndex ()), BrowseInstancesContextModeConverter ()); root->config_set (cfg_cib_context_mode, BrowseInstancesForm::mode_type (cbx_context->currentIndex ()), BrowseInstancesContextModeConverter ());
root->config_set (cfg_cib_window_mode, BrowseInstancesForm::window_type (cbx_window->currentIndex ()), BrowseInstancesWindowModeConverter ()); root->config_set (cfg_cib_window_mode, BrowseInstancesForm::window_type (cbx_window->currentIndex ()), BrowseInstancesWindowModeConverter ());
root->config_set (cfg_cib_window_dim, dim); root->config_set (cfg_cib_window_dim, mrg_window->get_margin ().to_string ());
root->config_set (cfg_cib_max_inst_count, max_inst_count); root->config_set (cfg_cib_max_inst_count, max_inst_count);
} }
@ -306,7 +303,7 @@ BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutViewBase
m_ef_enabled (true), m_ef_enabled (true),
m_mode (AnyTop), m_mode (AnyTop),
m_window (FitMarker), m_window (FitMarker),
m_window_dim (0.0), m_window_dim (),
m_max_inst_count (0), m_max_inst_count (0),
m_current_count (0) m_current_count (0)
{ {
@ -390,9 +387,8 @@ BrowseInstancesForm::configure (const std::string &name, const std::string &valu
} else if (name == cfg_cib_window_dim) { } else if (name == cfg_cib_window_dim) {
double wdim = m_window_dim; lay::Margin wdim = lay::Margin::from_string (value);
tl::from_string (value, wdim); if (wdim != m_window_dim) {
if (fabs (wdim - m_window_dim) > 1e-6) {
m_window_dim = wdim; m_window_dim = wdim;
need_update = true; need_update = true;
} }
@ -787,16 +783,18 @@ BrowseInstancesForm::highlight_current ()
if (index_set) { if (index_set) {
double window_dim = m_window_dim.get (dbox);
view ()->select_cell (index, m_cv_index); view ()->select_cell (index, m_cv_index);
if (m_window == FitCell) { if (m_window == FitCell) {
view ()->zoom_fit (); view ()->zoom_fit ();
} else if (m_window == FitMarker) { } 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) { } else if (m_window == Center) {
view ()->pan_center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); view ()->pan_center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5);
} else if (m_window == CenterSize) { } else if (m_window == CenterSize) {
double w = std::max (dbox.width (), m_window_dim); double w = std::max (dbox.width (), window_dim);
double h = std::max (dbox.height (), m_window_dim); double h = std::max (dbox.height (), window_dim);
db::DPoint center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); db::DPoint center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5);
db::DVector d (w * 0.5, h * 0.5); db::DVector d (w * 0.5, h * 0.5);
view ()->zoom_box (db::DBox (center - d, center + d)); view ()->zoom_box (db::DBox (center - d, center + d));

View File

@ -29,6 +29,7 @@
#include "ui_BrowseInstancesConfigPage.h" #include "ui_BrowseInstancesConfigPage.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"
#include "layMargin.h"
#include "layPluginConfigPage.h" #include "layPluginConfigPage.h"
#include "layBrowser.h" #include "layBrowser.h"
#include "layMarker.h" #include "layMarker.h"
@ -98,7 +99,7 @@ private:
mode_type m_mode; mode_type m_mode;
window_type m_window; window_type m_window;
double m_window_dim; lay::Margin m_window_dim;
std::string m_context_cell; std::string m_context_cell;
unsigned int m_max_inst_count; unsigned int m_max_inst_count;

View File

@ -202,9 +202,9 @@ BrowseShapesConfigPage::setup (lay::Dispatcher *root)
cbx_window->setCurrentIndex (int (wmode)); cbx_window->setCurrentIndex (int (wmode));
// window dimension // window dimension
double wdim = 1.0; std::string wdim_str;
root->config_get (cfg_shb_window_dim, wdim); root->config_get (cfg_shb_window_dim, wdim_str);
le_window->setText (tl::to_qstring (tl::to_string (wdim))); mrg_window->set_margin (lay::Margin::from_string (wdim_str));
// max. instance count // max. instance count
unsigned int max_inst_count = 1000; unsigned int max_inst_count = 1000;
@ -230,15 +230,12 @@ BrowseShapesConfigPage::context_changed (int m)
void void
BrowseShapesConfigPage::window_changed (int m) BrowseShapesConfigPage::window_changed (int m)
{ {
le_window->setEnabled (m == int (BrowseShapesForm::FitMarker) || m == int (BrowseShapesForm::CenterSize)); mrg_window->setEnabled (m == int (BrowseShapesForm::FitMarker) || m == int (BrowseShapesForm::CenterSize));
} }
void void
BrowseShapesConfigPage::commit (lay::Dispatcher *root) BrowseShapesConfigPage::commit (lay::Dispatcher *root)
{ {
double dim = 1.0;
tl::from_string_ext (tl::to_string (le_window->text ()), dim);
unsigned int max_inst_count = 1000; unsigned int max_inst_count = 1000;
tl::from_string_ext (tl::to_string (le_max_inst->text ()), max_inst_count); tl::from_string_ext (tl::to_string (le_max_inst->text ()), max_inst_count);
@ -248,7 +245,7 @@ BrowseShapesConfigPage::commit (lay::Dispatcher *root)
root->config_set (cfg_shb_context_cell, tl::to_string (le_cell_name->text ())); root->config_set (cfg_shb_context_cell, tl::to_string (le_cell_name->text ()));
root->config_set (cfg_shb_context_mode, BrowseShapesForm::mode_type (cbx_context->currentIndex ()), BrowseShapesContextModeConverter ()); root->config_set (cfg_shb_context_mode, BrowseShapesForm::mode_type (cbx_context->currentIndex ()), BrowseShapesContextModeConverter ());
root->config_set (cfg_shb_window_mode, BrowseShapesForm::window_type (cbx_window->currentIndex ()), BrowseShapesWindowModeConverter ()); root->config_set (cfg_shb_window_mode, BrowseShapesForm::window_type (cbx_window->currentIndex ()), BrowseShapesWindowModeConverter ());
root->config_set (cfg_shb_window_dim, dim); root->config_set (cfg_shb_window_dim, mrg_window->get_margin ().to_string ());
root->config_set (cfg_shb_max_inst_count, max_inst_count); root->config_set (cfg_shb_max_inst_count, max_inst_count);
root->config_set (cfg_shb_max_shape_count, max_shape_count); root->config_set (cfg_shb_max_shape_count, max_shape_count);
} }
@ -409,7 +406,7 @@ BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *vw)
m_ef_enabled (true), m_ef_enabled (true),
m_mode (AnyTop), m_mode (AnyTop),
m_window (FitMarker), m_window (FitMarker),
m_window_dim (0.0), m_window_dim (),
m_max_inst_count (0), m_max_inst_count (0),
m_max_shape_count (0) m_max_shape_count (0)
{ {
@ -496,9 +493,8 @@ BrowseShapesForm::configure (const std::string &name, const std::string &value)
} else if (name == cfg_shb_window_dim) { } else if (name == cfg_shb_window_dim) {
double wdim = m_window_dim; lay::Margin wdim = lay::Margin::from_string (value);
tl::from_string (value, wdim); if (wdim != m_window_dim) {
if (fabs (wdim - m_window_dim) > 1e-6) {
m_window_dim = wdim; m_window_dim = wdim;
need_update = true; need_update = true;
} }
@ -961,16 +957,18 @@ BrowseShapesForm::highlight_current ()
if (! dbox.empty ()) { if (! dbox.empty ()) {
double window_dim = m_window_dim.get (dbox);
view ()->select_cell (cell_index, m_cv_index); view ()->select_cell (cell_index, m_cv_index);
if (m_window == FitCell) { if (m_window == FitCell) {
view ()->zoom_fit (); view ()->zoom_fit ();
} else if (m_window == FitMarker) { } 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) { } else if (m_window == Center) {
view ()->pan_center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); view ()->pan_center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5);
} else if (m_window == CenterSize) { } else if (m_window == CenterSize) {
double w = std::max (dbox.width (), m_window_dim); double w = std::max (dbox.width (), window_dim);
double h = std::max (dbox.height (), m_window_dim); double h = std::max (dbox.height (), window_dim);
db::DPoint center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5); db::DPoint center (dbox.p1 () + (dbox.p2 () - dbox.p1 ()) * 0.5);
db::DVector d (w * 0.5, h * 0.5); db::DVector d (w * 0.5, h * 0.5);
view ()->zoom_box (db::DBox (center - d, center + d)); view ()->zoom_box (db::DBox (center - d, center + d));

View File

@ -29,6 +29,7 @@
#include "ui_BrowseShapesConfigPage.h" #include "ui_BrowseShapesConfigPage.h"
#include "layLayoutViewBase.h" #include "layLayoutViewBase.h"
#include "layMargin.h"
#include "layPluginConfigPage.h" #include "layPluginConfigPage.h"
#include "layBrowser.h" #include "layBrowser.h"
#include "layMarker.h" #include "layMarker.h"
@ -99,7 +100,7 @@ private:
mode_type m_mode; mode_type m_mode;
window_type m_window; window_type m_window;
double m_window_dim; lay::Margin m_window_dim;
std::string m_context_cell; std::string m_context_cell;
unsigned int m_max_inst_count; unsigned int m_max_inst_count;

View File

@ -1081,7 +1081,7 @@ ColorButton::browse_selected ()
// MarginWidget implementation // MarginWidget implementation
MarginWidget::MarginWidget (QWidget *parent, const char *name) MarginWidget::MarginWidget (QWidget *parent, const char *name)
: QFrame (parent) : QFrame (parent), m_margin ()
{ {
if (name) { if (name) {
setObjectName (name); setObjectName (name);
@ -1105,13 +1105,12 @@ MarginWidget::MarginWidget (QWidget *parent, const char *name)
QComboBox *mode = new QComboBox (this); QComboBox *mode = new QComboBox (this);
mode->addItem (tl::to_qstring ("µm")); mode->addItem (tl::to_qstring ("µm"));
mode->addItem (tl::to_qstring ("%")); mode->addItem (tl::to_qstring ("%"));
mode->setCurrentIndex (0);
mp_mode_cb = mode; mp_mode_cb = mode;
layout->addWidget (mode); layout->addWidget (mode);
connect (mode, SIGNAL (currentIndexChanged (int)), this, SLOT (mode_selection_changed ())); connect (mode, SIGNAL (currentIndexChanged (int)), this, SLOT (mode_selection_changed ()));
mode_selection_changed (); set_margin (lay::Margin ());
} }
lay::Margin lay::Margin
@ -1122,16 +1121,21 @@ MarginWidget::get_margin () const
tl::from_string (tl::to_string (mp_rel_edit->text ()), rel); tl::from_string (tl::to_string (mp_rel_edit->text ()), rel);
tl::from_string (tl::to_string (mp_abs_edit->text ()), abs); tl::from_string (tl::to_string (mp_abs_edit->text ()), abs);
lay::Margin m; lay::Margin m = m_margin;
m.set_relative_mode (rel_mode); m.set_relative_mode (rel_mode);
m.set_absolute_value (abs); if (rel_mode) {
m.set_relative_value (rel * 0.01); m.set_relative_value (rel * 0.01);
} else {
m.set_absolute_value (abs);
}
return m; return m;
} }
void void
MarginWidget::set_margin (const lay::Margin &margin) MarginWidget::set_margin (const lay::Margin &margin)
{ {
m_margin = margin;
mp_abs_edit->setText (tl::to_qstring (tl::to_string (margin.absolute_value ()))); mp_abs_edit->setText (tl::to_qstring (tl::to_string (margin.absolute_value ())));
mp_rel_edit->setText (tl::to_qstring (tl::to_string (margin.relative_value () * 100.0))); mp_rel_edit->setText (tl::to_qstring (tl::to_string (margin.relative_value () * 100.0)));
mp_mode_cb->setCurrentIndex (margin.relative_mode () ? 1 : 0); mp_mode_cb->setCurrentIndex (margin.relative_mode () ? 1 : 0);

View File

@ -341,6 +341,7 @@ private:
QLineEdit *mp_abs_edit; QLineEdit *mp_abs_edit;
QLineEdit *mp_rel_edit; QLineEdit *mp_rel_edit;
QComboBox *mp_mode_cb; QComboBox *mp_mode_cb;
lay::Margin m_margin;
}; };
/** /**