mirror of https://github.com/KLayout/klayout.git
Pushing the new functions to the grid menu and adding the 'default' indicator as proposed
This commit is contained in:
parent
68e7b271c3
commit
1a4d943556
|
|
@ -4167,6 +4167,20 @@ MainWindow::default_grids () const
|
||||||
return m_default_grids;
|
return m_default_grids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
MainWindow::default_grid () const
|
||||||
|
{
|
||||||
|
lay::TechnologyController *tc = lay::TechnologyController::instance ();
|
||||||
|
if (tc && tc->active_technology ()) {
|
||||||
|
auto tech_grids = tc->active_technology ()->default_grid_list ();
|
||||||
|
if (! tech_grids.empty ()) {
|
||||||
|
return tc->active_technology ()->default_grid ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_default_grid;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWindow::change_grid (int dir)
|
MainWindow::change_grid (int dir)
|
||||||
{
|
{
|
||||||
|
|
@ -4204,35 +4218,49 @@ MainWindow::change_grid (int dir)
|
||||||
void
|
void
|
||||||
MainWindow::do_update_grids ()
|
MainWindow::do_update_grids ()
|
||||||
{
|
{
|
||||||
const std::vector<double> *grids = &m_default_grids;
|
std::vector<double> grids = default_grids ();
|
||||||
double default_grid = m_default_grid;
|
double def_grid = default_grid ();
|
||||||
|
|
||||||
std::vector<double> tech_grids;
|
if (def_grid > db::epsilon) {
|
||||||
lay::TechnologyController *tc = lay::TechnologyController::instance ();
|
for (auto g = grids.begin (); g != grids.end (); ++g) {
|
||||||
if (tc && tc->active_technology ()) {
|
|
||||||
tech_grids = tc->active_technology ()->default_grid_list ();
|
|
||||||
if (! tech_grids.empty ()) {
|
|
||||||
grids = &tech_grids;
|
|
||||||
default_grid = tc->active_technology ()->default_grid ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (default_grid > db::epsilon) {
|
|
||||||
for (auto g = grids->begin (); g != grids->end (); ++g) {
|
|
||||||
if (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron)) {
|
if (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron)) {
|
||||||
default_grid = 0.0;
|
def_grid = 0.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_grid > db::epsilon) {
|
if (def_grid > db::epsilon) {
|
||||||
dispatcher ()->config_set (cfg_grid, default_grid);
|
dispatcher ()->config_set (cfg_grid, def_grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
do_update_menu ();
|
do_update_menu ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class GenericMenuAction
|
||||||
|
: public Action
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GenericMenuAction (lay::Dispatcher *dispatcher, const std::string &title, const std::string &symbol)
|
||||||
|
: Action (title), mp_dispatcher (dispatcher), m_symbol (symbol)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void triggered ()
|
||||||
|
{
|
||||||
|
if (mp_dispatcher) {
|
||||||
|
mp_dispatcher->menu_activated (m_symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Dispatcher *mp_dispatcher;
|
||||||
|
std::string m_symbol;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWindow::do_update_menu ()
|
MainWindow::do_update_menu ()
|
||||||
{
|
{
|
||||||
|
|
@ -4241,14 +4269,21 @@ MainWindow::do_update_menu ()
|
||||||
m_default_grids_updated = false;
|
m_default_grids_updated = false;
|
||||||
|
|
||||||
std::vector<double> grids = default_grids ();
|
std::vector<double> grids = default_grids ();
|
||||||
|
double def_grid = default_grid ();
|
||||||
|
|
||||||
std::vector<std::string> group = menu ()->group ("default_grids_group");
|
std::vector<std::string> group = menu ()->group ("default_grids_group");
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator t = group.begin (); t != group.end (); ++t) {
|
for (std::vector<std::string>::const_iterator t = group.begin (); t != group.end (); ++t) {
|
||||||
|
|
||||||
std::vector<std::string> items = menu ()->items (*t);
|
std::vector<std::string> items = menu ()->items (*t);
|
||||||
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
|
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
|
||||||
menu ()->delete_item (*i);
|
menu ()->delete_item (*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu ()->insert_item (*t + ".end", "finer_grid", new GenericMenuAction (dispatcher (), tl::to_string (tr ("Finer Grid(G)")), "cm_grid_decrease"));
|
||||||
|
menu ()->insert_item (*t + ".end", "coarser_grid", new GenericMenuAction (dispatcher (), tl::to_string (tr ("Coarser Grid(Shift+G)")), "cm_grid_increase"));
|
||||||
|
menu ()->insert_separator (*t + ".end", "default_grids_group_separator");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
@ -4264,6 +4299,10 @@ MainWindow::do_update_menu ()
|
||||||
gs = tl::to_string (*g) + tl::to_string (QObject::tr (" um"));
|
gs = tl::to_string (*g) + tl::to_string (QObject::tr (" um"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def_grid > 0 && db::coord_traits<db::DCoord>::equals (*g, def_grid)) {
|
||||||
|
gs += tl::to_string (tr (" \\(default)"));
|
||||||
|
}
|
||||||
|
|
||||||
lay::Action *ga = new lay::ConfigureAction (gs, cfg_grid, tl::to_string (*g));
|
lay::Action *ga = new lay::ConfigureAction (gs, cfg_grid, tl::to_string (*g));
|
||||||
ga->set_checkable (true);
|
ga->set_checkable (true);
|
||||||
ga->set_checked (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron));
|
ga->set_checked (db::coord_traits<db::DCoord>::equals (*g, m_grid_micron));
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,20 @@ public:
|
||||||
*/
|
*/
|
||||||
std::vector<double> default_grids () const;
|
std::vector<double> default_grids () const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the default grid
|
||||||
|
*
|
||||||
|
* The default (fallback) grid is the one marked with "!" in the grid list
|
||||||
|
* and it is used, when the current grid is not one of the provided grids
|
||||||
|
* in the default grid list.
|
||||||
|
*
|
||||||
|
* The default grid is globally defined, but my change depending on the technology
|
||||||
|
* selected in the current view.
|
||||||
|
*
|
||||||
|
* If no such grid exists, 0 is returned.
|
||||||
|
*/
|
||||||
|
double default_grid () const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hierarchy level selection setter
|
* @brief Hierarchy level selection setter
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2154,8 +2154,6 @@ public:
|
||||||
menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (tr ("Move Interactive"))));
|
menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (tr ("Move Interactive"))));
|
||||||
menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (tr ("Select Next Item(Space)"))));
|
menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (tr ("Select Next Item(Space)"))));
|
||||||
menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (tr ("Select Next Item too(Shift+Space)"))));
|
menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (tr ("Select Next Item too(Shift+Space)"))));
|
||||||
menu_entries.push_back (lay::menu_item ("cm_grid_decrease", "grid_decrease:edit", at, tl::to_string (tr ("Select Finer Grid(G)"))));
|
|
||||||
menu_entries.push_back (lay::menu_item ("cm_grid_increase", "grid_increase:edit", at, tl::to_string (tr ("Select Coarser Grid(Shift+G)"))));
|
|
||||||
|
|
||||||
at = "edit_menu.edit_options_group";
|
at = "edit_menu.edit_options_group";
|
||||||
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (tr ("Undo(Ctrl+Z)"))));
|
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (tr ("Undo(Ctrl+Z)"))));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue