Skip to content

Commit

Permalink
Implemented solution for issue #1741 (Feature request: tooltip string…
Browse files Browse the repository at this point in the history
… for PCell parameter)
  • Loading branch information
Matthias Koefferlein committed Jun 29, 2024
1 parent 564861a commit a5b98f9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/db/db/built-in-macros/pcell_declaration_helper.lym
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ Optional, named parameters are
@li
@b:unit@/b: the unit string
@/li
@li
@btooltip@/b: the tool tip text displayed on the edit fields and labels
@/li
@li
@b:min_value@/b: the minimum value (effective for numerical types and if no choices are present)
@/li
Expand Down Expand Up @@ -378,6 +381,7 @@ module RBA

# set additional attributes of the parameters
args[:default] && pdecl.default = args[:default]
args[:tooltip] && pdecl.tooltip = args[:tooltip]
args[:hidden] && pdecl.hidden = args[:hidden]
args[:readonly] && pdecl.readonly = args[:readonly]
args[:unit] && pdecl.unit = args[:unit]
Expand Down
3 changes: 3 additions & 0 deletions src/db/db/built-in-pymacros/pcell_declaration_helper.lym
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ Optional, named parameters are
@li
@bunit@/b: the unit string
@/li
@li
@btooltip@/b: the tool tip text displayed on the edit fields and labels
@/li
@li
@bmin_value@/b: the minimum value (effective for numerical types and if no choices are present)
@/li
Expand Down
19 changes: 18 additions & 1 deletion src/db/db/dbPCellDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ class DB_PUBLIC PCellParameterDeclaration
m_description = description;
}

/**
* @brief Getter for the tooltip property
*/
const std::string &get_tooltip () const
{
return m_tooltip;
}

/**
* @brief Setter for the tooltip property
*/
void set_tooltip (const std::string &tooltip)
{
m_tooltip = tooltip;
}

/**
* @brief Getter for the type property
*/
Expand Down Expand Up @@ -331,6 +347,7 @@ class DB_PUBLIC PCellParameterDeclaration
m_type == d.m_type &&
m_name == d.m_name &&
m_description == d.m_description &&
m_tooltip == d.m_tooltip &&
m_unit == d.m_unit &&
m_min_value == d.m_min_value &&
m_max_value == d.m_max_value;
Expand All @@ -343,7 +360,7 @@ class DB_PUBLIC PCellParameterDeclaration
bool m_hidden, m_readonly;
type m_type;
std::string m_name;
std::string m_description, m_unit;
std::string m_description, m_tooltip, m_unit;
tl::Variant m_min_value, m_max_value;
};

Expand Down
8 changes: 8 additions & 0 deletions src/db/db/gsiDeclDbLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,14 @@ Class<db::PCellParameterDeclaration> decl_PCellParameterDeclaration ("db", "PCel
gsi::method ("description=", &db::PCellParameterDeclaration::set_description, gsi::arg ("description"),
"@brief Sets the description\n"
) +
gsi::method ("tooltip", &db::PCellParameterDeclaration::get_tooltip,
"@brief Gets the tool tip text\n"
"This attribute has been introduced in version 0.29.3."
) +
gsi::method ("tooltip=", &db::PCellParameterDeclaration::set_tooltip, gsi::arg ("tooltip"),
"@brief Sets the tool tip text\n"
"This attribute has been introduced in version 0.29.3."
) +
gsi::method ("hidden?", &db::PCellParameterDeclaration::is_hidden,
"@brief Returns true, if the parameter is a hidden parameter that should not be shown in the user interface\n"
"By making a parameter hidden, it is possible to create internal parameters which cannot be\n"
Expand Down
10 changes: 7 additions & 3 deletions src/edt/edt/edtPCellParametersPage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::P
leader = tl::sprintf ("[%s] ", p->get_name ());
}

QLabel *l = new QLabel (tl::to_qstring (leader + description + range), inner_frame);

QLabel *l = new QLabel (tl::to_qstring (leader + description + range), inner_frame);
inner_grid->addWidget (l, row, 1);
m_all_widgets.back ().push_back (l);

Expand Down Expand Up @@ -975,6 +974,7 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat
for (std::vector<db::PCellParameterDeclaration>::const_iterator p = pcp.begin (); p != pcp.end () && i < m_widgets.size (); ++p, ++i) {

const std::string &name = p->get_name ();
const std::string &static_tooltip = p->get_tooltip ();
const db::ParameterState &ps = states.parameter (name);

if (m_widgets [i]) {
Expand All @@ -994,7 +994,11 @@ PCellParametersPage::update_widgets_from_states (const db::ParameterStates &stat
if (*w != m_icon_widgets [i]) {
(*w)->setVisible (ps.is_visible ());
}
(*w)->setToolTip (tl::to_qstring (ps.tooltip ()));
if (ps.tooltip ().empty ()) {
(*w)->setToolTip (tl::to_qstring (static_tooltip));
} else {
(*w)->setToolTip (tl::to_qstring (ps.tooltip ()));
}
}

if (m_icon_widgets [i]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, *args, **kwargs):
self.layer = None
self.cell = None

def param(self, name, value_type, description, hidden = False, readonly = False, unit = None, default = None, choices = None, min_value = None, max_value = None):
def param(self, name, value_type, description, hidden = False, readonly = False, unit = None, default = None, choices = None, min_value = None, max_value = None, tooltip = None):
"""
Defines a parameter
name -> the short name of the parameter
Expand All @@ -79,6 +79,7 @@ def param(self, name, value_type, description, hidden = False, readonly = False,
min_value -> the minimum value (only effective for numerical types and if no choices are present)
max_value -> the maximum value (only effective for numerical types and if no choices are present)
default -> the default value
tooltip -> tool tip text
choices -> ([ [ d, v ], ...) choice descriptions/value for choice type
this method defines accessor methods for the parameters
{name} -> read accessor
Expand All @@ -104,6 +105,8 @@ def param(self, name, value_type, description, hidden = False, readonly = False,
pdecl.readonly = readonly
if not (default is None):
pdecl.default = default
if not (tooltip is None):
pdecl.tooltip = tooltip
pdecl.min_value = min_value
pdecl.max_value = max_value
if not (unit is None):
Expand Down
2 changes: 2 additions & 0 deletions testdata/ruby/dbPCells.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def test_1
assert_equal(decl.description, "d")
decl.unit = "u"
assert_equal(decl.unit, "u")
decl.tooltip = "ttt"
assert_equal(decl.tooltip, "ttt")
decl.type = RBA::PCellParameterDeclaration::TypeBoolean
assert_equal(decl.type, RBA::PCellParameterDeclaration::TypeBoolean)
decl.default = true
Expand Down

0 comments on commit a5b98f9

Please sign in to comment.