WIP: library browser - take selected layer for default if there is no default layer

This commit is contained in:
Matthias Koefferlein 2019-08-02 23:40:54 +02:00
parent de9db84ac7
commit 741434dc13
2 changed files with 23 additions and 1 deletions

View File

@ -1138,6 +1138,20 @@ InstService::do_activated ()
return true; // start editing immediately
}
tl::Variant
InstService::get_default_layer_for_pcell ()
{
lay::LayerPropertiesConstIterator cl = view ()->current_layer ();
if (! cl.is_null () && ! cl->has_children () && (cl->source (true).cv_index() < 0 || cl->source (true).cv_index () == view ()->active_cellview_index ())) {
db::LayerProperties lp = cl->source (true).layer_props ();
if (! lp.is_null ()) {
return tl::Variant (lp);
}
}
return tl::Variant ();
}
bool
InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data)
{
@ -1171,7 +1185,11 @@ InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase
const std::vector<db::PCellParameterDeclaration> &pd = pcell_decl->parameter_declarations();
for (std::vector<db::PCellParameterDeclaration>::const_iterator i = pd.begin (); i != pd.end (); ++i) {
m_pcell_parameters.insert (std::make_pair (i->get_name (), i->get_default ()));
if (i->get_type () == db::PCellParameterDeclaration::t_layer && i->get_default ().is_nil ()) {
m_pcell_parameters.insert (std::make_pair (i->get_name (), get_default_layer_for_pcell ()));
} else {
m_pcell_parameters.insert (std::make_pair (i->get_name (), i->get_default ()));
}
}
do_begin_edit (p);
@ -1338,6 +1356,9 @@ InstService::make_cell (const lay::CellView &cv)
}
}
// make the parameters fit (i.e. PCells may not define consistent default parameters)
pc_decl->coerce_parameters (*layout, pv);
}
inst_cell_index = layout->get_pcell_variant (pci.second, pv);

View File

@ -241,6 +241,7 @@ private:
void update_marker ();
bool get_inst (db::CellInstArray &inst);
std::pair<bool, db::cell_index_type> make_cell (const lay::CellView &cv);
tl::Variant get_default_layer_for_pcell ();
};
}