Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/buddies/src/bd/bdWriterOptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ GenericWriterOptions::GenericWriterOptions ()
m_gds2_write_timestamps = save_options.get_option_by_name ("gds2_write_timestamps").to_bool ();
m_gds2_write_cell_properties = save_options.get_option_by_name ("gds2_write_cell_properties").to_bool ();
m_gds2_write_file_properties = save_options.get_option_by_name ("gds2_write_file_properties").to_bool ();
tl::Variant def_text_size = save_options.get_option_by_name ("gds2_default_text_size");
m_gds2_default_text_size = def_text_size.is_nil () ? -1.0 : def_text_size.to_double ();

m_oasis_compression_level = save_options.get_option_by_name ("oasis_compression_level").to_int ();
m_oasis_write_cblocks = save_options.get_option_by_name ("oasis_write_cblocks").to_bool ();
Expand Down Expand Up @@ -201,6 +203,13 @@ GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::strin
"This option enables a GDS2 extension that allows writing of file properties to GDS2 files. "
"Consumers that don't support this feature, may not be able to read such a GDS2 files."
)
<< tl::arg (group +
"#--default-text-size", &m_gds2_default_text_size, "Default text size",
"This text size (given in micrometers) is applied to text objects not coming with their "
"own text size (technically: with a zero text size). It can be set to 0 to preserve an original "
"text size of zero. This option is also handy to give text objects from OASIS files a "
"specific size. By default, text objects without a size (i.e. with a zero size) do not receive one."
)
;

}
Expand Down Expand Up @@ -379,6 +388,7 @@ GenericWriterOptions::configure (db::SaveLayoutOptions &save_options, const db::
save_options.set_option_by_name ("gds2_write_timestamps", m_gds2_write_timestamps);
save_options.set_option_by_name ("gds2_write_cell_properties", m_gds2_write_cell_properties);
save_options.set_option_by_name ("gds2_write_file_properties", m_gds2_write_file_properties);
save_options.set_option_by_name ("gds2_default_text_size", m_gds2_default_text_size < 0.0 ? tl::Variant () : tl::Variant (m_gds2_default_text_size));

save_options.set_option_by_name ("oasis_compression_level", m_oasis_compression_level);
save_options.set_option_by_name ("oasis_write_cblocks", m_oasis_write_cblocks);
Expand Down
1 change: 1 addition & 0 deletions src/buddies/src/bd/bdWriterOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class BD_PUBLIC GenericWriterOptions
bool m_gds2_write_timestamps;
bool m_gds2_write_cell_properties;
bool m_gds2_write_file_properties;
double m_gds2_default_text_size;

int m_oasis_compression_level;
bool m_oasis_write_cblocks;
Expand Down
54 changes: 51 additions & 3 deletions src/buddies/unit_tests/bdBasicTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ TEST(1)
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_multi_xy_records").to_bool (), false);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_timestamps").to_bool (), true);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_no_zero_length_paths").to_bool (), false);
EXPECT_EQ (tl::to_string (stream_opt.get_option_by_name ("gds2_user_units").to_double ()), "1");
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_user_units").to_double (), 1.0);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_cell_properties").to_bool (), false);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_file_properties").to_bool (), false);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "nil");
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_write_cblocks").to_bool (), true);
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_compression_level").to_int (), 2);
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_strict_mode").to_bool (), true);
Expand All @@ -107,9 +108,10 @@ TEST(1)
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_multi_xy_records").to_bool (), true);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_timestamps").to_bool (), false);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_no_zero_length_paths").to_bool (), true);
EXPECT_EQ (tl::to_string (stream_opt.get_option_by_name ("gds2_user_units").to_double ()), "2.5");
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_user_units").to_double (), 2.5);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_cell_properties").to_bool (), true);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_write_file_properties").to_bool (), true);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "nil");
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_write_cblocks").to_bool (), false);
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_compression_level").to_int (), 9);
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_strict_mode").to_bool (), false);
Expand All @@ -118,6 +120,52 @@ TEST(1)
EXPECT_EQ (stream_opt.get_option_by_name ("oasis_write_std_properties_ext").to_int (), 2);
}

