Merge branch 'master' into wip

This commit is contained in:
Matthias Koefferlein
2024-01-06 17:28:51 +01:00
14 changed files with 257 additions and 58 deletions
+16 -1
View File
@@ -40,6 +40,21 @@ namespace db {
template <class Coord> class generic_repository;
class ArrayRepository;
template <class C>
inline C box_world_min () { return std::numeric_limits<C>::min (); }
template <class C>
inline C box_world_max () { return std::numeric_limits<C>::max (); }
// NOTE: for 64bit coordinates the world coordinates do not fully exploit the coordinate
// range but only as much as can represented exactly by double (64bit) values.
template <>
inline int64_t box_world_min<int64_t> () { return -(int64_t (1) << 53); }
template <>
inline int64_t box_world_max<int64_t> () { return (int64_t (1) << 53); }
/**
* @brief A box class
*
@@ -134,7 +149,7 @@ struct DB_PUBLIC_TEMPLATE box
*/
static box world ()
{
return box (std::numeric_limits<C>::min (), std::numeric_limits<C>::min (), std::numeric_limits<C>::max (), std::numeric_limits<C>::max ());
return box (box_world_min<C> (), box_world_min<C> (), box_world_max<C> (), box_world_max<C> ());
}
/**
+12
View File
@@ -245,3 +245,15 @@ TEST(13)
EXPECT_EQ (b.perimeter (), 8000000000.0);
}
TEST(14)
{
// world, specifically with 64bit coordinates and
// transfer via double coordinates
db::Box b = db::Box::world ();
EXPECT_EQ (b == db::Box::world (), true);
db::ICplxTrans t;
EXPECT_EQ (t * b == db::Box::world (), true);
EXPECT_EQ (t.inverted () * b == db::Box::world (), true);
}
+8
View File
@@ -1263,7 +1263,11 @@ TEST(21)
#if !defined(_MSC_VER)
ms.clear ();
poly.mem_stat (&ms, db::MemStatistics::None, 0);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (ms.reqd, (sizeof(void *)-4)*5+116);
#else
EXPECT_EQ (ms.reqd, (sizeof(void *)-4)*5+68);
#endif
#endif
}
@@ -1277,7 +1281,11 @@ TEST(21)
#if !defined(_MSC_VER)
ms.clear ();
poly.mem_stat (&ms, db::MemStatistics::None, 0);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (ms.reqd, (sizeof(void *)-4)*5+84);
#else
EXPECT_EQ (ms.reqd, (sizeof(void *)-4)*5+52);
#endif
#endif
}
{
+88
View File
@@ -1730,8 +1730,44 @@ TEST(7)
"box (150,150;2150,1050) #12\n"
);
} else if (sizeof (db::ShortBox) > 8) {
EXPECT_EQ (shapes_to_string (_this, copy),
"box (0,100;2000,1000) #0\n"
"box (100,200;2100,1100) #0\n"
"box (150,150;2150,1050) #0\n"
"box (50,-1050;1050,-50) #0\n"
"box (50,8950;1050,9950) #0\n"
"box (50,18950;1050,19950) #0\n"
"box (11050,-1050;12050,-50) #0\n"
"box (11050,8950;12050,9950) #0\n"
"box (11050,18950;12050,19950) #0\n"
"box (22050,-1050;23050,-50) #0\n"
"box (22050,8950;23050,9950) #0\n"
"box (22050,18950;23050,19950) #0\n"
"box (33050,-1050;34050,-50) #0\n"
"box (33050,8950;34050,9950) #0\n"
"box (33050,18950;34050,19950) #0\n"
"box (0,100;2000,1000) #10\n"
"box (100,200;2100,1100) #11\n"
"box (150,150;2150,1050) #12\n"
"box (50,-1050;1050,-50) #20\n"
"box (50,8950;1050,9950) #20\n"
"box (50,18950;1050,19950) #20\n"
"box (11050,-1050;12050,-50) #20\n"
"box (11050,8950;12050,9950) #20\n"
"box (11050,18950;12050,19950) #20\n"
"box (22050,-1050;23050,-50) #20\n"
"box (22050,8950;23050,9950) #20\n"
"box (22050,18950;23050,19950) #20\n"
"box (33050,-1050;34050,-50) #20\n"
"box (33050,8950;34050,9950) #20\n"
"box (33050,18950;34050,19950) #20\n"
);
} else {
// 16 bit coordinate overflow happens during ShortBox array expansion
EXPECT_EQ (shapes_to_string (_this, copy),
"box (0,100;2000,1000) #0\n"
"box (100,200;2100,1100) #0\n"
@@ -1808,8 +1844,44 @@ TEST(7)
"box (150,150;2150,1050) #12\n"
);
} else if (sizeof (db::ShortBox) > 8) {
EXPECT_EQ (shapes_to_string (_this, sa_copy),
"box (0,100;2000,1000) #0\n"
"box (100,200;2100,1100) #0\n"
"box (150,150;2150,1050) #0\n"
"box (50,-1050;1050,-50) #0\n"
"box (50,8950;1050,9950) #0\n"
"box (50,18950;1050,19950) #0\n"
"box (11050,-1050;12050,-50) #0\n"
"box (11050,8950;12050,9950) #0\n"
"box (11050,18950;12050,19950) #0\n"
"box (22050,-1050;23050,-50) #0\n"
"box (22050,8950;23050,9950) #0\n"
"box (22050,18950;23050,19950) #0\n"
"box (33050,-1050;34050,-50) #0\n"
"box (33050,8950;34050,9950) #0\n"
"box (33050,18950;34050,19950) #0\n"
"box (0,100;2000,1000) #10\n"
"box (100,200;2100,1100) #11\n"
"box (150,150;2150,1050) #12\n"
"box (50,-1050;1050,-50) #20\n"
"box (50,8950;1050,9950) #20\n"
"box (50,18950;1050,19950) #20\n"
"box (11050,-1050;12050,-50) #20\n"
"box (11050,8950;12050,9950) #20\n"
"box (11050,18950;12050,19950) #20\n"
"box (22050,-1050;23050,-50) #20\n"
"box (22050,8950;23050,9950) #20\n"
"box (22050,18950;23050,19950) #20\n"
"box (33050,-1050;34050,-50) #20\n"
"box (33050,8950;34050,9950) #20\n"
"box (33050,18950;34050,19950) #20\n"
);
} else {
// 16 bit coordinate overflow happens during ShortBox array expansion
EXPECT_EQ (shapes_to_string (_this, sa_copy),
"box (0,100;2000,1000) #0\n"
"box (100,200;2100,1100) #0\n"
@@ -3185,19 +3257,35 @@ TEST(21)
s = shapes.begin_touching (db::Box (-500, -500, 500, 500), db::ShapeIterator::All);
size_t qid = s.quad_id ();
EXPECT_EQ (qid != 0, true);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (s.quad_box ().to_string (), "(0,0;9007199254740992,9007199254740992)");
#else
EXPECT_EQ (s.quad_box ().to_string (), "(0,0;2147483647,2147483647)");
#endif
EXPECT_EQ (s->to_string (), "box (100,100;200,200)");
++s;
EXPECT_EQ (qid == s.quad_id (), true);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (s.quad_box ().to_string (), "(0,0;9007199254740992,9007199254740992)");
#else
EXPECT_EQ (s.quad_box ().to_string (), "(0,0;2147483647,2147483647)");
#endif
EXPECT_EQ (s->to_string (), "box (100,100;200,200)");
s.skip_quad ();
EXPECT_EQ (qid != s.quad_id (), true);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (s.quad_box ().to_string (), "(-9007199254740992,0;0,9007199254740992)");
#else
EXPECT_EQ (s.quad_box ().to_string (), "(-2147483648,0;0,2147483647)");
#endif
EXPECT_EQ (s->to_string (), "box (-200,100;-100,200)");
s.skip_quad ();
EXPECT_EQ (qid != s.quad_id (), true);
#if defined(HAVE_64BIT_COORD)
EXPECT_EQ (s.quad_box ().to_string (), "(0,-9007199254740992;9007199254740992,0)");
#else
EXPECT_EQ (s.quad_box ().to_string (), "(0,-2147483648;2147483647,0)");
#endif
EXPECT_EQ (s->to_string (), "box (100,-200;200,-100)");
s.skip_quad ();
EXPECT_EQ (s.at_end (), true);
+26 -18
View File
@@ -8,28 +8,36 @@
<keyword name="Editing"/>
<p>
The "flatten cell" operation flattens a cell into all of its parents.
This basically removes a cell by promoting her shapes and instances up in the hierarchy.
A "flat" cell is a cell without hierarchy. This means that the cell contains
only shapes, but no instances of child cells. Flat cells are disconnected from
other cells, hence flattening is a way to "freeze" the contents of a cell: when
a cell is flat, changing any other cell does not have an effect on this cell or
in other places of the cell. On the other hand, flat cells store each shape
individually, hence cannot make use of data compression be reuse of geometry.
</p>
<p>
Cell flattening can be applied to single instances or cells as a whole.
When applied to an instance, the individual instance is resolved into shapes. The
instantiated cell will still exist afterwards. When applied to a cell, the cell
will disappear and replaced by its contents in all places it is used.
</p>
<p>
Instance-wise flattening is available by choosing "Edit/Selection/Flatten Instances".
Cell-wise flattening is available by choosing "Edit/Cell/Flatten Cell" or "Flatten Cell"
from the cell list's context menu.
</p>
<p>
The flatten operation offers some options, i.e. the number of hierarchy levels to
flatten and how to deal with child cells which become obsolete through this operation.
A hierarchical cell can be flattened by choosing "Edit/Cell/Flatten Cell" or "Flatten Cell"
from the cell list context menu.
The flatten operation offers some options, i.e. the number of hierarchy levels to
flatten and how to deal with child cells which become obsolete through this operation ("orphan cells").
By enabling this "prune" option, all child cells are removed when they are no longer needed.
Otherwise, new top level cells will appear - these are the cells which are not longer instantiated.
Otherwise, new top level cells will appear in that case - these are the cells which are not longer instantiated.
</p>
<p>
"Flatten" can also be applied to instances. In that case, the cell instance is removed
and replaced by the objects inside this cell. So instance flattening is a way to pull
the contents of a cell into the parent cell. One reason for doing so is to make the
cell contents accessible for editing, without having to change the child cell itself.
This prevents potential side effects when editing a cell would make the edits visible
in other places.
</p>
<p>
Instance-wise flattening is available by choosing "Edit/Selection/Flatten Instances".
Again, options are available to choose the number of hierarchy levels to flatten and
how to treat orphan cells.
</p>
</doc>
+10 -5
View File
@@ -713,12 +713,17 @@ MainWindow::close_all ()
void
MainWindow::about_to_exec ()
{
// NOTE: empirically by using "0" for the parent of the TipDialogs (not "this"),
// these dialog appear on the same screen than the application window. With "this"
// they usually appear somewhere else. Maybe because this method is called before
// the main window is properly set up.
bool f;
f = false;
dispatcher ()->config_get (cfg_full_hier_new_cell, f);
if (!f) {
TipDialog td (this,
TipDialog td (0,
tl::to_string (QObject::tr ("<html><body>"
"<p>With the current settings, only the top cell's content is shown initially, but the child cells are not drawn.</p>"
"<p>This can be confusing, since the full layout becomes visible only after selecting "
@@ -744,7 +749,7 @@ MainWindow::about_to_exec ()
// TODO: later, each view may get its own editable flag
if (lay::ApplicationBase::instance () && !lay::ApplicationBase::instance ()->is_editable ()) {
TipDialog td (this,
TipDialog td (0,
tl::to_string (QObject::tr ("KLayout has been started in viewer mode. In this mode, editor functions are not available.\n\nTo enable these functions, start KLayout in editor mode by using the \"-e\" command line switch or select it as the default mode in the setup dialog. Choose \"Setup\" in the \"File\" menu and check \"Use editing mode by default\" on the \"Editing Mode\" page in the \"Application\" section.")),
"editor-mode");
if (td.exec_dialog ()) {
@@ -756,7 +761,7 @@ MainWindow::about_to_exec ()
f = false;
dispatcher ()->config_get (cfg_no_stipple, f);
if (f) {
TipDialog td (this,
TipDialog td (0,
tl::to_string (QObject::tr ("Layers are shown without fill because fill has been intentionally turned off. This can be confusing since selecting a stipple does not have an effect in this case.\n\nTo turn this feature off, uncheck \"Show Layers Without Fill\" in the \"View\" menu.")),
"no-stipple");
if (td.exec_dialog ()) {
@@ -768,7 +773,7 @@ MainWindow::about_to_exec ()
f = false;
dispatcher ()->config_get (cfg_markers_visible, f);
if (! f) {
TipDialog td (this,
TipDialog td (0,
tl::to_string (QObject::tr ("Markers are not visible because they have been turned off.\nYou may not see markers when using the marker browser feature.\n\nTo turn markers on, check \"Show Markers\" in the \"View\" menu.")),
"show-markers");
if (td.exec_dialog ()) {
@@ -780,7 +785,7 @@ MainWindow::about_to_exec ()
f = false;
dispatcher ()->config_get (cfg_hide_empty_layers, f);
if (f) {
TipDialog td (this,
TipDialog td (0,
tl::to_string (QObject::tr ("The \"Hide Empty Layers\" feature is enabled. This can be confusing, in particular in edit mode, because layers are not shown although they are actually present.\n\nTo disable this feature, uncheck \"Hide Empty Layers\" in the layer panel's context menu.")),
"hide-empty-layers");
if (td.exec_dialog ()) {
@@ -1335,8 +1335,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {17 {17value}}\n"
@@ -1439,8 +1444,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {{S_BOUNDING_BOXES_AVAILABLE} {2}}\n"
@@ -1499,8 +1509,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {{S_BOUNDING_BOXES_AVAILABLE} {2}}\n"
@@ -1561,8 +1576,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {{name} {117}}\n"
@@ -1617,8 +1637,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$1}}\n"
" {17 {17value}}\n"
" {{name} {117}}\n"
@@ -1668,8 +1693,13 @@ TEST(116)
const char *expected =
"set props {\n"
#if defined(HAVE_64BIT_COORD)
" {{S_MAX_SIGNED_INTEGER_WIDTH} {8}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {8}}\n"
#else
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
#endif
" {{S_TOP_CELL} {$2}}\n"
" {17 {17value}}\n"
" {{name} {117}}\n"