mirror of https://github.com/KLayout/klayout.git
Refactoring OASIS reader which wasn't working in non-editable mode
This commit is contained in:
parent
34febff383
commit
b4d1aa131c
|
|
@ -727,9 +727,6 @@ Shapes::shape_type
|
|||
Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type prop_id)
|
||||
{
|
||||
tl_assert (! ref.is_array_member ());
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace_prop_id' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (ref.has_prop_id ()) {
|
||||
|
||||
|
|
@ -810,6 +807,10 @@ Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type p
|
|||
|
||||
} else {
|
||||
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace_prop_id' is permitted only in editable mode when going to property-less shapes to some with properties")));
|
||||
}
|
||||
|
||||
switch (ref.m_type) {
|
||||
case shape_type::Null:
|
||||
return ref;
|
||||
|
|
@ -1253,9 +1254,6 @@ void
|
|||
Shapes::replace_prop_id (const Sh *pos, db::properties_id_type prop_id)
|
||||
{
|
||||
if (pos->properties_id () != prop_id) {
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
check_is_editable_for_undo_redo ();
|
||||
db::layer_op<Sh, db::stable_layer_tag>::queue_or_append (manager (), this, false /*not insert*/, *pos);
|
||||
|
|
@ -1272,10 +1270,6 @@ template <class Sh, class Iter>
|
|||
Shapes::shape_type
|
||||
Shapes::replace_prop_id_iter (typename db::object_tag<Sh>, const Iter &iter, db::properties_id_type prop_id)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
check_is_editable_for_undo_redo ();
|
||||
db::layer_op<Sh, db::stable_layer_tag>::queue_or_append (manager (), this, false /*not insert*/, *iter);
|
||||
|
|
@ -1293,10 +1287,6 @@ template <class Sh1, class Sh2>
|
|||
Shapes::shape_type
|
||||
Shapes::reinsert_member_with_props (typename db::object_tag<Sh1>, const shape_type &ref, const Sh2 &sh)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
// the shape types are not equal - resolve into erase and insert (of new)
|
||||
if (! ref.has_prop_id ()) {
|
||||
erase_shape (ref);
|
||||
|
|
@ -1312,10 +1302,6 @@ template <class Sh1, class Sh2>
|
|||
Shapes::shape_type
|
||||
Shapes::replace_member_with_props (typename db::object_tag<Sh1>, const shape_type &ref, const Sh2 &sh)
|
||||
{
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
// the shape types are not equal - resolve into erase and insert (of new)
|
||||
if (! ref.has_prop_id ()) {
|
||||
erase_shape (ref);
|
||||
|
|
@ -1363,10 +1349,6 @@ Shapes::replace_member_with_props (typename db::object_tag<Sh> tag, const shape_
|
|||
|
||||
} else {
|
||||
|
||||
if (! is_editable ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode")));
|
||||
}
|
||||
|
||||
if (! ref.has_prop_id ()) {
|
||||
|
||||
if (manager () && manager ()->transacting ()) {
|
||||
|
|
|
|||
|
|
@ -1089,32 +1089,66 @@ OASISReader::do_read (db::Layout &layout)
|
|||
// Resolve forward references for stored shape and instance prop_ids.
|
||||
// This makes these shape and instance property IDs valid
|
||||
|
||||
for (auto p = m_forward_properties_for_instances.begin (); p != m_forward_properties_for_instances.end (); ++p) {
|
||||
{
|
||||
std::map <db::properties_id_type, db::properties_id_type> replaced_prop_ids;
|
||||
std::set <db::Instances *> instances_set;
|
||||
|
||||
db::PropertiesSet props = forward_properties (p->first);
|
||||
resolve_forward_references (props);
|
||||
for (auto p = m_forward_properties_for_instances.begin (); p != m_forward_properties_for_instances.end (); ++p) {
|
||||
|
||||
db::PropertiesSet props = forward_properties (p->first);
|
||||
resolve_forward_references (props);
|
||||
|
||||
replaced_prop_ids.insert (std::make_pair (p->first, db::properties_id (props)));
|
||||
|
||||
instances_set.insert (p->second.begin (), p->second.end ());
|
||||
|
||||
db::properties_id_type pid = db::properties_id (props);
|
||||
for (auto i = p->second.begin (); i != p->second.end (); ++i) {
|
||||
if (i->instances ()) {
|
||||
i->instances ()->replace_prop_id (*i, pid);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i = instances_set.begin (); i != instances_set.end (); ++i) {
|
||||
|
||||
for (auto ii = (*i)->begin (); ! ii.at_end (); ++ii) {
|
||||
auto pm = replaced_prop_ids.find (ii->prop_id ());
|
||||
if (pm != replaced_prop_ids.end ()) {
|
||||
(*i)->replace_prop_id (*ii, pm->second);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (auto p = m_forward_properties_for_shapes.begin (); p != m_forward_properties_for_shapes.end (); ++p) {
|
||||
{
|
||||
std::map <db::properties_id_type, db::properties_id_type> replaced_prop_ids;
|
||||
std::set <db::Shapes *> shapes_set;
|
||||
|
||||
db::PropertiesSet props = forward_properties (p->first);
|
||||
resolve_forward_references (props);
|
||||
for (auto p = m_forward_properties_for_shapes.begin (); p != m_forward_properties_for_shapes.end (); ++p) {
|
||||
|
||||
db::PropertiesSet props = forward_properties (p->first);
|
||||
resolve_forward_references (props);
|
||||
|
||||
replaced_prop_ids.insert (std::make_pair (p->first, db::properties_id (props)));
|
||||
|
||||
shapes_set.insert (p->second.begin (), p->second.end ());
|
||||
|
||||
db::properties_id_type pid = db::properties_id (props);
|
||||
for (auto i = p->second.begin (); i != p->second.end (); ++i) {
|
||||
if (i->shapes ()) {
|
||||
i->shapes ()-> replace_prop_id (*i, pid);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i = shapes_set.begin (); i != shapes_set.end (); ++i) {
|
||||
|
||||
for (auto ii = (*i)->begin (db::ShapeIterator::All); ! ii.at_end (); ) {
|
||||
auto pm = replaced_prop_ids.find (ii->prop_id ());
|
||||
if (ii.in_array ()) {
|
||||
if (pm != replaced_prop_ids.end ()) {
|
||||
(*i)->replace_prop_id (ii.array (), pm->second);
|
||||
}
|
||||
ii.finish_array ();
|
||||
} else {
|
||||
if (pm != replaced_prop_ids.end ()) {
|
||||
(*i)->replace_prop_id (*ii, pm->second);
|
||||
}
|
||||
++ii;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve forward cell properties and extract context strings
|
||||
|
|
@ -1266,13 +1300,13 @@ OASISReader::forward_properties (properties_id_type id) const
|
|||
void
|
||||
OASISReader::register_forward_property_for_shape (const db::Shape &shape)
|
||||
{
|
||||
m_forward_properties_for_shapes [shape.prop_id ()].push_back (shape);
|
||||
m_forward_properties_for_shapes [shape.prop_id ()].insert (shape.shapes ());
|
||||
}
|
||||
|
||||
void
|
||||
OASISReader::register_forward_property_for_instance (const db::Instance &instance)
|
||||
{
|
||||
m_forward_properties_for_instances [instance.prop_id ()].push_back (instance);
|
||||
m_forward_properties_for_instances [instance.prop_id ()].insert (instance.instances ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ private:
|
|||
|
||||
std::map <unsigned long, db::property_names_id_type> m_propname_forward_references;
|
||||
std::map <unsigned long, std::string> m_propvalue_forward_references;
|
||||
std::map <db::properties_id_type, std::list<db::Shape> > m_forward_properties_for_shapes;
|
||||
std::map <db::properties_id_type, std::list<db::Instance> > m_forward_properties_for_instances;
|
||||
std::map <db::properties_id_type, std::set<db::Shapes *> > m_forward_properties_for_shapes;
|
||||
std::map <db::properties_id_type, std::set<db::Instances *> > m_forward_properties_for_instances;
|
||||
std::map <db::cell_index_type, db::PropertiesSet> m_future_cell_properties;
|
||||
std::list<db::PropertiesSet> m_fwd_properties;
|
||||
db::property_names_id_type m_s_gds_property_name_id;
|
||||
|
|
|
|||
Loading…
Reference in New Issue