// Testing writer options (default_text_size)
TEST(2)
{
bd::GenericWriterOptions opt;
tl::CommandLineOptions cmd;

opt.add_options (cmd);

const char *argv[] = {
"x",
"--default-text-size=1.25",
};

cmd.parse (sizeof (argv) / sizeof (argv[0]), const_cast<char **> (argv));

db::Layout layout;

db::SaveLayoutOptions stream_opt;
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "nil");
opt.configure (stream_opt, layout);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "1.25");
}

// Testing writer options (default_text_size)
TEST(3)
{
bd::GenericWriterOptions opt;
tl::CommandLineOptions cmd;

opt.add_options (cmd);

const char *argv[] = {
"x",
"--default-text-size=-1",
};

cmd.parse (sizeof (argv) / sizeof (argv[0]), const_cast<char **> (argv));

db::Layout layout;

db::SaveLayoutOptions stream_opt;
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "nil");
opt.configure (stream_opt, layout);
EXPECT_EQ (stream_opt.get_option_by_name ("gds2_default_text_size").to_string (), "nil");
}

static std::string cells2string (const db::Layout &layout, const std::set<db::cell_index_type> &cells)
{
std::string res;
Expand All @@ -131,7 +179,7 @@ static std::string cells2string (const db::Layout &layout, const std::set<db::ce
}

// Testing writer options: cell resolution
TEST(2)
TEST(4)
{
// Build a layout with the hierarchy
// TOP -> A, B
Expand Down
1 change: 1 addition & 0 deletions src/plugins/streamers/gds2/db_plugin/dbGDS2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class GDS2FormatDeclaration
tl::make_member (&db::GDS2WriterOptions::write_cell_properties, "write-cell-properties") +
tl::make_member (&db::GDS2WriterOptions::write_file_properties, "write-file-properties") +
tl::make_member (&db::GDS2WriterOptions::no_zero_length_paths, "no-zero-length-paths") +
tl::make_member (&db::GDS2WriterOptions::default_text_size, "default-text-size") +
tl::make_member (&db::GDS2WriterOptions::multi_xy_records, "multi-xy-records") +
tl::make_member (&db::GDS2WriterOptions::resolve_skew_arrays, "resolve-skew-arrays") +
tl::make_member (&db::GDS2WriterOptions::max_vertex_count, "max-vertex-count") +
Expand Down
11 changes: 10 additions & 1 deletion src/plugins/streamers/gds2/db_plugin/dbGDS2Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class DB_PLUGIN_PUBLIC GDS2WriterOptions
user_units (1.0),
write_timestamps (true),
write_cell_properties (false),
write_file_properties (false)
write_file_properties (false),
default_text_size (-1.0)
{
// .. nothing yet ..
}
Expand Down Expand Up @@ -191,6 +192,14 @@ class DB_PLUGIN_PUBLIC GDS2WriterOptions
*/
bool write_file_properties;

/**
* @brief The default text size if none is given (in fact, if the text size is zero)
*
* You can set to option to 0 to preserve the zero text size on writing.
* A negative value means the text size is not set if missing.
*/
double default_text_size;

/**
* @brief Implementation of FormatSpecificWriterOptions
*/
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/streamers/gds2/db_plugin/dbGDS2WriterBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static uint16_t safe_convert_to_uint16 (uint64_t value)

GDS2WriterBase::GDS2WriterBase ()
: m_dbu (0.0), m_resolve_skew_arrays (false), m_multi_xy (false), m_no_zero_length_paths (false),
m_max_vertex_count (0), m_write_cell_properties (false), m_keep_instances (false)
m_max_vertex_count (0), m_write_cell_properties (false), m_keep_instances (false), m_default_text_size (-1.0)
{
// .. nothing yet ..
}
Expand Down Expand Up @@ -481,6 +481,7 @@ GDS2WriterBase::write (db::Layout &layout, tl::OutputStream &stream, const db::S
m_no_zero_length_paths = gds2_options.no_zero_length_paths;
m_resolve_skew_arrays = gds2_options.resolve_skew_arrays;
m_write_cell_properties = gds2_options.write_cell_properties;
m_default_text_size = gds2_options.default_text_size;

size_t max_cellname_length = std::max (gds2_options.max_cellname_length, (unsigned int)8);

Expand Down Expand Up @@ -902,7 +903,7 @@ GDS2WriterBase::write_text (int layer, int datatype, double sf, double dbu, cons
write_short (ha + va * 4 + f * 16);
}

if (trans.rot () != 0 || shape.text_size () != 0) {
if (trans.rot () != 0 || shape.text_size () != 0 || m_default_text_size >= 0.0) {

write_record_size (6);
write_record (sSTRANS);
Expand All @@ -912,6 +913,10 @@ GDS2WriterBase::write_text (int layer, int datatype, double sf, double dbu, cons
write_record_size (4 + 8);
write_record (sMAG);
write_double (shape.text_size () * sf * dbu);
} else if (m_default_text_size >= 0.0) {
write_record_size (4 + 8);
write_record (sMAG);
write_double (m_default_text_size * sf);
}

if ((trans.rot () % 4) != 0) {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/streamers/gds2/db_plugin/dbGDS2WriterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class DB_PLUGIN_PUBLIC GDS2WriterBase
size_t m_max_vertex_count;
bool m_write_cell_properties;
bool m_keep_instances;
double m_default_text_size;

void write_properties (const db::Layout &layout, db::properties_id_type prop_id);
void write_context_cell (db::Layout &layout, const short *time_data, const std::vector<cell_index_type> &cells);
Expand Down
27 changes: 27 additions & 0 deletions src/plugins/streamers/gds2/db_plugin/gsiDeclDbGDS2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ static bool get_gds2_write_timestamps (const db::SaveLayoutOptions *options)
return options->get_options<db::GDS2WriterOptions> ().write_timestamps;
}

static void set_gds2_default_text_size (db::SaveLayoutOptions *options, const tl::Variant &v)
{
options->get_options<db::GDS2WriterOptions> ().default_text_size = v.is_nil () ? -1.0 : v.to_double ();
}

static tl::Variant get_gds2_default_text_size (const db::SaveLayoutOptions *options)
{
double ts = options->get_options<db::GDS2WriterOptions> ().default_text_size;
return ts < 0.0 ? tl::Variant () : tl::Variant (ts);
}

static void set_gds2_libname (db::SaveLayoutOptions *options, const std::string &n)
{
options->get_options<db::GDS2WriterOptions> ().libname = n;
Expand Down Expand Up @@ -189,6 +200,22 @@ gsi::ClassExt<db::SaveLayoutOptions> gds2_writer_options (
"@brief Gets a value indicating whether the current time is written into the GDS2 timestamp fields\n"
"\nThis property has been added in version 0.21.16.\n"
) +
gsi::method_ext ("gds2_default_text_size=", &set_gds2_default_text_size, gsi::arg ("size"),
"@brief Specifies the default text size to use when a text does not have a size\n"
"\n"
"Text object can have no size, e.g. when they are read from OASIS files. Technically such texts\n"
"are represented by text object with a zero size. You can configure the GDS writer to use a specific\n"
"text size in this case. This property specifies the default text size in micrometer units. This\n"
"size can be set to 0 to preserve a zero size in GDS files read.\n"
"\n"
"Set this attribute to nil to disable writing of a text size if none is specified.\n"
"\n"
"\nThis property has been added in version 0.30.4.\n"
) +
gsi::method_ext ("gds2_default_text_size", &get_gds2_default_text_size,
"@brief Gets the default text size to use when a text does not have a size\n"
"\nThis property has been added in version 0.30.4.\n"
) +
gsi::method_ext ("gds2_no_zero_length_paths=", &set_gds2_no_zero_length_paths, gsi::arg ("flag"),
"@brief Eliminates zero-length paths if true\n"
"\n"
Expand Down
Loading
Loading