mirror of https://github.com/KLayout/klayout.git
Shape objects from custom queries 'select' are translated into shape markers when exporting to RDB
This commit is contained in:
parent
710d217b17
commit
4d64e95680
|
|
@ -38,6 +38,7 @@
|
|||
#include "tlLog.h"
|
||||
#include "tlProgress.h"
|
||||
#include "tlTimer.h"
|
||||
#include "rdbUtils.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QHeaderView>
|
||||
|
|
@ -537,10 +538,10 @@ SearchReplaceResults::export_rdb (rdb::Database &rdb, double dbu)
|
|||
rdb::Item *item = rdb.create_item (cell->id (), cat->id ());
|
||||
|
||||
if (! v->is_list ()) {
|
||||
item->add_value (std::string (v->to_string ()));
|
||||
rdb::add_item_value (item, *v, dbu);
|
||||
} else {
|
||||
for (std::vector<tl::Variant>::const_iterator i = v->get_list ().begin (); i != v->get_list ().end (); ++i) {
|
||||
item->add_value (std::string (i->to_string ()));
|
||||
rdb::add_item_value (item, *i, dbu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -317,5 +317,52 @@ void create_items_from_edge_pairs (rdb::Database *db, rdb::id_type cell_id, rdb:
|
|||
}
|
||||
}
|
||||
|
||||
void add_item_value (rdb::Item *item, const tl::Variant &v, double dbu)
|
||||
{
|
||||
if (dbu > 0 && v.is_user<db::Box> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::Box> ());
|
||||
} else if (dbu > 0 && v.is_user<db::Point> ()) {
|
||||
db::DPoint p = db::CplxTrans (dbu) * v.to_user<db::Point> ();
|
||||
item->add_value (db::DEdge (p, p));
|
||||
} else if (dbu > 0 && v.is_user<db::Polygon> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::Polygon> ());
|
||||
} else if (dbu > 0 && v.is_user<db::SimplePolygon> ()) {
|
||||
db::DPolygon p;
|
||||
db::DSimplePolygon sp = db::CplxTrans (dbu) * v.to_user<db::SimplePolygon> ();
|
||||
p.assign_hull (sp.begin_hull (), sp.end_hull ());
|
||||
item->add_value (p);
|
||||
} else if (dbu > 0 && v.is_user<db::Edge> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::Edge> ());
|
||||
} else if (dbu > 0 && v.is_user<db::EdgePair> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::EdgePair> ());
|
||||
} else if (dbu > 0 && v.is_user<db::Path> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::Path> ());
|
||||
} else if (dbu > 0 && v.is_user<db::Text> ()) {
|
||||
item->add_value (db::CplxTrans (dbu) * v.to_user<db::Text> ());
|
||||
} else if (v.is_user<db::DBox> ()) {
|
||||
item->add_value (v.to_user<db::DBox> ());
|
||||
} else if (v.is_user<db::DPoint> ()) {
|
||||
db::DPoint p = v.to_user<db::DPoint> ();
|
||||
item->add_value (db::DEdge (p, p));
|
||||
} else if (v.is_user<db::DPolygon> ()) {
|
||||
item->add_value (v.to_user<db::DPolygon> ());
|
||||
} else if (v.is_user<db::DSimplePolygon> ()) {
|
||||
db::DPolygon p;
|
||||
db::DSimplePolygon sp = v.to_user<db::DSimplePolygon> ();
|
||||
p.assign_hull (sp.begin_hull (), sp.end_hull ());
|
||||
item->add_value (p);
|
||||
} else if (v.is_user<db::DEdge> ()) {
|
||||
item->add_value (v.to_user<db::DEdge> ());
|
||||
} else if (v.is_user<db::DEdgePair> ()) {
|
||||
item->add_value (v.to_user<db::DEdgePair> ());
|
||||
} else if (v.is_user<db::DPath> ()) {
|
||||
item->add_value (v.to_user<db::DPath> ());
|
||||
} else if (v.is_user<db::DText> ()) {
|
||||
item->add_value (v.to_user<db::DText> ());
|
||||
} else {
|
||||
item->add_value (std::string (v.to_string ()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,18 @@ RDB_PUBLIC_TEMPLATE void create_items_from_sequence (rdb::Database *db, rdb::id_
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a value from a tl::Variant
|
||||
*
|
||||
* This produces values which reflect some values the variant can assume - specifically
|
||||
* shapes are converted into corresponding RDB values. The database unit is used to
|
||||
* translate integer-type values. Using a database unit of 0 will disable the conversion of
|
||||
* such types.
|
||||
*
|
||||
* Unknown types are converted to strings.
|
||||
*/
|
||||
RDB_PUBLIC void add_item_value (rdb::Item *item, const tl::Variant &v, double dbu = 0.0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue