From 361bc648703563de86cea1118616a649af03fd25 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 19 Jun 2018 20:31:55 +0200 Subject: [PATCH] WIP: fixed some build issues, removed some link dependencies which causes issues on Windows. --- src/buddies/src/bd/bd.pro | 6 - src/buddies/src/bd/bdConverterMain.cc | 1 - src/buddies/src/bd/bdReaderOptions.h | 2 +- src/buddies/src/bd/bdWriterOptions.h | 2 +- src/buddies/src/bd/strm2cif.cc | 2 +- src/buddies/src/buddy_app.pri | 1 - src/buddies/unit_tests/bdConverterTests.cc | 38 ++- src/buddies/unit_tests/bdStrmrunTests.cc | 47 ++++ src/buddies/unit_tests/unit_tests.pro | 7 +- src/gsi/gsi/gsi.cc | 18 +- src/gsi/gsi/gsiClassBase.cc | 9 +- src/gsi/gsi/gsiClassBase.h | 8 + src/gsi/gsi/gsiExpression.cc | 5 + src/lym/lym/lymMacro.cc | 5 + .../streamers/cif/db_plugin/dbCIFFormat.h | 169 +++++++++++++ .../streamers/cif/db_plugin/dbCIFReader.h | 83 +----- .../streamers/cif/db_plugin/dbCIFWriter.h | 49 +--- .../streamers/cif/db_plugin/db_plugin.pro | 1 + .../common/lay_plugin/lay_plugin.pro | 2 +- .../streamers/dxf/db_plugin/dbDXFFormat.h | 239 ++++++++++++++++++ .../streamers/dxf/db_plugin/dbDXFReader.h | 159 +----------- .../streamers/dxf/db_plugin/dbDXFWriter.h | 50 +--- .../streamers/dxf/db_plugin/db_plugin.pro | 1 + .../streamers/gds2/db_plugin/dbGDS2Format.h | 97 +++++++ .../streamers/gds2/db_plugin/dbGDS2Reader.h | 62 +---- .../streamers/gds2/db_plugin/db_plugin.pro | 1 + .../streamers/oasis/db_plugin/dbOASISFormat.h | 188 ++++++++++++++ .../streamers/oasis/db_plugin/dbOASISReader.h | 57 +---- .../streamers/oasis/db_plugin/dbOASISWriter.h | 95 +------ .../streamers/oasis/db_plugin/db_plugin.pro | 1 + testdata/bd/strmrun.py | 2 + 31 files changed, 824 insertions(+), 583 deletions(-) create mode 100644 src/buddies/unit_tests/bdStrmrunTests.cc create mode 100644 src/plugins/streamers/cif/db_plugin/dbCIFFormat.h create mode 100644 src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h create mode 100644 src/plugins/streamers/gds2/db_plugin/dbGDS2Format.h create mode 100644 src/plugins/streamers/oasis/db_plugin/dbOASISFormat.h create mode 100644 testdata/bd/strmrun.py diff --git a/src/buddies/src/bd/bd.pro b/src/buddies/src/bd/bd.pro index e3cefe76a..4a11a6fdf 100644 --- a/src/buddies/src/bd/bd.pro +++ b/src/buddies/src/bd/bd.pro @@ -45,12 +45,6 @@ PLUGINPATH += \ INCLUDEPATH += $$PLUGINPATH DEPENDPATH += $$PLUGINPATH -LIBS += -L$$DESTDIR/db_plugins \ - -lgds2 \ - -lcif \ - -loasis \ - -ldxf \ - INCLUDEPATH += $$RBA_INC DEPENDPATH += $$RBA_INC diff --git a/src/buddies/src/bd/bdConverterMain.cc b/src/buddies/src/bd/bdConverterMain.cc index 5cd1e8eb4..e60c14975 100644 --- a/src/buddies/src/bd/bdConverterMain.cc +++ b/src/buddies/src/bd/bdConverterMain.cc @@ -25,7 +25,6 @@ #include "bdConverterMain.h" #include "dbLayout.h" #include "dbReader.h" -#include "dbCIFWriter.h" #include "tlCommandLineParser.h" namespace bd diff --git a/src/buddies/src/bd/bdReaderOptions.h b/src/buddies/src/bd/bdReaderOptions.h index 9ff79067d..93e48c794 100644 --- a/src/buddies/src/bd/bdReaderOptions.h +++ b/src/buddies/src/bd/bdReaderOptions.h @@ -28,7 +28,7 @@ #include "dbGDS2Reader.h" #include "dbOASISReader.h" #include "dbDXFReader.h" -#include "dbCIFReader.h" +#include "dbCIFFormat.h" #include diff --git a/src/buddies/src/bd/bdWriterOptions.h b/src/buddies/src/bd/bdWriterOptions.h index 4e1693940..d4347b2ed 100644 --- a/src/buddies/src/bd/bdWriterOptions.h +++ b/src/buddies/src/bd/bdWriterOptions.h @@ -27,7 +27,7 @@ #include "dbGDS2WriterBase.h" #include "dbOASISWriter.h" #include "dbDXFWriter.h" -#include "dbCIFWriter.h" +#include "dbCIFFormat.h" #include diff --git a/src/buddies/src/bd/strm2cif.cc b/src/buddies/src/bd/strm2cif.cc index 1d22ac2b0..3502dd240 100644 --- a/src/buddies/src/bd/strm2cif.cc +++ b/src/buddies/src/bd/strm2cif.cc @@ -21,7 +21,7 @@ */ #include "bdConverterMain.h" -#include "dbCIFWriter.h" +#include "dbCIFFormat.h" BD_PUBLIC int strm2cif (int argc, char *argv[]) { diff --git a/src/buddies/src/buddy_app.pri b/src/buddies/src/buddy_app.pri index 3f72e8b5a..d5bafd153 100644 --- a/src/buddies/src/buddy_app.pri +++ b/src/buddies/src/buddy_app.pri @@ -39,7 +39,6 @@ equals(HAVE_PYTHON, "1") { LIBS += -lklayout_pyastub } - DEFINES += BD_TARGET=$$TARGET LIBS += $$RUBYLIBFILE diff --git a/src/buddies/unit_tests/bdConverterTests.cc b/src/buddies/unit_tests/bdConverterTests.cc index 19931297a..fbc538893 100644 --- a/src/buddies/unit_tests/bdConverterTests.cc +++ b/src/buddies/unit_tests/bdConverterTests.cc @@ -21,7 +21,8 @@ */ #include "bdConverterMain.h" -#include "dbCIFReader.h" +#include "dbStream.h" +#include "dbCIFFormat.h" #include "dbDXFReader.h" #include "dbOASISReader.h" #include "dbGDS2Reader.h" @@ -45,8 +46,11 @@ TEST(1) { tl::InputStream stream (output); - db::CIFReader reader (stream); - reader.read (layout, db::LoadLayoutOptions ()); + db::LoadLayoutOptions options; + options.set_options (new db::CIFReaderOptions ()); + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "CIF"); } db::compare_layouts (this, layout, input, db::NoNormalization); @@ -68,8 +72,11 @@ TEST(2) { tl::InputStream stream (output); - db::DXFReader reader (stream); - reader.read (layout, db::LoadLayoutOptions ()); + db::LoadLayoutOptions options; + options.set_options (new db::DXFReaderOptions ()); + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "DXF"); } // Fix top cell name (which is TOP in DXF, not RINGO as in reference) @@ -97,8 +104,11 @@ TEST(3) { tl::InputStream stream (output); - db::GDS2Reader reader (stream); - reader.read (layout, db::LoadLayoutOptions ()); + db::LoadLayoutOptions options; + options.set_options (new db::GDS2ReaderOptions ()); + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "GDS2"); } db::compare_layouts (this, layout, input, db::NoNormalization); @@ -120,8 +130,11 @@ TEST(4) { tl::InputStream stream (output); - db::GDS2ReaderText reader (stream); - reader.read (layout, db::LoadLayoutOptions ()); + db::LoadLayoutOptions options; + options.set_options (new db::GDS2ReaderOptions ()); + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "GDS2Text"); } db::compare_layouts (this, layout, input, db::NoNormalization); @@ -143,8 +156,11 @@ TEST(5) { tl::InputStream stream (output); - db::OASISReader reader (stream); - reader.read (layout, db::LoadLayoutOptions ()); + db::LoadLayoutOptions options; + options.set_options (new db::OASISReaderOptions ()); + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "OASIS"); } db::compare_layouts (this, layout, input, db::NoNormalization); diff --git a/src/buddies/unit_tests/bdStrmrunTests.cc b/src/buddies/unit_tests/bdStrmrunTests.cc new file mode 100644 index 000000000..324d8b647 --- /dev/null +++ b/src/buddies/unit_tests/bdStrmrunTests.cc @@ -0,0 +1,47 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include "tlUnitTest.h" + +#include +#include + +// Testing the converter main implementation (CIF) +TEST(1) +{ + QProcess process; + process.setProcessChannelMode (QProcess::MergedChannels); + + QStringList args; + + std::string fp (tl::testsrc ()); + fp += "/testdata/bd/strmrun.py"; + args << tl::to_qstring (fp); + + process.start (tl::to_qstring ("./strmrun"), args); + bool success = process.waitForFinished (-1); + + QByteArray ba = process.readAll (); + EXPECT_EQ (ba.constData (), "Hello, world (0,-42;42,0)!\n"); + EXPECT_EQ (success, true); +} + diff --git a/src/buddies/unit_tests/unit_tests.pro b/src/buddies/unit_tests/unit_tests.pro index da47c2ad5..702e0cb29 100644 --- a/src/buddies/unit_tests/unit_tests.pro +++ b/src/buddies/unit_tests/unit_tests.pro @@ -14,6 +14,7 @@ SOURCES = \ bdStrmclipTests.cc \ bdStrmcmpTests.cc \ bdStrmxorTests.cc \ + bdStrmrunTests.cc \ INCLUDEPATH += $$BD_INC $$DB_INC $$TL_INC $$GSI_INC @@ -30,9 +31,3 @@ PLUGINPATH += \ INCLUDEPATH += $$PLUGINPATH DEPENDPATH += $$PLUGINPATH - -LIBS += -L$$DESTDIR_UT/db_plugins \ - -lgds2 \ - -lcif \ - -loasis \ - -ldxf \ diff --git a/src/gsi/gsi/gsi.cc b/src/gsi/gsi/gsi.cc index b8904c67f..440657f84 100644 --- a/src/gsi/gsi/gsi.cc +++ b/src/gsi/gsi/gsi.cc @@ -57,13 +57,19 @@ initialize () tl::VariantUserClassBase::clear_class_table (); for (gsi::ClassBase::class_iterator c = gsi::ClassBase::begin_classes (); c != gsi::ClassBase::end_classes (); ++c) { - // Note: for backward compatibility we use lower case names - std::string lc = tl::to_lower_case (c->name ()); - std::string lc_trans = tl::VariantUserClassBase::translate_class_name (lc); - tl::VariantUserClassBase::register_user_class (lc, c->var_cls (false)); - if (lc != lc_trans) { - tl::VariantUserClassBase::register_user_class (lc_trans, c->var_cls (false)); + + if (! c->is_external ()) { + + // Note: for backward compatibility we use lower case names + std::string lc = tl::to_lower_case (c->name ()); + std::string lc_trans = tl::VariantUserClassBase::translate_class_name (lc); + tl::VariantUserClassBase::register_user_class (lc, c->var_cls (false)); + if (lc != lc_trans) { + tl::VariantUserClassBase::register_user_class (lc_trans, c->var_cls (false)); + } + } + } } diff --git a/src/gsi/gsi/gsiClassBase.cc b/src/gsi/gsi/gsiClassBase.cc index 2293b2f81..f40d0a596 100644 --- a/src/gsi/gsi/gsiClassBase.cc +++ b/src/gsi/gsi/gsiClassBase.cc @@ -435,6 +435,11 @@ ClassBase::merge_declarations () // Add to the classes the special methods and clean up the method table for (gsi::ClassBase::class_iterator c = gsi::ClassBase::begin_new_classes (); c != gsi::ClassBase::end_new_classes (); ++c) { + // Skip external classes (i.e. provided by Ruby or Python) + if (c->is_external ()) { + continue; + } + std::set > name_map; for (gsi::ClassBase::method_iterator m = c->begin_methods (); m != c->end_methods (); ++m) { for (gsi::MethodBase::synonym_iterator syn = (*m)->begin_synonyms (); syn != (*m)->end_synonyms (); ++syn) { @@ -525,7 +530,9 @@ ClassBase::merge_declarations () (const_cast (&*c))->initialize (); // there should be only main declarations since we merged - tl_assert (c->declaration () == &*c); + // (the declaration==0 case covers dummy declarations introduced by + // lym::ExternalClass) + tl_assert (! c->declaration () || c->declaration () == &*c); } } diff --git a/src/gsi/gsi/gsiClassBase.h b/src/gsi/gsi/gsiClassBase.h index 92b3a3f75..8716e7de0 100644 --- a/src/gsi/gsi/gsiClassBase.h +++ b/src/gsi/gsi/gsiClassBase.h @@ -523,6 +523,14 @@ public: return 0; } + /** + * @brief Returns true, if the class is an external class provided by Python or Ruby code + */ + virtual bool is_external () const + { + return false; + } + /** * @brief Post-construction initialization * diff --git a/src/gsi/gsi/gsiExpression.cc b/src/gsi/gsi/gsiExpression.cc index 300376c64..ef3635dab 100644 --- a/src/gsi/gsi/gsiExpression.cc +++ b/src/gsi/gsi/gsiExpression.cc @@ -1079,6 +1079,11 @@ initialize_expressions () // Go through all classes (maybe again) for (gsi::ClassBase::class_iterator c = gsi::ClassBase::begin_classes (); c != gsi::ClassBase::end_classes (); ++c) { + // Skip external classes + if (c->is_external ()) { + continue; + } + // install the method table: ExpressionMethodTable::initialize_class (&*c); diff --git a/src/lym/lym/lymMacro.cc b/src/lym/lym/lymMacro.cc index 9e189da57..91373d24c 100644 --- a/src/lym/lym/lymMacro.cc +++ b/src/lym/lym/lymMacro.cc @@ -839,6 +839,11 @@ public: return true; } + virtual bool is_external () const + { + return true; + } + private: std::string m_category; }; diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFFormat.h b/src/plugins/streamers/cif/db_plugin/dbCIFFormat.h new file mode 100644 index 000000000..00164ba83 --- /dev/null +++ b/src/plugins/streamers/cif/db_plugin/dbCIFFormat.h @@ -0,0 +1,169 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef HDR_dbCIFFormat +#define HDR_dbCIFFormat + +#include "dbSaveLayoutOptions.h" +#include "dbLoadLayoutOptions.h" + +namespace db +{ + +/** + * @brief Structure that holds the CIF specific options for the reader + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class CIFReaderOptions + : public FormatSpecificReaderOptions +{ +public: + /** + * @brief The constructor + */ + CIFReaderOptions () + : wire_mode (0), + dbu (0.001), + create_other_layers (true), + keep_layer_names (false) + { + // .. nothing yet .. + } + + /** + * @brief How to read 'W' objects + * + * This property specifies how to read 'W' (wire) objects. + * Allowed values are 0 (as square ended paths), 1 (as flush ended paths), 2 (as round paths) + */ + unsigned int wire_mode; + + /** + * @brief Specify the database unit to produce + * + * Specify the database unit which the resulting layout will receive. + */ + double dbu; + + /** + * @brief Specifies a layer mapping + * + * If a layer mapping is specified, only the given layers are read. + * Otherwise, all layers are read. + * Setting "create_other_layers" to true will make the reader + * create other layers for all layers not given in the layer map. + * Setting an empty layer map and create_other_layers to true effectively + * enables all layers for reading. + */ + db::LayerMap layer_map; + + /** + * @brief A flag indicating that a new layers shall be created + * + * If this flag is set to true, layers not listed in the layer map a created + * too. + */ + bool create_other_layers; + + /** + * @brief A flag indicating whether the names of layers shall be kept as such + * + * If this flag is set to false (the default), layer name translation happens. + * If set to true, translation will not happen. + * Name translation will try to extract GDS layer/datatype numbers from the + * layer names. If this value is set to true, no name translation happens. + */ + bool keep_layer_names; + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual FormatSpecificReaderOptions *clone () const + { + return new CIFReaderOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual const std::string &format_name () const + { + static const std::string n ("CIF"); + return n; + } +}; + +/** + * @brief Structure that holds the CIF specific options for the Writer + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class CIFWriterOptions + : public FormatSpecificWriterOptions +{ +public: + /** + * @brief The constructor + */ + CIFWriterOptions () + : dummy_calls (false), blank_separator (false) + { + // .. nothing yet .. + } + + /** + * @brief A flag indicating whether dummy calls shall be written + * If this flag is true, the writer will produce dummy cell calls on global + * level for all top cells. + */ + bool dummy_calls; + + /** + * @brief A flag indicating whether to use blanks as x/y separators + * If this flag is true, blank characters will be used to separate x and y values. + * Otherwise comma characters will be used. + */ + bool blank_separator; + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual FormatSpecificWriterOptions *clone () const + { + return new CIFWriterOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual const std::string &format_name () const + { + static std::string n ("CIF"); + return n; + } +}; + +} + +#endif + diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFReader.h b/src/plugins/streamers/cif/db_plugin/dbCIFReader.h index d2ce02c22..1e307eaab 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFReader.h +++ b/src/plugins/streamers/cif/db_plugin/dbCIFReader.h @@ -29,6 +29,7 @@ #include "dbNamedLayerReader.h" #include "dbLayout.h" #include "dbCIF.h" +#include "dbCIFFormat.h" #include "dbStreamLayers.h" #include "dbPropertiesRepository.h" @@ -44,88 +45,6 @@ namespace db { -/** - * @brief Structure that holds the CIF specific options for the reader - */ -class DB_PLUGIN_PUBLIC CIFReaderOptions - : public FormatSpecificReaderOptions -{ -public: - /** - * @brief The constructor - */ - CIFReaderOptions () - : wire_mode (0), - dbu (0.001), - create_other_layers (true), - keep_layer_names (false) - { - // .. nothing yet .. - } - - /** - * @brief How to read 'W' objects - * - * This property specifies how to read 'W' (wire) objects. - * Allowed values are 0 (as square ended paths), 1 (as flush ended paths), 2 (as round paths) - */ - unsigned int wire_mode; - - /** - * @brief Specify the database unit to produce - * - * Specify the database unit which the resulting layout will receive. - */ - double dbu; - - /** - * @brief Specifies a layer mapping - * - * If a layer mapping is specified, only the given layers are read. - * Otherwise, all layers are read. - * Setting "create_other_layers" to true will make the reader - * create other layers for all layers not given in the layer map. - * Setting an empty layer map and create_other_layers to true effectively - * enables all layers for reading. - */ - db::LayerMap layer_map; - - /** - * @brief A flag indicating that a new layers shall be created - * - * If this flag is set to true, layers not listed in the layer map a created - * too. - */ - bool create_other_layers; - - /** - * @brief A flag indicating whether the names of layers shall be kept as such - * - * If this flag is set to false (the default), layer name translation happens. - * If set to true, translation will not happen. - * Name translation will try to extract GDS layer/datatype numbers from the - * layer names. If this value is set to true, no name translation happens. - */ - bool keep_layer_names; - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual FormatSpecificReaderOptions *clone () const - { - return new CIFReaderOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual const std::string &format_name () const - { - static const std::string n ("CIF"); - return n; - } -}; - /** * @brief Generic base class of CIF reader exceptions */ diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFWriter.h b/src/plugins/streamers/cif/db_plugin/dbCIFWriter.h index 9626f398e..b858eb1c5 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFWriter.h +++ b/src/plugins/streamers/cif/db_plugin/dbCIFWriter.h @@ -28,6 +28,7 @@ #include "dbPluginCommon.h" #include "dbWriter.h" #include "dbCIF.h" +#include "dbCIFFormat.h" #include "dbSaveLayoutOptions.h" #include "tlProgress.h" @@ -42,54 +43,6 @@ namespace db class Layout; class SaveLayoutOptions; -/** - * @brief Structure that holds the CIF specific options for the Writer - */ -class DB_PLUGIN_PUBLIC CIFWriterOptions - : public FormatSpecificWriterOptions -{ -public: - /** - * @brief The constructor - */ - CIFWriterOptions () - : dummy_calls (false), blank_separator (false) - { - // .. nothing yet .. - } - - /** - * @brief A flag indicating whether dummy calls shall be written - * If this flag is true, the writer will produce dummy cell calls on global - * level for all top cells. - */ - bool dummy_calls; - - /** - * @brief A flag indicating whether to use blanks as x/y separators - * If this flag is true, blank characters will be used to separate x and y values. - * Otherwise comma characters will be used. - */ - bool blank_separator; - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual FormatSpecificWriterOptions *clone () const - { - return new CIFWriterOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual const std::string &format_name () const - { - static std::string n ("CIF"); - return n; - } -}; - /** * @brief A CIF writer abstraction */ diff --git a/src/plugins/streamers/cif/db_plugin/db_plugin.pro b/src/plugins/streamers/cif/db_plugin/db_plugin.pro index 29547bd31..e93d505fc 100644 --- a/src/plugins/streamers/cif/db_plugin/db_plugin.pro +++ b/src/plugins/streamers/cif/db_plugin/db_plugin.pro @@ -8,6 +8,7 @@ HEADERS = \ dbCIF.h \ dbCIFReader.h \ dbCIFWriter.h \ + dbCIFFormat.h \ SOURCES = \ dbCIF.cc \ diff --git a/src/plugins/streamers/common/lay_plugin/lay_plugin.pro b/src/plugins/streamers/common/lay_plugin/lay_plugin.pro index 35b9218fb..835956be0 100644 --- a/src/plugins/streamers/common/lay_plugin/lay_plugin.pro +++ b/src/plugins/streamers/common/lay_plugin/lay_plugin.pro @@ -6,7 +6,7 @@ include($$PWD/../../../lay_plugin.pri) INCLUDEPATH += $$PWD/../db_plugin DEPENDPATH += $$PWD/../db_plugin -LIBS += -L$$DESTDIR/../db_plugins -lcif +LIBS += -L$$DESTDIR/../db_plugins !isEmpty(RPATH) { QMAKE_RPATHDIR += $$RPATH/db_plugins diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h b/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h new file mode 100644 index 000000000..3939795e4 --- /dev/null +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h @@ -0,0 +1,239 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef HDR_dbDXFFormat +#define HDR_dbDXFFormat + +#include "dbLoadLayoutOptions.h" +#include "dbSaveLayoutOptions.h" + +namespace db +{ + +/** + * @brief Structure that holds the DXF specific options for the reader + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class DXFReaderOptions + : public FormatSpecificReaderOptions +{ +public: + /** + * @brief The constructor + */ + DXFReaderOptions () + : dbu (0.001), + unit (1.0), + text_scaling (100.0), + polyline_mode (0), + circle_points (100), + circle_accuracy (0.0), + contour_accuracy (0.0), + render_texts_as_polygons (false), + keep_other_cells (false), + create_other_layers (true), + keep_layer_names (false) + { + // .. nothing yet .. + } + + /** + * @brief Specify the database unit to produce + * + * Specify the database unit which the resulting layout will receive. + */ + double dbu; + + /** + * @brief Specify the unit of the DXF file + * + * Since DXF is unitless, this value allows to specify the units of the DXF file given as input. + */ + double unit; + + /** + * @brief Text scaling factor + * + * This value specifies text scaling in percent. A value of 100 roughly means that the letter + * pitch of the font will be 92% of the specified text height. That value applies for ROMANS fonts. + * When generating GDS texts, a value of 100 generates TEXT objects with + * the specified size. Smaller values generate smaller sizes. + */ + double text_scaling; + + /** + * @brief POLYLINE/LWPOLYLINE mode + * + * 0: automatic mode + * 1: keep lines + * 2: create polygons from closed POLYLINE/LWPOLYLINE with width == 0 + * 3: merge all lines (width width 0) + * 4: as 3 and auto-close contours + */ + int polyline_mode; + + /** + * @brief Number of points for a full circle for arc interpolation + * + * See circle_accuracy for another way of specifying the number of + * points per circle. + */ + int circle_points; + + /** + * @brief Accuracy of circle approximation + * + * This value specifies the approximation accuracy of the circle and other + * "round" structures. If this value is a positive number bigger than the + * database unit (see dbu), it will control the number of points the + * circle is resolved into. The number of points will be chosen such that + * the deviation from the ideal curve is less than this value. + * + * The actual number of points used for the circle approximation is + * not larger than circle_points. + * + * The value is given in the units of the DXF file. + */ + double circle_accuracy; + + /** + * @brief Accuracy for closing polylines + * + * When polylines need to be connected or closed, this + * value is used to indicate the accuracy. This is the value (in DXF units) + * by which points may be separated and still be considered + * connected. The default is 0.0 which implies exact + * (within one DBU) closing. + */ + double contour_accuracy; + + /** + * @brief If set to true, converts texts to polygons on read + * + * Converting texts avoids problems with UTF-8 character sets. + */ + bool render_texts_as_polygons; + + /** + * @brief If set to true, cells other than the top cell are kept instead of removed + */ + bool keep_other_cells; + + /** + * @brief Specifies a layer mapping + * + * If a layer mapping is specified, only the given layers are read. + * Otherwise, all layers are read. + * Setting "create_other_layers" to true will make the reader + * create other layers for all layers not given in the layer map. + * Setting an empty layer map and create_other_layers to true effectively + * enables all layers for reading. + */ + db::LayerMap layer_map; + + /** + * @brief A flag indicating that a new layers shall be created + * + * If this flag is set to true, layers not listed in the layer map a created + * too. + */ + bool create_other_layers; + + /** + * @brief A flag indicating whether the names of layers shall be kept as such + * + * If this flag is set to false (the default), layer name translation happens. + * If set to true, translation will not happen. + * Name translation will try to extract GDS layer/datatype numbers from the + * layer names. If this value is set to true, no name translation happens. + */ + bool keep_layer_names; + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual FormatSpecificReaderOptions *clone () const + { + return new DXFReaderOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual const std::string &format_name () const + { + static const std::string n ("DXF"); + return n; + } +}; + +/** + * @brief Structure that holds the DXF specific options for the Writer + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class DXFWriterOptions + : public FormatSpecificWriterOptions +{ +public: + /** + * @brief The constructor + */ + DXFWriterOptions () + : polygon_mode (0) + { + // .. nothing yet .. + } + + /** + * @brief Polygon mode + * + * 0: create POLYLINE + * 1: create LWPOLYLINE + * 2: decompose into SOLID + * 3: create HATCH + */ + int polygon_mode; + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual FormatSpecificWriterOptions *clone () const + { + return new DXFWriterOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual const std::string &format_name () const + { + static std::string n ("DXF"); + return n; + } +}; + +} // namespace db + +#endif + diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h index d0d24e77e..476e41499 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFReader.h @@ -20,8 +20,6 @@ */ - - #ifndef HDR_dbDXFReader #define HDR_dbDXFReader @@ -29,6 +27,7 @@ #include "dbLayout.h" #include "dbNamedLayerReader.h" #include "dbDXF.h" +#include "dbDXFFormat.h" #include "dbStreamLayers.h" #include "dbPropertiesRepository.h" @@ -46,162 +45,6 @@ namespace db class Matrix3d; -/** - * @brief Structure that holds the DXF specific options for the reader - */ -class DB_PLUGIN_PUBLIC DXFReaderOptions - : public FormatSpecificReaderOptions -{ -public: - /** - * @brief The constructor - */ - DXFReaderOptions () - : dbu (0.001), - unit (1.0), - text_scaling (100.0), - polyline_mode (0), - circle_points (100), - circle_accuracy (0.0), - contour_accuracy (0.0), - render_texts_as_polygons (false), - keep_other_cells (false), - create_other_layers (true), - keep_layer_names (false) - { - // .. nothing yet .. - } - - /** - * @brief Specify the database unit to produce - * - * Specify the database unit which the resulting layout will receive. - */ - double dbu; - - /** - * @brief Specify the unit of the DXF file - * - * Since DXF is unitless, this value allows to specify the units of the DXF file given as input. - */ - double unit; - - /** - * @brief Text scaling factor - * - * This value specifies text scaling in percent. A value of 100 roughly means that the letter - * pitch of the font will be 92% of the specified text height. That value applies for ROMANS fonts. - * When generating GDS texts, a value of 100 generates TEXT objects with - * the specified size. Smaller values generate smaller sizes. - */ - double text_scaling; - - /** - * @brief POLYLINE/LWPOLYLINE mode - * - * 0: automatic mode - * 1: keep lines - * 2: create polygons from closed POLYLINE/LWPOLYLINE with width == 0 - * 3: merge all lines (width width 0) - * 4: as 3 and auto-close contours - */ - int polyline_mode; - - /** - * @brief Number of points for a full circle for arc interpolation - * - * See circle_accuracy for another way of specifying the number of - * points per circle. - */ - int circle_points; - - /** - * @brief Accuracy of circle approximation - * - * This value specifies the approximation accuracy of the circle and other - * "round" structures. If this value is a positive number bigger than the - * database unit (see dbu), it will control the number of points the - * circle is resolved into. The number of points will be chosen such that - * the deviation from the ideal curve is less than this value. - * - * The actual number of points used for the circle approximation is - * not larger than circle_points. - * - * The value is given in the units of the DXF file. - */ - double circle_accuracy; - - /** - * @brief Accuracy for closing polylines - * - * When polylines need to be connected or closed, this - * value is used to indicate the accuracy. This is the value (in DXF units) - * by which points may be separated and still be considered - * connected. The default is 0.0 which implies exact - * (within one DBU) closing. - */ - double contour_accuracy; - - /** - * @brief If set to true, converts texts to polygons on read - * - * Converting texts avoids problems with UTF-8 character sets. - */ - bool render_texts_as_polygons; - - /** - * @brief If set to true, cells other than the top cell are kept instead of removed - */ - bool keep_other_cells; - - /** - * @brief Specifies a layer mapping - * - * If a layer mapping is specified, only the given layers are read. - * Otherwise, all layers are read. - * Setting "create_other_layers" to true will make the reader - * create other layers for all layers not given in the layer map. - * Setting an empty layer map and create_other_layers to true effectively - * enables all layers for reading. - */ - db::LayerMap layer_map; - - /** - * @brief A flag indicating that a new layers shall be created - * - * If this flag is set to true, layers not listed in the layer map a created - * too. - */ - bool create_other_layers; - - /** - * @brief A flag indicating whether the names of layers shall be kept as such - * - * If this flag is set to false (the default), layer name translation happens. - * If set to true, translation will not happen. - * Name translation will try to extract GDS layer/datatype numbers from the - * layer names. If this value is set to true, no name translation happens. - */ - bool keep_layer_names; - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual FormatSpecificReaderOptions *clone () const - { - return new DXFReaderOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual const std::string &format_name () const - { - static const std::string n ("DXF"); - return n; - } -}; - /** * @brief Generic base class of DXF reader exceptions */ diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.h b/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.h index 0b768aa86..ab39ed5f0 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.h +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.h @@ -20,15 +20,13 @@ */ - - - #ifndef HDR_dbDXFWriter #define HDR_dbDXFWriter #include "dbPluginCommon.h" #include "dbWriter.h" #include "dbDXF.h" +#include "dbDXFFormat.h" #include "dbSaveLayoutOptions.h" #include "tlProgress.h" @@ -43,50 +41,6 @@ namespace db class Layout; class SaveLayoutOptions; -/** - * @brief Structure that holds the DXF specific options for the Writer - */ -class DB_PLUGIN_PUBLIC DXFWriterOptions - : public FormatSpecificWriterOptions -{ -public: - /** - * @brief The constructor - */ - DXFWriterOptions () - : polygon_mode (0) - { - // .. nothing yet .. - } - - /** - * @brief Polygon mode - * - * 0: create POLYLINE - * 1: create LWPOLYLINE - * 2: decompose into SOLID - * 3: create HATCH - */ - int polygon_mode; - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual FormatSpecificWriterOptions *clone () const - { - return new DXFWriterOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual const std::string &format_name () const - { - static std::string n ("DXF"); - return n; - } -}; - /** * @brief A DXF writer abstraction */ @@ -108,7 +62,7 @@ private: struct endl_tag { }; tl::OutputStream *mp_stream; - DXFWriterOptions m_options; + db::DXFWriterOptions m_options; tl::AbsoluteProgress m_progress; endl_tag endl; db::LayerProperties m_layer; diff --git a/src/plugins/streamers/dxf/db_plugin/db_plugin.pro b/src/plugins/streamers/dxf/db_plugin/db_plugin.pro index 88142baa2..94f383c56 100644 --- a/src/plugins/streamers/dxf/db_plugin/db_plugin.pro +++ b/src/plugins/streamers/dxf/db_plugin/db_plugin.pro @@ -6,6 +6,7 @@ include($$PWD/../../../db_plugin.pri) HEADERS = \ dbDXF.h \ + dbDXFFormat.h \ dbDXFReader.h \ dbDXFWriter.h \ diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2Format.h b/src/plugins/streamers/gds2/db_plugin/dbGDS2Format.h new file mode 100644 index 000000000..a88f99ad8 --- /dev/null +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2Format.h @@ -0,0 +1,97 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef HDR_dbGDS2Format +#define HDR_dbGDS2Format + +#include "dbSaveLayoutOptions.h" +#include "dbLoadLayoutOptions.h" + +namespace db +{ + +/** + * @brief Structure that holds the GDS2 specific options for the reader + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class GDS2ReaderOptions + : public FormatSpecificReaderOptions +{ +public: + /** + * @brief The constructor + */ + GDS2ReaderOptions () + : box_mode (1), + allow_big_records (true), + allow_multi_xy_records (true) + { + // .. nothing yet .. + } + + /** + * @brief How to treat BOX records + * + * This property specifies how to treat BOX records. + * Allowed values are 0 (ignore), 1 (treat as rectangles), 2 (treat as boundaries) or 3 (treat as errors). + */ + unsigned int box_mode; + + /** + * @brief Allow multiple big records + * + * Setting this property to true allows to use up to 65535 bytes (instead of 32767) per record + * by treating the record length as unsigned short rather than signed short. + * This allows bigger polygons (up to ~8000 points) without having to use multiple XY records. + */ + bool allow_big_records; + + /** + * @brief Allow multiple XY records in BOUNDARY elements for unlimited large polygons + * + * Setting this property to true allows to unlimited polygons + * by using multiple XY records. + */ + bool allow_multi_xy_records; + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual FormatSpecificReaderOptions *clone () const + { + return new GDS2ReaderOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual const std::string &format_name () const + { + static const std::string n ("GDS2"); + return n; + } +}; + +} // namespace db + +#endif diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h index 5d301fc93..63005c0f6 100644 --- a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.h @@ -27,6 +27,7 @@ #include "dbPluginCommon.h" #include "dbLayout.h" +#include "dbGDS2Format.h" #include "dbGDS2ReaderBase.h" #include "dbCommonReader.h" #include "dbStreamLayers.h" @@ -40,67 +41,6 @@ namespace db { -/** - * @brief Structure that holds the GDS2 specific options for the reader - */ -class DB_PLUGIN_PUBLIC GDS2ReaderOptions - : public FormatSpecificReaderOptions -{ -public: - /** - * @brief The constructor - */ - GDS2ReaderOptions () - : box_mode (1), - allow_big_records (true), - allow_multi_xy_records (true) - { - // .. nothing yet .. - } - - /** - * @brief How to treat BOX records - * - * This property specifies how to treat BOX records. - * Allowed values are 0 (ignore), 1 (treat as rectangles), 2 (treat as boundaries) or 3 (treat as errors). - */ - unsigned int box_mode; - - /** - * @brief Allow multiple big records - * - * Setting this property to true allows to use up to 65535 bytes (instead of 32767) per record - * by treating the record length as unsigned short rather than signed short. - * This allows bigger polygons (up to ~8000 points) without having to use multiple XY records. - */ - bool allow_big_records; - - /** - * @brief Allow multiple XY records in BOUNDARY elements for unlimited large polygons - * - * Setting this property to true allows to unlimited polygons - * by using multiple XY records. - */ - bool allow_multi_xy_records; - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual FormatSpecificReaderOptions *clone () const - { - return new GDS2ReaderOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual const std::string &format_name () const - { - static const std::string n ("GDS2"); - return n; - } -}; - /** * @brief Generic base class of GDS2 reader exceptions */ diff --git a/src/plugins/streamers/gds2/db_plugin/db_plugin.pro b/src/plugins/streamers/gds2/db_plugin/db_plugin.pro index 7755a91b0..2403146be 100644 --- a/src/plugins/streamers/gds2/db_plugin/db_plugin.pro +++ b/src/plugins/streamers/gds2/db_plugin/db_plugin.pro @@ -8,6 +8,7 @@ HEADERS = \ contrib/dbGDS2Converter.h \ contrib/dbGDS2TextReader.h \ contrib/dbGDS2TextWriter.h \ + dbGDS2Format.h \ dbGDS2.h \ dbGDS2ReaderBase.h \ dbGDS2Reader.h \ diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISFormat.h b/src/plugins/streamers/oasis/db_plugin/dbOASISFormat.h new file mode 100644 index 000000000..4dfa13376 --- /dev/null +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISFormat.h @@ -0,0 +1,188 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef HDR_dbOASISFormat +#define HDR_dbOASISFormat + +#include "dbSaveLayoutOptions.h" +#include "dbLoadLayoutOptions.h" + +namespace db +{ + +/** + * @brief Structure that holds the OASIS specific options for the reader + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class OASISReaderOptions + : public FormatSpecificReaderOptions +{ +public: + /** + * @brief The constructor + */ + OASISReaderOptions () + : read_all_properties (false), expect_strict_mode (-1) + { + // .. nothing yet .. + } + + /** + * @brief A flag indicating whether to read all properties + * + * If this flag is set, all properties, including the special properties are read. + * This mode is only provided for testing and writing such a layout will probably + * result in duplicate entries. + */ + bool read_all_properties; + + /** + * @brief Indicates that the reader expects strict mode or note + * + * This is mainly a debugging an testing option but it may be used to verifiy + * the compliance of a file with string or non-strict mode. + * + * The values are: + * -1: don't care (default) + * 0: expect non-strict + * 1: expect strict + */ + int expect_strict_mode; + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual FormatSpecificReaderOptions *clone () const + { + return new OASISReaderOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificReaderOptions + */ + virtual const std::string &format_name () const + { + static const std::string n ("OASIS"); + return n; + } +}; + +/** + * @brief Structure that holds the OASIS specific options for the Writer + * NOTE: this structure is non-public linkage by intention. This way it's instantiated + * in all compile units and the shared object does not need to be linked. + */ +class OASISWriterOptions + : public FormatSpecificWriterOptions +{ +public: + /** + * @brief The constructor + */ + OASISWriterOptions () + : compression_level (2), write_cblocks (false), strict_mode (false), recompress (false), permissive (false), write_std_properties (1), subst_char ("*") + { + // .. nothing yet .. + } + + /** + * @brief OASIS writer compression level + * + * This level describes how hard the OASIS writer will try to compress the shapes + * using shape arrays. Building shape arrays may take some time and requires some memory. + * 0 - no shape array building + * 1 - nearest neighbor shape array formation + * 2++ - enhanced shape array search algorithm using 2nd and further neighbor distances as well + */ + int compression_level; + + /** + * @brief CBLOCK compression + * + * If this flag is set, every cell is CBLOCK-compressed. + */ + bool write_cblocks; + + /** + * @brief Strict mode + * + * If this flag is set, a strict-mode file will be produced + */ + bool strict_mode; + + /** + * @brief Recompressions + * + * If the recompression flag is true, existing shape arrays will be resolved and + * put into the compressor again (may take longer). + */ + bool recompress; + + /** + * @brief Permissive mode + * + * In permissive mode, a warning is issued for certain cases rather than + * an error: + * - Polygons with less than three points (omitted) + * - Paths/circles with odd diameter (rounded) + */ + bool permissive; + + /** + * @brief Write global standard properties + * + * If this value is 0, no standard properties are written. If it's 1, global + * standard properties such as S_TOP_CELL are written. If 2, bounding box + * standard properties are written for every cell too. + */ + int write_std_properties; + + /** + * @brief Substitution character + * + * If non-empty, this string (first character) will be used for + * substituting invalid characters in a-strings and n-strings. + */ + std::string subst_char; + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual FormatSpecificWriterOptions *clone () const + { + return new OASISWriterOptions (*this); + } + + /** + * @brief Implementation of FormatSpecificWriterOptions + */ + virtual const std::string &format_name () const + { + static std::string n ("OASIS"); + return n; + } +}; + +} // namespace db + +#endif diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h index c30ea967b..8d0de04f0 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h @@ -30,6 +30,7 @@ #include "dbReader.h" #include "dbTypes.h" #include "dbOASIS.h" +#include "dbOASISFormat.h" #include "dbStreamLayers.h" #include "dbPropertiesRepository.h" @@ -57,62 +58,6 @@ public: { } }; -/** - * @brief Structure that holds the OASIS specific options for the reader - */ -class DB_PLUGIN_PUBLIC OASISReaderOptions - : public FormatSpecificReaderOptions -{ -public: - /** - * @brief The constructor - */ - OASISReaderOptions () - : read_all_properties (false), expect_strict_mode (-1) - { - // .. nothing yet .. - } - - /** - * @brief A flag indicating whether to read all properties - * - * If this flag is set, all properties, including the special properties are read. - * This mode is only provided for testing and writing such a layout will probably - * result in duplicate entries. - */ - bool read_all_properties; - - /** - * @brief Indicates that the reader expects strict mode or note - * - * This is mainly a debugging an testing option but it may be used to verifiy - * the compliance of a file with string or non-strict mode. - * - * The values are: - * -1: don't care (default) - * 0: expect non-strict - * 1: expect strict - */ - int expect_strict_mode; - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual FormatSpecificReaderOptions *clone () const - { - return new OASISReaderOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificReaderOptions - */ - virtual const std::string &format_name () const - { - static const std::string n ("OASIS"); - return n; - } -}; - /** * @brief The OASIS format stream reader */ diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h index 4bdabc164..6ae68c2fb 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h @@ -27,6 +27,7 @@ #include "dbPluginCommon.h" #include "dbWriter.h" #include "dbOASIS.h" +#include "dbOASISFormat.h" #include "dbSaveLayoutOptions.h" #include "dbObjectWithProperties.h" #include "dbHash.h" @@ -47,100 +48,6 @@ class Layout; class SaveLayoutOptions; class OASISWriter; -/** - * @brief Structure that holds the OASIS specific options for the Writer - */ -class DB_PLUGIN_PUBLIC OASISWriterOptions - : public FormatSpecificWriterOptions -{ -public: - /** - * @brief The constructor - */ - OASISWriterOptions () - : compression_level (2), write_cblocks (false), strict_mode (false), recompress (false), permissive (false), write_std_properties (1), subst_char ("*") - { - // .. nothing yet .. - } - - /** - * @brief OASIS writer compression level - * - * This level describes how hard the OASIS writer will try to compress the shapes - * using shape arrays. Building shape arrays may take some time and requires some memory. - * 0 - no shape array building - * 1 - nearest neighbor shape array formation - * 2++ - enhanced shape array search algorithm using 2nd and further neighbor distances as well - */ - int compression_level; - - /** - * @brief CBLOCK compression - * - * If this flag is set, every cell is CBLOCK-compressed. - */ - bool write_cblocks; - - /** - * @brief Strict mode - * - * If this flag is set, a strict-mode file will be produced - */ - bool strict_mode; - - /** - * @brief Recompressions - * - * If the recompression flag is true, existing shape arrays will be resolved and - * put into the compressor again (may take longer). - */ - bool recompress; - - /** - * @brief Permissive mode - * - * In permissive mode, a warning is issued for certain cases rather than - * an error: - * - Polygons with less than three points (omitted) - * - Paths/circles with odd diameter (rounded) - */ - bool permissive; - - /** - * @brief Write global standard properties - * - * If this value is 0, no standard properties are written. If it's 1, global - * standard properties such as S_TOP_CELL are written. If 2, bounding box - * standard properties are written for every cell too. - */ - int write_std_properties; - - /** - * @brief Substitution character - * - * If non-empty, this string (first character) will be used for - * substituting invalid characters in a-strings and n-strings. - */ - std::string subst_char; - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual FormatSpecificWriterOptions *clone () const - { - return new OASISWriterOptions (*this); - } - - /** - * @brief Implementation of FormatSpecificWriterOptions - */ - virtual const std::string &format_name () const - { - static std::string n ("OASIS"); - return n; - } -}; - /** * @brief A displacement list compactor * diff --git a/src/plugins/streamers/oasis/db_plugin/db_plugin.pro b/src/plugins/streamers/oasis/db_plugin/db_plugin.pro index 80a4cbd5a..6de930b7d 100644 --- a/src/plugins/streamers/oasis/db_plugin/db_plugin.pro +++ b/src/plugins/streamers/oasis/db_plugin/db_plugin.pro @@ -6,6 +6,7 @@ include($$PWD/../../../db_plugin.pri) HEADERS = \ dbOASIS.h \ + dbOASISFormat.h \ dbOASISReader.h \ dbOASISWriter.h \ diff --git a/testdata/bd/strmrun.py b/testdata/bd/strmrun.py new file mode 100644 index 000000000..649b33d59 --- /dev/null +++ b/testdata/bd/strmrun.py @@ -0,0 +1,2 @@ +import pya +print("Hello, world " + str(pya.DBox(0, 0, 42, -42)) + "!")