mirror of https://github.com/KLayout/klayout.git
Merge pull request #332 from KLayout/gridline-colors
Implemented individual colors for grid lines, axes and rulers (backgr…
This commit is contained in:
commit
cb541f935e
|
|
@ -1,136 +1,180 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GridNetConfigPage</class>
|
||||
<widget class="QFrame" name="GridNetConfigPage" >
|
||||
<property name="geometry" >
|
||||
<widget class="QFrame" name="GridNetConfigPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<height>204</height>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grid_group" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<widget class="QGroupBox" name="grid_group">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<property name="title">
|
||||
<string>Show background decoration</string>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Grid </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="Close style" >
|
||||
<property name="text" >
|
||||
<string>Close style</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2" >
|
||||
<widget class="QComboBox" name="style1_cbx" >
|
||||
<item row="2" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="style1_cbx">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Invisible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dots</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Light dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dotted lines, ten dots per division </string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Crosses</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Lines with ticks, ten ticks per division</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Checkerboard</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" colspan="2" >
|
||||
<widget class="QCheckBox" name="show_ruler" >
|
||||
<property name="text" >
|
||||
<string>Show Ruler</string>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<item row="5" column="0" colspan="5">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="style0_cbx">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Invisible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dots</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Light dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dotted lines, ten dots per division </string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Crosses</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Lines with ticks, ten ticks per division</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
|
|
@ -138,145 +182,202 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QPushButton" name="grid_net_color_pb" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<item row="10" column="2">
|
||||
<widget class="QPushButton" name="grid_ruler_color_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Far style</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<item row="1" column="0" colspan="5">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2" >
|
||||
<widget class="QComboBox" name="style2_cbx" >
|
||||
<item row="3" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="style2_cbx">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Invisible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dots</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Light dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dotted lines, ten dots per division </string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Crosses</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Lines with ticks, ten ticks per division</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Checkerboard</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Axis style</string>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Far style</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="2" >
|
||||
<widget class="QComboBox" name="style0_cbx" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Invisible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Dots</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Light dotted lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Dotted lines, ten dots per division </string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Crosses</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Lines</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Lines with ticks, ten ticks per division</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="Close style">
|
||||
<property name="text">
|
||||
<string>Close style</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Color (all)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="grid_grid_color_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Grid </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="show_ruler">
|
||||
<property name="text">
|
||||
<string>Show Ruler</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QPushButton" name="grid_axis_color_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="grid_net_color_pb">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Axis</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Ruler</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="5">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
@ -284,7 +385,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11" />
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ void
|
|||
GridNetPluginDeclaration::get_options (std::vector < std::pair<std::string, std::string> > &options) const
|
||||
{
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_color, "auto"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_ruler_color, "auto"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_axis_color, "auto"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_grid_color, "auto"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_style0, GridNetStyleConverter ().to_string (lay::GridNet::Invisible)));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_style1, GridNetStyleConverter ().to_string (lay::GridNet::Dots)));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_grid_style2, GridNetStyleConverter ().to_string (lay::GridNet::TenthDottedLines)));
|
||||
|
|
@ -119,6 +122,9 @@ GridNetConfigPage::GridNetConfigPage (QWidget *parent)
|
|||
mp_ui->setupUi (this);
|
||||
|
||||
mp_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_net_color_pb);
|
||||
mp_grid_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_grid_color_pb);
|
||||
mp_grid_axis_color_cbtn = new lay::ColorButton (mp_ui->grid_axis_color_pb);
|
||||
mp_grid_ruler_color_cbtn = new lay::ColorButton (mp_ui->grid_ruler_color_pb);
|
||||
}
|
||||
|
||||
GridNetConfigPage::~GridNetConfigPage ()
|
||||
|
|
@ -145,6 +151,15 @@ GridNetConfigPage::setup (lay::PluginRoot *root)
|
|||
root->config_get (cfg_grid_color, color, ColorConverter ());
|
||||
mp_grid_color_cbtn->set_color (color);
|
||||
|
||||
root->config_get (cfg_grid_grid_color, color, ColorConverter ());
|
||||
mp_grid_grid_color_cbtn->set_color (color);
|
||||
|
||||
root->config_get (cfg_grid_axis_color, color, ColorConverter ());
|
||||
mp_grid_axis_color_cbtn->set_color (color);
|
||||
|
||||
root->config_get (cfg_grid_ruler_color, color, ColorConverter ());
|
||||
mp_grid_ruler_color_cbtn->set_color (color);
|
||||
|
||||
lay::GridNet::GridStyle style;
|
||||
|
||||
style = lay::GridNet::Invisible;
|
||||
|
|
@ -166,6 +181,9 @@ GridNetConfigPage::commit (lay::PluginRoot *root)
|
|||
root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ());
|
||||
root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ());
|
||||
root->config_set (cfg_grid_color, mp_grid_color_cbtn->get_color (), lay::ColorConverter ());
|
||||
root->config_set (cfg_grid_grid_color, mp_grid_grid_color_cbtn->get_color (), lay::ColorConverter ());
|
||||
root->config_set (cfg_grid_axis_color, mp_grid_axis_color_cbtn->get_color (), lay::ColorConverter ());
|
||||
root->config_set (cfg_grid_ruler_color, mp_grid_ruler_color_cbtn->get_color (), lay::ColorConverter ());
|
||||
root->config_set (cfg_grid_style0, lay::GridNet::GridStyle (mp_ui->style0_cbx->currentIndex ()), GridNetStyleConverter ());
|
||||
root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ());
|
||||
root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ());
|
||||
|
|
@ -196,6 +214,24 @@ GridNet::configure (const std::string &name, const std::string &value)
|
|||
ColorConverter ().from_string (value, color);
|
||||
need_update = test_and_set (m_color, color);
|
||||
|
||||
} else if (name == cfg_grid_grid_color) {
|
||||
|
||||
QColor color;
|
||||
ColorConverter ().from_string (value, color);
|
||||
need_update = test_and_set (m_grid_color, color);
|
||||
|
||||
} else if (name == cfg_grid_axis_color) {
|
||||
|
||||
QColor color;
|
||||
ColorConverter ().from_string (value, color);
|
||||
need_update = test_and_set (m_axis_color, color);
|
||||
|
||||
} else if (name == cfg_grid_ruler_color) {
|
||||
|
||||
QColor color;
|
||||
ColorConverter ().from_string (value, color);
|
||||
need_update = test_and_set (m_ruler_color, color);
|
||||
|
||||
} else if (name == cfg_grid_style0) {
|
||||
|
||||
lay::GridNet::GridStyle style;
|
||||
|
|
@ -404,6 +440,17 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
color = QColor (128, 128, 128); // TODO: this is not a "real" automatic color ..
|
||||
}
|
||||
|
||||
QColor grid_color = color, axis_color = color, ruler_color = color;
|
||||
if (m_grid_color.isValid ()) {
|
||||
grid_color = m_grid_color;
|
||||
}
|
||||
if (m_axis_color.isValid ()) {
|
||||
axis_color = m_axis_color;
|
||||
}
|
||||
if (m_ruler_color.isValid ()) {
|
||||
ruler_color = m_ruler_color;
|
||||
}
|
||||
|
||||
// TODO: currently, the grid net can only be rendered to a bitmap canvas ..
|
||||
BitmapViewObjectCanvas *bmp_canvas = dynamic_cast<BitmapViewObjectCanvas *> (&canvas);
|
||||
if (! bmp_canvas) {
|
||||
|
|
@ -457,15 +504,15 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
|
||||
painter.fill_rect (QPoint (xoffset, vp.height () - yoffset - rh / 2),
|
||||
QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2),
|
||||
color);
|
||||
ruler_color);
|
||||
|
||||
painter.draw_rect (QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset - rh / 2),
|
||||
QPoint (xoffset + int (floor (0.5 + 2 * dgrid)), vp.height () - yoffset + rh / 2),
|
||||
color);
|
||||
ruler_color);
|
||||
|
||||
painter.draw_text (tl::sprintf ("%g \265m", grid * 2).c_str (),
|
||||
QPoint (xoffset + int (floor (0.5 + trans.ctrans (2 * grid))), vp.height () - yoffset - rh / 2 - 2),
|
||||
color, -1, 1);
|
||||
ruler_color, -1, 1);
|
||||
|
||||
if (mp_view->global_trans ().fp_trans () != db::DFTrans ()) {
|
||||
|
||||
|
|
@ -492,7 +539,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
QPoint p0 (xoffset + 2 * rh, vp.height () - yoffset - rh * 5);
|
||||
QPoint p1 = p0 + QPoint (int (floor (0.5 + (*e).p1 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p1 ().y () * 0.1 * rh * 4)));
|
||||
QPoint p2 = p0 + QPoint (int (floor (0.5 + (*e).p2 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p2 ().y () * 0.1 * rh * 4)));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, ruler_color);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -518,7 +565,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
n = nx;
|
||||
for (db::DCoord x = x1; n > 0; x += grid, --n) {
|
||||
for (db::DCoord y = y1; y < y2 + g * eps; y += g) {
|
||||
painter.set (draw_round (trans * db::DPoint (x, y), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (x, y), vp.height ()), grid_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -526,7 +573,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
n = ny;
|
||||
for (db::DCoord y = y1; n > 0; y += grid, --n) {
|
||||
for (db::DCoord x = x1; x < x2 + g * eps; x += g) {
|
||||
painter.set (draw_round (trans * db::DPoint (x, y), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (x, y), vp.height ()), grid_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -536,8 +583,8 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
for (db::DCoord x = x1; x < x2 + grid * eps; x += grid) {
|
||||
for (db::DCoord y = y1; y < y2 + grid * eps; y += grid) {
|
||||
QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ()));
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), color);
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -550,14 +597,14 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
for (db::DCoord x = x1; n > 0; x += grid, --n) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, grid_color);
|
||||
}
|
||||
|
||||
n = ny;
|
||||
for (db::DCoord y = y1; n > 0; y += grid, --n) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, grid_color);
|
||||
}
|
||||
|
||||
} else if (style == TenthMarkedLines) {
|
||||
|
|
@ -578,10 +625,10 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
for (db::DCoord x = x1; n > 0; x += grid, --n) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, grid_color);
|
||||
for (db::DCoord y = y1; y < y2 + g * eps; y += g) {
|
||||
QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ()));
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), color);
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,10 +636,10 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
for (db::DCoord y = y1; n > 0; y += grid, --n) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, grid_color);
|
||||
for (db::DCoord x = x1; x < x2 + g * eps; x += g) {
|
||||
QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ()));
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -604,7 +651,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
if (idx - 2.0 * floor (idx * 0.5) < 0.5) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x, y), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x + grid, y + grid), vp.height ()));
|
||||
painter.fill_rect (p1, p2 + QPoint (-1, 1), color);
|
||||
painter.fill_rect (p1, p2 + QPoint (-1, 1), grid_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -638,19 +685,19 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
// the way we iterate here is safe against integer overflow ..
|
||||
n = nx;
|
||||
for (db::DCoord x = x1; n > 0 && draw_xaxis; x += grid, --n) {
|
||||
painter.set (draw_round (trans * db::DPoint (x, 0.0), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (x, 0.0), vp.height ()), axis_color);
|
||||
}
|
||||
for (db::DCoord y = y1; y < y2 + g * eps && draw_yaxis; y += g) {
|
||||
painter.set (draw_round (trans * db::DPoint (0.0, y), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (0.0, y), vp.height ()), axis_color);
|
||||
}
|
||||
|
||||
if (m_style0 != Dots) {
|
||||
n = ny;
|
||||
for (db::DCoord y = y1; n > 0 && draw_yaxis; y += grid, --n) {
|
||||
painter.set (draw_round (trans * db::DPoint (0.0, y), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (0.0, y), vp.height ()), axis_color);
|
||||
}
|
||||
for (db::DCoord x = x1; x < x2 + g * eps && draw_xaxis; x += g) {
|
||||
painter.set (draw_round (trans * db::DPoint (x, 0.0), vp.height ()), color);
|
||||
painter.set (draw_round (trans * db::DPoint (x, 0.0), vp.height ()), axis_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -658,13 +705,13 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
|
||||
for (db::DCoord y = y1; y < y2 + grid * eps && draw_yaxis; y += grid) {
|
||||
QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ()));
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), color);
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color);
|
||||
}
|
||||
for (db::DCoord x = x1; x < x2 + grid * eps && draw_xaxis; x += grid) {
|
||||
QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ()));
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), color);
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color);
|
||||
}
|
||||
|
||||
} else if (m_style0 == Lines) {
|
||||
|
|
@ -673,13 +720,13 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
if (draw_yaxis) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, axis_color);
|
||||
}
|
||||
|
||||
if (draw_xaxis) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, axis_color);
|
||||
}
|
||||
|
||||
} else if (m_style0 == TenthMarkedLines) {
|
||||
|
|
@ -698,20 +745,20 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
|
|||
if (draw_yaxis) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, axis_color);
|
||||
for (db::DCoord y = y1; y < y2 + g * eps; y += g) {
|
||||
QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ()));
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), color);
|
||||
painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color);
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_xaxis) {
|
||||
QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ()));
|
||||
QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ()));
|
||||
painter.draw_line (p1, p2, color);
|
||||
painter.draw_line (p1, p2, axis_color);
|
||||
for (db::DCoord x = x1; x < x2 + g * eps; x += g) {
|
||||
QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ()));
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), color);
|
||||
painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ public:
|
|||
private:
|
||||
Ui::GridNetConfigPage *mp_ui;
|
||||
lay::ColorButton *mp_grid_color_cbtn;
|
||||
lay::ColorButton *mp_grid_grid_color_cbtn;
|
||||
lay::ColorButton *mp_grid_axis_color_cbtn;
|
||||
lay::ColorButton *mp_grid_ruler_color_cbtn;
|
||||
};
|
||||
|
||||
class GridNet
|
||||
|
|
@ -92,6 +95,9 @@ private:
|
|||
bool m_show_ruler;
|
||||
double m_grid;
|
||||
QColor m_color;
|
||||
QColor m_grid_color;
|
||||
QColor m_axis_color;
|
||||
QColor m_ruler_color;
|
||||
GridStyle m_style0;
|
||||
GridStyle m_style1;
|
||||
GridStyle m_style2;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ namespace lay
|
|||
static const std::string cfg_grid ("grid-micron");
|
||||
|
||||
static const std::string cfg_grid_color ("grid-color");
|
||||
static const std::string cfg_grid_ruler_color ("grid-ruler-color");
|
||||
static const std::string cfg_grid_axis_color ("grid-axis-color");
|
||||
static const std::string cfg_grid_grid_color ("grid-grid-color");
|
||||
static const std::string cfg_grid_style0 ("grid-style0");
|
||||
static const std::string cfg_grid_style1 ("grid-style1");
|
||||
static const std::string cfg_grid_style2 ("grid-style2");
|
||||
|
|
|
|||
Loading…
Reference in New Issue