Skip to content

Commit

Permalink
Merge pull request #1529 from KLayout/wip2
Browse files Browse the repository at this point in the history
Wip2
  • Loading branch information
klayoutmatthias authored Nov 13, 2023
2 parents c1da4cc + 284182c commit 9d8e0f4
Show file tree
Hide file tree
Showing 24 changed files with 637 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/buddies/src/bd/bdReaderOptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ GenericReaderOptions::add_options (tl::CommandLineOptions &cmd)
"* 1: produce LEF geometry always and ignore FOREIGN\n"
"* 2: Never produce LEF geometry and assume FOREIGN always\n"
"\n"
"In case of FOREIGN macros in mode 1 or always in mode 2, the '--" + m_long_prefix + "lefdef-lef-layouts' option is available to specify "
"In case of FOREIGN macros in mode 0 or always in mode 2, the '--" + m_long_prefix + "lefdef-lef-layouts' option is available to specify "
"external layout files for providing the LEF macro layouts.\n"
)
<< tl::arg (group +
Expand Down
8 changes: 2 additions & 6 deletions src/db/db/db.pro
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,8 @@ HEADERS = \
dbShapeCollection.h \
dbShapeCollectionUtils.h

!equals(HAVE_QT, "0") {

RESOURCES = \
dbResources.qrc \

}
RESOURCES = \
dbResources.qrc \

INCLUDEPATH += $$TL_INC $$GSI_INC
DEPENDPATH += $$TL_INC $$GSI_INC
Expand Down
4 changes: 2 additions & 2 deletions src/db/db/dbLayoutLayers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ unsigned int
LayoutLayers::error_layer () const
{
if (m_error_layer < 0) {
// create the waste layer (since that layer is cached we can do
// create the error layer (since that layer is cached we can do
// this in a "const" fashion.
db::LayoutLayers *self = const_cast<db::LayoutLayers *> (this);
self->m_error_layer = (int) self->insert_special_layer (db::LayerProperties ("WASTE"));
self->m_error_layer = (int) self->insert_special_layer (db::LayerProperties ("ERROR"));
}

return (unsigned int) m_error_layer;
Expand Down
6 changes: 6 additions & 0 deletions src/db/db/gsiDeclDbLayout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,12 @@ Class<db::Layout> decl_Layout ("db", "Layout",
"\n"
"This method has been added in version 0.22.\n"
) +
gsi::method ("error_layer", &db::Layout::error_layer,
"@brief Returns the index of the error layer\n"
"The error layer is used to place error texts on it, for example when a PCell evaluation fails.\n"
"\n"
"This method has been added in version 0.23.13.\n"
) +
gsi::method ("insert_special_layer", (unsigned int (db::Layout::*) (const db::LayerProperties &)) &db::Layout::insert_special_layer, gsi::arg ("props"),
"@brief Inserts a new special layer with the given properties\n"
"\n"
Expand Down
13 changes: 13 additions & 0 deletions src/db/unit_tests/dbLayoutTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,16 @@ TEST(8_MetaInfo)
EXPECT_EQ (ly.has_context_info (ci), false);
EXPECT_EQ (ly.meta_info (ci, "a").value.to_string (), "nil");
}

TEST(9_ErrorLayer)
{
db::Manager m;
db::Layout l (&m);

EXPECT_EQ (l.is_valid_layer (0), false);
EXPECT_EQ (l.guiding_shape_layer (), (unsigned int) 0);
EXPECT_EQ (l.is_valid_layer (1), false);
EXPECT_EQ (l.error_layer (), (unsigned int) 1);
EXPECT_EQ (l.is_special_layer (1), true);
EXPECT_EQ (int (l.layers ()), 2);
}
3 changes: 1 addition & 2 deletions src/doc/doc/manual/drc_runsets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ output(w, "width violations")</pre>
<a href="/about/drc_ref_layer.xml#|">| (or)</a>,
<a href="/about/drc_ref_layer.xml#-">- (not)</a>,
<a href="/about/drc_ref_layer.xml#^">^ (xor)</a>,
<a href="/about/drc_ref_layer.xml#+">+ (xor)</a>,
<a href="/about/drc_ref_layer.xml#join">join</a>
<a href="/about/drc_ref_layer.xml#+">+ (join)</a>,
</li>
<li>Sizing:<br/>
<a href="/about/drc_ref_layer.xml#size">size</a>,
Expand Down
76 changes: 75 additions & 1 deletion src/klayout_main/klayout_main/klayout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ FORCE_LINK_GSI_QTUITOOLS
#include <QTextCodec>

#include <iostream>
#include <fstream>
#include <memory>
#include <cstdlib>

int klayout_main (int &argc, char **argv);
Expand Down Expand Up @@ -202,6 +204,74 @@ void custom_message_handler(QtMsgType type, const char *msg)

static int klayout_main_cont (int &argc, char **argv);

namespace {

class LogFileWriter
: public tl::Channel
{
public:
static std::unique_ptr<std::ofstream> m_os;

LogFileWriter (int min_verbosity, const std::string &prefix)
: m_min_verbosity (min_verbosity), m_prefix (prefix), m_new_line (true)
{ }

static bool open (const std::string &path)
{
m_os.reset (new std::ofstream (path));
return m_os->good ();
}

void puts (const char *s)
{
if (m_os && tl::verbosity () >= m_min_verbosity) {
m_os->write (s, strlen (s));
}
}

void endl ()
{
puts ("\n");
m_new_line = true;
}

void end ()
{
if (m_os && tl::verbosity () >= m_min_verbosity) {
m_os->flush ();
}
}

void begin ()
{
if (m_new_line) {
puts (m_prefix.c_str ());
m_new_line = false;
}
}

void yield () { }

private:
int m_min_verbosity;
std::string m_prefix;
bool m_new_line;
};

std::unique_ptr<std::ofstream> LogFileWriter::m_os;

}

static void set_log_file (const std::string &log_file)
{
if (LogFileWriter::open (log_file)) {
tl::info.add (new LogFileWriter (0, std::string ()), true);
tl::log.add (new LogFileWriter (10, std::string ()), true);
tl::warn.add (new LogFileWriter (0, std::string ("Warning: ")), true);
tl::error.add (new LogFileWriter (0, std::string ("ERROR: ")), true);
}
}

/**
* @brief The basic entry point
* Note that by definition, klayout_main receives arguments in UTF-8
Expand Down Expand Up @@ -229,7 +299,7 @@ klayout_main (int &argc, char **argv)
about_text += prg_about_text;
lay::Version::set_about_text (about_text.c_str ());

// Capture the shortcut command line arguments and the verbosity settings
// Capture the shortcut command line arguments, log file and the verbosity settings
// for early errors and warnings

for (int i = 1; i < argc; ++i) {
Expand All @@ -244,6 +314,10 @@ klayout_main (int &argc, char **argv)
tl::info << lay::ApplicationBase::usage () << tl::noendl;
return 0;

} else if (argv [i] == std::string ("-k") && (i + 1) < argc) {

set_log_file (argv [++i]);

} else if (argv [i] == std::string ("-d") && (i + 1) < argc) {

int v = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/lay/lay/layApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ ApplicationBase::parse_cmd (int &argc, char **argv)
}
tl::verbosity (v);

} else if (a == "-k" && (i + 1) < argc) {

// ignored (handled earlier)
++i;

} else if (a == "-l" && (i + 1) < argc) {

m_layer_props_file = args [++i];
Expand Down Expand Up @@ -1055,6 +1060,7 @@ ApplicationBase::usage ()
r += tl::to_string (QObject::tr (" -i Disable undo buffering (less memory requirements)")) + "\n";
r += tl::to_string (QObject::tr (" -ni Enable undo buffering (default, overrides previous -i option)")) + "\n";
r += tl::to_string (QObject::tr (" -j <path> Add the given path to the macro project paths")) + "\n";
r += tl::to_string (QObject::tr (" -k <log file> Write log to the given file plus stdout/stderr")) + "\n";
r += tl::to_string (QObject::tr (" -l <lyp file> Use layer properties file")) + "\n";
r += tl::to_string (QObject::tr (" -lx With -l: add other layers as well")) + "\n";
r += tl::to_string (QObject::tr (" -lf With -l: use the lyp file as it is (no expansion to multiple layouts)")) + "\n";
Expand Down
3 changes: 2 additions & 1 deletion src/lay/lay/layMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4333,7 +4333,8 @@ class MainWindowPluginDeclaration
menu_entries.push_back (lay::menu_item ("cm_reset_window_state", "reset_window_state", at, tl::to_string (QObject::tr ("Restore Window")))),
menu_entries.push_back (lay::separator ("selection_group", at));
menu_entries.push_back (lay::config_menu_item ("transient_selection", at, tl::to_string (QObject::tr ("Highlight Object Under Mouse")), cfg_sel_transient_mode, "?"));
menu_entries.push_back (lay::config_menu_item ("mouse_tracking", at, tl::to_string (QObject::tr ("Mouse tracking")), cfg_tracking_cursor_enabled, "?"));
menu_entries.push_back (lay::config_menu_item ("mouse_tracking", at, tl::to_string (QObject::tr ("Mouse Tracking")), cfg_tracking_cursor_enabled, "?"));
menu_entries.push_back (lay::config_menu_item ("crosshair_cursor", at, tl::to_string (QObject::tr ("Crosshair Cursor")), cfg_crosshair_cursor_enabled, "?"));

at = "help_menu.end";
menu_entries.push_back (lay::menu_item ("cm_show_all_tips", "show_all_tips", at, tl::to_string (QObject::tr ("Show All Tips"))));
Expand Down
7 changes: 7 additions & 0 deletions src/laybasic/laybasic/layLayoutViewBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,10 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
return true;
}

if (mp_tracker && mp_tracker->configure (name, value)) {
return true;
}

if (name == cfg_default_lyp_file) {

m_def_lyp_file = value;
Expand Down Expand Up @@ -3693,6 +3697,9 @@ LayoutViewBase::refresh ()

// Issue a "tick" to execute all other pending tasks
timer ();

// Update the view ops as this is not always guaranteed (issue #1512)
set_view_ops ();
}

void
Expand Down
4 changes: 4 additions & 0 deletions src/laybasic/laybasic/layLayoutViewConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ class LayoutViewBasicConfigDeclaration
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_width, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_vertex_size, "3"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_dither_pattern, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_style, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_halo, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_transient_mode, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_inside_pcells_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_line_style, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_enabled, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_background_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ctx_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ctx_dimming, "50"));
Expand Down
39 changes: 23 additions & 16 deletions src/laybasic/laybasic/layLineStyles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,38 @@ LineStyleInfo::is_bit_set (unsigned int n) const

#if defined(HAVE_QT)
QBitmap
LineStyleInfo::get_bitmap (int width, int height) const
LineStyleInfo::get_bitmap (int w, int h, int fw) const
{
if (height < 0) {
height = 5;
}
if (width < 0) {
width = 34;
}

unsigned int height = h < 0 ? 5 : (unsigned int) h;
unsigned int width = w < 0 ? 34 : (unsigned int) w;
unsigned int frame_width = fw <= 0 ? 1 : (unsigned int) fw;
unsigned int stride = (width + 7) / 8;

unsigned char *data = new unsigned char[stride * height];
memset (data, 0x00, size_t (stride * height));

for (unsigned int i = 0; i < (unsigned int)(height - 2); ++i) {
if (is_bit_set (i)) {
data [(height - 2 - i) * stride] |= 0x01;
data [(height - 2 - i) * stride + (width - 1) / 8] |= (1 << ((width - 1) % 8));
unsigned int hv = height - 2 * frame_width;

for (unsigned int i = 0; i < hv; ++i) {
if (is_bit_set (i / frame_width + 1)) {
unsigned int y = height - 1 - frame_width - i;
for (unsigned int x = 0; x < frame_width; ++x) {
data [y * stride + x / 8] |= (1 << (x % 8));
}
for (unsigned int x = width - frame_width; x < width; ++x) {
data [y * stride + x / 8] |= (1 << (x % 8));
}
}
}

for (unsigned int i = 1; i < (unsigned int)(width - 1); ++i) {
if (is_bit_set (i)) {
data [stride + i / 8] |= (1 << (i % 8));
data [(height - 2) * stride + i / 8] |= (1 << (i % 8));
for (unsigned int i = 0; i < width; ++i) {
if (is_bit_set (i / frame_width)) {
for (unsigned int y = 0; y < frame_width; ++y) {
data [y * stride + i / 8] |= (1 << (i % 8));
}
for (unsigned int y = height - frame_width; y < height; ++y) {
data [y * stride + i / 8] |= (1 << (i % 8));
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/laybasic/laybasic/layLineStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ class LAYBASIC_PUBLIC LineStyleInfo
*
* @param width The desired width (-1 for default)
* @param height The desired height (-1 for default)
* @param The intended frame width in pixels
*/
QBitmap get_bitmap (int width = -1, int height = -1) const;
QBitmap get_bitmap (int width = -1, int height = -1, int frame_width = 1) const;
#endif

/**
Expand Down
Loading

0 comments on commit 9d8e0f4

Please sign in to comment.