From 4d64e95680c22f5d693eea8825ed03447b7e41b5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 18 Oct 2021 23:08:38 +0200 Subject: [PATCH] Shape objects from custom queries 'select' are translated into shape markers when exporting to RDB --- src/lay/lay/laySearchReplaceDialog.cc | 5 +-- src/rdb/rdb/rdbUtils.cc | 47 +++++++++++++++++++++++++++ src/rdb/rdb/rdbUtils.h | 12 +++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index 4f8196e64..3c70640ba 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -38,6 +38,7 @@ #include "tlLog.h" #include "tlProgress.h" #include "tlTimer.h" +#include "rdbUtils.h" #include #include @@ -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::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); } } diff --git a/src/rdb/rdb/rdbUtils.cc b/src/rdb/rdb/rdbUtils.cc index 336ed963e..c6940a56a 100644 --- a/src/rdb/rdb/rdbUtils.cc +++ b/src/rdb/rdb/rdbUtils.cc @@ -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 ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (dbu > 0 && v.is_user ()) { + db::DPoint p = db::CplxTrans (dbu) * v.to_user (); + item->add_value (db::DEdge (p, p)); + } else if (dbu > 0 && v.is_user ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (dbu > 0 && v.is_user ()) { + db::DPolygon p; + db::DSimplePolygon sp = db::CplxTrans (dbu) * v.to_user (); + p.assign_hull (sp.begin_hull (), sp.end_hull ()); + item->add_value (p); + } else if (dbu > 0 && v.is_user ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (dbu > 0 && v.is_user ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (dbu > 0 && v.is_user ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (dbu > 0 && v.is_user ()) { + item->add_value (db::CplxTrans (dbu) * v.to_user ()); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else if (v.is_user ()) { + db::DPoint p = v.to_user (); + item->add_value (db::DEdge (p, p)); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else if (v.is_user ()) { + db::DPolygon p; + db::DSimplePolygon sp = v.to_user (); + p.assign_hull (sp.begin_hull (), sp.end_hull ()); + item->add_value (p); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else if (v.is_user ()) { + item->add_value (v.to_user ()); + } else { + item->add_value (std::string (v.to_string ())); + } +} + } diff --git a/src/rdb/rdb/rdbUtils.h b/src/rdb/rdb/rdbUtils.h index d89cd6c72..f6b579008 100644 --- a/src/rdb/rdb/rdbUtils.h +++ b/src/rdb/rdb/rdbUtils.h @@ -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