mirror of https://github.com/KLayout/klayout.git
First attempt to implement X2 net names. Needs reconfirmation. (#1056)
This commit is contained in:
parent
f8bd4dafaf
commit
6a842cdc53
|
|
@ -415,7 +415,7 @@ GerberFileReader::collect (db::Region ®ion)
|
|||
}
|
||||
|
||||
void
|
||||
GerberFileReader::flush ()
|
||||
GerberFileReader::flush (const std::string &net_name)
|
||||
{
|
||||
process_clear_polygons ();
|
||||
|
||||
|
|
@ -425,14 +425,35 @@ GerberFileReader::flush ()
|
|||
m_polygons.swap (merged_polygons);
|
||||
}
|
||||
|
||||
std::string nn = net_name;
|
||||
for (std::vector <unsigned int>::const_iterator t = m_target_layers.begin (); t != m_target_layers.end (); ++t) {
|
||||
|
||||
db::Shapes &shapes = mp_top_cell->shapes (*t);
|
||||
|
||||
for (std::vector<db::Polygon>::const_iterator p = m_polygons.begin (); p != m_polygons.end (); ++p) {
|
||||
|
||||
shapes.insert (*p);
|
||||
|
||||
if (! nn.empty () && p->hull ().begin () != p->hull ().end ()) {
|
||||
db::Point pt = *p->hull ().begin ();
|
||||
shapes.insert (db::Text (nn, db::Trans (pt - db::Point ())));
|
||||
nn.clear ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (std::vector<db::Path>::const_iterator p = m_lines.begin (); p != m_lines.end (); ++p) {
|
||||
|
||||
shapes.insert (*p);
|
||||
|
||||
if (! nn.empty () && p->begin () != p->end ()) {
|
||||
db::Point pt = *p->begin ();
|
||||
shapes.insert (db::Text (nn, db::Trans (pt - db::Point ())));
|
||||
nn.clear ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_polygons.clear ();
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ protected:
|
|||
* @brief Flush the stored data to the output
|
||||
* This method is similar to collect(), but writes the data to the layout.
|
||||
*/
|
||||
void flush ();
|
||||
void flush (const std::string &net_name = std::string ());
|
||||
|
||||
/**
|
||||
* @brief Collects the data taken so far into the given region
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ RS274XReader::init ()
|
|||
{
|
||||
// Initialize reader:
|
||||
m_clear = false;
|
||||
m_net_name.clear ();
|
||||
m_guess_polarity = true;
|
||||
m_neg_polarity = false;
|
||||
m_relative = false;
|
||||
|
|
@ -263,6 +264,16 @@ RS274XReader::do_read ()
|
|||
read_pf_parameter (get_block ());
|
||||
} else if (param == "AD") {
|
||||
read_ad_parameter (get_block ());
|
||||
} else if (param == "TO") {
|
||||
|
||||
std::string net_name;
|
||||
if (read_net_name (get_block (), net_name)) {
|
||||
if (! m_net_name.empty ()) {
|
||||
flush (m_net_name);
|
||||
}
|
||||
m_net_name = net_name;
|
||||
}
|
||||
|
||||
} else if (param == "TA" || param == "TD" || param == "TF") {
|
||||
|
||||
// TA, TD and TF paramters are skipped for layout
|
||||
|
|
@ -677,6 +688,10 @@ RS274XReader::do_read ()
|
|||
|
||||
}
|
||||
|
||||
if (! m_net_name.empty ()) {
|
||||
flush (m_net_name);
|
||||
}
|
||||
|
||||
if (! graphics_stack_empty ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("AB block not closed")));
|
||||
}
|
||||
|
|
@ -963,6 +978,28 @@ RS274XReader::read_pf_parameter (const std::string & /*block*/)
|
|||
warn (tl::to_string (tr ("PF parameters are ignored")));
|
||||
}
|
||||
|
||||
bool
|
||||
RS274XReader::read_net_name (const std::string &block, std::string &net_name) const
|
||||
{
|
||||
tl::Extractor ex (block.c_str ());
|
||||
|
||||
ex.test (".");
|
||||
|
||||
if (ex.test ("N")) {
|
||||
|
||||
// only parse net names
|
||||
ex.test (",");
|
||||
|
||||
std::string n = ex.get ();
|
||||
if (! n.empty () && n != "N/C") {
|
||||
net_name = n;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
RS274XReader::read_ad_parameter (const std::string &block)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ private:
|
|||
std::map<std::string, std::string> m_aperture_macros;
|
||||
enum { ab_xy, ab_yx } m_axis_mapping;
|
||||
RS274XApertureBase *m_current_aperture;
|
||||
std::string m_net_name;
|
||||
|
||||
void read_as_parameter (const std::string &block);
|
||||
void read_fs_parameter (const std::string &block);
|
||||
|
|
@ -103,6 +104,7 @@ private:
|
|||
void read_lp_parameter (const std::string &block);
|
||||
void read_sr_parameter (const std::string &block);
|
||||
void read_if_parameter (const std::string &block);
|
||||
bool read_net_name (const std::string &block, std::string &net_name) const;
|
||||
void install_block_aperture (const std::string &dcode, const db::Region ®ion);
|
||||
void process_mcode (int mcode);
|
||||
const std::string &get_block ();
|
||||
|
|
|
|||
Loading…
Reference in New Issue