mirror of https://github.com/KLayout/klayout.git
Added title support, tests, debugging
This commit is contained in:
parent
226ba429f1
commit
30ac61ea20
|
|
@ -31,6 +31,7 @@
|
|||
#include "dbTechnology.h"
|
||||
#include "dbCellMapping.h"
|
||||
#include "dbLayerMapping.h"
|
||||
#include "dbGlyphs.h"
|
||||
|
||||
#include "tlException.h"
|
||||
#include "tlString.h"
|
||||
|
|
@ -218,9 +219,30 @@ MALYReader::import_data (db::Layout &layout, const MALYData &data)
|
|||
|
||||
}
|
||||
|
||||
// produce the titles
|
||||
|
||||
for (auto t = m->titles.begin (); t != m->titles.end (); ++t) {
|
||||
|
||||
const double one_mm = 1000.0;
|
||||
|
||||
auto gen = db::TextGenerator::default_generator ();
|
||||
double scale = std::min (t->width * one_mm / (gen->width () * gen->dbu ()), t->height * one_mm / (gen->height () * gen->dbu ()));
|
||||
|
||||
auto &s = t->string;
|
||||
int len = int (s.size ());
|
||||
db::DVector shift (-t->width * one_mm * len * 0.5, -t->height * one_mm * 0.5);
|
||||
double char_spacing = t->width * one_mm - gen->width () * gen->dbu () * scale;
|
||||
|
||||
db::Region text = gen->text_as_region (s, layout.dbu (), scale, false, 0.0, char_spacing, 0.0);
|
||||
text.transform (db::Trans (db::CplxTrans (layout.dbu ()).inverted () * shift));
|
||||
text.transform (db::CplxTrans (layout.dbu ()).inverted () * db::DCplxTrans (t->transformation) * db::CplxTrans (layout.dbu ()));
|
||||
|
||||
text.insert_into (&layout, mask_cell.cell_index (), target_layer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @@@ TODO: generate titles
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -376,6 +398,10 @@ MALYReader::extract_title_trans (tl::Extractor &ex, MALYReaderTitleSpec &spec)
|
|||
ex.read (spec.width);
|
||||
ex.read (spec.height);
|
||||
ex.read (spec.pitch);
|
||||
} else {
|
||||
spec.width = 1.0;
|
||||
spec.height = 1.0;
|
||||
spec.pitch = 1.0;
|
||||
}
|
||||
|
||||
if (ex.test ("MIRROR")) {
|
||||
|
|
@ -394,7 +420,7 @@ MALYReader::extract_title_trans (tl::Extractor &ex, MALYReaderTitleSpec &spec)
|
|||
rot = (a / 90) % 4;
|
||||
}
|
||||
|
||||
spec.trans = db::DTrans (rot, ymirror, db::DVector (x, y));
|
||||
spec.trans = db::DTrans (rot, false, db::DVector (x, y)) * db::DTrans (ymirror ? db::DFTrans::m90 : db::DFTrans::r0);
|
||||
}
|
||||
|
||||
MALYReader::MALYReaderParametersData::Base
|
||||
|
|
@ -552,6 +578,8 @@ MALYReader::read_title (MALYReaderTitleData &data)
|
|||
break;
|
||||
} else if (ex.test ("DATE")) {
|
||||
|
||||
data.date_spec.given = true;
|
||||
|
||||
if (ex.test ("OFF")) {
|
||||
data.date_spec.enabled = false;
|
||||
} else {
|
||||
|
|
@ -562,6 +590,8 @@ MALYReader::read_title (MALYReaderTitleData &data)
|
|||
|
||||
} else if (ex.test ("SERIAL")) {
|
||||
|
||||
data.serial_spec.given = true;
|
||||
|
||||
if (ex.test ("OFF")) {
|
||||
data.serial_spec.enabled = false;
|
||||
} else {
|
||||
|
|
@ -779,31 +809,33 @@ MALYReader::create_masks (const MALYReaderMaskData &cmask, const std::list<MALYR
|
|||
font = MALYTitle::Standard;
|
||||
}
|
||||
|
||||
bool maskmirror = (i->parameters.maskmirror != cmask.parameters.maskmirror);
|
||||
|
||||
const MALYReaderTitleSpec *date_spec = 0;
|
||||
if (i->title.date_spec.enabled) {
|
||||
if (i->title.date_spec.given) {
|
||||
date_spec = &i->title.date_spec;
|
||||
} else if (cmask.title.date_spec.enabled) {
|
||||
} else if (cmask.title.date_spec.given) {
|
||||
date_spec = &cmask.title.date_spec;
|
||||
}
|
||||
if (date_spec) {
|
||||
m.titles.push_back (create_title (MALYTitle::Date, *date_spec, font, std::string ("<SERIAL>")));
|
||||
if (date_spec && date_spec->enabled) {
|
||||
m.titles.push_back (create_title (MALYTitle::Date, *date_spec, font, maskmirror, std::string ("<DATE>")));
|
||||
}
|
||||
|
||||
const MALYReaderTitleSpec *serial_spec = 0;
|
||||
if (i->title.serial_spec.enabled) {
|
||||
if (i->title.serial_spec.given) {
|
||||
serial_spec = &i->title.serial_spec;
|
||||
} else if (cmask.title.serial_spec.enabled) {
|
||||
} else if (cmask.title.serial_spec.given) {
|
||||
serial_spec = &cmask.title.serial_spec;
|
||||
}
|
||||
if (date_spec) {
|
||||
m.titles.push_back (create_title (MALYTitle::Serial, *serial_spec, font, std::string ("<DATE>")));
|
||||
if (serial_spec && serial_spec->enabled) {
|
||||
m.titles.push_back (create_title (MALYTitle::Serial, *serial_spec, font, maskmirror, std::string ("<SERIAL>")));
|
||||
}
|
||||
|
||||
for (auto t = i->title.string_titles.begin (); t != i->title.string_titles.end (); ++t) {
|
||||
m.titles.push_back (create_title (MALYTitle::String, t->second, font, t->first));
|
||||
m.titles.push_back (create_title (MALYTitle::String, t->second, font, maskmirror, t->first));
|
||||
}
|
||||
for (auto t = cmask.title.string_titles.begin (); t != cmask.title.string_titles.end (); ++t) {
|
||||
m.titles.push_back (create_title (MALYTitle::String, t->second, font, t->first));
|
||||
m.titles.push_back (create_title (MALYTitle::String, t->second, font, maskmirror, t->first));
|
||||
}
|
||||
|
||||
MALYReaderParametersData::Base base = i->parameters.base;
|
||||
|
|
@ -839,11 +871,11 @@ MALYReader::create_masks (const MALYReaderMaskData &cmask, const std::list<MALYR
|
|||
}
|
||||
|
||||
MALYTitle
|
||||
MALYReader::create_title (MALYTitle::Type type, const MALYReaderTitleSpec &data, MALYTitle::Font font, const std::string &string)
|
||||
MALYReader::create_title (MALYTitle::Type type, const MALYReaderTitleSpec &data, MALYTitle::Font font, bool maskmirror, const std::string &string)
|
||||
{
|
||||
MALYTitle title;
|
||||
|
||||
title.transformation = data.trans;
|
||||
title.transformation = db::DTrans (maskmirror ? db::DFTrans::m90 : db::DFTrans::r0) * data.trans;
|
||||
title.width = data.width;
|
||||
title.height = data.height;
|
||||
title.pitch = data.pitch;
|
||||
|
|
|
|||
|
|
@ -149,9 +149,10 @@ private:
|
|||
struct MALYReaderTitleSpec
|
||||
{
|
||||
MALYReaderTitleSpec ()
|
||||
: enabled (false), width (1.0), height (1.0), pitch (1.0)
|
||||
: given (false), enabled (false), width (1.0), height (1.0), pitch (1.0)
|
||||
{ }
|
||||
|
||||
bool given;
|
||||
bool enabled;
|
||||
db::DTrans trans;
|
||||
double width, height, pitch;
|
||||
|
|
@ -243,7 +244,7 @@ private:
|
|||
bool begin_section (tl::Extractor &ex, const std::string &name = std::string ());
|
||||
bool end_section (tl::Extractor &ex);
|
||||
void skip_section ();
|
||||
MALYTitle create_title (MALYTitle::Type type, const MALYReaderTitleSpec &data, MALYTitle::Font font, const std::string &string);
|
||||
MALYTitle create_title (MALYTitle::Type type, const MALYReaderTitleSpec &data, MALYTitle::Font font, bool maskmirror, const std::string &string);
|
||||
void create_masks (const MALYReaderMaskData &cmask, const std::list<MALYReaderMaskData> &masks, MALYData &data);
|
||||
MALYStructure create_structure (const MALYReaderParametersData &mparam, const MALYReaderParametersData &cparam, const MALYReaderStrRefData &data, const std::string &strgroup_name, MALYReaderParametersData::Base base, MALYReaderParametersData::Base array_base);
|
||||
std::string resolve_path (const MALYReaderParametersData ¶m, const std::string &path);
|
||||
|
|
|
|||
|
|
@ -86,10 +86,9 @@ TEST(1_Basic)
|
|||
EXPECT_EQ (data.to_string (),
|
||||
"Mask A\n"
|
||||
" Size 127000\n"
|
||||
" Title \"<SERIAL>\" m90 50,-50 1,1,1 [Standard]\n"
|
||||
" Title \"<DATE>\" r0 0,-50 1,1,1 [Standard]\n"
|
||||
" Title \"MaskA1\" r0 -50,50 1,1,1 [Standard]\n"
|
||||
" Title \"WITH \"QUOTES\"\" m45 50,0 1,1,1 [Standard]\n"
|
||||
" Title \"<SERIAL>\" m90 0,-50 1,1,1 [Standard]\n"
|
||||
" Title \"MaskA1\" m90 50,50 1,1,1 [Standard]\n"
|
||||
" Title \"WITH \"QUOTES\"\" r270 -50,0 1,1,1 [Standard]\n"
|
||||
" Ref A1.oas{CHIP_A}(1) (0,0;10,10) m90 *1 20,0\n"
|
||||
" Ref A2.oas{CHIP_A}(2) ename(e001) dname(d001) (0,0;50,50) m90 *0.8 20,0 [2x5,1x2]\n"
|
||||
" Ref B3.oas{CHIP_A}(2) (0,0;12,12) m90 *1 20,0"
|
||||
|
|
@ -137,3 +136,8 @@ TEST(10_BasicLayout)
|
|||
run_test (_this, tl::testdata (), "MALY_test10.maly", "maly_test10_au.oas");
|
||||
}
|
||||
|
||||
TEST(11_Titles)
|
||||
{
|
||||
run_test (_this, tl::testdata (), "MALY_test11.maly", "maly_test11_au.oas");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
BEGIN MALY 1.1
|
||||
BEGIN MASKSET
|
||||
BEGIN CMASK
|
||||
BEGIN PARAMETER
|
||||
MASKSIZE 7
|
||||
FONT STANDARD
|
||||
BASE ORIGIN
|
||||
ARYBASE ORIGIN
|
||||
ROOT OASIS.MASK test10_oas
|
||||
MASKMIRROR NONE
|
||||
END PARAMETER
|
||||
BEGIN TITLE
|
||||
DATE -50000 -5000 MIRROR Y ROTATE 90
|
||||
SERIAL -50000 -10000
|
||||
STRING "A STRING TITLE UPSIDE DOWN" 0 -50000 MIRROR Y ROTATE 180
|
||||
STRING "A STRING TITLE" 0 -51500
|
||||
END TITLE
|
||||
END CMASK
|
||||
BEGIN MASK A
|
||||
END MASK
|
||||
BEGIN MASK B
|
||||
BEGIN PARAMETER
|
||||
MASKMIRROR Y
|
||||
END PARAMETER
|
||||
BEGIN TITLE
|
||||
SERIAL OFF
|
||||
STRING "A STRING TITLE FOR MASK B" 5000 -53000
|
||||
END TITLE
|
||||
END MASK
|
||||
BEGIN MASK C
|
||||
BEGIN TITLE
|
||||
DATE OFF
|
||||
STRING "A STRING TITLE FOR MASK C" 0 -55000 SIZE 1.5 2.0 3.0
|
||||
END TITLE
|
||||
END MASK
|
||||
END MASKSET
|
||||
END MALY
|
||||
Binary file not shown.
Loading…
Reference in New Issue