Fixed #77 (copy_tree should work in non-editable mode too)

This commit is contained in:
Matthias Koefferlein 2018-02-21 07:47:41 +01:00
parent a272ba39a7
commit 5f4e715dcf
2 changed files with 778 additions and 884 deletions

View File

@ -883,8 +883,6 @@ static bool cell_has_prop_id (const db::Cell *c)
static void delete_cell_property (db::Cell *c, const tl::Variant &key) static void delete_cell_property (db::Cell *c, const tl::Variant &key)
{ {
check_is_editable (c);
db::properties_id_type id = c->prop_id (); db::properties_id_type id = c->prop_id ();
if (id == 0) { if (id == 0) {
return; return;
@ -911,8 +909,6 @@ static void delete_cell_property (db::Cell *c, const tl::Variant &key)
static void set_cell_property (db::Cell *c, const tl::Variant &key, const tl::Variant &value) static void set_cell_property (db::Cell *c, const tl::Variant &key, const tl::Variant &value)
{ {
check_is_editable (c);
db::properties_id_type id = c->prop_id (); db::properties_id_type id = c->prop_id ();
db::Layout *layout = c->layout (); db::Layout *layout = c->layout ();
@ -1110,13 +1106,11 @@ static void move_or_copy_from_other_cell (db::Cell *cell, db::Cell *src_cell, un
static void move_from_other_cell (db::Cell *cell, db::Cell *src_cell, unsigned int src_layer, unsigned int dest_layer) static void move_from_other_cell (db::Cell *cell, db::Cell *src_cell, unsigned int src_layer, unsigned int dest_layer)
{ {
check_is_editable (cell);
move_or_copy_from_other_cell (cell, src_cell, src_layer, dest_layer, true); move_or_copy_from_other_cell (cell, src_cell, src_layer, dest_layer, true);
} }
static void copy_from_other_cell (db::Cell *cell, db::Cell *src_cell, unsigned int src_layer, unsigned int dest_layer) static void copy_from_other_cell (db::Cell *cell, db::Cell *src_cell, unsigned int src_layer, unsigned int dest_layer)
{ {
check_is_editable (cell);
move_or_copy_from_other_cell (cell, src_cell, src_layer, dest_layer, false); move_or_copy_from_other_cell (cell, src_cell, src_layer, dest_layer, false);
} }
@ -1158,7 +1152,6 @@ write_options (const db::Cell *cell, const std::string &filename, const db::Save
static void static void
clear_all (db::Cell *cell) clear_all (db::Cell *cell)
{ {
check_is_editable (cell);
cell->clear_shapes (); cell->clear_shapes ();
cell->clear_insts (); cell->clear_insts ();
} }
@ -1166,7 +1159,6 @@ clear_all (db::Cell *cell)
static void static void
delete_cell (db::Cell *cell) delete_cell (db::Cell *cell)
{ {
check_is_editable (cell);
db::Layout *layout = cell->layout (); db::Layout *layout = cell->layout ();
if (layout) { if (layout) {
layout->delete_cell (cell->cell_index ()); layout->delete_cell (cell->cell_index ());
@ -1176,7 +1168,6 @@ delete_cell (db::Cell *cell)
static void static void
prune_subcells (db::Cell *cell, int levels) prune_subcells (db::Cell *cell, int levels)
{ {
check_is_editable (cell);
db::Layout *layout = cell->layout (); db::Layout *layout = cell->layout ();
if (layout) { if (layout) {
layout->prune_subcells (cell->cell_index (), levels); layout->prune_subcells (cell->cell_index (), levels);
@ -1192,7 +1183,6 @@ prune_subcells0 (db::Cell *cell)
static void static void
prune_cell (db::Cell *cell, int levels) prune_cell (db::Cell *cell, int levels)
{ {
check_is_editable (cell);
db::Layout *layout = cell->layout (); db::Layout *layout = cell->layout ();
if (layout) { if (layout) {
layout->prune_cell (cell->cell_index (), levels); layout->prune_cell (cell->cell_index (), levels);
@ -1208,7 +1198,6 @@ prune_cell0 (db::Cell *cell)
static void static void
flatten (db::Cell *cell, int levels, bool prune) flatten (db::Cell *cell, int levels, bool prune)
{ {
check_is_editable (cell);
db::Layout *layout = cell->layout (); db::Layout *layout = cell->layout ();
if (layout) { if (layout) {
layout->flatten (*cell, levels, prune); layout->flatten (*cell, levels, prune);
@ -1288,8 +1277,6 @@ begin_shapes_rec_overlapping_um (const db::Cell *cell, unsigned int layer, db::D
static void copy_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::LayerMapping &layer_mapping) static void copy_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::LayerMapping &layer_mapping)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
} }
@ -1318,8 +1305,6 @@ static void copy_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db:
static void copy_shapes1 (db::Cell *cell, const db::Cell &source_cell) static void copy_shapes1 (db::Cell *cell, const db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
} }
@ -1344,8 +1329,6 @@ static void copy_shapes1 (db::Cell *cell, const db::Cell &source_cell)
static void copy_instances (db::Cell *cell, const db::Cell &source_cell) static void copy_instances (db::Cell *cell, const db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy instances within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy instances within the same cell")));
} }
@ -1360,8 +1343,6 @@ static void copy_instances (db::Cell *cell, const db::Cell &source_cell)
static std::vector<db::cell_index_type> copy_tree (db::Cell *cell, const db::Cell &source_cell) static std::vector<db::cell_index_type> copy_tree (db::Cell *cell, const db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
} }
@ -1393,8 +1374,6 @@ static std::vector<db::cell_index_type> copy_tree (db::Cell *cell, const db::Cel
static void copy_tree_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm) static void copy_tree_shapes2 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
} }
@ -1421,8 +1400,6 @@ static void copy_tree_shapes2 (db::Cell *cell, const db::Cell &source_cell, cons
static void copy_tree_shapes3 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm) static void copy_tree_shapes3 (db::Cell *cell, const db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot copy shapes within the same cell")));
} }
@ -1446,8 +1423,6 @@ static void copy_tree_shapes3 (db::Cell *cell, const db::Cell &source_cell, cons
static void move_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::LayerMapping &layer_mapping) static void move_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::LayerMapping &layer_mapping)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
} }
@ -1478,8 +1453,6 @@ static void move_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::Layer
static void move_shapes1 (db::Cell *cell, db::Cell &source_cell) static void move_shapes1 (db::Cell *cell, db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
} }
@ -1505,8 +1478,6 @@ static void move_shapes1 (db::Cell *cell, db::Cell &source_cell)
static void move_instances (db::Cell *cell, db::Cell &source_cell) static void move_instances (db::Cell *cell, db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move instances within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move instances within the same cell")));
} }
@ -1523,8 +1494,6 @@ static void move_instances (db::Cell *cell, db::Cell &source_cell)
static std::vector<db::cell_index_type> move_tree (db::Cell *cell, db::Cell &source_cell) static std::vector<db::cell_index_type> move_tree (db::Cell *cell, db::Cell &source_cell)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
} }
@ -1558,8 +1527,6 @@ static std::vector<db::cell_index_type> move_tree (db::Cell *cell, db::Cell &sou
static void move_tree_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm) static void move_tree_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
} }
@ -1586,8 +1553,6 @@ static void move_tree_shapes2 (db::Cell *cell, db::Cell &source_cell, const db::
static void move_tree_shapes3 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm) static void move_tree_shapes3 (db::Cell *cell, db::Cell &source_cell, const db::CellMapping &cm, const db::LayerMapping &lm)
{ {
check_is_editable (cell);
if (cell == &source_cell) { if (cell == &source_cell) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot move shapes within the same cell")));
} }
@ -1612,8 +1577,6 @@ static void move_tree_shapes3 (db::Cell *cell, db::Cell &source_cell, const db::
static void static void
fill_region1 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cell_index, const db::Box &fc_box, const db::Point *origin) fill_region1 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cell_index, const db::Box &fc_box, const db::Point *origin)
{ {
check_is_editable (cell);
if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) { if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)"))); throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)")));
} }
@ -1624,8 +1587,6 @@ static void
fill_region2 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cell_index, const db::Box &fc_box, const db::Point *origin, fill_region2 (db::Cell *cell, const db::Region &fr, db::cell_index_type fill_cell_index, const db::Box &fc_box, const db::Point *origin,
db::Region *remaining_parts, const db::Vector &fill_margin, db::Region *remaining_polygons) db::Region *remaining_parts, const db::Vector &fill_margin, db::Region *remaining_polygons)
{ {
check_is_editable (cell);
if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) { if (fc_box.empty () || fc_box.width () == 0 || fc_box.height () == 0) {
throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)"))); throw tl::Exception (tl::to_string (QObject::tr ("Invalid fill cell footprint (empty or zero width/height)")));
} }

View File

@ -488,8 +488,6 @@ END
def test_5a def test_5a
if RBA::Application::instance.is_editable?
# delete_cell # delete_cell
l = RBA::Layout.new l = RBA::Layout.new
@ -544,12 +542,8 @@ END
end end
end
def test_5b def test_5b
if RBA::Application::instance.is_editable?
# delete_cells # delete_cells
l = RBA::Layout.new l = RBA::Layout.new
@ -589,13 +583,8 @@ END
end end
end
def test_5d def test_5d
# TODO: undo tests crashes in non-editable mode! Should be checked properly.
if RBA::Application::instance.is_editable?
# prune_cell # prune_cell
l = RBA::Layout.new l = RBA::Layout.new
@ -670,13 +659,8 @@ END
end end
end
def test_5e def test_5e
# TODO: undo tests crashes in non-editable mode! Should be checked properly.
if RBA::Application::instance.is_editable?
# delete_cell_rec # delete_cell_rec
l = RBA::Layout.new l = RBA::Layout.new
@ -716,13 +700,8 @@ END
end end
end
def test_5f def test_5f
# TODO: undo tests crashes in non-editable mode! Should be checked properly.
if RBA::Application::instance.is_editable?
# delete_cell_rec # delete_cell_rec
l = RBA::Layout.new l = RBA::Layout.new
@ -835,13 +814,8 @@ END
end end
end
def test_5g def test_5g
# TODO: undo tests crashes in non-editable mode! Should be checked properly.
if RBA::Application::instance.is_editable?
# prune_subcells # prune_subcells
l = RBA::Layout.new l = RBA::Layout.new
@ -926,8 +900,6 @@ END
end end
end
def test_6 def test_6
m = RBA::Manager.new m = RBA::Manager.new
@ -1218,8 +1190,6 @@ END
# copy shapes between cells # copy shapes between cells
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1297,14 +1267,10 @@ END
end end
end
def test_9 def test_9
# move shapes between cells # move shapes between cells
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1402,14 +1368,10 @@ END
end end
end
def test_10 def test_10
# copy instances between cells # copy instances between cells
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1458,14 +1420,10 @@ END
end end
end
def test_11 def test_11
# move instances between cells # move instances between cells
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1516,14 +1474,10 @@ END
end end
end
def test_12 def test_12
# copy cell tree # copy cell tree
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1579,14 +1533,10 @@ END
end end
end
def test_13 def test_13
# move cell tree # move cell tree
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1660,14 +1610,10 @@ END
end end
end
def test_14 def test_14
# copy shapes between cell trees # copy shapes between cell trees
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1744,14 +1690,10 @@ END
end end
end
def test_15 def test_15
# move shapes between cell trees # move shapes between cell trees
if RBA::Application::instance.is_editable?
l = RBA::Layout.new l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0)) l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
l.insert_layer_at(1, RBA::LayerInfo.new(2, 0)) l.insert_layer_at(1, RBA::LayerInfo.new(2, 0))
@ -1851,14 +1793,8 @@ END
end end
end
def test_16 def test_16
if !RBA::Application::instance.is_editable?
return
end
# fill tool # fill tool
l = nil l = nil
@ -1980,9 +1916,6 @@ END
def test_18 def test_18
ly = RBA::Layout::new ly = RBA::Layout::new
if !ly.is_editable?
return
end
cell = ly.create_cell("X") cell = ly.create_cell("X")