diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d65f09686..d9598516d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,7 @@ jobs: path: dist - uses: pypa/gh-action-pypi-publish@v1.4.2 + continue-on-error: true # might fail if we don't bump the version with: user: __token__ password: ${{ secrets.test_pypi_password }} diff --git a/MANIFEST.in b/MANIFEST.in index 531a510b2..42f956cba 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,10 +1,16 @@ -recursive-include src/tl/tl *.cc *.h +recursive-include src/ant/ant *.cc *.h recursive-include src/db/db *.cc *.cc_gen *.h +recursive-include src/edt/edt *.cc *.h recursive-include src/gsi/gsi *.cc *.h -recursive-include src/rdb/rdb *.cc *.h -recursive-include src/pya/pya *.cc *.h +recursive-include src/img/img *.cc *.h +recursive-include src/laybasic/laybasic *.cc *.h recursive-include src/lib/lib *.cc *.h +recursive-include src/lym/lym *.cc *.h +recursive-include src/pya/pya *.cc *.h recursive-include src/pymod *.cc *.h +recursive-include src/rbastub *.cc *.h +recursive-include src/rdb/rdb *.cc *.h +recursive-include src/tl/tl *.cc *.h include src/plugins/*/db_plugin/*.cc include src/plugins/*/*/db_plugin/*.cc include src/plugins/*/db_plugin/*.h diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2cfe0c5ad..7daf2454d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,11 +14,6 @@ jobs: vmImage: 'windows-2019' # other options: 'macOS-10.13', 'ubuntu-16.04' strategy: matrix: - # Python27: - # python.version: '2.7' - # cp35-cp35m-win_amd64.whl: - # python.version: '3.5' - # python.architecture: 'x64' cp36-cp36m-win_amd64.whl: python.version: '3.6' python.architecture: 'x64' @@ -34,9 +29,6 @@ jobs: cp310-cp310-win_amd64.whl: python.version: '3.10' python.architecture: 'x64' - # cp35-cp35m-win32.whl: - # python.version: '3.5' - # python.architecture: 'x86' cp36-cp36m-win32.whl: python.version: '3.6' python.architecture: 'x86' @@ -70,9 +62,9 @@ jobs: #arguments: # Optional script: | # Required when targetType == Inline pwd - Invoke-WebRequest -Uri "https://www.klayout.org/downloads/klayout-microbits-1.0.zip" -OutFile klayout-microbits-1.0.zip + Invoke-WebRequest -Uri "https://www.klayout.org/downloads/klayout-microbits-4.0.zip" -OutFile klayout-microbits-4.0.zip dir - Expand-Archive klayout-microbits-1.0.zip -DestinationPath klayout-microbits + Expand-Archive klayout-microbits-4.0.zip -DestinationPath klayout-microbits dir klayout-microbits #errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue #failOnStderr: false # Optional @@ -81,37 +73,30 @@ jobs: #workingDirectory: # Optional displayName: 'Download and Extract KLayout bits' - # - script: | - # curl https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -o VCForPython27.msi - # msiexec /i VCForPython27.msi /quiet - # set "VS90COMNTOOLS=C:\Users\VssAdministrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC" - # curl https://raw.githubusercontent.com/mattn/gntp-send/master/include/msinttypes/stdint.h -o "%VS90COMNTOOLS%\Include\stdint.h" - # dir "%VS90COMNTOOLS%\Include" - # condition: eq(variables['python.version'], '2.7') - # displayName: 'Install Microsoft Visual C++ Compiler for Python 2.7' - - script: | python -m pip install --upgrade pip setuptools wheel displayName: 'Update pip, setuptools and wheel' - script: | python -V - set "KLAYOUT_BITS=%cd%\klayout-microbits\klayout-microbits-1.0\msvc2017\%PYTHON_ARCHITECTURE%" + set "KLAYOUT_BITS=%cd%\klayout-microbits\klayout-microbits-4.0\msvc2017\%PYTHON_ARCHITECTURE%" echo KLAYOUT_BITS=%KLAYOUT_BITS% python setup.py bdist_wheel displayName: 'Build KLayout' - bash: | - bash `pwd`/ci-scripts/windows/fix_wheel.sh `pwd`/dist/*.whl "`pwd`/klayout-microbits/klayout-microbits-1.0/msvc2017/$PYTHON_ARCHITECTURE" + bash `pwd`/ci-scripts/windows/fix_wheel.sh `pwd`/dist/*.whl "`pwd`/klayout-microbits/klayout-microbits-4.0/msvc2017/$PYTHON_ARCHITECTURE" displayName: 'Copy klayout bits dlls into wheel' - script: | echo PATH=%PATH% + set TESTSRC=. pip install klayout --no-index -f dist python testdata/pymod/import_db.py python testdata/pymod/import_rdb.py python testdata/pymod/import_tl.py python testdata/pymod/import_lib.py + python testdata/pymod/import_lay.py python testdata/pymod/pya_tests.py displayName: 'Test KLayout pymod' diff --git a/ci-scripts/docker/docker_prepare.sh b/ci-scripts/docker/docker_prepare.sh index e380fdc45..4fb6e50c5 100644 --- a/ci-scripts/docker/docker_prepare.sh +++ b/ci-scripts/docker/docker_prepare.sh @@ -5,7 +5,7 @@ set -xe if [[ -f "/etc/centos-release" ]]; then # sometimes the epel server is down. retry 5 times for i in $(seq 1 5); do - yum install -y zlib-devel curl-devel expat-devel ccache && s=0 && break || s=$? && sleep 15; + yum install -y zlib-devel curl-devel expat-devel libpng-devel ccache && s=0 && break || s=$? && sleep 15; done [ $s -eq 0 ] || exit $s @@ -27,7 +27,7 @@ if [[ -f "/etc/centos-release" ]]; then elif [[ -f "/etc/alpine-release" ]]; then # musllinux prep # ccache already present - apk add curl-dev expat-dev zlib-dev ccache + apk add curl-dev expat-dev zlib-dev libpng-dev ccache export PATH="/usr/lib/ccache/bin:$PATH" fi diff --git a/ci-scripts/windows/fix_wheel.sh b/ci-scripts/windows/fix_wheel.sh index 3ac9593c9..8890b98a6 100644 --- a/ci-scripts/windows/fix_wheel.sh +++ b/ci-scripts/windows/fix_wheel.sh @@ -70,6 +70,7 @@ cp -v $KLAYOUT_BITS/curl/bin/* . cp -v $KLAYOUT_BITS/expat/bin/* . cp -v $KLAYOUT_BITS/ptw/bin/* . cp -v $KLAYOUT_BITS/zlib/bin/* . +cp -v $KLAYOUT_BITS/png/bin/* . # if [ $? -ne 0 ]; then # >&2 echo "ERROR: lib not found. Quitting." # exit 1 diff --git a/pyproject.toml b/pyproject.toml index 5e3833538..a97cc10fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,8 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "python {package}/testdata/pymod/pya_tests.py" + "python {package}/testdata/pymod/import_lay.py", + "TESTSRC={package} python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms skip = "pp*" @@ -24,4 +25,4 @@ environment-pass = ["HOST_CCACHE_DIR"] [tool.cibuildwheel.macos] # Don't repair macOS wheels -repair-wheel-command = "" \ No newline at end of file +repair-wheel-command = "" diff --git a/setup.py b/setup.py index a2631a25a..37c56c99f 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ The standalone libraries are basically extension modules. Build requirements are: * curl library * expat library + * png library The main challenge is to map KLayout's shared object architecture. The structure consists of the Python extension libraries and a bunch @@ -269,6 +270,7 @@ class Config(object): if bits: return [quote_path("-I" + os.path.join(bits, "zlib", "include")), quote_path("-I" + os.path.join(bits, "ptw", "include")), + quote_path("-I" + os.path.join(bits, "png", "include")), quote_path("-I" + os.path.join(bits, "expat", "include")), quote_path("-I" + os.path.join(bits, "curl", "include"))] else: @@ -285,9 +287,13 @@ class Config(object): if platform.system() == "Windows": if mod == "_tl": return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32" ] + elif mod == "_laybasic": + return [ "libpng16" ] else: if mod == "_tl": return ['curl', 'expat'] + elif mod == "_laybasic": + return [ 'png' ] return [] def link_args(self, mod): @@ -298,8 +304,9 @@ class Config(object): args = ["/DLL"] bits = os.getenv("KLAYOUT_BITS") if bits: - args += [quote_path("/LIBPATH:" + os.path.join(bits, "zlib", "libraries")), + args += [quote_path("/LIBPATH:" + os.path.join(bits, "zlib", "lib")), quote_path("/LIBPATH:" + os.path.join(bits, "ptw", "libraries")), + quote_path("/LIBPATH:" + os.path.join(bits, "png", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "expat", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "curl", "libraries"))] return args @@ -334,7 +341,7 @@ class Config(object): """ Returns the macros to use for building """ - return [('HAVE_CURL', 1), ('HAVE_EXPAT', 1), ('KLAYOUT_MAJOR_VERSION', self.major_version()), ('KLAYOUT_MINOR_VERSION', self.minor_version())] + return [('HAVE_PNG', 1), ('HAVE_CURL', 1), ('HAVE_EXPAT', 1), ('KLAYOUT_MAJOR_VERSION', self.major_version()), ('KLAYOUT_MINOR_VERSION', self.minor_version())] def minor_version(self): """ @@ -425,6 +432,7 @@ _gsi = Library(config.root + '._gsi', include_dirs=[_tl_path], extra_objects=[config.path_of('_tl', _tl_path)], language='c++', + libraries=config.libraries('_gsi'), extra_link_args=config.link_args('_gsi'), extra_compile_args=config.compile_args('_gsi'), sources=list(_gsi_sources)) @@ -441,11 +449,29 @@ _pya = Library(config.root + '._pya', include_dirs=[_tl_path, _gsi_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], language='c++', + libraries=config.libraries('_pya'), extra_link_args=config.link_args('_pya'), extra_compile_args=config.compile_args('_pya'), sources=list(_pya_sources)) config.add_extension(_pya) +# ------------------------------------------------------------------ +# _rba dependency library (dummy) + +_rba_path = os.path.join("src", "rbastub") +_rba_sources = set(glob.glob(os.path.join(_rba_path, "*.cc"))) + +_rba = Library(config.root + '._rba', + define_macros=config.macros() + [('MAKE_RBA_LIBRARY', 1)], + include_dirs=[_tl_path, _gsi_path], + extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], + language='c++', + libraries=config.libraries('_rba'), + extra_link_args=config.link_args('_rba'), + extra_compile_args=config.compile_args('_rba'), + sources=list(_rba_sources)) +config.add_extension(_rba) + # ------------------------------------------------------------------ # _db dependency library @@ -457,6 +483,7 @@ _db = Library(config.root + '._db', include_dirs=[_tl_path, _gsi_path, _db_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], language='c++', + libraries=config.libraries('_db'), extra_link_args=config.link_args('_db'), extra_compile_args=config.compile_args('_db'), sources=list(_db_sources)) @@ -473,6 +500,7 @@ _lib = Library(config.root + '._lib', include_dirs=[_tl_path, _gsi_path, _db_path, _lib_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', + libraries=config.libraries('_lib'), extra_link_args=config.link_args('_lib'), extra_compile_args=config.compile_args('_lib'), sources=list(_lib_sources)) @@ -489,11 +517,114 @@ _rdb = Library(config.root + '._rdb', include_dirs=[_db_path, _tl_path, _gsi_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', + libraries=config.libraries('_rdb'), extra_link_args=config.link_args('_rdb'), extra_compile_args=config.compile_args('_rdb'), sources=list(_rdb_sources)) config.add_extension(_rdb) +# ------------------------------------------------------------------ +# _laybasic dependency library + +_laybasic_path = os.path.join("src", "laybasic", "laybasic") +_laybasic_sources = set(glob.glob(os.path.join(_laybasic_path, "*.cc"))) + +_laybasic = Library(config.root + '._laybasic', + define_macros=config.macros() + [('MAKE_LAYBASIC_LIBRARY', 1)], + include_dirs=[_rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_laybasic'), + extra_link_args=config.link_args('_laybasic'), + extra_compile_args=config.compile_args('_laybasic'), + sources=list(_laybasic_sources)) +config.add_extension(_laybasic) + +# ------------------------------------------------------------------ +# _layview dependency library + +_layview_path = os.path.join("src", "layview", "layview") +_layview_sources = set(glob.glob(os.path.join(_layview_path, "*.cc"))) + +_layview = Library(config.root + '._layview', + define_macros=config.macros() + [('MAKE_LAYVIEW_LIBRARY', 1)], + include_dirs=[_laybasic_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_layview'), + extra_link_args=config.link_args('_layview'), + extra_compile_args=config.compile_args('_layview'), + sources=list(_layview_sources)) +config.add_extension(_layview) + +# ------------------------------------------------------------------ +# _lym dependency library + +_lym_path = os.path.join("src", "lym", "lym") +_lym_sources = set(glob.glob(os.path.join(_lym_path, "*.cc"))) + +_lym = Library(config.root + '._lym', + define_macros=config.macros() + [('MAKE_LYM_LIBRARY', 1)], + include_dirs=[_pya_path, _rba_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_rba', _rba_path), config.path_of('_pya', _pya_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], + language='c++', + libraries=config.libraries('_lym'), + extra_link_args=config.link_args('_lym'), + extra_compile_args=config.compile_args('_lym'), + sources=list(_lym_sources)) +config.add_extension(_lym) + +# ------------------------------------------------------------------ +# _ant dependency library + +_ant_path = os.path.join("src", "ant", "ant") +_ant_sources = set(glob.glob(os.path.join(_ant_path, "*.cc"))) + +_ant = Library(config.root + '._ant', + define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_ant'), + extra_link_args=config.link_args('_ant'), + extra_compile_args=config.compile_args('_ant'), + sources=list(_ant_sources)) +config.add_extension(_ant) + +# ------------------------------------------------------------------ +# _img dependency library + +_img_path = os.path.join("src", "img", "img") +_img_sources = set(glob.glob(os.path.join(_img_path, "*.cc"))) + +_img = Library(config.root + '._img', + define_macros=config.macros() + [('MAKE_IMG_LIBRARY', 1)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_img'), + extra_link_args=config.link_args('_img'), + extra_compile_args=config.compile_args('_img'), + sources=list(_img_sources)) +config.add_extension(_img) + +# ------------------------------------------------------------------ +# _edt dependency library + +_edt_path = os.path.join("src", "edt", "edt") +_edt_sources = set(glob.glob(os.path.join(_edt_path, "*.cc"))) + +_edt = Library(config.root + '._edt', + define_macros=config.macros() + [('MAKE_EDT_LIBRARY', 1)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_edt'), + extra_link_args=config.link_args('_edt'), + extra_compile_args=config.compile_args('_edt'), + sources=list(_edt_sources)) +config.add_extension(_edt) + # ------------------------------------------------------------------ # dependency libraries from db_plugins @@ -577,6 +708,36 @@ rdb = Extension(config.root + '.rdbcore', extra_compile_args=config.compile_args('rdbcore'), sources=list(rdb_sources)) +# ------------------------------------------------------------------ +# lay extension library + +lay_path = os.path.join("src", "pymod", "lay") +lay_sources = set(glob.glob(os.path.join(lay_path, "*.cc"))) + +lay = Extension(config.root + '.laycore', + define_macros=config.macros(), + include_dirs=[_laybasic_path, + _layview_path, + _img_path, + _ant_path, + _edt_path, + _lym_path, + _tl_path, + _gsi_path, + _pya_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), + config.path_of('_layview', _layview_path), + config.path_of('_img', _img_path), + config.path_of('_ant', _ant_path), + config.path_of('_edt', _edt_path), + config.path_of('_lym', _lym_path), + config.path_of('_tl', _tl_path), + config.path_of('_gsi', _gsi_path), + config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('laycore'), + extra_compile_args=config.compile_args('laycore'), + sources=list(lay_sources)) + # ------------------------------------------------------------------ # Core setup function @@ -602,4 +763,4 @@ if __name__ == '__main__': url='https://github.com/klayout/klayout', packages=find_packages('src/pymod/distutils_src'), package_dir={'': 'src/pymod/distutils_src'}, # https://github.com/pypa/setuptools/issues/230 - ext_modules=[_tl, _gsi, _pya, _db, _lib, _rdb] + db_plugins + [tl, db, lib, rdb]) + ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _laybasic, _layview, _ant, _edt, _img] + db_plugins + [tl, db, lib, rdb, lay]) diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 033a687ac..c6052dab5 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -6,16 +6,7 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_ANT_LIBRARY -HEADERS = \ - antConfig.h \ - antConfigPage.h \ - antObject.h \ - antPlugin.h \ - antPropertiesPage.h \ - antService.h \ - antTemplate.h \ - antForceLink.h \ - antCommon.h +!equals(HAVE_QT, "0") { FORMS = \ RulerConfigPage.ui \ @@ -24,18 +15,48 @@ FORMS = \ RulerConfigPage4.ui \ RulerPropertiesPage.ui \ +} + +# Disabled without Qt: + +HEADERS = \ + antConfigPage.h \ + antPropertiesPage.h \ + SOURCES = \ - antConfig.cc \ antConfigPage.cc \ + antPropertiesPage.cc \ + +# Enabled without Qt: + +HEADERS += \ + antConfig.h \ + antObject.h \ + antPlugin.h \ + antService.h \ + antTemplate.h \ + antForceLink.h \ + antCommon.h + +SOURCES += \ + antConfig.cc \ antObject.cc \ antPlugin.cc \ - antPropertiesPage.cc \ antService.cc \ antTemplate.cc \ gsiDeclAnt.cc \ - antForceLink.cc + antForceLink.cc -INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_db +INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db + +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} diff --git a/src/ant/ant/antConfigPage.cc b/src/ant/ant/antConfigPage.cc index 2d3e2247e..bf3ef673b 100644 --- a/src/ant/ant/antConfigPage.cc +++ b/src/ant/ant/antConfigPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "antConfigPage.h" #include "ui_RulerConfigPage.h" @@ -417,3 +418,5 @@ ConfigPage4::commit () } } // namespace ant + +#endif diff --git a/src/ant/ant/antConfigPage.h b/src/ant/ant/antConfigPage.h index a99d37b34..6c588e88f 100644 --- a/src/ant/ant/antConfigPage.h +++ b/src/ant/ant/antConfigPage.h @@ -20,12 +20,13 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_antConfigPage #define HDR_antConfigPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "antTemplate.h" class QListWidgetItem; @@ -133,3 +134,5 @@ private: #endif +#endif + diff --git a/src/ant/ant/antForceLink.cc b/src/ant/ant/antForceLink.cc index 4a96a1893..41d78f078 100644 --- a/src/ant/ant/antForceLink.cc +++ b/src/ant/ant/antForceLink.cc @@ -20,7 +20,6 @@ */ - #include "antForceLink.h" namespace ant diff --git a/src/ant/ant/antForceLink.h b/src/ant/ant/antForceLink.h index 4821171a1..4a1323c39 100644 --- a/src/ant/ant/antForceLink.h +++ b/src/ant/ant/antForceLink.h @@ -33,7 +33,7 @@ namespace ant { ANT_PUBLIC int _force_link_f (); - int _force_link_target = _force_link_f (); + static int _force_link_target = _force_link_f (); } #endif diff --git a/src/ant/ant/antObject.cc b/src/ant/ant/antObject.cc index 6f421383b..43bdf736b 100644 --- a/src/ant/ant/antObject.cc +++ b/src/ant/ant/antObject.cc @@ -284,7 +284,7 @@ public: void execute (const tl::ExpressionParserContext &context, tl::Variant &out, const std::vector &vv) const { if (vv.size () != 0) { - throw tl::EvalError (tl::to_string (QObject::tr ("Annotation function must not have arguments")), context); + throw tl::EvalError (tl::to_string (tr ("Annotation function must not have arguments")), context); } const Object &obj = mp_eval->obj (); diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 330442a94..4ad479762 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -22,15 +22,22 @@ #include "layPlugin.h" -#include "layAbstractMenu.h" #include "layConverters.h" -#include "layConfigurationDialog.h" #include "layDispatcher.h" -#include "antConfigPage.h" +#include "layColor.h" +#if defined(HAVE_QT) +# include "layConfigurationDialog.h" +# include "layAbstractMenu.h" +#endif #include "antConfig.h" +#if defined(HAVE_QT) +# include "antConfigPage.h" +#endif #include "antPlugin.h" -#include +#if defined(HAVE_QT) +# include +#endif namespace ant { @@ -60,7 +67,7 @@ PluginDeclaration::get_options (std::vector < std::pair (cfg_max_number_of_rulers, "-1")); options.push_back (std::pair (cfg_ruler_snap_range, "8")); - options.push_back (std::pair (cfg_ruler_color, lay::ColorConverter ().to_string (QColor ()))); + options.push_back (std::pair (cfg_ruler_color, lay::ColorConverter ().to_string (lay::Color ()))); options.push_back (std::pair (cfg_ruler_halo, "true")); options.push_back (std::pair (cfg_ruler_snap_mode, ACConverter ().to_string (lay::AC_Any))); options.push_back (std::pair (cfg_ruler_obj_snap, tl::to_string (true))); @@ -70,28 +77,30 @@ PluginDeclaration::get_options (std::vector < std::pair > PluginDeclaration::config_pages (QWidget *parent) const { std::vector > pages; - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Snapping")), new ant::ConfigPage (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Appearance")), new ant::ConfigPage2 (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Angle")), new ant::ConfigPage3 (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Templates")), new ant::ConfigPage4 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Snapping")), new ant::ConfigPage (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Appearance")), new ant::ConfigPage2 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Angle")), new ant::ConfigPage3 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Templates")), new ant::ConfigPage4 (parent))); return pages; } +#endif void PluginDeclaration::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("rulers_group", "edit_menu.end")); - menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); - menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); + menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (tr ("Clear All Rulers And Annotations(Ctrl+K)")))); + menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (tr ("Ruler And Annotation Setup")))); } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new ant::Service (manager, view); } @@ -101,9 +110,11 @@ PluginDeclaration::menu_activated (const std::string &symbol) const { if (symbol == "ant::configure") { +#if defined(HAVE_QT) lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::Dispatcher::instance (), "ant::Plugin"); config_dialog.exec (); - +#endif + return true; } else { @@ -114,14 +125,14 @@ PluginDeclaration::menu_activated (const std::string &symbol) const bool PluginDeclaration::implements_editable (std::string &title) const { - title = tl::to_string (QObject::tr ("Rulers And Annotations")); + title = tl::to_string (tr ("Rulers And Annotations")); return true; } bool PluginDeclaration::implements_mouse_mode (std::string &title) const { - title = "ruler:ruler_mode_group:ruler_templates_group\t" + tl::to_string (QObject::tr ("Ruler{Add rulers and annotations}")) + "<:ruler.png>"; + title = "ruler:ruler_mode_group:ruler_templates_group\t" + tl::to_string (tr ("Ruler{Add rulers and annotations}")) + "<:ruler.png>"; return true; } @@ -182,17 +193,17 @@ PluginDeclaration::initialized (lay::Dispatcher *root) // Set up the templates we want to see (plus some non-categorized templates) - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Ruler")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_ruler")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Ruler")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_ruler")); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Cross")), "", "", "$U,$V", ant::Object::STY_cross_both, ant::Object::OL_diag, true, lay::AC_Global, "_cross")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Cross")), "", "", "$U,$V", ant::Object::STY_cross_both, ant::Object::OL_diag, true, lay::AC_Global, "_cross")); m_templates.back ().set_mode (ant::Template::RulerSingleClick); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Measure")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_measure")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Measure")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_measure")); m_templates.back ().set_mode (ant::Template::RulerAutoMetric); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Ellipse")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_ellipse, true, lay::AC_Global, std::string ())); + m_templates.push_back (ant::Template (tl::to_string (tr ("Ellipse")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_ellipse, true, lay::AC_Global, std::string ())); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Box")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_box, true, lay::AC_Global, std::string ())); + m_templates.push_back (ant::Template (tl::to_string (tr ("Box")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_box, true, lay::AC_Global, std::string ())); root->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); root->config_end (); @@ -203,12 +214,15 @@ PluginDeclaration::initialized (lay::Dispatcher *root) void PluginDeclaration::uninitialize (lay::Dispatcher *) { +#if defined(HAVE_QT) m_actions.clear (); +#endif } void PluginDeclaration::update_current_template () { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -234,11 +248,13 @@ PluginDeclaration::update_current_template () } } +#endif } void PluginDeclaration::update_menu () { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -278,7 +294,7 @@ PluginDeclaration::update_menu () } } } - +#endif } void diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 6d65c03e6..0b8b4ac05 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -31,6 +31,8 @@ namespace ant { +class Template; + class PluginDeclaration : public lay::PluginDeclaration { @@ -40,11 +42,13 @@ public: virtual void get_options (std::vector < std::pair > &options) const; virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); +#if defined(HAVE_QT) virtual std::vector > config_pages (QWidget *parent) const; +#endif virtual void config_finalize (); virtual void initialized (lay::Dispatcher *); virtual void uninitialize (lay::Dispatcher *); @@ -60,7 +64,9 @@ private: std::vector m_templates; int m_current_template; +#if defined(HAVE_QT) tl::weak_collection m_actions; +#endif bool m_current_template_updated; bool m_templates_updated; }; diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 565bf182e..1c7794db4 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -20,9 +20,10 @@ */ +#if defined(HAVE_QT) #include "antPropertiesPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" namespace ant @@ -365,3 +366,4 @@ PropertiesPage::apply () } +#endif diff --git a/src/ant/ant/antPropertiesPage.h b/src/ant/ant/antPropertiesPage.h index cd3253129..8e50f4dc4 100644 --- a/src/ant/ant/antPropertiesPage.h +++ b/src/ant/ant/antPropertiesPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_antPropertiesPage #define HDR_antPropertiesPage @@ -70,3 +71,5 @@ private: } #endif + +#endif diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 7fe8733ce..e9d6401c5 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -28,13 +28,17 @@ #include "layPlugin.h" #include "layRenderer.h" #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" #include "layConverters.h" #include "layLayoutCanvas.h" -#include "layProperties.h" +#if defined(HAVE_QT) +# include "layProperties.h" +#endif #include "antService.h" -#include "antPropertiesPage.h" +#if defined(HAVE_QT) +# include "antPropertiesPage.h" +#endif #include "antConfig.h" namespace ant @@ -759,9 +763,9 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) int basic_width = int(0.5 + 1.0 / canvas.resolution ()); - QColor c (mp_rulers->color ()); - if (! c.isValid ()) { - c = QColor (canvas.foreground_color ().rgb ()); + lay::Color c (mp_rulers->color ()); + if (! c.is_valid ()) { + c = canvas.foreground_color (); } // obtain bitmap to render on @@ -784,7 +788,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // ant::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), lay::Drawing (1/*number of planes*/, view->drawings ()), db::Object (manager), @@ -819,7 +823,7 @@ Service::configure (const std::string &name, const std::string &value) if (name == cfg_ruler_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); // make the color available for the dynamic view objects too. @@ -910,7 +914,7 @@ Service::annotations_changed () } std::vector -Service::get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor /*active*/) const +Service::get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color /*active*/) const { int basic_width = int(0.5 + 1.0 / canvas.resolution ()); @@ -920,7 +924,7 @@ Service::get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColo if (m_halo) { view_ops.push_back (lay::ViewOp (background.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 3 * basic_width, 0)); } - if (m_color.isValid ()) { + if (m_color.is_valid ()) { view_ops.push_back (lay::ViewOp (m_color.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, basic_width, 0)); } else { view_ops.push_back (lay::ViewOp (foreground.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, basic_width, 0)); @@ -1525,7 +1529,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); m_current = ant::Object (pt, pt, 0, tpl); show_message (); @@ -1562,7 +1566,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); m_current = ant::Object (ee.first, ee.second, 0, tpl); show_message (); @@ -1598,7 +1602,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); show_message (); @@ -2160,19 +2164,21 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } - msg += tl::sprintf (tl::to_string (QObject::tr ("annotation(d=%s x=%s y=%s)")), ruler->text (), ruler->text_x (), ruler->text_y ()); + msg += tl::sprintf (tl::to_string (tr ("annotation(d=%s x=%s y=%s)")), ruler->text (), ruler->text_x (), ruler->text_y ()); view ()->message (msg); } } +#if defined(HAVE_QT) lay::PropertiesPage * Service::properties_page (db::Manager *manager, QWidget *parent) { return new PropertiesPage (this, manager, parent); } +#endif void Service::get_selection (std::vector &sel) const @@ -2248,7 +2254,7 @@ Service::menu_activated (const std::string &symbol) if (symbol == "ant::clear_all_rulers_internal") { clear_rulers (); } else if (symbol == "ant::clear_all_rulers") { - manager ()->transaction (tl::to_string (QObject::tr ("Clear all rulers"))); + manager ()->transaction (tl::to_string (tr ("Clear all rulers"))); clear_rulers (); manager ()->commit (); } else { diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 2856ba067..c52c4d138 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -41,7 +41,7 @@ namespace ant { -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class Service; @@ -201,7 +201,7 @@ public: */ enum MoveMode { MoveNone, MoveP1, MoveP2, MoveP12, MoveP21, MoveP1X, MoveP2X, MoveP1Y, MoveP2Y, MoveRuler, MoveSelected }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -346,10 +346,12 @@ public: */ virtual void transform (const db::DCplxTrans &trans); +#if defined(HAVE_QT) /** * @brief Create the properties page */ virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif /** * @brief Get the selection for the properties page @@ -387,7 +389,7 @@ public: /** * @brief Color accessor */ - QColor color () const + lay::Color color () const { return m_color; } @@ -427,7 +429,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -498,7 +500,7 @@ public: private: // Ruler display and snapping configuration - QColor m_color; + lay::Color m_color; bool m_halo; lay::angle_constraint_type m_snap_mode; double m_grid; @@ -510,7 +512,7 @@ private: int m_max_number_of_rulers; // The layout view that the ruler service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The ruler view objects representing the selection // and the moved rules in move mode @@ -599,7 +601,7 @@ private: /** * @brief implementation of the "Drawing" interface: configuration */ - std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor active) const; + std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const; /** * @brief Update m_rulers to reflect the selection diff --git a/src/ant/ant/antTemplate.cc b/src/ant/ant/antTemplate.cc index e47f523c7..390a4b8a9 100644 --- a/src/ant/ant/antTemplate.cc +++ b/src/ant/ant/antTemplate.cc @@ -31,7 +31,7 @@ namespace ant { Template::Template () - : m_title (tl::to_string (QObject::tr ("Ruler"))), + : m_title (tl::to_string (tr ("Ruler"))), m_fmt_x ("$X"), m_fmt_y ("$Y"), m_fmt ("$D"), m_style (ant::Object::STY_ruler), m_outline (ant::Object::OL_diag), m_snap (true), m_angle_constraint (lay::AC_Global), diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index ee928abc6..8889af167 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -25,7 +25,7 @@ #include "antObject.h" #include "antService.h" #include "antPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -70,10 +70,10 @@ static int align_right () { return int (ant::Object::AL_right); } static int align_top () { return int (ant::Object::AL_top); } static int align_up () { return int (ant::Object::AL_up); } -static void clear_annotations (lay::LayoutView *view); -static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj); -static void erase_annotation (lay::LayoutView *view, int id); -static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj); +static void clear_annotations (lay::LayoutViewBase *view); +static void insert_annotation (lay::LayoutViewBase *view, AnnotationRef *obj); +static void erase_annotation_base (lay::LayoutViewBase *view, int id); +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj); /** * @brief An extension of the ant::Object that provides "live" updates of the view @@ -88,7 +88,7 @@ public: // .. nothing yet .. } - AnnotationRef (const ant::Object &other, lay::LayoutView *view) + AnnotationRef (const ant::Object &other, lay::LayoutViewBase *view) : ant::Object (other), mp_view (view) { // .. nothing yet .. @@ -132,7 +132,7 @@ public: void erase () { if (mp_view && id () >= 0) { - erase_annotation (mp_view.get (), id ()); + erase_annotation_base (mp_view.get (), id ()); detach (); } } @@ -140,10 +140,10 @@ public: template AnnotationRef transformed (const T &t) const { - return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); + return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutView *view) + void set_view (lay::LayoutViewBase *view) { mp_view.reset (view); } @@ -152,15 +152,15 @@ protected: void property_changed () { if (mp_view && id () >= 0) { - replace_annotation (mp_view.get (), id (), *this); + replace_annotation_base (mp_view.get (), id (), *this); } } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static void clear_annotations (lay::LayoutView *view) +static void clear_annotations (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -168,10 +168,10 @@ static void clear_annotations (lay::LayoutView *view) } } -static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) +static void insert_annotation (lay::LayoutViewBase *view, AnnotationRef *obj) { if (obj->is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The object is already inserted into a view - detach the object first or create a different object."))); + throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); } ant::Service *ant_service = view->get_plugin (); @@ -182,7 +182,7 @@ static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) } } -static void erase_annotation (lay::LayoutView *view, int id) +static void erase_annotation_base (lay::LayoutViewBase *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -195,7 +195,12 @@ static void erase_annotation (lay::LayoutView *view, int id) } } -static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj) +static void erase_annotation (lay::LayoutViewBase *view, int id) +{ + erase_annotation_base (view, id); +} + +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -208,7 +213,12 @@ static void replace_annotation (lay::LayoutView *view, int id, const AnnotationR } } -static AnnotationRef create_measure_ruler (lay::LayoutView *view, const db::DPoint &pt, int angle_constraint) +static void replace_annotation (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) +{ + replace_annotation_base (view, id, obj); +} + +static AnnotationRef create_measure_ruler (lay::LayoutViewBase *view, const db::DPoint &pt, int angle_constraint) { std::vector ant_services = view->get_plugins (); if (! ant_services.empty ()) { @@ -341,7 +351,7 @@ public: // .. nothing yet .. } - AnnotationRefIterator (const ant::AnnotationIterator &iter, lay::LayoutView *view) + AnnotationRefIterator (const ant::AnnotationIterator &iter, lay::LayoutViewBase *view) : ant::AnnotationIterator (iter), mp_view (view) { // .. nothing yet .. @@ -349,14 +359,14 @@ public: reference operator* () const { - return reference (ant::AnnotationIterator::operator* (), const_cast(mp_view.get ())); + return reference (ant::AnnotationIterator::operator* (), const_cast(mp_view.get ())); } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static AnnotationRefIterator begin_annotations (lay::LayoutView *view) +static AnnotationRefIterator begin_annotations (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -366,7 +376,7 @@ static AnnotationRefIterator begin_annotations (lay::LayoutView *view) } } -static AnnotationRef get_annotation (lay::LayoutView *view, int id) +static AnnotationRef get_annotation (lay::LayoutViewBase *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -379,21 +389,21 @@ static AnnotationRef get_annotation (lay::LayoutView *view, int id) return AnnotationRef (); } -static tl::Event &get_annotations_changed_event (lay::LayoutView *view) +static tl::Event &get_annotations_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); return ant_service->annotations_changed_event; } -static tl::Event &get_annotation_selection_changed_event (lay::LayoutView *view) +static tl::Event &get_annotation_selection_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); return ant_service->annotation_selection_changed_event; } -static tl::event &get_annotation_changed_event (lay::LayoutView *view) +static tl::event &get_annotation_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); @@ -979,7 +989,7 @@ gsi::Class decl_Annotation (decl_BasicAnnotation, "lay", "Annotat ); static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("clear_annotations", &gsi::clear_annotations, "@brief Clears all annotations on this view" ) + @@ -1113,7 +1123,7 @@ private: // extend the layout view by "edtService" specific methods -static bool has_annotation_selection (const lay::LayoutView *view) +static bool has_annotation_selection (const lay::LayoutViewBase *view) { std::vector ant_services = view->get_plugins (); for (std::vector::const_iterator s = ant_services.begin (); s != ant_services.end (); ++s) { @@ -1124,13 +1134,13 @@ static bool has_annotation_selection (const lay::LayoutView *view) return false; } -static AnnotationSelectionIterator begin_annotations_selected (const lay::LayoutView *view) +static AnnotationSelectionIterator begin_annotations_selected (const lay::LayoutViewBase *view) { return AnnotationSelectionIterator (view->get_plugins ()); } static -gsi::ClassExt layout_view_decl2 ( +gsi::ClassExt layout_view_decl2 ( gsi::method_ext ("has_annotation_selection?", &has_annotation_selection, "@brief Returns true, if annotations (rulers) are selected in this view" "\n" diff --git a/src/buddies/src/bd/strmxor.cc b/src/buddies/src/bd/strmxor.cc index 03de6cf80..1e5cf7722 100644 --- a/src/buddies/src/bd/strmxor.cc +++ b/src/buddies/src/bd/strmxor.cc @@ -408,7 +408,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]) db::Layout layout_b; { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading file (A): ")) + infile_a); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading file (A): ")) + infile_a); db::LoadLayoutOptions load_options; generic_reader_options_a.configure (load_options); @@ -416,7 +416,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]) } { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading file (B): ")) + infile_b); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading file (B): ")) + infile_b); db::LoadLayoutOptions load_options; generic_reader_options_b.configure (load_options); diff --git a/src/db/db/dbStreamLayers.h b/src/db/db/dbStreamLayers.h index 6baf6ef36..3ee89a468 100644 --- a/src/db/db/dbStreamLayers.h +++ b/src/db/db/dbStreamLayers.h @@ -201,6 +201,8 @@ public: /** * @brief Returns the first logical layer for a given layer specification + * The first value of the pair indicates whether there is a valid mapping. + * The second value will give the layer to map to. */ template std::pair first_logical (const L &p) const @@ -215,6 +217,8 @@ public: /** * @brief Returns the first logical layer for a given layer specification + * The first value of the pair indicates whether there is a valid mapping. + * The second value will give the layer to map to. */ template std::pair first_logical (const L &p, db::Layout &layout) const @@ -230,24 +234,21 @@ public: /** * @brief Query a layer mapping * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. */ std::set logical (const LDPair &p) const; /** * @brief Query a layer mapping from a name * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. */ std::set logical (const std::string &name) const; /** * @brief Query a layer mapping from a name or LDPair * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. * * @param p The layer that is looked for */ @@ -256,8 +257,7 @@ public: /** * @brief Query or install a layer mapping from a name or LDPair * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. * * @param p The layer that is looked for * diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 5515e57c8..24075ca3b 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -6,70 +6,88 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_EDT_LIBRARY -HEADERS = \ - edtConfig.h \ - edtDialogs.h \ - edtEditorOptionsPages.h \ - edtInstPropertiesPage.h \ - edtMainService.h \ - edtPartialService.h \ - edtPCellParametersPage.h \ - edtPlugin.h \ - edtPropertiesPages.h \ - edtPropertiesPageUtils.h \ - edtService.h \ - edtServiceImpl.h \ - edtUtils.h \ - edtCommon.h \ - edtDistribute.h \ - edtRecentConfigurationPage.h +!equals(HAVE_QT, "0") { -FORMS = \ - AlignOptionsDialog.ui \ - BoxPropertiesPage.ui \ - CopyModeDialog.ui \ - ChangeLayerOptionsDialog.ui \ - EditablePathPropertiesPage.ui \ - EditorOptionsGeneric.ui \ - EditorOptionsInst.ui \ - EditorOptionsPath.ui \ - EditorOptionsText.ui \ - InstantiationForm.ui \ - InstPropertiesPage.ui \ - MakeArrayOptionsDialog.ui \ - MakeCellOptionsDialog.ui \ - PathPropertiesPage.ui \ - PolygonPropertiesPage.ui \ - RoundCornerOptionsDialog.ui \ - TextPropertiesPage.ui \ + FORMS = \ + AlignOptionsDialog.ui \ + BoxPropertiesPage.ui \ + CopyModeDialog.ui \ + ChangeLayerOptionsDialog.ui \ + EditablePathPropertiesPage.ui \ + EditorOptionsGeneric.ui \ + EditorOptionsInst.ui \ + EditorOptionsPath.ui \ + EditorOptionsText.ui \ + InstantiationForm.ui \ + InstPropertiesPage.ui \ + MakeArrayOptionsDialog.ui \ + MakeCellOptionsDialog.ui \ + PathPropertiesPage.ui \ + PolygonPropertiesPage.ui \ + RoundCornerOptionsDialog.ui \ + TextPropertiesPage.ui \ DistributeOptionsDialog.ui \ EditorOptionsInstPCellParam.ui +} + +# Disabled without Qt: + +HEADERS = \ + edtDialogs.h \ + edtEditorOptionsPages.h \ + edtInstPropertiesPage.h \ + edtPCellParametersPage.h \ + edtPropertiesPages.h \ + edtPropertiesPageUtils.h \ + edtRecentConfigurationPage.h + SOURCES = \ + edtDialogs.cc \ + edtEditorOptionsPages.cc \ + edtInstPropertiesPage.cc \ + edtPCellParametersPage.cc \ + edtPropertiesPages.cc \ + edtPropertiesPageUtils.cc \ + edtRecentConfigurationPage.cc + +# Enabled without Qt: + +HEADERS += \ + edtForceLink.h \ + edtConfig.h \ + edtMainService.h \ + edtPartialService.h \ + edtPlugin.h \ + edtService.h \ + edtServiceImpl.h \ + edtUtils.h \ + edtCommon.h \ + edtDistribute.h \ + +SOURCES += \ + edtForceLink.cc \ edtConfig.cc \ - edtDialogs.cc \ - edtEditorOptionsPages.cc \ - edtInstPropertiesPage.cc \ edtMainService.cc \ edtPartialService.cc \ - edtPCellParametersPage.cc \ edtPlugin.cc \ - edtPropertiesPages.cc \ - edtPropertiesPageUtils.cc \ edtService.cc \ edtServiceImpl.cc \ edtUtils.cc \ gsiDeclEdt.cc \ - edtDistribute.cc \ - edtRecentConfigurationPage.cc + edtDistribute.cc \ -INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC +INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC -# Note: this accounts for UI-generated headers placed into the output folders in -# shadow builds: -INCLUDEPATH += $$DESTDIR/laybasic/laybasic -DEPENDPATH += $$DESTDIR/laybasic/laybasic +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_db +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} diff --git a/src/edt/edt/edtConfig.cc b/src/edt/edt/edtConfig.cc index 782c7718e..b33601771 100644 --- a/src/edt/edt/edtConfig.cc +++ b/src/edt/edt/edtConfig.cc @@ -289,7 +289,7 @@ EditGridConverter::from_string_picky (const std::string &s, db::DVector &eg) y = x; } if (x < 1e-6 || y < 1e-6) { - throw tl::Exception (tl::to_string (QObject::tr ("The grid must be larger than zero"))); + throw tl::Exception (tl::to_string (tr ("The grid must be larger than zero"))); } eg = db::DVector (x, y); } diff --git a/src/edt/edt/edtDialogs.cc b/src/edt/edt/edtDialogs.cc index 55fd4a0a2..1486b2abf 100644 --- a/src/edt/edt/edtDialogs.cc +++ b/src/edt/edt/edtDialogs.cc @@ -20,13 +20,15 @@ */ +#if defined(HAVE_QT) + #include "dbBox.h" #include "dbLayout.h" #include "edtDialogs.h" #include "layObjectInstPath.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "tlException.h" #include "tlExceptions.h" @@ -103,7 +105,7 @@ InstantiationForm::double_clicked (QListWidgetItem *item) } void -InstantiationForm::show (lay::LayoutView *view, const lay::ObjectInstPath &path) +InstantiationForm::show (lay::LayoutViewBase *view, const lay::ObjectInstPath &path) { mp_view = view; mp_path = &path; @@ -231,7 +233,7 @@ ChangeLayerOptionsDialog::~ChangeLayerOptionsDialog () } bool -ChangeLayerOptionsDialog::exec_dialog (lay::LayoutView *view, int cv_index, unsigned int &new_layer) +ChangeLayerOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int cv_index, unsigned int &new_layer) { std::vector > ll; @@ -280,7 +282,7 @@ AlignOptionsDialog::~AlignOptionsDialog () } bool -AlignOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, int &hmode, int &vmode, bool &visible_layers) +AlignOptionsDialog::exec_dialog (int &hmode, int &vmode, bool &visible_layers) { QRadioButton *hmode_buttons [] = { this->h_none_rb, this->h_left_rb, this->h_center_rb, this->h_right_rb }; QRadioButton *vmode_buttons [] = { this->v_none_rb, this->v_top_rb, this->v_center_rb, this->v_bottom_rb }; @@ -343,7 +345,7 @@ DistributeOptionsDialog::~DistributeOptionsDialog () } bool -DistributeOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers) +DistributeOptionsDialog::exec_dialog (bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers) { QRadioButton *hmode_buttons [] = { this->h_none_rb, this->h_left_rb, this->h_center_rb, this->h_right_rb }; QRadioButton *vmode_buttons [] = { this->v_none_rb, this->v_top_rb, this->v_center_rb, this->v_bottom_rb }; @@ -683,3 +685,5 @@ END_PROTECTED; } +#endif + diff --git a/src/edt/edt/edtDialogs.h b/src/edt/edt/edtDialogs.h index 30444311a..5864a8d54 100644 --- a/src/edt/edt/edtDialogs.h +++ b/src/edt/edt/edtDialogs.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtDialogs @@ -45,7 +46,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; class Marker; class ObjectInstPath; } @@ -81,7 +82,7 @@ public: InstantiationForm (QWidget *parent); virtual ~InstantiationForm (); - void show (lay::LayoutView *view, const lay::ObjectInstPath &path); + void show (lay::LayoutViewBase *view, const lay::ObjectInstPath &path); public slots: void display_mode_changed (bool); @@ -90,7 +91,7 @@ public slots: private: void update (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; const lay::ObjectInstPath *mp_path; lay::Marker *mp_marker; bool m_enable_cb_callbacks; @@ -109,7 +110,7 @@ public: ChangeLayerOptionsDialog (QWidget *parent); virtual ~ChangeLayerOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int cv_index, unsigned int &new_layer); + bool exec_dialog (lay::LayoutViewBase *view, int cv_index, unsigned int &new_layer); }; /** @@ -125,7 +126,7 @@ public: AlignOptionsDialog (QWidget *parent); virtual ~AlignOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &hmode, int &vmode, bool &visible_layers); + bool exec_dialog (int &hmode, int &vmode, bool &visible_layers); }; /** @@ -141,7 +142,7 @@ public: DistributeOptionsDialog (QWidget *parent); virtual ~DistributeOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers); + bool exec_dialog (bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers); }; /** @@ -208,3 +209,5 @@ private: #endif +#endif + diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index 3f33fd310..36c4a253c 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "dbLibrary.h" @@ -32,7 +33,7 @@ #include "edtPropertiesPageUtils.h" #include "tlExceptions.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellSelectionForm.h" #include "layQtTools.h" #include "ui_EditorOptionsGeneric.h" @@ -69,7 +70,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le // ------------------------------------------------------------------ // EditorOptionsGeneric implementation -EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsGeneric (); @@ -206,7 +207,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsText implementation -EditorOptionsText::EditorOptionsText (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsText::EditorOptionsText (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsText (); @@ -284,7 +285,7 @@ EditorOptionsText::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsPath implementation -EditorOptionsPath::EditorOptionsPath (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsPath::EditorOptionsPath (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsPath (); @@ -385,7 +386,7 @@ EditorOptionsPath::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsInst implementation -EditorOptionsInst::EditorOptionsInst (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsInst::EditorOptionsInst (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsInst (); @@ -678,7 +679,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsInstPCellParam implementation -EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0) { mp_ui = new Ui::EditorOptionsInstPCellParam (); @@ -890,3 +891,4 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector - #include "dbEdgeProcessor.h" #include "dbPolygonTools.h" #include "dbLibrary.h" #include "dbLibraryManager.h" #include "tlExceptions.h" -#include "layLayoutView.h" -#include "layDialogs.h" +#include "layLayoutViewBase.h" #include "laySelector.h" -#include "layCellSelectionForm.h" #include "layFinder.h" #include "layLayerProperties.h" -#include "layLayerTreeModel.h" #include "tlProgress.h" #include "edtPlugin.h" #include "edtMainService.h" #include "edtService.h" #include "edtServiceImpl.h" #include "edtConfig.h" -#include "edtDialogs.h" -#include "edtEditorOptionsPages.h" #include "edtDistribute.h" -#include -#include -#include +#if defined(HAVE_QT) +# include "layDialogs.h" +# include "layLayerTreeModel.h" +# include "layCellSelectionForm.h" +# include "edtDialogs.h" +# include "edtEditorOptionsPages.h" +#endif + +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif namespace edt { @@ -55,7 +59,7 @@ namespace edt // ----------------------------------------------------------------------------- // Main Service implementation -MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) +MainService::MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : lay::Plugin (view), lay::Editable (view), db::Object (manager), @@ -73,15 +77,16 @@ MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Disp m_origin_mode_x (-1), m_origin_mode_y (-1), m_origin_visible_layers_for_bbox (false), m_array_a (0.0, 1.0), m_array_b (1.0, 0.0), m_array_na (1), m_array_nb (1), - m_router (0.0), m_rinner (0.0), m_npoints (64), m_undo_before_apply (true), - mp_round_corners_dialog (0), - mp_align_options_dialog (0), - mp_distribute_options_dialog (0), - mp_flatten_inst_options_dialog (0), - mp_make_cell_options_dialog (0), - mp_make_array_options_dialog (0) + m_router (0.0), m_rinner (0.0), m_npoints (64), m_undo_before_apply (true) { - // .. nothing yet .. +#if defined(HAVE_QT) + mp_round_corners_dialog = 0; + mp_align_options_dialog = 0; + mp_distribute_options_dialog = 0; + mp_flatten_inst_options_dialog = 0; + mp_make_cell_options_dialog = 0; + mp_make_array_options_dialog = 0; +#endif } MainService::~MainService () @@ -89,11 +94,13 @@ MainService::~MainService () // .. nothing yet .. } +#if defined(HAVE_QT) + edt::RoundCornerOptionsDialog * MainService::round_corners_dialog () { if (! mp_round_corners_dialog) { - mp_round_corners_dialog = new edt::RoundCornerOptionsDialog (view ()); + mp_round_corners_dialog = new edt::RoundCornerOptionsDialog (view ()->widget ()); } return mp_round_corners_dialog; } @@ -102,7 +109,7 @@ edt::AlignOptionsDialog * MainService::align_options_dialog () { if (! mp_align_options_dialog) { - mp_align_options_dialog = new edt::AlignOptionsDialog (view ()); + mp_align_options_dialog = new edt::AlignOptionsDialog (view ()->widget ()); } return mp_align_options_dialog; } @@ -111,7 +118,7 @@ edt::DistributeOptionsDialog * MainService::distribute_options_dialog () { if (! mp_distribute_options_dialog) { - mp_distribute_options_dialog = new edt::DistributeOptionsDialog (view ()); + mp_distribute_options_dialog = new edt::DistributeOptionsDialog (view ()->widget ()); } return mp_distribute_options_dialog; } @@ -120,7 +127,7 @@ lay::FlattenInstOptionsDialog * MainService::flatten_inst_options_dialog () { if (! mp_flatten_inst_options_dialog) { - mp_flatten_inst_options_dialog = new lay::FlattenInstOptionsDialog (view (), false /*don't allow pruning*/); + mp_flatten_inst_options_dialog = new lay::FlattenInstOptionsDialog (view ()->widget (), false /*don't allow pruning*/); } return mp_flatten_inst_options_dialog; } @@ -129,7 +136,7 @@ edt::MakeCellOptionsDialog * MainService::make_cell_options_dialog () { if (! mp_make_cell_options_dialog) { - mp_make_cell_options_dialog = new edt::MakeCellOptionsDialog (view ()); + mp_make_cell_options_dialog = new edt::MakeCellOptionsDialog (view ()->widget ()); } return mp_make_cell_options_dialog; } @@ -138,11 +145,13 @@ edt::MakeArrayOptionsDialog * MainService::make_array_options_dialog () { if (! mp_make_array_options_dialog) { - mp_make_array_options_dialog = new edt::MakeArrayOptionsDialog (view ()); + mp_make_array_options_dialog = new edt::MakeArrayOptionsDialog (view ()->widget ()); } return mp_make_array_options_dialog; } +#endif + void MainService::menu_activated (const std::string &symbol) { @@ -298,10 +307,10 @@ MainService::cm_descend () } if (! common_inst.anything ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Select an object to determine into which instance to descend"))); + throw tl::Exception (tl::to_string (tr ("Select an object to determine into which instance to descend"))); } if (! common_inst.valid () || common_inst.ambiguous ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection is ambiguous - cannot determine into which instance to descend"))); + throw tl::Exception (tl::to_string (tr ("Selection is ambiguous - cannot determine into which instance to descend"))); } // remove the common path and create a new set of selections @@ -388,59 +397,66 @@ MainService::cm_ascend () void MainService::cm_flatten_insts () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); - if (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0) { +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally + if (! (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0)) { + return; + } +#endif - view ()->cancel_edits (); + view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Flatten instances"))); + manager ()->transaction (tl::to_string (tr ("Flatten instances"))); - std::set needs_cleanup; + std::set needs_cleanup; - std::vector edt_services = view ()->get_plugins (); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + std::vector edt_services = view ()->get_plugins (); + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - const lay::CellView &cv = view ()->cellview (r->cv_index ()); - if (cv.is_valid ()) { + const lay::CellView &cv = view ()->cellview (r->cv_index ()); + if (cv.is_valid ()) { - db::Cell &target_cell = cv->layout ().cell (r->cell_index ()); - if (r->is_cell_inst () && target_cell.is_valid (r->back ().inst_ptr)) { - - // because we select whole arrays in editable mode, we can iterator over them - db::CellInstArray cell_inst = r->back ().inst_ptr.cell_inst (); - for (db::CellInstArray::iterator a = cell_inst.begin (); ! a.at_end (); ++a) { - cv->layout ().flatten (cv->layout ().cell (r->cell_index_tot ()), target_cell, cell_inst.complex_trans (*a), m_flatten_insts_levels < 0 ? m_flatten_insts_levels : m_flatten_insts_levels - 1); - } - - if (cv->layout ().cell (r->back ().inst_ptr.cell_index ()).is_proxy ()) { - needs_cleanup.insert (& cv->layout ()); - } - - target_cell.erase (r->back ().inst_ptr); + db::Cell &target_cell = cv->layout ().cell (r->cell_index ()); + if (r->is_cell_inst () && target_cell.is_valid (r->back ().inst_ptr)) { + // because we select whole arrays in editable mode, we can iterator over them + db::CellInstArray cell_inst = r->back ().inst_ptr.cell_inst (); + for (db::CellInstArray::iterator a = cell_inst.begin (); ! a.at_end (); ++a) { + cv->layout ().flatten (cv->layout ().cell (r->cell_index_tot ()), target_cell, cell_inst.complex_trans (*a), m_flatten_insts_levels < 0 ? m_flatten_insts_levels : m_flatten_insts_levels - 1); } + if (cv->layout ().cell (r->back ().inst_ptr.cell_index ()).is_proxy ()) { + needs_cleanup.insert (& cv->layout ()); + } + + target_cell.erase (r->back ().inst_ptr); + } } } - // clean up the layouts that need to do so. - for (std::set::const_iterator l = needs_cleanup.begin (); l != needs_cleanup.end (); ++l) { - (*l)->cleanup (); - } - - // The selection is no longer valid - view ()->clear_selection (); - - manager ()->commit (); - } + + // clean up the layouts that need to do so. + for (std::set::const_iterator l = needs_cleanup.begin (); l != needs_cleanup.end (); ++l) { + (*l)->cleanup (); + } + + // The selection is no longer valid + view ()->clear_selection (); + + manager ()->commit (); } void @@ -449,7 +465,7 @@ MainService::cm_move_hier_up () view ()->cancel_edits (); check_no_guiding_shapes (); - manager ()->transaction (tl::to_string (QObject::tr ("Move up in hierarchy"))); + manager ()->transaction (tl::to_string (tr ("Move up in hierarchy"))); std::vector edt_services = view ()->get_plugins (); for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -691,7 +707,7 @@ MainService::cm_make_cell_variants () if (cv_index < 0) { cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'make cell variants'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'make cell variants'"))); } } } @@ -705,7 +721,7 @@ MainService::cm_make_cell_variants () view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Make cell variants for selection"))); + manager ()->transaction (tl::to_string (tr ("Make cell variants for selection"))); std::vector new_selection; for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -716,7 +732,7 @@ MainService::cm_make_cell_variants () // TODO: the algorithm is basically O(2) in the number of selected items. A first // step to mitigate that problem is to provide a progress and hence a way to cancel it. - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Make cell variants for selection")), num_sel, 1); + tl::RelativeProgress progress (tl::to_string (tr ("Make cell variants for selection")), num_sel, 1); for (size_t nsel = 0; nsel < num_sel; ++nsel) { @@ -901,7 +917,7 @@ MainService::cm_resolve_arefs () cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { // TODO: this limitation is not really necessary, but makes the code somewhat simpler - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'resolve array references'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'resolve array references'"))); } insts_to_resolve.push_back (*r); } @@ -917,7 +933,7 @@ MainService::cm_resolve_arefs () std::vector new_selection; - manager ()->transaction (tl::to_string (QObject::tr ("Resolve array references"))); + manager ()->transaction (tl::to_string (tr ("Resolve array references"))); for (std::vector::const_iterator p = insts_to_resolve.begin (); p != insts_to_resolve.end (); ++p) { @@ -962,6 +978,10 @@ MainService::cm_resolve_arefs () void MainService::cm_make_cell () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -972,7 +992,7 @@ MainService::cm_make_cell () if (cv_index < 0) { cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'make cell'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'make cell'"))); } } } @@ -981,80 +1001,83 @@ MainService::cm_make_cell () const lay::CellView &cv = view ()->cellview (cv_index); - if (make_cell_options_dialog ()->exec_dialog (cv->layout (), m_make_cell_name, m_origin_mode_x, m_origin_mode_y)) { +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally + if (! make_cell_options_dialog ()->exec_dialog (cv->layout (), m_make_cell_name, m_origin_mode_x, m_origin_mode_y)) { + return; + } + #endif - // Compute the selection's bbox to establish a good origin for the new cell - db::Box selection_bbox; - db::box_convert bc (cv->layout ()); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - if (r->is_cell_inst ()) { - selection_bbox += db::ICplxTrans (r->trans ()) * r->back ().bbox (bc); - } else { - selection_bbox += db::ICplxTrans (r->trans ()) * r->shape ().bbox (); - } + // Compute the selection's bbox to establish a good origin for the new cell + db::Box selection_bbox; + db::box_convert bc (cv->layout ()); + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + if (r->is_cell_inst ()) { + selection_bbox += db::ICplxTrans (r->trans ()) * r->back ().bbox (bc); + } else { + selection_bbox += db::ICplxTrans (r->trans ()) * r->shape ().bbox (); } } + } - if (selection_bbox.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection is empty. Cannot create a cell from an empty selection."))); - } + if (selection_bbox.empty ()) { + throw tl::Exception (tl::to_string (tr ("The selection is empty. Cannot create a cell from an empty selection."))); + } - view ()->cancel_edits (); + view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Make cell from selection"))); + manager ()->transaction (tl::to_string (tr ("Make cell from selection"))); - db::cell_index_type target_ci = cv->layout ().add_cell (m_make_cell_name.c_str ()); - // create target cell - db::Cell &target_cell = cv->layout ().cell (target_ci); + db::cell_index_type target_ci = cv->layout ().add_cell (m_make_cell_name.c_str ()); + // create target cell + db::Cell &target_cell = cv->layout ().cell (target_ci); - // create target cell instance - db::Vector ref; - if (m_origin_mode_x >= -1) { - ref = db::Vector (selection_bbox.left () + ((m_origin_mode_x + 1) * selection_bbox.width ()) / 2, selection_bbox.bottom () + ((m_origin_mode_y + 1) * selection_bbox.height ()) / 2); - } + // create target cell instance + db::Vector ref; + if (m_origin_mode_x >= -1) { + ref = db::Vector (selection_bbox.left () + ((m_origin_mode_x + 1) * selection_bbox.width ()) / 2, selection_bbox.bottom () + ((m_origin_mode_y + 1) * selection_bbox.height ()) / 2); + } - db::Instance target_cell_inst = cv.cell ()->insert (db::CellInstArray (db::CellInst (target_ci), db::Trans (ref))); - db::ICplxTrans to = db::ICplxTrans (db::Trans (-ref)); + db::Instance target_cell_inst = cv.cell ()->insert (db::CellInstArray (db::CellInst (target_ci), db::Trans (ref))); + db::ICplxTrans to = db::ICplxTrans (db::Trans (-ref)); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - if (r->is_cell_inst ()) { + if (r->is_cell_inst ()) { - db::Instance new_inst = target_cell.insert (r->back ().inst_ptr); - target_cell.transform (new_inst, to * db::ICplxTrans (r->trans ())); + db::Instance new_inst = target_cell.insert (r->back ().inst_ptr); + target_cell.transform (new_inst, to * db::ICplxTrans (r->trans ())); - } else { + } else { - db::Shapes &target_shapes = target_cell.shapes (r->layer ()); - db::Shape new_shape = target_shapes.insert (r->shape ()); - target_shapes.transform (new_shape, to * db::ICplxTrans (r->trans ())); - - } + db::Shapes &target_shapes = target_cell.shapes (r->layer ()); + db::Shape new_shape = target_shapes.insert (r->shape ()); + target_shapes.transform (new_shape, to * db::ICplxTrans (r->trans ())); } - // delete all the objects currently selected and set the new selection - (*es)->del_selected (); - - // establish the new instance as selection for the instance service - std::vector new_selection; - if ((*es)->flags () == db::ShapeIterator::Nothing) { - new_selection.push_back (lay::ObjectInstPath ()); - new_selection.back ().set_topcell (cv.cell_index ()); - new_selection.back ().set_cv_index (cv_index); - new_selection.back ().add_path (db::InstElement (target_cell_inst)); - } - (*es)->set_selection (new_selection.begin (), new_selection.end ()); - } - manager ()->commit (); + // delete all the objects currently selected and set the new selection + (*es)->del_selected (); + + // establish the new instance as selection for the instance service + std::vector new_selection; + if ((*es)->flags () == db::ShapeIterator::Nothing) { + new_selection.push_back (lay::ObjectInstPath ()); + new_selection.back ().set_topcell (cv.cell_index ()); + new_selection.back ().set_cv_index (cv_index); + new_selection.back ().add_path (db::InstElement (target_cell_inst)); + } + (*es)->set_selection (new_selection.begin (), new_selection.end ()); } + manager ()->commit (); + } } @@ -1069,7 +1092,7 @@ MainService::cm_convert_to_cell () try { - manager ()->transaction (tl::to_string (QObject::tr ("Convert to static cell"))); + manager ()->transaction (tl::to_string (tr ("Convert to static cell"))); std::vector edt_services = view ()->get_plugins (); @@ -1110,7 +1133,7 @@ MainService::cm_convert_to_cell () } if (needs_cleanup.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No instance of a PCell or library cell selected - nothing to convert"))); + throw tl::Exception (tl::to_string (tr ("No instance of a PCell or library cell selected - nothing to convert"))); } // clean up the layouts that need to do so. @@ -1132,6 +1155,10 @@ MainService::cm_convert_to_cell () void MainService::cm_convert_to_pcell () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1143,13 +1170,13 @@ MainService::cm_convert_to_pcell () num_selected += (*es)->selection ().size (); for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { if (s->is_cell_inst ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection contains instances - they cannot be converted to PCells."))); + throw tl::Exception (tl::to_string (tr ("Selection contains instances - they cannot be converted to PCells."))); } } } // Collected items - QStringList items; + std::vector pcell_items; // Collect the libraries and PCells within these libraries that are candidates here std::vector > pcells; @@ -1176,7 +1203,7 @@ MainService::cm_convert_to_pcell () // We have positive hit if (pc_decl) { pcells.push_back (std::make_pair (lib, pc->second)); - items.push_back (tl::to_qstring (lib->get_name () + "." + pc_decl->name ())); + pcell_items.push_back (lib->get_name () + "." + pc_decl->name ()); } } catch (...) { @@ -1187,18 +1214,33 @@ MainService::cm_convert_to_pcell () } + if (pcell_items.empty ()) { + throw tl::Exception (tl::to_string (tr ("No PCell found that accepts the selected shapes for conversion."))); + } + + int index = 0; + +#if defined(HAVE_QT) + // TODO: In Qt-less case keep selection persistent so we can set it externally + QStringList items; + for (auto i = pcell_items.begin (); i != pcell_items.end (); ++i) { + items.push_back (tl::to_qstring (*i)); + } + bool ok = false; - QString item = QInputDialog::getItem (view (), QObject::tr ("Select Target PCell"), - QObject::tr ("Select the PCell the shape should be converted into"), - items, 0, false, &ok); + QString item = QInputDialog::getItem (view ()->widget (), + tr ("Select Target PCell"), + tr ("Select the PCell the shape should be converted into"), + items, 0, false, &ok); if (! ok) { return; } - int index = items.indexOf (item); + index = items.indexOf (item); if (index < 0) { return; } +#endif db::Library *lib = pcells [index].first; db::pcell_id_type pcid = pcells [index].second; @@ -1209,7 +1251,7 @@ MainService::cm_convert_to_pcell () try { - manager ()->transaction (tl::to_string (QObject::tr ("Convert to PCell"))); + manager ()->transaction (tl::to_string (tr ("Convert to PCell"))); std::vector to_delete; std::vector new_selection; @@ -1218,7 +1260,7 @@ MainService::cm_convert_to_pcell () bool any_converted = false; { - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Convert to PCell")), num_selected, 1000); + tl::RelativeProgress progress (tl::to_string (tr ("Convert to PCell")), num_selected, 1000); // convert the shapes which can be converted for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1266,7 +1308,7 @@ MainService::cm_convert_to_pcell () } if (! any_converted) { - throw tl::Exception (tl::to_string (QObject::tr ("None of the shapes could be converted to the desired PCell"))); + throw tl::Exception (tl::to_string (tr ("None of the shapes could be converted to the desired PCell"))); } // Delete the shapes which have been converted @@ -1289,7 +1331,10 @@ MainService::cm_convert_to_pcell () } if (any_non_converted) { - QMessageBox::warning (view (), QObject::tr ("Warning"), QObject::tr ("Some of the shapes could not be converted to the desired PCell")); + tl::warn << tl::to_string (tr ("Some of the shapes could not be converted to the desired PCell")); +#if defined(HAVE_QT) + QMessageBox::warning (view ()->widget (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); +#endif } manager ()->commit (); @@ -1343,6 +1388,10 @@ static bool extract_rad (std::vector &poly, double &rinner, double void MainService::cm_round_corners () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1360,12 +1409,12 @@ MainService::cm_round_corners () if (! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1379,7 +1428,7 @@ MainService::cm_round_corners () } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Selection does not contain polygons"))); } // prepare: merge to remove cutlines and smooth to remove effects of cutlines @@ -1402,9 +1451,12 @@ MainService::cm_round_corners () rinner *= dbu; router *= dbu; +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! round_corners_dialog ()->exec_dialog (cv->layout (), m_router, m_rinner, m_npoints, m_undo_before_apply, router, rinner, n, has_extracted)) { return; } +#endif if (! m_undo_before_apply || ! has_extracted) { out.swap (in); @@ -1419,7 +1471,7 @@ MainService::cm_round_corners () ep.merge (out, primary, 0 /*min_wc*/, true /*resolve holes*/, true /*min coherence*/); view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Corner rounding operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Corner rounding operation on selection"))); // Delete the current selection for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1465,6 +1517,10 @@ MainService::cm_round_corners () void MainService::cm_size () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1482,12 +1538,12 @@ MainService::cm_size () if (! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1501,13 +1557,17 @@ MainService::cm_size () } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Selection does not contain polygons"))); } + std::string sl ("0.0"); + +#if defined(HAVE_QT) + // TODO: keep the value persistent so we can set it externally in the Qt-less case bool ok = false; - QString s = QInputDialog::getText (view (), - QObject::tr ("Sizing"), - QObject::tr ("Sizing (in micron, positive or negative). Two values (dx, dy) for anisotropic sizing."), + QString s = QInputDialog::getText (view ()->widget (), + tr ("Sizing"), + tr ("Sizing (in micron, positive or negative). Two values (dx, dy) for anisotropic sizing."), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1515,8 +1575,10 @@ MainService::cm_size () return; } + sl = tl::to_string (s); +#endif + double dx = 0.0, dy = 0.0; - std::string sl (tl::to_string (s)); tl::Extractor ex (sl.c_str ()); ex.read (dx); if (ex.test (",")) { @@ -1535,7 +1597,7 @@ MainService::cm_size () ep.size (primary, idx, idy, out, 2 /*mode, TODO: make variable*/, true /*resolve holes*/, true /*min coherence*/); view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Sizing operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Sizing operation on selection"))); // Delete the current selection for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1598,12 +1660,12 @@ MainService::boolean_op (int mode) if (s->seq () == 0 && ! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Primary selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Primary selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1617,7 +1679,7 @@ MainService::boolean_op (int mode) } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Primary selection does not contain polygons"))); } std::vector secondary; @@ -1655,7 +1717,7 @@ MainService::boolean_op (int mode) } view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Boolean operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Boolean operation on selection"))); // Delete the current selection // NOTE: we delete only those shapes from the primary layer and keep shapes from other layers. @@ -1750,7 +1812,7 @@ db::DVector compute_alignment_vector (const db::DBox &prim_box, const db::DBox & } static db::DBox -inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const db::InstElement &inst_element, bool visible_only) +inst_bbox (const db::CplxTrans &tr, lay::LayoutViewBase *view, int cv_index, const db::InstElement &inst_element, bool visible_only) { db::DBox box; @@ -1774,14 +1836,21 @@ inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const d void MainService::cm_align () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); std::vector edt_services = view ()->get_plugins (); - if (! align_options_dialog ()->exec_dialog (view (), m_align_hmode, m_align_vmode, m_align_visible_layers)) { +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally + if (! align_options_dialog ()->exec_dialog (m_align_hmode, m_align_vmode, m_align_visible_layers)) { return; } +#endif db::DBox prim_box; bool has_secondary = false; @@ -1811,7 +1880,7 @@ MainService::cm_align () if (! prim_box.empty ()) { view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Alignment"))); + manager ()->transaction (tl::to_string (tr ("Alignment"))); // do the alignment for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1860,16 +1929,23 @@ MainService::cm_align () void MainService::cm_distribute () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); std::vector edt_services = view ()->get_plugins (); - if (! distribute_options_dialog ()->exec_dialog (view (), m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, - m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, - m_distribute_visible_layers)) { +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally + if (! distribute_options_dialog ()->exec_dialog (m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, + m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, + m_distribute_visible_layers)) { return; } +#endif if (! m_hdistribute && ! m_vdistribute) { return; @@ -1945,7 +2021,7 @@ MainService::cm_distribute () { view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Distribution"))); + manager ()->transaction (tl::to_string (tr ("Distribution"))); // do the distribution for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1968,6 +2044,10 @@ MainService::cm_distribute () void MainService::cm_make_array () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + size_t n = 0; check_no_guiding_shapes (); @@ -1980,97 +2060,104 @@ MainService::cm_make_array () } if (n == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to make arrays of"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to make arrays of"))); } - if (make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) { +#if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally + if (! make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) { + return; + } +#endif - view ()->cancel_edits (); + view ()->cancel_edits (); - // undo support for small arrays only - bool has_undo = (m_array_na * m_array_nb < 1000); + // undo support for small arrays only + bool has_undo = (m_array_na * m_array_nb < 1000); - // No undo support currently - the undo buffering is pretty inefficient right now. - if (! has_undo) { - manager ()->clear (); - } else { - manager ()->transaction (tl::to_string (QObject::tr ("Make array"))); - } + // No undo support currently - the undo buffering is pretty inefficient right now. + if (! has_undo) { + manager ()->clear (); + } else { + manager ()->transaction (tl::to_string (tr ("Make array"))); + } - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Make array")), (size_t (m_array_na) * size_t (m_array_nb) - 1) * n, 1000); + tl::RelativeProgress progress (tl::to_string (tr ("Make array")), (size_t (m_array_na) * size_t (m_array_nb) - 1) * n, 1000); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { + for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { + + const lay::CellView &cv = view ()->cellview (s->cv_index ()); + if (! cv.is_valid ()) { + continue; + } + + db::Cell &target_cell = cv->layout ().cell (s->cell_index ()); + + if (s->is_cell_inst ()) { + + for (unsigned int ia = 0; ia < m_array_na; ++ia) { + for (unsigned int ib = 0; ib < m_array_nb; ++ib) { + + // don't create a copy + if (ia == 0 && ib == 0) { + continue; + } + + db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); + db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); + + db::Instance new_inst = target_cell.insert (s->back ().inst_ptr); + target_cell.transform (new_inst, itrans); + + ++progress; + + } - const lay::CellView &cv = view ()->cellview (s->cv_index ()); - if (! cv.is_valid ()) { - continue; } - db::Cell &target_cell = cv->layout ().cell (s->cell_index ()); + } else { - if (s->is_cell_inst ()) { + db::Shapes &target_shapes = target_cell.shapes (s->layer ()); - for (unsigned int ia = 0; ia < m_array_na; ++ia) { - for (unsigned int ib = 0; ib < m_array_nb; ++ib) { - - // don't create a copy - if (ia == 0 && ib == 0) { - continue; - } - - db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); - db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); - - db::Instance new_inst = target_cell.insert (s->back ().inst_ptr); - target_cell.transform (new_inst, itrans); - - ++progress; + for (unsigned int ia = 0; ia < m_array_na; ++ia) { + for (unsigned int ib = 0; ib < m_array_nb; ++ib) { + // don't create a copy + if (ia == 0 && ib == 0) { + continue; } + db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); + db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); + + db::Shape new_shape = target_shapes.insert (s->shape ()); + target_shapes.transform (new_shape, itrans); + + ++progress; + } - - } else { - - db::Shapes &target_shapes = target_cell.shapes (s->layer ()); - - for (unsigned int ia = 0; ia < m_array_na; ++ia) { - for (unsigned int ib = 0; ib < m_array_nb; ++ib) { - - // don't create a copy - if (ia == 0 && ib == 0) { - continue; - } - - db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); - db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); - - db::Shape new_shape = target_shapes.insert (s->shape ()); - target_shapes.transform (new_shape, itrans); - - ++progress; - - } - } - } } } - if (has_undo) { - manager ()->commit (); - } + } + if (has_undo) { + manager ()->commit (); } } void MainService::cm_tap () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + if (! view ()->view_object_widget ()->mouse_in_window ()) { return; } @@ -2107,12 +2194,15 @@ MainService::cm_tap () // List the layers under the cursor as pop up a menu - std::unique_ptr menu (new QMenu (view ())); +#if defined(HAVE_QT) + // TODO: what to do here in Qt-less case? Store results in configuration so they can be retrieved externally? + std::unique_ptr menu (new QMenu (view ()->widget ())); menu->show (); int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize); - QPoint mp = view ()->view_object_widget ()->mapToGlobal (view ()->view_object_widget ()->mouse_position ()); + db::DPoint mp_local = view ()->view_object_widget ()->mouse_position (); + QPoint mp = view ()->view_object_widget ()->mapToGlobal (QPoint (mp_local.x (), mp_local.y ())); for (std::vector::const_iterator l = tapped_layers.begin (); l != tapped_layers.end (); ++l) { QAction *a = menu->addAction (lay::LayerTreeModel::icon_for_layer (*l, view (), icon_size, icon_size, 0, true), tl::to_qstring ((*l)->display_string (view (), true, true /*with source*/))); @@ -2132,6 +2222,7 @@ MainService::cm_tap () } } +#endif } void @@ -2145,7 +2236,7 @@ MainService::cm_change_layer () // get (common) cellview index of the selected shapes for (SelectionIterator s (view ()); ! s.at_end (); ++s) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selections originate from different layouts - cannot switch layer in this case."))); + throw tl::Exception (tl::to_string (tr ("Selections originate from different layouts - cannot switch layer in this case."))); } cv_index = int (s->cv_index ()); } @@ -2157,24 +2248,24 @@ MainService::cm_change_layer () lay::LayerPropertiesConstIterator cl = view ()->current_layer (); if (cl.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a layer first")).c_str ()); } if (cv_index != cl->cellview_index ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Shapes cannot be moved to a different layout")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Shapes cannot be moved to a different layout")).c_str ()); } const lay::CellView &cv = view ()->cellview (cv_index); int layer = cl->layer_index (); if (! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a cell first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a cell first")).c_str ()); } if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { if (cl->has_children ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a valid drawing layer first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a valid drawing layer first")).c_str ()); } else { // create this layer now @@ -2203,7 +2294,7 @@ MainService::cm_change_layer () view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Change layer"))); + manager ()->transaction (tl::to_string (tr ("Change layer"))); db::Layout &layout = view ()->cellview (cv_index)->layout (); @@ -2264,7 +2355,7 @@ MainService::cm_change_layer () manager ()->commit (); } else { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to switch layers for"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to switch layers for"))); } } @@ -2277,7 +2368,7 @@ MainService::check_no_guiding_shapes () for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { if (! s->is_cell_inst ()) { if (s->layer () == view ()->cellview (s->cv_index ())->layout ().guiding_shape_layer ()) { - throw tl::Exception (tl::to_string (QObject::tr ("This function cannot be applied to PCell guiding shapes"))); + throw tl::Exception (tl::to_string (tr ("This function cannot be applied to PCell guiding shapes"))); } } } @@ -2294,7 +2385,7 @@ class NewObjectsSelection : public db::ClipboardDataInsertReceiver { public: - NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutView *view) + NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutViewBase *view) : m_cv_index (cv_index), m_topcell (topcell) { mp_polygon_service = view->get_plugin (); @@ -2374,7 +2465,7 @@ MainService::paste () if (value) { if (! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No cell selected to paste something into"))); + throw tl::Exception (tl::to_string (tr ("No cell selected to paste something into"))); } std::vector nl = value->get ().insert (cv->layout (), cv.context_trans ().inverted (), &cv->layout ().cell (cv.cell_index ()), 0 /*new_tops*/, &insert_notification); diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 60c8c4a8f..e6b26f98b 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -64,7 +64,7 @@ public: /** * @brief The constructor */ - MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -74,7 +74,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -196,7 +196,7 @@ public: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_needs_update; @@ -221,21 +221,25 @@ private: double m_router, m_rinner; unsigned int m_npoints; bool m_undo_before_apply; +#if defined(HAVE_QT) edt::RoundCornerOptionsDialog *mp_round_corners_dialog; edt::AlignOptionsDialog *mp_align_options_dialog; edt::DistributeOptionsDialog *mp_distribute_options_dialog; lay::FlattenInstOptionsDialog *mp_flatten_inst_options_dialog; edt::MakeCellOptionsDialog *mp_make_cell_options_dialog; edt::MakeArrayOptionsDialog *mp_make_array_options_dialog; +#endif void boolean_op (int mode); void check_no_guiding_shapes (); +#if defined(HAVE_QT) edt::RoundCornerOptionsDialog *round_corners_dialog (); edt::AlignOptionsDialog *align_options_dialog (); edt::DistributeOptionsDialog *distribute_options_dialog (); lay::FlattenInstOptionsDialog *flatten_inst_options_dialog (); edt::MakeCellOptionsDialog *make_cell_options_dialog (); edt::MakeArrayOptionsDialog *make_array_options_dialog (); +#endif }; } diff --git a/src/edt/edt/edtPCellParametersPage.cc b/src/edt/edt/edtPCellParametersPage.cc index b6381f774..4edab8ab7 100644 --- a/src/edt/edt/edtPCellParametersPage.cc +++ b/src/edt/edt/edtPCellParametersPage.cc @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #include "edtPCellParametersPage.h" #include "edtPropertiesPageUtils.h" #include "layWidgets.h" #include "layQtTools.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlScriptError.h" #include @@ -232,7 +233,7 @@ PCellParametersPage::lazy_evaluation () } void -PCellParametersPage::setup (lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters) +PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters) { mp_pcell_decl.reset (const_cast (pcell_decl)); // no const weak_ptr ... mp_view = view; @@ -732,4 +733,4 @@ PCellParametersPage::set_parameters_internal (const std::vector &pa } - +#endif diff --git a/src/edt/edt/edtPCellParametersPage.h b/src/edt/edt/edtPCellParametersPage.h index f148c7c1c..83eadfea1 100644 --- a/src/edt/edt/edtPCellParametersPage.h +++ b/src/edt/edt/edtPCellParametersPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPCellParametersPage #define HDR_edtPCellParametersPage @@ -34,7 +35,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt @@ -79,7 +80,7 @@ public: * @param pcell_decl The PCell declaration * @param parameters The parameter values to show (if empty, the default values are used) */ - void setup (lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters); + void setup (lay::LayoutViewBase *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters); /** * @brief Gets the pages current state @@ -140,7 +141,7 @@ private: QFrame *mp_error_frame, *mp_update_frame; tl::weak_ptr mp_pcell_decl; std::vector m_widgets; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_cv_index; db::pcell_parameters_type m_parameters; bool m_dense; @@ -157,3 +158,5 @@ private: } #endif + +#endif diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index fe5bf02df..7f89ef2fa 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -21,19 +21,20 @@ */ -#include - #include "dbVector.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySnap.h" #include "layFinder.h" #include "tlProgress.h" #include "edtPartialService.h" #include "edtService.h" #include "edtConfig.h" -#include "edtDialogs.h" #include "edtPlugin.h" -#include "edtEditorOptionsPages.h" + +#if defined(HAVE_QT) +# include "edtDialogs.h" +# include "edtEditorOptionsPages.h" +#endif #include @@ -1010,8 +1011,10 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) - : QObject (), +PartialService::PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : +#if defined(HAVE_QT) + QObject (), +#endif lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -1027,9 +1030,11 @@ PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay m_hover (false), m_hover_wait (false) { +#if defined(HAVE_QT) m_timer.setInterval (100 /*hover time*/); m_timer.setSingleShot (true); connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ())); +#endif } PartialService::~PartialService () @@ -1077,7 +1082,9 @@ void PartialService::hover_reset () { if (m_hover_wait) { +#if defined(HAVE_QT) m_timer.stop (); +#endif m_hover_wait = false; } if (m_hover) { @@ -1086,7 +1093,9 @@ PartialService::hover_reset () } } -void +// TODO: should receive timer calls from regular timer update +#if defined(HAVE_QT) +void PartialService::timeout () { m_hover_wait = false; @@ -1209,6 +1218,7 @@ PartialService::timeout () resize_inst_markers (n_inst_marker, true); } +#endif void PartialService::clear_partial_transient_selection () @@ -1220,7 +1230,7 @@ PartialService::clear_partial_transient_selection () } void -PartialService::set_colors (QColor /*background*/, QColor color) +PartialService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { @@ -1571,7 +1581,9 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo } else if (view ()->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } @@ -1622,8 +1634,7 @@ PartialService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bo try { partial_select (db::DBox (p, p), lay::Editable::Replace); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } @@ -1703,7 +1714,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo // stop dragging widget ()->ungrab_mouse (this); - manager ()->transaction (tl::to_string (QObject::tr ("Partial move"))); + manager ()->transaction (tl::to_string (tr ("Partial move"))); // heuristically, if there is just one edge selected: do not confine to the movement // angle constraint - the edge usually is confined enough @@ -1862,8 +1873,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo selection_to_view (); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } @@ -1901,7 +1911,7 @@ PartialService::mouse_double_click_event (const db::DPoint &p, unsigned int butt partial_objects::iterator r = m_selection.begin (); // we assert above that we have at least one selected element if (! r->first.is_cell_inst ()) { - manager ()->transaction (tl::to_string (QObject::tr ("Insert point"))); + manager ()->transaction (tl::to_string (tr ("Insert point"))); // snap the point db::DPoint new_point_d = snap (p); @@ -2018,8 +2028,7 @@ PartialService::mouse_release_event (const db::DPoint &p, unsigned int buttons, try { partial_select (db::DBox (m_p1, m_p2), mode); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 03d09da96..a0f7b0e78 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -34,8 +34,10 @@ #include "edtUtils.h" #include "edtConfig.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace db { class Manager; @@ -136,12 +138,16 @@ struct EdgeWithIndex /** * @brief The partial selection and manipulation service */ -class PartialService - : public QObject, +class PartialService : +#if defined(HAVE_QT) + public QObject, +#endif public lay::EditorServiceBase, public db::Object { +#if defined(HAVE_QT) Q_OBJECT +#endif public: typedef std::map > partial_objects; @@ -149,7 +155,7 @@ public: /** * @brief The constructor */ - PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -159,7 +165,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -282,15 +288,17 @@ public: /** * @brief Reimplementation of the ViewService interface: set the colors */ - virtual void set_colors (QColor background, QColor text); + virtual void set_colors (lay::Color background, lay::Color text); /** * @brief Cancel any edit operations (in this case, unselect all & cancel any drag operation) */ virtual void edit_cancel (); +#if defined(HAVE_QT) public slots: void timeout (); +#endif protected: lay::angle_constraint_type connect_ac () const; @@ -298,7 +306,7 @@ protected: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_dragging; bool m_keep_selection; @@ -324,7 +332,9 @@ private: std::vector m_inst_markers; std::vector m_transient_inst_markers; +#if defined(HAVE_QT) QTimer m_timer; +#endif bool m_hover; bool m_hover_wait; db::DPoint m_hover_point; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index a4a6e3608..5da6ed90a 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -21,36 +21,49 @@ */ -#include "layTipDialog.h" -#include "layEditorOptionsPages.h" +#if defined(HAVE_QT) +# include "layTipDialog.h" +# include "layEditorOptionsPages.h" +#endif + #include "layDispatcher.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "edtPlugin.h" #include "edtConfig.h" #include "edtService.h" #include "edtServiceImpl.h" #include "edtMainService.h" #include "edtPartialService.h" -#include "edtEditorOptionsPages.h" -#include "edtRecentConfigurationPage.h" +#if defined(HAVE_QT) +# include "edtEditorOptionsPages.h" +# include "edtRecentConfigurationPage.h" +#endif -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace edt { +#if defined(HAVE_QT) edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] = { edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer), }; +#endif +#if defined(HAVE_QT) static -void get_shape_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_shape_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param", &shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])])); } +#else +static void get_shape_editor_options_pages () { } +#endif static void get_text_options (std::vector < std::pair > &options) @@ -61,8 +74,9 @@ void get_text_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_text_valign, "bottom")); } +#if defined(HAVE_QT) static -void get_text_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_text_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor text_cfg_descriptors[] = { @@ -77,6 +91,9 @@ void get_text_editor_options_pages (std::vector &ret, &text_cfg_descriptors[0], &text_cfg_descriptors[sizeof (text_cfg_descriptors) / sizeof (text_cfg_descriptors[0])])); ret.push_back (new edt::EditorOptionsText (view, dispatcher)); } +#else +static void get_text_editor_options_pages () { } +#endif static void get_path_options (std::vector < std::pair > &options) @@ -87,8 +104,9 @@ void get_path_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_path_ext_var_end, "0.0")); } +#if defined(HAVE_QT) static -void get_path_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_path_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor path_cfg_descriptors[] = { @@ -103,6 +121,9 @@ void get_path_editor_options_pages (std::vector &ret, &path_cfg_descriptors[0], &path_cfg_descriptors[sizeof (path_cfg_descriptors) / sizeof (path_cfg_descriptors[0])])); ret.push_back (new EditorOptionsPath (view, dispatcher)); } +#else +static void get_path_editor_options_pages () { } +#endif static void get_inst_options (std::vector < std::pair > &options) @@ -123,8 +144,9 @@ void get_inst_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_show_shapes_of_instances, "true")); } +#if defined(HAVE_QT) static -void get_inst_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_inst_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor inst_cfg_descriptors[] = { @@ -148,19 +170,32 @@ void get_inst_editor_options_pages (std::vector &ret, ret.push_back (new EditorOptionsInstPCellParam (view, dispatcher)); ret.push_back (new EditorOptionsInst (view, dispatcher)); } +#else +static void get_inst_editor_options_pages () { } +#endif template class PluginDeclaration : public PluginDeclarationBase { public: +#if defined(HAVE_QT) PluginDeclaration (const std::string &title, const std::string &mouse_mode, void (*option_get_f) (std::vector < std::pair > &) = 0, - void (*pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *) = 0) + void (*pages_f) (std::vector &, lay::LayoutViewBase *, lay::Dispatcher *) = 0) : m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f) { // .. nothing yet .. } +#else + PluginDeclaration (const std::string &title, const std::string &mouse_mode, + void (*option_get_f) (std::vector < std::pair > &) = 0, + void (*pages_f) () = 0) + : m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f) + { + // .. nothing yet .. + } +#endif virtual void get_options (std::vector < std::pair > &options) const { @@ -169,17 +204,20 @@ public: } } +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget * /*parent*/, std::string & /*title*/) const { return 0; } +#endif virtual void get_menu_entries (std::vector & /*menu_entries*/) const { // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *root) const +#if defined(HAVE_QT) + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const { if (mp_pages_f != 0) { size_t nstart = pages.size (); @@ -189,8 +227,9 @@ public: } } } +#endif - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { Svc *service = new Svc (manager, view); service->set_plugin_declaration (this); @@ -214,31 +253,35 @@ private: std::string m_mouse_mode; void (*mp_option_get_f) (std::vector < std::pair > &options); - void (*mp_pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *); +#if defined(HAVE_QT) + void (*mp_pages_f) (std::vector &, lay::LayoutViewBase *, lay::Dispatcher *); +#else + void (*mp_pages_f) (); +#endif }; static tl::RegisteredClass config_decl1 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (QObject::tr ("Polygon")) + "<:polygon.png>" + tl::to_string (QObject::tr ("{Create a polygon}")), 0, &get_shape_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (tr ("Polygon")) + "<:polygon.png>" + tl::to_string (tr ("{Create a polygon}")), 0, &get_shape_editor_options_pages), 4010, "edt::Service(Polygons)" ); static tl::RegisteredClass config_decl2 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Boxes")), "box:edit_mode\t" + tl::to_string (QObject::tr ("Box")) + "\t<:box.png>" + tl::to_string (QObject::tr ("{Create a box}")), 0, &get_shape_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Boxes")), "box:edit_mode\t" + tl::to_string (tr ("Box")) + "\t<:box.png>" + tl::to_string (tr ("{Create a box}")), 0, &get_shape_editor_options_pages), 4011, "edt::Service(Boxes)" ); static tl::RegisteredClass config_decl3 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Texts")), "text:edit_mode\t" + tl::to_string (QObject::tr ("Text")) + "\t<:text.png>" + tl::to_string (QObject::tr ("{Create a text object}")), &get_text_options, &get_text_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Texts")), "text:edit_mode\t" + tl::to_string (tr ("Text")) + "\t<:text.png>" + tl::to_string (tr ("{Create a text object}")), &get_text_options, &get_text_editor_options_pages), 4012, "edt::Service(Texts)" ); static tl::RegisteredClass config_decl4 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Paths")), "path:edit_mode\t" + tl::to_string (QObject::tr ("Path")) + "\t<:path.png>" + tl::to_string (QObject::tr ("{Create a path}")), &get_path_options, &get_path_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Paths")), "path:edit_mode\t" + tl::to_string (tr ("Path")) + "\t<:path.png>" + tl::to_string (tr ("{Create a path}")), &get_path_options, &get_path_editor_options_pages), 4013, "edt::Service(Paths)" ); static tl::RegisteredClass config_decl5 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Instances")), "instance:edit_mode\t" + tl::to_string (QObject::tr ("Instance")) + "\t<:instance.png>" + tl::to_string (QObject::tr ("{Create a cell instance}")), &get_inst_options, &get_inst_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Instances")), "instance:edit_mode\t" + tl::to_string (tr ("Instance")) + "\t<:instance.png>" + tl::to_string (tr ("{Create a cell instance}")), &get_inst_options, &get_inst_editor_options_pages), 4020, "edt::Service(CellInstances)" ); @@ -264,41 +307,43 @@ public: options.push_back (std::pair (cfg_edit_combine_mode, "add")); } +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget * /*parent*/, std::string & /*title*/) const { return 0; } +#endif virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("edt::hier_group", "zoom_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)")); - menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)")); + menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (tr ("Descend")) + "(Ctrl+D)")); + menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (tr ("Ascend")) + "(Ctrl+A)")); - menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Array")))); menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer")))); - menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)")); - menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align")))); - menu_entries.push_back (lay::menu_item ("edt::sel_distribute", "distribute:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Distribute")))); - menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners")))); - menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes")))); - menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes")))); - menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First")))); - menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First")))); - menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others")))); + menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Change Layer")))); + menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap", "edit_menu.selection_menu.end", tl::to_string (tr ("Tap")) + "(T)")); + menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Align")))); + menu_entries.push_back (lay::menu_item ("edt::sel_distribute", "distribute:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Distribute")))); + menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Round Corners")))); + menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Size Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Merge Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Intersection - Others With First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Subtraction - Others From First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Separate - First into Inside/Outside Others")))); menu_entries.push_back (lay::separator ("hier_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances")))); - menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays")))); - menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy")))); - menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell")))); - menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants")))); - menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell")))); - menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Flatten Instances")))); + menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Resolve Arrays")))); + menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Move Up In Hierarchy")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Cell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Cell Variants")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Convert To PCell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Convert To Static Cell")))); - menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}")))); + menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (tr ("Combine{Select background combination mode}")))); } bool configure (const std::string &name, const std::string &value) @@ -312,7 +357,7 @@ public: return false; } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::MainService (manager, view, root); } @@ -327,12 +372,14 @@ public: return false; } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *dispatcher) const +#if defined(HAVE_QT) + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const { // NOTE: we do not set plugin_declaration which makes the page unspecific EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher); pages.push_back (generic_opt); } +#endif virtual void initialize (lay::Dispatcher *root) { @@ -343,18 +390,21 @@ public: mp_root = root; +#if defined(HAVE_QT) // add entries to the combine mode dialog - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", new lay::ConfigureAction (tl::to_string (QObject::tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", new lay::ConfigureAction (tl::to_string (QObject::tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", new lay::ConfigureAction (tl::to_string (QObject::tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", new lay::ConfigureAction (tl::to_string (tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", new lay::ConfigureAction (tl::to_string (tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", new lay::ConfigureAction (tl::to_string (tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff))); update_menu (CM_Add); +#endif } void update_menu (combine_mode_type cm) { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -363,21 +413,22 @@ public: lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); if (cm == CM_Add) { - combine_menu->set_title (tl::to_string (QObject::tr ("Add"))); + combine_menu->set_title (tl::to_string (tr ("Add"))); combine_menu->set_icon (":/cm_add.png"); } else if (cm == CM_Merge) { - combine_menu->set_title (tl::to_string (QObject::tr ("Merge"))); + combine_menu->set_title (tl::to_string (tr ("Merge"))); combine_menu->set_icon (":/cm_merge.png"); } else if (cm == CM_Erase) { - combine_menu->set_title (tl::to_string (QObject::tr ("Erase"))); + combine_menu->set_title (tl::to_string (tr ("Erase"))); combine_menu->set_icon (":/cm_erase.png"); } else if (cm == CM_Mask) { - combine_menu->set_title (tl::to_string (QObject::tr ("Mask"))); + combine_menu->set_title (tl::to_string (tr ("Mask"))); combine_menu->set_icon (":/cm_mask.png"); } else if (cm == CM_Diff) { - combine_menu->set_title (tl::to_string (QObject::tr ("Diff"))); + combine_menu->set_title (tl::to_string (tr ("Diff"))); combine_menu->set_icon (":/cm_diff.png"); } +#endif } void initialized (lay::Dispatcher *root) @@ -387,22 +438,27 @@ public: return; } - lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); +#if defined(HAVE_QT) - // Do some more initialization here. + // generate a warning if the combine mode isn't "Add" combine_mode_type cm = CM_Add; root->config_get (cfg_edit_combine_mode, cm, CMConverter ()); + + lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); + if (cm != CM_Add && combine_menu->is_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("The background combination mode of the shape editor is set to some other mode than 'Add'.\n" - "This can be confusing, because a shape may not be drawn as expected.\n\nTo switch back to normal mode, choose 'Add' for the background combination mode in the toolbar.")), + tl::to_string (tr ("The background combination mode of the shape editor is set to some other mode than 'Add'.\n" + "This can be confusing, because a shape may not be drawn as expected.\n\nTo switch back to normal mode, choose 'Add' for the background combination mode in the toolbar.")), "has-non-add-edit-combine-mode"); if (td.exec_dialog ()) { // Don't bother the user with more dialogs. return; } } + +#endif } private: @@ -410,12 +466,13 @@ private: std::string m_title; }; -static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); +static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (tr ("Instances and shapes"))), 4000, "edt::MainService"); void -commit_recent (lay::LayoutView *view) +commit_recent (lay::LayoutViewBase *view) { - lay::EditorOptionsPages *eo_pages = view->editor_options_pages ();; +#if defined(HAVE_QT) + lay::EditorOptionsPages *eo_pages = view->editor_options_pages (); if (!eo_pages) { return; } @@ -425,6 +482,7 @@ commit_recent (lay::LayoutView *view) (*op)->commit_recent (view); } } +#endif } class PartialPluginDeclaration @@ -442,12 +500,12 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*root*/) const { // .. no specific ones .. } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::PartialService (manager, view, root); } @@ -470,7 +528,7 @@ private: }; static tl::RegisteredClass config_decl30 ( - new edt::PartialPluginDeclaration (tl::to_string (QObject::tr ("Partial shapes")), "partial:edit_mode\t" + tl::to_string (QObject::tr ("Partial{Edit points and edges of shapes}")) + "<:partial.png>"), + new edt::PartialPluginDeclaration (tl::to_string (tr ("Partial shapes")), "partial:edit_mode\t" + tl::to_string (tr ("Partial{Edit points and edges of shapes}")) + "<:partial.png>"), 4030, "edt::PartialService" ); diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index f5a789a3e..4b036e553 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -32,6 +32,7 @@ namespace lay { class Dispatcher; class EditorOptionsPage; + class LayoutViewBase; } namespace edt @@ -48,7 +49,7 @@ namespace edt /** * @brief Commits the current configuration for the recently used configuration list */ - void commit_recent (lay::LayoutView *view); + void commit_recent (lay::LayoutViewBase *view); } #endif diff --git a/src/edt/edt/edtPropertiesPageUtils.cc b/src/edt/edt/edtPropertiesPageUtils.cc index f6df8fc63..abd3c4afe 100644 --- a/src/edt/edt/edtPropertiesPageUtils.cc +++ b/src/edt/edt/edtPropertiesPageUtils.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "edtPropertiesPageUtils.h" @@ -870,3 +871,4 @@ coords_to_string (const db::DPoint &dp, double dbu, bool du, const char *sep) } +#endif diff --git a/src/edt/edt/edtPropertiesPageUtils.h b/src/edt/edt/edtPropertiesPageUtils.h index e20e76db7..b66eba7b6 100644 --- a/src/edt/edt/edtPropertiesPageUtils.h +++ b/src/edt/edt/edtPropertiesPageUtils.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPropertiesPageUtils #define HDR_edtPropertiesPageUtils @@ -522,3 +523,4 @@ db::Coord coord_from_string (const char *txt, double dbu, bool du, const db::VCp #endif +#endif diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 5943d609a..7f01f3158 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "edtPropertiesPages.h" #include "edtPropertiesPageUtils.h" @@ -27,7 +28,7 @@ #include "edtPropertiesPageUtils.h" #include "layDialogs.h" #include "layObjectInstPath.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" #include "tlExceptions.h" #include "tlString.h" @@ -1183,3 +1184,4 @@ EditablePathPropertiesPage::type_selected (int t) } +#endif diff --git a/src/edt/edt/edtPropertiesPages.h b/src/edt/edt/edtPropertiesPages.h index 39e0b6fb5..0172cd1c5 100644 --- a/src/edt/edt/edtPropertiesPages.h +++ b/src/edt/edt/edtPropertiesPages.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPropertiesPages @@ -207,3 +208,5 @@ private: } #endif + +#endif diff --git a/src/edt/edt/edtRecentConfigurationPage.cc b/src/edt/edt/edtRecentConfigurationPage.cc index 3781aeffc..ee68dbd75 100644 --- a/src/edt/edt/edtRecentConfigurationPage.cc +++ b/src/edt/edt/edtRecentConfigurationPage.cc @@ -20,10 +20,12 @@ */ +#if defined(HAVE_QT) + #include "edtRecentConfigurationPage.h" #include "edtUtils.h" #include "layDispatcher.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layLayerTreeModel.h" #include "dbLibraryManager.h" #include "dbLibrary.h" @@ -32,6 +34,7 @@ #include #include #include +#include namespace edt { @@ -131,7 +134,7 @@ RecentConfigurationPage::set_stored_values (const std::list[@]) db::LayerProperties lp; @@ -179,7 +182,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std case RecentConfigurationPage::Layer: { - int icon_size = view ()->style ()->pixelMetric (QStyle::PM_ButtonIconSize); + int icon_size = view ()->widget ()->style ()->pixelMetric (QStyle::PM_ButtonIconSize); lay::LayerPropertiesConstIterator l; try { l = lp_iter_from_string (view (), values [column]); @@ -344,6 +347,40 @@ RecentConfigurationPage::update_list (const std::list > mp_tree_widget->header ()->resizeSections (QHeaderView::ResizeToContents); } +static bool +set_or_request_current_layer (lay::LayoutViewBase *view, unsigned int cv_index, const db::LayerProperties &lp) +{ + bool ok = view->set_current_layer (cv_index, lp); + if (ok) { + return true; + } + + if (! view->control_panel ()) { + return false; + } + + const lay::CellView &cv = view->cellview (cv_index); + if (! cv.is_valid ()) { + return false; + } + + if (QMessageBox::question (view->widget (), tr ("Create Layer"), tr ("Layer %1 does not exist yet. Create it now?").arg (tl::to_qstring (lp.to_string ()))) == QMessageBox::Yes) { + + lay::LayerPropertiesNode lpn; + lpn.set_source (lay::ParsedLayerSource (lp, cv_index)); + view->init_layer_properties (lpn); + + view->transaction (tl::to_string (QObject::tr ("Create new layer"))); + view->set_current_layer (lay::LayerPropertiesConstIterator (& view->insert_layer (view->end_layers (), lpn))); + view->commit (); + + return true; + + } + + return false; +} + void RecentConfigurationPage::item_clicked (QTreeWidgetItem *item) { @@ -363,7 +400,7 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item) ex.read (cv_index); } - view ()->set_or_request_current_layer (cv_index, lp); + set_or_request_current_layer (view (), cv_index, lp); } else { dispatcher ()->config_set (c->cfg_name, v); @@ -428,3 +465,5 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root) } } + +#endif diff --git a/src/edt/edt/edtRecentConfigurationPage.h b/src/edt/edt/edtRecentConfigurationPage.h index e43352ec3..00997fd0f 100644 --- a/src/edt/edt/edtRecentConfigurationPage.h +++ b/src/edt/edt/edtRecentConfigurationPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtRecentConfigurationPage #define HDR_edtRecentConfigurationPage @@ -32,7 +33,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt @@ -77,7 +78,7 @@ public: }; template - RecentConfigurationPage (lay::LayoutView *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg) + RecentConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg) : EditorOptionsPage (view, dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg) { init (); @@ -112,3 +113,4 @@ private: #endif +#endif diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index 40dbefc39..7e3320bee 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -26,10 +26,12 @@ #include "dbLibrary.h" #include "edtPlugin.h" #include "edtService.h" -#include "edtEditorOptionsPages.h" -#include "edtDialogs.h" +#if defined(HAVE_QT) +# include "edtEditorOptionsPages.h" +# include "edtDialogs.h" +#endif #include "layFinder.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySnap.h" #include "tlProgress.h" #include "tlTimer.h" @@ -60,7 +62,7 @@ ac_from_buttons (unsigned int buttons) // ------------------------------------------------------------- -Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type flags) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type flags) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -80,7 +82,7 @@ Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator // .. nothing yet .. } -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -312,7 +314,8 @@ Service::copy () void Service::copy_selected () { - edt::CopyModeDialog mode_dialog (view ()); +#if defined(HAVE_QT) + edt::CopyModeDialog mode_dialog (view ()->widget ()); bool need_to_ask_for_copy_mode = false; unsigned int inst_mode = 0; @@ -340,33 +343,49 @@ Service::copy_selected () dispatcher ()->config_end (); } - // create one ClipboardData object per cv_index because, this one assumes that there is - // only one source layout object. - std::set cv_indices; + copy_selected (inst_mode); + + } +#else + + unsigned int inst_mode = 0; + if (m_hier_copy_mode >= 0) { + inst_mode = int (m_hier_copy_mode); + } + + copy_selected (inst_mode); + +#endif +} + +void +Service::copy_selected (unsigned int inst_mode) +{ + // create one ClipboardData object per cv_index because, this one assumes that there is + // only one source layout object. + std::set cv_indices; + for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { + cv_indices.insert (r->cv_index ()); + } + + for (std::set ::const_iterator cvi = cv_indices.begin (); cvi != cv_indices.end (); ++cvi) { + + db::ClipboardValue *cd = new db::ClipboardValue (); + + // add the selected objects to the clipboard data objects. + const lay::CellView &cv = view ()->cellview (*cvi); for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { - cv_indices.insert (r->cv_index ()); - } - - for (std::set ::const_iterator cvi = cv_indices.begin (); cvi != cv_indices.end (); ++cvi) { - - db::ClipboardValue *cd = new db::ClipboardValue (); - - // add the selected objects to the clipboard data objects. - const lay::CellView &cv = view ()->cellview (*cvi); - for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { - if (r->cv_index () == *cvi) { - if (! r->is_cell_inst ()) { - cd->get ().add (cv->layout (), r->layer (), r->shape (), cv.context_trans () * r->trans ()); - } else { - cd->get ().add (cv->layout (), r->back ().inst_ptr, inst_mode, cv.context_trans () * r->trans ()); - } + if (r->cv_index () == *cvi) { + if (! r->is_cell_inst ()) { + cd->get ().add (cv->layout (), r->layer (), r->shape (), cv.context_trans () * r->trans ()); + } else { + cd->get ().add (cv->layout (), r->back ().inst_ptr, inst_mode, cv.context_trans () * r->trans ()); } } - - db::Clipboard::instance () += cd; - } + db::Clipboard::instance () += cd; + } } @@ -799,7 +818,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio bool Service::key_event (unsigned int key, unsigned int buttons) { - if (view ()->is_editable () && m_editing && buttons == 0 && key == Qt::Key_Backspace) { + if (view ()->is_editable () && m_editing && buttons == 0 && key == lay::KeyBackspace) { do_delete (); return true; } else { @@ -1141,7 +1160,7 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } db::Instance inst = r->back ().inst_ptr; @@ -1149,12 +1168,12 @@ Service::display_status (bool transient) db::Vector a, b; unsigned long amax = 0, bmax = 0; if (! inst.is_regular_array (a, b, amax, bmax)) { - msg += tl::sprintf (tl::to_string (QObject::tr ("instance(\"%s\" %s)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string ()); + msg += tl::sprintf (tl::to_string (tr ("instance(\"%s\" %s)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string ()); } else { - msg += tl::sprintf (tl::to_string (QObject::tr ("instance(\"%s\" %s %ldx%ld)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string (), amax, bmax); + msg += tl::sprintf (tl::to_string (tr ("instance(\"%s\" %s %ldx%ld)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string (), amax, bmax); } - msg += tl::to_string (QObject::tr (" in ")); + msg += tl::to_string (tr (" in ")); msg += path_to_string (layout, *r); view ()->message (msg, transient ? 10 : 10000); @@ -1163,31 +1182,31 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } if (r->shape ().is_box ()) { db::Box b (r->shape ().bbox ()); - msg += tl::sprintf (tl::to_string (QObject::tr ("box(%d,%d %d,%d)")), int (b.left ()), int (b.bottom ()), int (b.right ()), int (b.top ())); + msg += tl::sprintf (tl::to_string (tr ("box(%d,%d %d,%d)")), int (b.left ()), int (b.bottom ()), int (b.right ()), int (b.top ())); } else if (r->shape ().is_text ()) { - msg += tl::sprintf (tl::to_string (QObject::tr ("text(\"%s\" %s)")), tl::escape_string (r->shape ().text_string ()), r->shape ().text_trans ().to_string ()); + msg += tl::sprintf (tl::to_string (tr ("text(\"%s\" %s)")), tl::escape_string (r->shape ().text_string ()), r->shape ().text_trans ().to_string ()); } else if (r->shape ().is_polygon ()) { size_t npoints = 0; for (db::Shape::polygon_edge_iterator e = r->shape ().begin_edge (); ! e.at_end (); ++e) { ++npoints; } - msg += tl::sprintf (tl::to_string (QObject::tr ("polygon(#points=%lu)")), npoints); + msg += tl::sprintf (tl::to_string (tr ("polygon(#points=%lu)")), npoints); } else if (r->shape ().is_path ()) { size_t npoints = 0; for (db::Shape::point_iterator p = r->shape ().begin_point (); p != r->shape ().end_point (); ++p) { ++npoints; } - msg += tl::sprintf (tl::to_string (QObject::tr ("path(w=%d #points=%lu)")), int (r->shape ().path_width ()), npoints); + msg += tl::sprintf (tl::to_string (tr ("path(w=%d #points=%lu)")), int (r->shape ().path_width ()), npoints); } if (! msg.empty ()) { - msg += tl::to_string (QObject::tr (" on ")); + msg += tl::to_string (tr (" on ")); std::string ln = layout.get_properties (r->layer ()).to_string (); for (lay::LayerPropertiesConstIterator lp = view ()->begin_layers (); ! lp.at_end (); ++lp) { @@ -1198,7 +1217,7 @@ Service::display_status (bool transient) } msg += ln; - msg += tl::to_string (QObject::tr (" in ")); + msg += tl::to_string (tr (" in ")); msg += path_to_string (layout, *r); view ()->message (msg, transient ? 10 : 10000); diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index f084f7a01..cd05cd739 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -32,6 +32,7 @@ #include "layMarker.h" #include "laySnap.h" #include "layObjectInstPath.h" +#include "layColor.h" #include "dbLayout.h" #include "dbShape.h" #include "edtUtils.h" @@ -41,7 +42,6 @@ #include #include -#include namespace lay { class LayerPropertiesConstIterator; @@ -83,12 +83,12 @@ public: /** * @brief The constructor for an service selecting shapes */ - Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); /** * @brief The constructor for an service selecting instances */ - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief The destructor @@ -220,7 +220,7 @@ public: /** * @brief Color accessor */ - QColor color () const + lay::Color color () const { return m_color; } @@ -244,7 +244,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -560,7 +560,7 @@ protected: private: // The layout view that the editor service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The marker objects representing the selection std::vector m_markers; @@ -593,7 +593,7 @@ private: db::ShapeIterator::flags_type m_flags; // The look of the markers - QColor m_color; + lay::Color m_color; // The current transformation on movement db::DTrans m_move_trans; @@ -645,6 +645,9 @@ private: * @brief Display the status bar message for the given selection */ void display_status (bool transient); + +private: + void copy_selected (unsigned int inst_mode); }; } diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index b22360339..60cd2ee29 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -23,8 +23,10 @@ #include "edtMainService.h" #include "edtServiceImpl.h" -#include "edtPropertiesPages.h" -#include "edtInstPropertiesPage.h" +#if defined(HAVE_QT) +# include "edtPropertiesPages.h" +# include "edtInstPropertiesPage.h" +#endif #include "edtService.h" #include "edtPlugin.h" #include "dbEdge.h" @@ -35,11 +37,16 @@ #include "dbEdgeProcessor.h" #include "layMarker.h" #include "layLayerProperties.h" -#include "layLayoutView.h" -#include "layTipDialog.h" +#include "layLayoutViewBase.h" -#include -#include +#if defined(HAVE_QT) +# include "layTipDialog.h" +# include "layDragDropData.h" +#endif + +#if defined(HAVE_QT) +# include +#endif namespace edt { @@ -47,7 +54,7 @@ namespace edt // ----------------------------------------------------------------------------- // ShapeEditService implementation -ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types) +ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types) : edt::Service (manager, view, shape_types), m_layer (0), m_cv_index (0), mp_cell (0), mp_layout (0), m_combine_mode (CM_Add) { @@ -71,7 +78,7 @@ ShapeEditService::get_edit_layer () lay::LayerPropertiesConstIterator cl = view ()->current_layer (); if (cl.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first"))); + throw tl::Exception (tl::to_string (tr ("Please select a layer first"))); } int cv_index = cl->cellview_index (); @@ -79,20 +86,22 @@ ShapeEditService::get_edit_layer () int layer = cl->layer_index (); if (cv_index < 0 || ! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a cell first"))); + throw tl::Exception (tl::to_string (tr ("Please select a cell first"))); } +#if defined(HAVE_QT) if (! cl->visible (true)) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")), + tl::to_string (tr ("You are about to draw on a hidden layer. The result won't be visible.")), "drawing-on-invisible-layer"); td.exec_dialog (); } +#endif if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { if (cl->has_children ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a valid drawing layer first"))); + throw tl::Exception (tl::to_string (tr ("Please select a valid drawing layer first"))); } else { // create this layer now @@ -125,7 +134,7 @@ ShapeEditService::get_edit_layer () mp_cell = &(mp_layout->cell (cv.cell_index ())); if (mp_cell->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot put a shape into a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot put a shape into a PCell or library cell"))); } } @@ -152,12 +161,14 @@ ShapeEditService::update_edit_layer (const lay::LayerPropertiesConstIterator &cl return; } +#if defined(HAVE_QT) if (! cl->visible (true)) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("You are now drawing on a hidden layer. The result won't be visible.")), + tl::to_string (tr ("You are now drawing on a hidden layer. The result won't be visible.")), "drawing-on-invisible-layer"); td.exec_dialog (); } +#endif if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { @@ -255,7 +266,7 @@ ShapeEditService::deliver_shape (const db::Polygon &poly) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create polygon"))); + manager ()->transaction (tl::to_string (tr ("Create polygon"))); cell ().shapes (layer ()).insert (poly); manager ()->commit (); @@ -315,7 +326,7 @@ ShapeEditService::deliver_shape (const db::Polygon &poly) result = input; } - manager ()->transaction (tl::to_string (QObject::tr ("Combine shape with background"))); + manager ()->transaction (tl::to_string (tr ("Combine shape with background"))); // Erase existing shapes for (std::vector::const_iterator s = shapes.begin (); s != shapes.end (); ++s) { @@ -339,7 +350,7 @@ void ShapeEditService::deliver_shape (const db::Path &path) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create path"))); + manager ()->transaction (tl::to_string (tr ("Create path"))); cell ().shapes (layer ()).insert (path); manager ()->commit (); } else { @@ -351,7 +362,7 @@ void ShapeEditService::deliver_shape (const db::Box &box) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create box"))); + manager ()->transaction (tl::to_string (tr ("Create box"))); cell ().shapes (layer ()).insert (box); manager ()->commit (); } else { @@ -362,18 +373,20 @@ ShapeEditService::deliver_shape (const db::Box &box) // ----------------------------------------------------------------------------- // PolygonService implementation -PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view) +PolygonService::PolygonService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Polygons), m_closure_set (false), m_closure () { // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * PolygonService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::PolygonPropertiesPage (this, manager, parent); } +#endif void PolygonService::do_begin_edit (const db::DPoint &p) @@ -468,7 +481,7 @@ PolygonService::get_polygon () const db::Polygon poly; if (m_points.size () < 4) { - throw tl::Exception (tl::to_string (QObject::tr ("A polygon must have at least 3 points"))); + throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 points"))); } std::vector points_dbu; @@ -485,7 +498,7 @@ PolygonService::get_polygon () const poly.assign_hull (points_dbu.begin (), points_dbu.end (), true, true /*remove reflected*/); if (poly.hull ().size () < 3) { - throw tl::Exception (tl::to_string (QObject::tr ("A polygon must have at least 3 effective points"))); + throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 effective points"))); } return poly; @@ -692,17 +705,19 @@ PolygonService::update_marker () // ----------------------------------------------------------------------------- // BoxService implementation -BoxService::BoxService (db::Manager *manager, lay::LayoutView *view) +BoxService::BoxService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Boxes) { // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * BoxService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::BoxPropertiesPage (this, manager, parent); } +#endif void BoxService::do_begin_edit (const db::DPoint &p) @@ -784,7 +799,7 @@ BoxService::selection_applies (const lay::ObjectInstPath &sel) const // ----------------------------------------------------------------------------- // TextService implementation -TextService::TextService (db::Manager *manager, lay::LayoutView *view) +TextService::TextService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Texts), m_rot (0) { @@ -796,11 +811,13 @@ TextService::~TextService () // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * TextService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::TextPropertiesPage (this, manager, parent); } +#endif void TextService::do_begin_edit (const db::DPoint &p) @@ -889,16 +906,17 @@ TextService::do_finish_edit () { get_edit_layer (); - manager ()->transaction (tl::to_string (QObject::tr ("Create text"))); + manager ()->transaction (tl::to_string (tr ("Create text"))); cell ().shapes (layer ()).insert (get_text ()); manager ()->commit (); commit_recent (view ()); +#if defined(HAVE_QT) if (! view ()->text_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("A text object is created but texts are disabled for drawing and are not visible. Do you want to enable drawing of texts?\n\nChoose \"Yes\" to enable text drawing now.")), + tl::to_string (tr ("A text object is created but texts are disabled for drawing and are not visible. Do you want to enable drawing of texts?\n\nChoose \"Yes\" to enable text drawing now.")), "text-created-but-not-visible", lay::TipDialog::yesno_buttons); @@ -909,6 +927,7 @@ TextService::do_finish_edit () } } +#endif } void @@ -972,7 +991,7 @@ TextService::configure (const std::string &name, const std::string &value) // ----------------------------------------------------------------------------- // PathService implementation -PathService::PathService (db::Manager *manager, lay::LayoutView *view) +PathService::PathService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Paths), m_width (0.1), m_bgnext (0.0), m_endext (0.0), m_type (Flush), m_needs_update (true) { @@ -984,6 +1003,7 @@ PathService::~PathService () // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * PathService::properties_page (db::Manager *manager, QWidget *parent) { @@ -993,6 +1013,7 @@ PathService::properties_page (db::Manager *manager, QWidget *parent) return new edt::PathPropertiesPage (this, manager, parent); } } +#endif void PathService::do_begin_edit (const db::DPoint &p) @@ -1083,7 +1104,7 @@ PathService::do_finish_edit () { // one point is reserved for the "current one" if (m_points.size () < 3) { - throw tl::Exception (tl::to_string (QObject::tr ("A path must have at least 2 points"))); + throw tl::Exception (tl::to_string (tr ("A path must have at least 2 points"))); } m_points.pop_back (); @@ -1211,7 +1232,7 @@ PathService::config_finalize () // ----------------------------------------------------------------------------- // InstService implementation -InstService::InstService (db::Manager *manager, lay::LayoutView *view) +InstService::InstService (db::Manager *manager, lay::LayoutViewBase *view) : edt::Service (manager, view), m_angle (0.0), m_scale (1.0), m_mirror (false), m_is_pcell (false), @@ -1224,11 +1245,13 @@ InstService::InstService (db::Manager *manager, lay::LayoutView *view) // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * InstService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::InstPropertiesPage (this, manager, parent); } +#endif bool InstService::do_activated () @@ -1253,6 +1276,7 @@ InstService::get_default_layer_for_pcell () return tl::Variant (); } +#if defined(HAVE_QT) bool InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data) { @@ -1323,7 +1347,7 @@ InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase return false; } -bool +bool InstService::drag_move_event (const db::DPoint &p, const lay::DragDropDataBase * /*data*/) { if (m_in_drag_drop) { @@ -1343,19 +1367,20 @@ InstService::drag_leave_event () } } +bool +InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/) +{ + m_in_drag_drop = false; + return false; +} +#endif + bool InstService::selection_applies (const lay::ObjectInstPath &sel) const { return sel.is_cell_inst (); } -bool -InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/) -{ - m_in_drag_drop = false; - return false; -} - void InstService::sync_to_config () { @@ -1383,7 +1408,7 @@ InstService::do_begin_edit (const db::DPoint &p) } if (cv.cell ()->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot put an instance into a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot put an instance into a PCell or library cell"))); } m_trans = cv.context_trans (); @@ -1429,7 +1454,7 @@ InstService::make_cell (const lay::CellView &cv) // NOTE: do this at the beginning: creating a transaction might delete transactions behind the // head transaction, hence releasing (thus: deleting) cells. To prevert interference, create // the transaction at the beginning. - db::Transaction tr (manager (), tl::to_string (QObject::tr ("Create reference cell")), m_reference_transaction_id); + db::Transaction transaction (manager (), tl::to_string (tr ("Create reference cell")), m_reference_transaction_id); lay::LayerState layer_state = view ()->layer_snapshot (); @@ -1497,8 +1522,8 @@ InstService::make_cell (const lay::CellView &cv) m_has_valid_cell = true; m_current_cell = inst_cell_index; - if (! tr.is_empty ()) { - m_reference_transaction_id = tr.id (); + if (! transaction.is_empty ()) { + m_reference_transaction_id = transaction.id (); } return std::pair (true, inst_cell_index); @@ -1596,10 +1621,10 @@ InstService::do_finish_edit () std::vector intersection; std::set_intersection (called.begin (), called.end (), callers.begin (), callers.end (), std::back_inserter (intersection)); if (! intersection.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Inserting this instance would create a recursive hierarchy"))); + throw tl::Exception (tl::to_string (tr ("Inserting this instance would create a recursive hierarchy"))); } - manager ()->transaction (tl::to_string (QObject::tr ("Create instance")), m_reference_transaction_id); + manager ()->transaction (tl::to_string (tr ("Create instance")), m_reference_transaction_id); m_reference_transaction_id = 0; db::Instance i = cv->layout ().cell (cv.cell_index ()).insert (inst); cv->layout ().cleanup (); diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index c3caf4383..1de7c70a6 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -32,6 +32,7 @@ namespace lay { class CellView; + class LayoutViewBase; class LayerPropertiesConstIterator; } @@ -45,7 +46,7 @@ class ShapeEditService : public edt::Service { public: - ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); protected: void get_edit_layer (); @@ -86,9 +87,11 @@ class PolygonService : public ShapeEditService { public: - PolygonService (db::Manager *manager, lay::LayoutView *view); + PolygonService (db::Manager *manager, lay::LayoutViewBase *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_delete (); virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); @@ -117,9 +120,11 @@ class BoxService : public ShapeEditService { public: - BoxService (db::Manager *manager, lay::LayoutView *view); + BoxService (db::Manager *manager, lay::LayoutViewBase *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move_inactive (const db::DPoint &p); @@ -142,10 +147,12 @@ class TextService : public ShapeEditService { public: - TextService (db::Manager *manager, lay::LayoutView *view); + TextService (db::Manager *manager, lay::LayoutViewBase *view); ~TextService (); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_transform (const db::DPoint &p, db::DFTrans trans); virtual void do_mouse_move (const db::DPoint &p); @@ -174,10 +181,12 @@ class PathService : public ShapeEditService { public: - PathService (db::Manager *manager, lay::LayoutView *view); + PathService (db::Manager *manager, lay::LayoutViewBase *view); ~PathService (); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p); @@ -211,9 +220,11 @@ class InstService : public edt::Service { public: - InstService (db::Manager *manager, lay::LayoutView *view); + InstService (db::Manager *manager, lay::LayoutViewBase *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move_inactive (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); @@ -222,10 +233,12 @@ public: virtual void do_finish_edit (); virtual void do_cancel_edit (); virtual bool do_activated (); +#if defined(HAVE_QT) virtual bool drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data); virtual bool drag_move_event (const db::DPoint &p, const lay::DragDropDataBase *data); virtual void drag_leave_event (); virtual bool drop_event (const db::DPoint &p, const lay::DragDropDataBase *data); +#endif virtual bool selection_applies (const lay::ObjectInstPath &sel) const; protected: diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index 4b04d9de8..e4e6c69c0 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -29,7 +29,7 @@ #include "edtService.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layEditable.h" #include "tlException.h" @@ -77,7 +77,7 @@ std::map pcell_parameters_from_string (const std::stri // ------------------------------------------------------------- // SelectionIterator implementation -SelectionIterator::SelectionIterator (lay::LayoutView *view, bool including_transient) +SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient) : m_transient_mode (false) { mp_edt_services = view->get_plugins (); @@ -145,7 +145,7 @@ SelectionIterator::next () // TransformationsVariants implementation // for a lay::LayoutView -TransformationVariants::TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer, bool per_cv) +TransformationVariants::TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer, bool per_cv) { // build the transformation variants cache diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index af9a81999..dc2a0c293 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -29,8 +29,6 @@ #include #include -#include - #include "layObjectInstPath.h" #include "dbInstElement.h" @@ -40,7 +38,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt { @@ -84,7 +82,7 @@ public: class TransformationVariants { public: - TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer = true, bool per_cv = true); + TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true); const std::vector *per_cv_and_layer (unsigned int cv, unsigned int layer) const; const std::vector *per_cv (unsigned int cv) const; @@ -109,7 +107,7 @@ public: * * If "including_transient" is true, the transient selection will be used as fallback. */ - SelectionIterator (lay::LayoutView *view, bool including_transient = true); + SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true); /** * @brief Returns a value indicating whether the transient selection is taken diff --git a/src/edt/edt/gsiDeclEdt.cc b/src/edt/edt/gsiDeclEdt.cc index 75e96b0f4..95a55f333 100644 --- a/src/edt/edt/gsiDeclEdt.cc +++ b/src/edt/edt/gsiDeclEdt.cc @@ -25,7 +25,7 @@ #include "edtService.h" #include "dbRecursiveShapeIterator.h" #include "layObjectInstPath.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -489,7 +489,7 @@ private: // extend the layout view by "edtService" specific methods -static std::vector object_selection (const lay::LayoutView *view) +static std::vector object_selection (const lay::LayoutViewBase *view) { std::vector result; std::vector edt_services = view->get_plugins (); @@ -501,7 +501,7 @@ static std::vector object_selection (const la return result; } -static void set_object_selection (const lay::LayoutView *view, const std::vector &all_selected) +static void set_object_selection (const lay::LayoutViewBase *view, const std::vector &all_selected) { std::vector sel; @@ -521,7 +521,7 @@ static void set_object_selection (const lay::LayoutView *view, const std::vector } } -static bool has_object_selection (const lay::LayoutView *view) +static bool has_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -532,7 +532,7 @@ static bool has_object_selection (const lay::LayoutView *view) return false; } -static void clear_object_selection (const lay::LayoutView *view) +static void clear_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -540,7 +540,7 @@ static void clear_object_selection (const lay::LayoutView *view) } } -static void select_object (const lay::LayoutView *view, const edt::Service::objects::value_type &object) +static void select_object (const lay::LayoutViewBase *view, const edt::Service::objects::value_type &object) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -551,7 +551,7 @@ static void select_object (const lay::LayoutView *view, const edt::Service::obje } } -static void unselect_object (const lay::LayoutView *view, const edt::Service::objects::value_type &object) +static void unselect_object (const lay::LayoutViewBase *view, const edt::Service::objects::value_type &object) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -562,7 +562,7 @@ static void unselect_object (const lay::LayoutView *view, const edt::Service::ob } } -static bool has_transient_object_selection (const lay::LayoutView *view) +static bool has_transient_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -573,18 +573,18 @@ static bool has_transient_object_selection (const lay::LayoutView *view) return false; } -static EditableSelectionIterator begin_objects_selected (const lay::LayoutView *view) +static EditableSelectionIterator begin_objects_selected (const lay::LayoutViewBase *view) { return EditableSelectionIterator (view->get_plugins (), false); } -static EditableSelectionIterator begin_objects_selected_transient (const lay::LayoutView *view) +static EditableSelectionIterator begin_objects_selected_transient (const lay::LayoutViewBase *view) { return EditableSelectionIterator (view->get_plugins (), true); } static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("has_object_selection?", &has_object_selection, "@brief Returns true, if geometrical objects (shapes or cell instances) are selected in this view" ) + diff --git a/src/gsi/gsi/gsiDeclBasic.cc b/src/gsi/gsi/gsiDeclBasic.cc index 15f7a18fb..b38f25968 100644 --- a/src/gsi/gsi/gsiDeclBasic.cc +++ b/src/gsi/gsi/gsiDeclBasic.cc @@ -102,7 +102,7 @@ static gsi::Interpreter *ruby_interpreter () return interpreter_by_name ("rba"); } -Class decl_Macro ("tl", "Interpreter", +Class decl_Interpreter ("tl", "Interpreter", gsi::method ("load_file", &Interpreter::load_file, gsi::arg ("path"), "@brief Loads the given file into the interpreter\n" "This will execute the code inside the file.\n" diff --git a/src/gsi/gsi/gsiTypes.h b/src/gsi/gsi/gsiTypes.h index ad806fcca..bdc66b928 100644 --- a/src/gsi/gsi/gsiTypes.h +++ b/src/gsi/gsi/gsiTypes.h @@ -448,7 +448,6 @@ template struct type_traits > : generic_type_trait template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits > : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits > : generic_type_traits { }; @@ -459,6 +458,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits > : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -492,7 +492,6 @@ template struct type_traits &> : generic_ty template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits &> : generic_type_traits { }; @@ -503,6 +502,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -533,7 +533,6 @@ template struct type_traits &> : generic_type_tra template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits &> : generic_type_traits { }; @@ -544,6 +543,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -575,7 +575,6 @@ template struct type_traits *> : generic_ty template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits *> : generic_type_traits { }; @@ -586,6 +585,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -617,7 +617,6 @@ template struct type_traits *> : generic_type_t template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits *> : generic_type_traits { }; @@ -628,6 +627,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 27e13f72c..01bc8fefa 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -28,7 +28,7 @@ #include "imgService.h" #include "imgStream.h" #include "dbTilingProcessor.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -45,12 +45,12 @@ static void clear_colormap (img::DataMapping *dm) static void add_colormap (img::DataMapping *dm, double value, lay::color_t color) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (QColor (color), QColor (color)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (color), lay::Color (color)))); } static void add_colormap2 (img::DataMapping *dm, double value, lay::color_t lcolor, lay::color_t rcolor) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (QColor (lcolor), QColor (rcolor)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (lcolor), lay::Color (rcolor)))); } static size_t num_colormap_entries (const img::DataMapping *dm) @@ -299,8 +299,8 @@ gsi::Class decl_ImageDataMapping ("lay", "ImageDataMapping", class ImageRef; -static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj); -static void erase_image (lay::LayoutView *view, size_t id); +static void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj); +static void erase_image_base (lay::LayoutViewBase *view, size_t id); /** * @brief An extension of the img::Object that provides "live" updates of the view @@ -321,7 +321,7 @@ public: // .. nothing yet .. } - ImageRef (const img::Object &other, lay::LayoutView *view) + ImageRef (const img::Object &other, lay::LayoutViewBase *view) : img::Object (other), mp_view (view), dm_update_view (this, &ImageRef::do_update_view) { // .. nothing yet .. @@ -365,7 +365,7 @@ public: void erase () { if (mp_view) { - erase_image (mp_view.get (), id ()); + erase_image_base (mp_view.get (), id ()); detach (); } } @@ -373,10 +373,10 @@ public: template ImageRef transformed (const T &t) const { - return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); + return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutView *view) + void set_view (lay::LayoutViewBase *view) { mp_view.reset (view); } @@ -398,12 +398,12 @@ protected: void do_update_view () { if (mp_view) { - replace_image (mp_view.get (), id (), *this); + replace_image_base (mp_view.get (), id (), *this); } } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; tl::DeferredMethod dm_update_view; }; @@ -1073,7 +1073,7 @@ public: // .. nothing yet .. } - ImageRefIterator (const img::ImageIterator &iter, lay::LayoutView *view) + ImageRefIterator (const img::ImageIterator &iter, lay::LayoutViewBase *view) : img::ImageIterator (iter), mp_view (view) { // .. nothing yet .. @@ -1081,14 +1081,14 @@ public: reference operator* () const { - return reference (img::ImageIterator::operator* (), const_cast(mp_view.get ())); + return reference (img::ImageIterator::operator* (), const_cast(mp_view.get ())); } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static void clear_images (lay::LayoutView *view) +static void clear_images (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1096,14 +1096,14 @@ static void clear_images (lay::LayoutView *view) } } -static void show_image (lay::LayoutView *view, size_t id, bool visible) +static void show_image (lay::LayoutViewBase *view, size_t id, bool visible) { img::Service *img_service = view->get_plugin (); if (img_service) { const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img::Object new_img (*img); @@ -1114,14 +1114,14 @@ static void show_image (lay::LayoutView *view, size_t id, bool visible) } } -static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) +void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) { img::Service *img_service = view->get_plugin (); if (img_service) { const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img_service->change_image_by_id (id, new_obj); @@ -1129,14 +1129,19 @@ static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) } } -static void erase_image (lay::LayoutView *view, size_t id) +static void replace_image (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) +{ + replace_image_base (view, id, new_obj); +} + +void erase_image_base (lay::LayoutViewBase *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img_service->erase_image_by_id (id); @@ -1144,10 +1149,15 @@ static void erase_image (lay::LayoutView *view, size_t id) } } -static void insert_image (lay::LayoutView *view, ImageRef &obj) +static void erase_image (lay::LayoutViewBase *view, size_t id) +{ + erase_image_base (view, id); +} + +static void insert_image (lay::LayoutViewBase *view, ImageRef &obj) { if (obj.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The object is already inserted into a view - detach the object first or create a different object."))); + throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); } img::Service *img_service = view->get_plugin (); @@ -1158,7 +1168,7 @@ static void insert_image (lay::LayoutView *view, ImageRef &obj) } } -static ImageRef get_image (lay::LayoutView *view, size_t id) +static ImageRef get_image (lay::LayoutViewBase *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1171,28 +1181,28 @@ static ImageRef get_image (lay::LayoutView *view, size_t id) return ImageRef (); } -static tl::Event &get_images_changed_event (lay::LayoutView *view) +static tl::Event &get_images_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->images_changed_event; } -static tl::Event &get_image_selection_changed_event (lay::LayoutView *view) +static tl::Event &get_image_selection_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->image_selection_changed_event; } -static tl::event &get_image_changed_event (lay::LayoutView *view) +static tl::event &get_image_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->image_changed_event; } -static ImageRefIterator begin_images (lay::LayoutView *view) +static ImageRefIterator begin_images (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1203,7 +1213,7 @@ static ImageRefIterator begin_images (lay::LayoutView *view) } static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("clear_images", &gsi::clear_images, "@brief Clear all images on this view" ) + @@ -1332,7 +1342,7 @@ private: // extend the layout view by "edtService" specific methods -static bool has_image_selection (const lay::LayoutView *view) +static bool has_image_selection (const lay::LayoutViewBase *view) { std::vector img = view->get_plugins (); for (std::vector::const_iterator s = img.begin (); s != img.end (); ++s) { @@ -1343,14 +1353,14 @@ static bool has_image_selection (const lay::LayoutView *view) return false; } -static SelectionIterator begin_images_selected (const lay::LayoutView *view) +static SelectionIterator begin_images_selected (const lay::LayoutViewBase *view) { return SelectionIterator (view->get_plugins ()); } static -gsi::ClassExt layout_view_decl2 ( +gsi::ClassExt layout_view_decl2 ( gsi::method_ext ("has_image_selection?", &has_image_selection, "@brief Returns true, if images are selected in this view" "\n" diff --git a/src/img/img/img.pro b/src/img/img/img.pro index c5337e156..89d40ba90 100644 --- a/src/img/img/img.pro +++ b/src/img/img/img.pro @@ -6,36 +6,56 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_IMG_LIBRARY -HEADERS = \ - imgLandmarksDialog.h \ - imgNavigator.h \ - imgObject.h \ - imgPlugin.h \ - imgPropertiesPage.h \ - imgService.h \ - imgWidgets.h \ - imgForceLink.h \ - imgCommon.h \ - imgStream.h +!equals(HAVE_QT, "0") { FORMS = \ AddNewImageDialog.ui \ ImageLandmarksDialog.ui \ ImagePropertiesPage.ui \ +} + +# Disabled without Qt: + +HEADERS = \ + imgLandmarksDialog.h \ + imgNavigator.h \ + imgPropertiesPage.h \ + imgWidgets.h \ + SOURCES = \ - gsiDeclImg.cc \ imgLandmarksDialog.cc \ imgNavigator.cc \ + imgPropertiesPage.cc \ + imgWidgets.cc \ + +# Enabled without Qt: + +HEADERS += \ + imgObject.h \ + imgPlugin.h \ + imgService.h \ + imgForceLink.h \ + imgCommon.h \ + imgStream.h + +SOURCES += \ + gsiDeclImg.cc \ imgObject.cc \ imgPlugin.cc \ - imgPropertiesPage.cc \ imgService.cc \ - imgWidgets.cc \ imgForceLink.cc \ - imgStream.cc + imgStream.cc -INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_db -lklayout_gsi -lklayout_laybasic -lklayout_db +INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_db -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} diff --git a/src/img/img/imgForceLink.cc b/src/img/img/imgForceLink.cc index 2dbd66143..86247ea5c 100644 --- a/src/img/img/imgForceLink.cc +++ b/src/img/img/imgForceLink.cc @@ -10,7 +10,7 @@ (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 + but WITHOUT ANY WARRANTY; without even the implied warrimgy of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -20,7 +20,6 @@ */ - #include "imgForceLink.h" namespace img diff --git a/src/img/img/imgForceLink.h b/src/img/img/imgForceLink.h index 1dfc4e901..a86fd3b88 100644 --- a/src/img/img/imgForceLink.h +++ b/src/img/img/imgForceLink.h @@ -10,7 +10,7 @@ (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 + but WITHOUT ANY WARRANTY; without even the implied warrimgy of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -33,7 +33,7 @@ namespace img { IMG_PUBLIC int _force_link_f (); - int _force_link_target = _force_link_f (); + static int _force_link_target = _force_link_f (); } #endif diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 1a8d3d152..4be4ba291 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgLandmarksDialog.h" #include "imgService.h" @@ -144,7 +145,7 @@ class LandmarkEditorService : public lay::ViewService { public: - LandmarkEditorService (lay::LayoutView *view, img::Object *img) + LandmarkEditorService (lay::LayoutViewBase *view, img::Object *img) : lay::ViewService (view->view_object_widget ()), mp_image (img), m_selected (-1), m_dragging (false), m_mode (LandmarksDialog::None) @@ -345,7 +346,7 @@ public: widget ()->ungrab_mouse (this); } - void set_colors (QColor /*background*/, QColor /*color*/) + void set_colors (lay::Color /*background*/, lay::Color /*color*/) { // ... } @@ -499,3 +500,4 @@ LandmarksDialog::landmarks_updated () } +#endif diff --git a/src/img/img/imgLandmarksDialog.h b/src/img/img/imgLandmarksDialog.h index cad11fbfe..8c0d099e9 100644 --- a/src/img/img/imgLandmarksDialog.h +++ b/src/img/img/imgLandmarksDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgLandmarksDialog #define HDR_imgLandmarksDialog @@ -65,3 +66,5 @@ private: } #endif + +#endif diff --git a/src/img/img/imgNavigator.cc b/src/img/img/imgNavigator.cc index b6640e070..634b8bd1e 100644 --- a/src/img/img/imgNavigator.cc +++ b/src/img/img/imgNavigator.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laybasicConfig.h" #include "layMarker.h" @@ -113,3 +114,4 @@ Navigator::background_color (QColor c) } +#endif diff --git a/src/img/img/imgNavigator.h b/src/img/img/imgNavigator.h index 6e5922b3f..e9c70ffdc 100644 --- a/src/img/img/imgNavigator.h +++ b/src/img/img/imgNavigator.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgNavigator #define HDR_imgNavigator @@ -54,7 +55,7 @@ public: void background_color (QColor c); img::Object *setup (lay::Dispatcher *root, img::Object *img); - lay::LayoutView *view () + lay::LayoutView *view () { return mp_view; } @@ -62,7 +63,7 @@ public: void activate_service (lay::ViewService *service); private: - lay::LayoutView *mp_view; + lay::LayoutView *mp_view; lay::ZoomService *mp_zoom_service; }; @@ -70,3 +71,4 @@ private: #endif +#endif diff --git a/src/img/img/imgObject.cc b/src/img/img/imgObject.cc index f8758b9d3..e2912b2d1 100644 --- a/src/img/img/imgObject.cc +++ b/src/img/img/imgObject.cc @@ -22,15 +22,16 @@ #include "imgObject.h" -#include "imgWidgets.h" // for interpolate_color() #include "imgStream.h" #include "tlLog.h" #include "tlTimer.h" #include "layPlugin.h" #include "layConverters.h" +#include "layPixelBuffer.h" #include "dbPolygonTools.h" #include "tlFileUtils.h" #include "tlUri.h" +#include "tlThreads.h" #include #include @@ -39,8 +40,9 @@ #include #include -#include -#include +#if defined(HAVE_QT) +# include +#endif namespace img { @@ -51,8 +53,8 @@ namespace img DataMapping::DataMapping () : brightness (0.0), contrast (0.0), gamma (1.0), red_gain (1.0), green_gain (1.0), blue_gain (1.0) { - false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } bool @@ -192,21 +194,25 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns for (unsigned int i = 1; i < false_color_nodes.size (); ++i) { - int h1, s1, v1; - false_color_nodes [i - 1].second.second.getHsv (&h1, &s1, &v1); + unsigned int h1, s1, v1; + false_color_nodes [i - 1].second.second.get_hsv (h1, s1, v1); - int h2, s2, v2; - false_color_nodes [i].second.first.getHsv (&h2, &s2, &v2); + unsigned int h2, s2, v2; + false_color_nodes [i].second.first.get_hsv (h2, s2, v2); + + int dh = int (h1) - int (h2); + int ds = int (s1) - int (s2); + int dv = int (v1) - int (v2); // The number of steps is chosen such that the full HSV band divides into approximately 200 steps - double nsteps = 0.5 * sqrt (double (h1 - h2) * double (h1 - h2) + double (s1 - s2) * double (s1 - s2) + double (v1 - v2) * double (v1 - v2)); + double nsteps = 0.5 * sqrt (double (dh * dh) + double (ds * ds) + double (dv * dv)); int n = int (floor (nsteps + 1.0)); double dx = (false_color_nodes [i].first - false_color_nodes [i - 1].first) / n; double x = false_color_nodes [i - 1].first; for (int j = 0; j < n; ++j) { - QColor c = interpolated_color (false_color_nodes, x); + lay::Color c = interpolated_color (false_color_nodes, x); double y = 0.0; if (channel == 0) { @@ -260,6 +266,57 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns return dm; } +// -------------------------------------------------------------------------------------- + +namespace +{ + +struct compare_first_of_node +{ + bool operator() (const std::pair > &a, const std::pair > &b) const + { + return a.first < b.first; + } +}; + +} + +lay::Color +interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x) +{ + if (nodes.size () < 1) { + return lay::Color (); + } else if (nodes.size () < 2) { + return x < nodes[0].first ? nodes[0].second.first : nodes[0].second.second; + } else { + + std::vector > >::const_iterator p = std::lower_bound (nodes.begin (), nodes.end (), std::make_pair (x, std::make_pair (lay::Color (), lay::Color ())), compare_first_of_node ()); + if (p == nodes.end ()) { + return nodes.back ().second.second; + } else if (p == nodes.begin ()) { + return nodes.front ().second.first; + } else { + + double x1 = p[-1].first; + double x2 = p->first; + + unsigned int h1 = 0, s1 = 0, v1 = 0; + p[-1].second.second.get_hsv (h1, s1, v1); + + unsigned int h2 = 0, s2 = 0, v2 = 0; + p->second.first.get_hsv (h2, s2, v2); + + int h = int (0.5 + h1 + double(x - x1) * double (int (h2) - int (h1)) / double(x2 - x1)); + int s = int (0.5 + s1 + double(x - x1) * double (int (s2) - int (s1)) / double(x2 - x1)); + int v = int (0.5 + v1 + double(x - x1) * double (int (v2) - int (v1)) / double(x2 - x1)); + + return lay::Color::from_hsv ((unsigned int) h, (unsigned int) s, (unsigned int) v); + + } + + } +} + // -------------------------------------------------------------------------------------- // img::DataHeader definition and implementation @@ -690,7 +747,7 @@ private: static size_t make_id () { - static QMutex id_lock; + static tl::Mutex id_lock; static size_t s_id_counter = 1; // Get a new Id for the object. Id == 0 is reserved. @@ -1283,7 +1340,7 @@ Object::from_string (const char *str, const char *base_dir) double x = 0.0; lay::ColorConverter cc; - QColor cl, cr; + lay::Color cl, cr; std::string s; m_data_mapping.false_color_nodes.clear (); @@ -1506,6 +1563,8 @@ Object::read_file () // continue with other formats ... } +#if defined(HAVE_QT) + QImage qimage (tl::to_qstring (m_filename)); if (! qimage.isNull ()) { @@ -1566,6 +1625,85 @@ Object::read_file () } } + +#elif defined(HAVE_PNG) + + lay::PixelBuffer img; + + { + tl::InputStream stream (m_filename); + img = lay::PixelBuffer::read_png (stream); + } + + bool is_color = false; + for (unsigned int i = 0; i < img.height () && ! is_color; ++i) { + const lay::color_t *d = img.scan_line (i); + const lay::color_t *dd = d + img.width (); + while (! is_color && d != dd) { + lay::color_t c = *d++; + is_color = (((c >> 8) ^ c) & 0xffff) != 0; + } + } + + if (! m_min_value_set) { + m_min_value = 0.0; + } + + if (! m_max_value_set) { + m_max_value = 255.0; + } + + m_min_value_set = true; + m_max_value_set = true; + + unsigned int w = img.width (), h = img.height (); + + mp_data = new DataHeader (w, h, is_color, true); + mp_data->add_ref (); + + if (is_color) { + + unsigned char *red = mp_data->byte_data (0); + unsigned char *green = mp_data->byte_data (1); + unsigned char *blue = mp_data->byte_data (2); + unsigned char *msk = img.transparent () ? mp_data->set_mask () : 0; + + for (unsigned int y = 0; y < h; ++y) { + const lay::color_t *d = img.scan_line (h - y - 1); + const lay::color_t *dd = d + img.width (); + while (d != dd) { + lay::color_t rgb = *d++; + *red++ = lay::red (rgb); + *green++ = lay::green (rgb); + *blue++ = lay::blue (rgb); + if (msk) { + *msk++ = lay::alpha (rgb) > 128; + } + } + } + + } else { + + unsigned char *mono = mp_data->byte_data (); + unsigned char *msk = img.transparent () ? mp_data->set_mask () : 0; + + for (unsigned int y = 0; y < h; ++y) { + const lay::color_t *d = img.scan_line (h - y - 1); + const lay::color_t *dd = d + img.width (); + while (d != dd) { + lay::color_t rgb = *d++; + *mono++ = lay::green (rgb); + if (msk) { + *msk++ = lay::alpha (rgb) > 128; + } + } + } + + } + +#else + throw tl::Exception (tl::to_string ("No PNG support compiled in - cannot load PNG files")); +#endif } void @@ -1654,7 +1792,7 @@ Object::to_string () const for (unsigned int i = 0; i < data_mapping ().false_color_nodes.size (); ++i) { os << data_mapping ().false_color_nodes[i].first; os << ","; - const std::pair &clr = data_mapping ().false_color_nodes[i].second; + const std::pair &clr = data_mapping ().false_color_nodes[i].second; os << tl::to_word_or_quoted_string (cc.to_string (clr.first)); if (clr.first != clr.second) { os << ","; diff --git a/src/img/img/imgObject.h b/src/img/img/imgObject.h index c5dcdb467..1d3f734e1 100644 --- a/src/img/img/imgObject.h +++ b/src/img/img/imgObject.h @@ -33,13 +33,11 @@ #include "dbMatrix.h" #include "dbPolygon.h" #include "tlDataMapping.h" -#include "layViewOp.h" +#include "layColor.h" #include #include -#include - namespace img { class DataHeader; @@ -52,7 +50,7 @@ class DataHeader; struct IMG_PUBLIC DataMapping { public: - typedef std::vector< std::pair > > false_color_nodes_type; + typedef std::vector< std::pair > > false_color_nodes_type; /** * @brief The constructor @@ -139,6 +137,11 @@ public: tl::DataMappingBase *create_data_mapping (bool monochrome, double xmin, double xmax, unsigned int channel) const; }; +/** + * @brief A helper function to interpolate a color in the color bar at a given x + */ +lay::Color interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x); + /** * @brief A image object * diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 74d710786..a5472c5e7 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -22,7 +22,6 @@ #include "layPlugin.h" -#include "layAbstractMenu.h" #include "imgService.h" #include "imgPlugin.h" @@ -36,16 +35,16 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("image_group", "edit_menu.end")); - menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image")))); - menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images")))); - menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front")))); - menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back")))); - menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images")))); - menu_entries.push_back (lay::config_menu_item ("show_images", "view_menu.layout_group+", tl::to_string (QObject::tr ("Show Images")), cfg_images_visible, "?")); + menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (tr ("Add Image")))); + menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (tr ("Images")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Image Stack: Selected Images to Front")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Image Stack: Selected Images to Back")))); + menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Clear All Images")))); + menu_entries.push_back (lay::config_menu_item ("show_images", "view_menu.layout_group+", tl::to_string (tr ("Show Images")), cfg_images_visible, "?")); } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new img::Service (manager, view); } @@ -53,7 +52,7 @@ PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay:: bool PluginDeclaration::implements_editable (std::string &title) const { - title = tl::to_string (QObject::tr ("Images")); + title = tl::to_string (tr ("Images")); return true; } diff --git a/src/img/img/imgPlugin.h b/src/img/img/imgPlugin.h index 4dc9fa0bd..1575ceccb 100644 --- a/src/img/img/imgPlugin.h +++ b/src/img/img/imgPlugin.h @@ -36,7 +36,7 @@ class PluginDeclaration { public: virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual void get_options (std::vector < std::pair > &options) const; }; diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index fef5a1fa8..c53d36d77 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgPropertiesPage.h" #include "imgLandmarksDialog.h" @@ -735,9 +736,9 @@ PropertiesPage::blue_spinbox_changed (double value) void PropertiesPage::black_to_white () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -745,9 +746,9 @@ PropertiesPage::black_to_white () void PropertiesPage::white_to_black () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -755,9 +756,9 @@ PropertiesPage::white_to_black () void PropertiesPage::red_to_blue () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (255, 0, 0), QColor (255, 0, 0)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (0, 0, 255), QColor (0, 0, 255)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (255, 0, 0), lay::Color (255, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (0, 0, 255), lay::Color (0, 0, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -765,9 +766,9 @@ PropertiesPage::red_to_blue () void PropertiesPage::blue_to_red () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 255), QColor (0, 0, 255)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 0, 0), QColor (255, 0, 0)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 255), lay::Color (0, 0, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 0, 0), lay::Color (255, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -775,7 +776,7 @@ PropertiesPage::blue_to_red () void PropertiesPage::reverse_color_order () { - std::vector > > nodes (false_color_control->nodes ()); + std::vector > > nodes (false_color_control->nodes ()); for (size_t i = 0; i < nodes.size () / 2; ++i) { std::swap (nodes [i].second.second, nodes [nodes.size () - 1 - i].second.first); std::swap (nodes [i].second.first, nodes [nodes.size () - 1 - i].second.second); @@ -1003,3 +1004,4 @@ PropertiesPage::define_landmarks_pressed () } +#endif diff --git a/src/img/img/imgPropertiesPage.h b/src/img/img/imgPropertiesPage.h index c3b139b85..797bedd86 100644 --- a/src/img/img/imgPropertiesPage.h +++ b/src/img/img/imgPropertiesPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgPropertiesPage #define HDR_imgPropertiesPage @@ -105,3 +106,5 @@ private: } #endif + +#endif diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 627c03967..de9fd331f 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -30,24 +30,30 @@ #include "layPlugin.h" #include "layRenderer.h" #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" -#include "layLayoutCanvas.h" -#include "layProperties.h" -#include "layTipDialog.h" +#if defined(HAVE_QT) +# include "layProperties.h" +# include "layTipDialog.h" +#endif #include "tlExceptions.h" #include "imgService.h" #include "imgPlugin.h" -#include "ui_AddNewImageDialog.h" +#if defined(HAVE_QT) +# include "ui_AddNewImageDialog.h" +#endif -#include +#if defined(HAVE_QT) +# include +#endif namespace img { // ------------------------------------------------------------- -class AddNewImageDialog +#if defined(HAVE_QT) +class AddNewImageDialog : public QDialog, public Ui::AddNewImageDialog { @@ -68,7 +74,7 @@ public: properties_frame->apply (); if (mp_image_object->is_empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No data loaded for that image"))); + throw tl::Exception (tl::to_string (tr ("No data loaded for that image"))); } QDialog::accept (); @@ -79,11 +85,12 @@ public: private: img::Object *mp_image_object; }; +#endif // ------------------------------------------------------------- static void -draw_scanline (unsigned int level, const img::Object &image_object, QImage &qimage, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2) +draw_scanline (unsigned int level, const img::Object &image_object, lay::PixelBuffer &pxbuffer, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2) { double source_width = image_object.width (); double source_height = image_object.height (); @@ -95,8 +102,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima std::swap (x1, x2); } - int xstart = int (std::max (0.0, std::min (floor (x1), double (qimage.width ())))); - int xstop = int (std::max (0.0, std::min (ceil (x2) + 1.0, double (qimage.width ())))); + int xstart = int (std::max (0.0, std::min (floor (x1), double (pxbuffer.width ())))); + int xstop = int (std::max (0.0, std::min (ceil (x2) + 1.0, double (pxbuffer.width ())))); db::DPoint p1 = it.trans (db::DPoint (xstart, y)); db::DPoint p2 = it.trans (db::DPoint (xstop, y)); @@ -106,8 +113,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima if (level < 7 && xstop > xstart + 1 && fabs (xm - (xstart + xstop) / 2) > 1.0 && xm > xstart + 1 && xm < xstop - 1) { - draw_scanline (level + 1, image_object, qimage, y, t, it, q1, qm); - draw_scanline (level + 1, image_object, qimage, y, t, it, qm, q2); + draw_scanline (level + 1, image_object, pxbuffer, y, t, it, q1, qm); + draw_scanline (level + 1, image_object, pxbuffer, y, t, it, qm, q2); } else { @@ -115,8 +122,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima double dpx = (p2.x () - p1.x ()) / double (xstop - xstart); double dpy = (p2.y () - p1.y ()) / double (xstop - xstart); - QRgb *scanline_data = (QRgb *) qimage.scanLine (qimage.height () - y - 1) + xstart; - QRgb *pixel_data = (QRgb *) image_object.pixel_data (); + lay::color_t *scanline_data = pxbuffer.scan_line (pxbuffer.height () - y - 1) + xstart; + lay::color_t *pixel_data = (lay::color_t *) image_object.pixel_data (); const unsigned char *mask_data = image_object.mask (); for (int x = xstart; x < xstop; ++x) { @@ -144,15 +151,15 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO { // TODO: currently, the images can only be rendered to a bitmap canvas .. lay::BitmapViewObjectCanvas *bmp_canvas = dynamic_cast (&canvas); - if (! bmp_canvas) { + if (! bmp_canvas || ! bmp_canvas->bg_image ()) { return; } - QImage &qimage = bmp_canvas->bg_image (); + lay::PixelBuffer &image = *bmp_canvas->bg_image (); db::DBox source_image_box (0.0, 0.0, image_object.width (), image_object.height ()); // safety measure to avoid division by zero. - if (qimage.width () < 1 || qimage.height () < 1) { + if (image.width () < 1 || image.height () < 1) { return; } @@ -165,7 +172,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO db::DBox image_box = source_image_box.transformed (t); int y1 = int (floor (std::max (0.0, image_box.bottom ()))); - int y2 = int (floor (std::min (double (qimage.height ()) - 1, image_box.top ()))); + int y2 = int (floor (std::min (double (image.height ()) - 1, image_box.top ()))); for (int y = y1; y <= y2; ++y) { @@ -175,7 +182,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO // clip the transformed scanline to the original image std::pair clipped = scanline.clipped_line (source_image_box); if (clipped.first) { - draw_scanline (0, image_object, qimage, y, t, it, clipped.second.p1 (), clipped.second.p2 ()); + draw_scanline (0, image_object, image, y, t, it, clipped.second.p1 (), clipped.second.p2 ()); } } @@ -402,7 +409,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // img::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), @@ -1361,19 +1368,21 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } - msg += tl::sprintf (tl::to_string (QObject::tr ("image(%dx%d)")), image->width (), image->height ()); + msg += tl::sprintf (tl::to_string (tr ("image(%dx%d)")), image->width (), image->height ()); view ()->message (msg); } } +#if defined(HAVE_QT) lay::PropertiesPage * Service::properties_page (db::Manager *manager, QWidget *parent) { return new img::PropertiesPage (this, manager, parent); } +#endif void Service::get_selection (std::vector &sel) const @@ -1463,15 +1472,16 @@ Service::menu_activated (const std::string &symbol) { if (symbol == "img::clear_all_images") { - manager ()->transaction (tl::to_string (QObject::tr ("Clear all images"))); + manager ()->transaction (tl::to_string (tr ("Clear all images"))); clear_images (); manager ()->commit (); } else if (symbol == "img::add_image") { +#if defined(HAVE_QT) if (! images_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Images are not visible. If you add an image you will not see it.\n\n" + tl::to_string (tr ("Images are not visible. If you add an image you will not see it.\n\n" "Choose 'View/Show Images' to make images visible.")), "add-image-while-not-visible", lay::TipDialog::okcancel_buttons); @@ -1482,6 +1492,7 @@ Service::menu_activated (const std::string &symbol) return; } } +#endif add_image (); @@ -1573,6 +1584,7 @@ Service::top_z_position () const void Service::add_image () { +#if defined(HAVE_QT) img::Object *new_image = new img::Object (); AddNewImageDialog dialog (QApplication::activeWindow (), new_image); @@ -1580,7 +1592,7 @@ Service::add_image () clear_selection (); - manager ()->transaction (tl::to_string (QObject::tr ("Add image"))); + manager ()->transaction (tl::to_string (tr ("Add image"))); new_image->set_z_position (top_z_position ()); mp_view->annotation_shapes ().insert (db::DUserObject (new_image)); manager ()->commit (); @@ -1588,6 +1600,7 @@ Service::add_image () } else { delete new_image; } +#endif } void diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 65e7bfa70..9379c9b49 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -203,7 +203,7 @@ public: typedef lay::AnnotationShapes::iterator obj_iterator; enum MoveMode { move_none, move_selected, move_landmark, move_l, move_r, move_t, move_b, move_lr, move_tr, move_ll, move_tl, move_all }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -369,10 +369,12 @@ public: */ virtual void transform (const db::DCplxTrans &trans); +#if defined(HAVE_QT) /** * @brief Create the properties page */ virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif /** * @brief Get the selection for the properties page @@ -432,7 +434,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -480,7 +482,7 @@ public: private: // The layout view that the image service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The view objects representing the selection and the moved images in move mode std::vector m_selected_image_views; diff --git a/src/img/img/imgStream.cc b/src/img/img/imgStream.cc index 72dcb9c21..cb84b63b6 100644 --- a/src/img/img/imgStream.cc +++ b/src/img/img/imgStream.cc @@ -373,7 +373,7 @@ namespace { struct ColorMapConverter { - std::string to_string (const std::pair > &cm) const + std::string to_string (const std::pair > &cm) const { std::string s; s = tl::to_string (cm.first); @@ -389,7 +389,7 @@ namespace { return s; } - void from_string (const std::string &s, std::pair > &cm) const + void from_string (const std::string &s, std::pair > &cm) const { tl::Extractor ex (s.c_str ()); @@ -427,7 +427,7 @@ tl::XMLStruct s_img_structure ("image-data", tl::make_member (&ImageProxy::max_value, &ImageProxy::set_max_value, "max-value") + tl::make_element (&ImageProxy::data_mapping, &ImageProxy::set_data_mapping, "data-mapping", tl::make_element (&img::DataMapping::false_color_nodes, "color-map", - tl::make_member >, img::DataMapping::false_color_nodes_type::const_iterator, img::DataMapping::false_color_nodes_type, ColorMapConverter> (&img::DataMapping::false_color_nodes_type::begin, &img::DataMapping::false_color_nodes_type::end, &img::DataMapping::false_color_nodes_type::push_back, "color-map-entry", ColorMapConverter ()) + tl::make_member >, img::DataMapping::false_color_nodes_type::const_iterator, img::DataMapping::false_color_nodes_type, ColorMapConverter> (&img::DataMapping::false_color_nodes_type::begin, &img::DataMapping::false_color_nodes_type::end, &img::DataMapping::false_color_nodes_type::push_back, "color-map-entry", ColorMapConverter ()) ) + tl::make_member (&img::DataMapping::brightness, "brightness") + tl::make_member (&img::DataMapping::contrast, "contrast") + diff --git a/src/img/img/imgWidgets.cc b/src/img/img/imgWidgets.cc index 587e77322..32d85fdae 100644 --- a/src/img/img/imgWidgets.cc +++ b/src/img/img/imgWidgets.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgWidgets.h" @@ -44,52 +45,6 @@ const int min_bar_height = 4; const double min_value_interval = 1e-3; const double epsilon = 1e-6; -struct compare_first_of_node -{ - bool operator() (const std::pair > &a, const std::pair > &b) const - { - return a.first < b.first; - } -}; - -QColor -interpolated_color (const std::vector > > &nodes, double x) -{ - if (nodes.size () < 1) { - return QColor (); - } else if (nodes.size () < 2) { - return x < nodes[0].first ? nodes[0].second.first : nodes[0].second.second; - } else { - - std::vector > >::const_iterator p = std::lower_bound (nodes.begin (), nodes.end (), std::make_pair (x, std::make_pair (QColor (), QColor ())), compare_first_of_node ()); - if (p == nodes.end ()) { - return nodes.back ().second.second; - } else if (p == nodes.begin ()) { - return nodes.front ().second.first; - } else { - - double x1 = p[-1].first; - double x2 = p->first; - - int h1 = 0, s1 = 0, v1 = 0; - p[-1].second.second.getHsv (&h1, &s1, &v1); - - int h2 = 0, s2 = 0, v2 = 0; - p->second.first.getHsv (&h2, &s2, &v2); - - int h = int (0.5 + h1 + double(x - x1) * double (h2 - h1) / double(x2 - x1)); - int s = int (0.5 + s1 + double(x - x1) * double (s2 - s1) / double(x2 - x1)); - int v = int (0.5 + v1 + double(x - x1) * double (v2 - v1) / double(x2 - x1)); - - QColor r; - r.setHsv (h, s, v); - return r; - - } - - } -} - // -------------------------------------------------------------------------------------------------------------------- TwoColorWidget::TwoColorWidget (QWidget *parent) @@ -173,8 +128,8 @@ TwoColorWidget::lock_changed (bool checked) ColorBar::ColorBar (QWidget *parent) : QWidget (parent), m_dragging (false), m_selected (-1) { - m_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - m_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + m_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } ColorBar::~ColorBar () @@ -206,7 +161,7 @@ void ColorBar::set_current_color (std::pair c) { if (has_selection ()) { - m_nodes [m_selected].second = c; + m_nodes [m_selected].second = std::make_pair (lay::Color (c.first.rgb ()), lay::Color (c.second.rgb ())); emit color_mapping_changed (); update (); } @@ -260,22 +215,35 @@ ColorBar::keyPressEvent (QKeyEvent *event) } } +namespace +{ + +struct compare_first_of_node +{ + bool operator() (const std::pair > &a, const std::pair > &b) const + { + return a.first < b.first; + } +}; + +} + void -ColorBar::set_nodes (const std::vector > > &nodes) +ColorBar::set_nodes (const std::vector > > &nodes) { m_nodes = nodes; std::sort (m_nodes.begin (), m_nodes.end (), compare_first_of_node ()); if (m_nodes.size () == 0 || fabs (m_nodes[0].first) > epsilon) { - m_nodes.insert (m_nodes.begin (), std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); + m_nodes.insert (m_nodes.begin (), std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); } else { m_nodes[0].first = 0.0; } - std::vector > >::iterator w = m_nodes.begin (); - std::vector > >::const_iterator nn = m_nodes.begin (); - for (std::vector > >::const_iterator n = m_nodes.begin () + 1; n != m_nodes.end (); ++n) { + std::vector > >::iterator w = m_nodes.begin (); + std::vector > >::const_iterator nn = m_nodes.begin (); + for (std::vector > >::const_iterator n = m_nodes.begin () + 1; n != m_nodes.end (); ++n) { if (fabs (nn->first - n->first) > min_value_interval) { *w++ = *nn; nn = n; @@ -288,7 +256,7 @@ ColorBar::set_nodes (const std::vector 1.0 - min_value_interval) { m_nodes.back ().first = 1.0; } else { - m_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } m_selected = -1; @@ -313,8 +281,8 @@ ColorBar::mousePressEvent (QMouseEvent *event) double xx = double (event->x () - xl) / double (xr - xl); double dmin = 100.0; - std::vector > >::const_iterator pmin = m_nodes.end (); - for (std::vector > >::const_iterator p = m_nodes.begin (); p != m_nodes.end (); ++p) { + std::vector > >::const_iterator pmin = m_nodes.end (); + for (std::vector > >::const_iterator p = m_nodes.begin (); p != m_nodes.end (); ++p) { double d = fabs (p->first - xx); if (d < 0.05 && d < dmin) { dmin = d; @@ -323,9 +291,10 @@ ColorBar::mousePressEvent (QMouseEvent *event) } if (pmin != m_nodes.end ()) { - m_selected = int (std::distance (std::vector > >::const_iterator (m_nodes.begin ()), pmin)); + m_selected = int (std::distance (std::vector > >::const_iterator (m_nodes.begin ()), pmin)); emit selection_changed (); - emit selection_changed (m_nodes [m_selected].second); + std::pair cp = m_nodes [m_selected].second; + emit selection_changed (std::make_pair (QColor (cp.first.rgb ()), QColor (cp.second.rgb ()))); m_dragging = true; update (); } else { @@ -359,13 +328,14 @@ ColorBar::mouseDoubleClickEvent (QMouseEvent *event) double xx = double (event->x () - xl) / double (xr - xl); - std::vector > >::iterator p = std::lower_bound (m_nodes.begin (), m_nodes.end (), std::make_pair (xx, std::make_pair (QColor (), QColor ())), compare_first_of_node ()); + std::vector > >::iterator p = std::lower_bound (m_nodes.begin (), m_nodes.end (), std::make_pair (xx, std::make_pair (lay::Color (), lay::Color ())), compare_first_of_node ()); if (p != m_nodes.begin () && p != m_nodes.end ()) { m_selected = int (std::distance (m_nodes.begin (), p)); - QColor ci = interpolated_color (m_nodes, xx); + lay::Color ci = interpolated_color (m_nodes, xx); m_nodes.insert (p, std::make_pair (xx, std::make_pair (ci, ci))); emit selection_changed (); - emit selection_changed (m_nodes [m_selected].second); + std::pair cp = m_nodes [m_selected].second; + emit selection_changed (std::make_pair (QColor (cp.first.rgb ()), QColor (cp.second.rgb ()))); emit color_mapping_changed (); update (); } @@ -440,9 +410,9 @@ ColorBar::paintEvent (QPaintEvent *) if (xr != xl) { xx = double (x - xl) / double (xr - xl); } - QColor c = interpolated_color (m_nodes, xx); + lay::Color c = interpolated_color (m_nodes, xx); - painter.fillRect (x, yb - hbar, 1, hbar + 1, QBrush (c)); + painter.fillRect (x, yb - hbar, 1, hbar + 1, QBrush (QColor (c.rgb ()))); } @@ -483,3 +453,5 @@ ColorBar::paintEvent (QPaintEvent *) } +#endif + diff --git a/src/img/img/imgWidgets.h b/src/img/img/imgWidgets.h index d0ce8ed63..b44a8e0b0 100644 --- a/src/img/img/imgWidgets.h +++ b/src/img/img/imgWidgets.h @@ -20,10 +20,14 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_imgWidgets #define HDR_imgWidgets #include "layWidgets.h" +#include "layColor.h" +#include "imgObject.h" #include #include @@ -38,13 +42,6 @@ class QPaintEvent; namespace img { -/** - * @brief A helper function to interpolate a color in the color bar at a given x - * - * TODO: move this somewhere else. - */ -QColor interpolated_color (const std::vector > > &nodes, double x); - /** * @brief A two-color widget * @@ -114,9 +111,9 @@ public: return m_selected >= 0; } - void set_nodes (const std::vector > > &nodes); + void set_nodes (const std::vector > > &nodes); - const std::vector > > &nodes () const + const std::vector > > &nodes () const { return m_nodes; } @@ -135,7 +132,7 @@ signals: private: bool m_dragging; int m_selected; - std::vector > > m_nodes; + std::vector > > m_nodes; std::vector m_histogram; }; @@ -143,3 +140,4 @@ private: #endif +#endif diff --git a/src/img/unit_tests/imgFile.cc b/src/img/unit_tests/imgFile.cc index 49719aa02..5daf917f2 100644 --- a/src/img/unit_tests/imgFile.cc +++ b/src/img/unit_tests/imgFile.cc @@ -45,9 +45,9 @@ TEST(1_FloatMono) dm.gamma = 1.5; dm.brightness = 1.25; dm.false_color_nodes.clear (); - dm.false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - dm.false_color_nodes.push_back (std::make_pair (0.5, std::make_pair (QColor (255, 0, 0), QColor (0, 255, 0)))); - dm.false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + dm.false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + dm.false_color_nodes.push_back (std::make_pair (0.5, std::make_pair (lay::Color (255, 0, 0), lay::Color (0, 255, 0)))); + dm.false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); image.set_data_mapping (dm); image.set_pixel (0, 0, 0.25); diff --git a/src/img/unit_tests/imgObject.cc b/src/img/unit_tests/imgObject.cc index 7eaa24198..1dfabda0c 100644 --- a/src/img/unit_tests/imgObject.cc +++ b/src/img/unit_tests/imgObject.cc @@ -101,8 +101,8 @@ TEST(1) dm.red_gain = 1.25; dm.green_gain = 0.75; dm.blue_gain = 2.5; - QColor c (128, 255, 64); - QColor c2 (64, 32, 192); + lay::Color c (128, 255, 64); + lay::Color c2 (64, 32, 192); dm.false_color_nodes.insert (dm.false_color_nodes.begin () + 1, std::make_pair (0.5, std::make_pair (c, c))); image.set_data_mapping (dm); EXPECT_EQ (copy1.equals (&image), false); @@ -226,7 +226,7 @@ TEST(2) dm.red_gain = 1.25; dm.green_gain = 0.75; dm.blue_gain = 2.5; - QColor c (128, 255, 64); + lay::Color c (128, 255, 64); dm.false_color_nodes.insert (dm.false_color_nodes.begin () + 1, std::make_pair (0.5, std::make_pair (c, c))); image.set_data_mapping (dm); EXPECT_EQ (copy1.equals (&image), false); diff --git a/src/klayout.pri b/src/klayout.pri index 1c11043ad..9bf6debac 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -11,8 +11,10 @@ RDB_INC = $$PWD/rdb/rdb IMG_INC = $$PWD/img/img LYM_INC = $$PWD/lym/lym LIB_INC = $$PWD/lib/lib -LAY_INC = $$PWD/lay/lay LAYBASIC_INC = $$PWD/laybasic/laybasic +LAYVIEW_INC = $$PWD/layview/layview +LAYUI_INC = $$PWD/layui/layui +LAY_INC = $$PWD/lay/lay QTBASIC_INC = $$PWD/gsiqt/qtbasic @@ -72,6 +74,15 @@ equals(HAVE_CURL, "1") { DEFINES += HAVE_CURL } +equals(HAVE_PNG, "1") { + !isEmpty(BITS_PATH) { + include($$BITS_PATH/png/png.pri) + } else { + LIBS += -lpng + } + DEFINES += HAVE_PNG +} + equals(HAVE_EXPAT, "1") { !isEmpty(BITS_PATH) { include($$BITS_PATH/expat/expat.pri) diff --git a/src/klayout.pro b/src/klayout.pro index 1cea2a7a7..228db95b3 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -11,19 +11,25 @@ SUBDIRS = \ lib \ plugins \ unit_tests \ + buddies \ + lym \ + laybasic \ + layview \ + ant \ + img \ + edt \ + +equals(HAVE_RUBY, "1") { + SUBDIRS += drc lvs +} !equals(HAVE_QT, "0") { # TODO: make buddies able to build without Qt SUBDIRS += \ klayout_main \ - laybasic \ lay \ - ant \ - buddies \ - lym \ - img \ - edt \ + layui \ fontgen \ } @@ -58,23 +64,35 @@ db.depends += gsi rdb.depends += db lib.depends += db -plugins.depends += lib rdb db +buddies.depends += plugins lym $$LANG_DEPENDS +lym.depends += gsi $$LANG_DEPENDS + +laybasic.depends += rdb +layview.depends += laybasic + +ant.depends += layview +img.depends += layview +edt.depends += layview + +plugins.depends += lib rdb db ant + +equals(HAVE_PYTHON, "1") { + pymod.depends += layview ant img edt lym +} + +equals(HAVE_RUBY, "1") { + MAIN_DEPENDS += drc lvs + drc.depends += rdb lym + lvs.depends += drc + buddies.depends += drc lvs +} !equals(HAVE_QT, "0") { - buddies.depends += plugins lym $$LANG_DEPENDS - equals(HAVE_PYTHON, "1") { pymod.depends += lay } - equals(HAVE_RUBY, "1") { - SUBDIRS += drc lvs - MAIN_DEPENDS += drc lvs - drc.depends += rdb lym - lvs.depends += drc - } - equals(HAVE_QTBINDINGS, "1") { SUBDIRS += gsiqt @@ -87,23 +105,14 @@ plugins.depends += lib rdb db } - plugins.depends += lay ant + layui.depends += laybasic + layview.depends += layui + lay.depends += ant img edt layui - lym.depends += gsi $$LANG_DEPENDS - laybasic.depends += rdb lym - ant.depends += laybasic - img.depends += laybasic - edt.depends += laybasic - - lay.depends += laybasic ant img edt + plugins.depends += lay klayout_main.depends += plugins $$MAIN_DEPENDS } unit_tests.depends += plugins $$MAIN_DEPENDS $$LANG_DEPENDS - -RESOURCES += \ - plugins/tools/import/lay_plugin/layResources.qrc \ - laybasic/laybasic/layResources.qrc - diff --git a/src/lay/lay/lay.pro b/src/lay/lay/lay.pro index dea36e8e7..71bd193f7 100644 --- a/src/lay/lay/lay.pro +++ b/src/lay/lay/lay.pro @@ -56,7 +56,6 @@ HEADERS = \ laySignalHandler.h \ layLibraryController.h \ layFontController.h \ - layNativePlugin.h \ laySystemPaths.h \ layMacroEditorSetupPage.h \ layPasswordDialog.h \ @@ -164,7 +163,6 @@ SOURCES = \ laySignalHandler.cc \ layLibraryController.cc \ layFontController.cc \ - layNativePlugin.cc \ laySystemPaths.cc \ layMacroEditorSetupPage.cc \ layPasswordDialog.cc \ @@ -179,9 +177,9 @@ RESOURCES = layBuildInMacros.qrc \ laySaltTemplates.qrc \ layDRCLVSHelpResources.qrc -INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt +INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_layui -lklayout_ant -lklayout_img -lklayout_edt win32 { # for stack trace support: diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index e28d5589d..2c28187e0 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -55,7 +55,7 @@ public: menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new ClipDialog (root, view); } @@ -66,7 +66,7 @@ static tl::RegisteredClass config_decl (new ClipDialogPl // ------------------------------------------------------------ -ClipDialog::ClipDialog (lay::Dispatcher *root, lay::LayoutView *vw) +ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::ClipDialog () { diff --git a/src/lay/lay/layClipDialog.h b/src/lay/lay/layClipDialog.h index bab730bf9..e84ad2435 100644 --- a/src/lay/lay/layClipDialog.h +++ b/src/lay/lay/layClipDialog.h @@ -40,7 +40,7 @@ class ClipDialog Q_OBJECT public: - ClipDialog (lay::Dispatcher *root, lay::LayoutView *view); + ClipDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~ClipDialog (); public slots: diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 2cc2d500b..458c90afa 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -62,7 +62,7 @@ public: menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new FillDialog (root, view); } @@ -73,8 +73,8 @@ static tl::RegisteredClass config_decl (new FillDialogPl // ------------------------------------------------------------ -FillDialog::FillDialog (lay::Dispatcher *main, lay::LayoutView *view) - : QDialog (view), +FillDialog::FillDialog (lay::Dispatcher *main, LayoutViewBase *view) + : QDialog (view->widget ()), lay::Plugin (main), Ui::FillDialog (), mp_view (view) @@ -315,8 +315,9 @@ FillDialog::get_fill_parameters () } else if (layer_spec_cbx->currentIndex () == 2) { - // selected layers + // get selected layers std::vector s = mp_view->selected_layers (); + for (std::vector::const_iterator l = s.begin (); l != s.end (); ++l) { if (! (*l)->has_children () && cv->layout ().is_valid_layer ((*l)->layer_index ())) { fp.exclude_layers.push_back (cv->layout ().get_properties ((*l)->layer_index ())); diff --git a/src/lay/lay/layFillDialog.h b/src/lay/lay/layFillDialog.h index 52deb5826..faa06851a 100644 --- a/src/lay/lay/layFillDialog.h +++ b/src/lay/lay/layFillDialog.h @@ -76,7 +76,7 @@ class LAY_PUBLIC FillDialog Q_OBJECT public: - FillDialog (lay::Dispatcher *root, lay::LayoutView *view); + FillDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~FillDialog (); public slots: @@ -95,7 +95,7 @@ private: void generate_fill (const FillParameters &fp); FillParameters get_fill_parameters (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/lay/lay/layMacroController.h b/src/lay/lay/layMacroController.h index cae8e979b..707cc44e9 100644 --- a/src/lay/lay/layMacroController.h +++ b/src/lay/lay/layMacroController.h @@ -26,7 +26,7 @@ #include "layCommon.h" #include "layPlugin.h" -#include "lymMacro.h" +#include "lymMacroCollection.h" #include "tlObject.h" #include "tlDeferredExecution.h" #include "tlFileSystemWatcher.h" diff --git a/src/lay/lay/layMacroEditorSetupPage.h b/src/lay/lay/layMacroEditorSetupPage.h index b8a693d7b..b6de86b0d 100644 --- a/src/lay/lay/layMacroEditorSetupPage.h +++ b/src/lay/lay/layMacroEditorSetupPage.h @@ -25,6 +25,7 @@ #define HDR_layMacroEditorSetupPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "ui_MacroEditorSetupPage.h" namespace lay diff --git a/src/lay/lay/layMacroEditorTree.cc b/src/lay/lay/layMacroEditorTree.cc index 544930dd0..a6035d641 100644 --- a/src/lay/lay/layMacroEditorTree.cc +++ b/src/lay/lay/layMacroEditorTree.cc @@ -23,7 +23,7 @@ #include "layMacroEditorTree.h" #include "layMacroEditorDialog.h" -#include "lymMacro.h" +#include "lymMacroCollection.h" #include "tlExceptions.h" #include "tlInternational.h" #include "tlException.h" diff --git a/src/lay/lay/layMainConfigPages.h b/src/lay/lay/layMainConfigPages.h index 7b15fc78f..92d6fe97a 100644 --- a/src/lay/lay/layMainConfigPages.h +++ b/src/lay/lay/layMainConfigPages.h @@ -28,6 +28,7 @@ #include #include "layPlugin.h" +#include "layPluginConfigPage.h" #include diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 77455f3b2..b7bdabddf 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -159,7 +159,7 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled) : QMainWindow (0), tl::Object (), lay::DispatcherDelegate (), - m_dispatcher (this, this), + m_dispatcher (this), m_text_progress (this, 10 /*verbosity threshold*/), m_mode (std::numeric_limits::max ()), mp_setup_form (0), @@ -179,6 +179,8 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled) mp_app (app), m_manager (undo_enabled) { + m_dispatcher.set_menu_parent_widget (this); + // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); @@ -2882,7 +2884,9 @@ MainWindow::close_view (int index) view_closed_event (int (index)); - delete view (index); + // delete the view later as it may still be needed by event handlers or similar + std::unique_ptr old_view (view (index)); + mp_views.erase (mp_views.begin () + index, mp_views.begin () + index + 1); if (index >= int (mp_views.size ())) { diff --git a/src/lay/lay/layNavigator.cc b/src/lay/lay/layNavigator.cc index 20f828626..77b19d25a 100644 --- a/src/lay/lay/layNavigator.cc +++ b/src/lay/lay/layNavigator.cc @@ -72,18 +72,18 @@ public: void background_color_changed () { - QColor c = mp_view->background_color (); + lay::Color c = mp_view->background_color (); // replace by "real" background color if required - if (! c.isValid ()) { - c = mp_view->palette ().color (QPalette::Normal, QPalette::Base); + if (! c.is_valid ()) { + c = lay::Color (mp_view->palette ().color (QPalette::Normal, QPalette::Base).rgb ()); } - QColor contrast; - if (c.green () > 128) { - contrast = QColor (0, 0, 0); + lay::Color contrast; + if (c.to_mono ()) { + contrast = lay::Color (0, 0, 0); } else { - contrast = QColor (255, 255, 255); + contrast = lay::Color (255, 255, 255); } set_colors (c, contrast); @@ -388,7 +388,7 @@ public: widget ()->ungrab_mouse (this); } - void set_colors (QColor /*background*/, QColor color) + void set_colors (lay::Color /*background*/, lay::Color color) { // set zoom box color m_color = color.rgb (); diff --git a/src/lay/lay/laySearchReplaceConfigPage.h b/src/lay/lay/laySearchReplaceConfigPage.h index acf2e3d67..9a7889ae4 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.h +++ b/src/lay/lay/laySearchReplaceConfigPage.h @@ -25,6 +25,7 @@ #define HDR_laySearchReplaceConfigPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "laySearchReplaceDialog.h" #include "ui_SearchReplaceConfigPage.h" diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index f2f46bdb2..76dd57c08 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -699,7 +699,7 @@ fill_ctx_cbx (QComboBox *cbx) cbx->addItem (QObject::tr ("All cells")); } -SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view) +SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view), Ui::SearchReplaceDialog (), mp_view (view), diff --git a/src/lay/lay/laySearchReplaceDialog.h b/src/lay/lay/laySearchReplaceDialog.h index ae0223f85..3ad00e469 100644 --- a/src/lay/lay/laySearchReplaceDialog.h +++ b/src/lay/lay/laySearchReplaceDialog.h @@ -164,7 +164,7 @@ public: std::string text; }; - SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view); + SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~SearchReplaceDialog (); private: @@ -174,7 +174,7 @@ private: // implementation of the lay::Plugin interface void menu_activated (const std::string &symbol); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_mru; std::vector m_saved; int m_current_mode; diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index bc603736d..6c4be161b 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -63,7 +63,7 @@ public: menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new SearchReplaceDialog (root, view); } diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.cc b/src/lay/lay/laySearchReplacePropertiesWidgets.cc index 26263b288..f8aa33081 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.cc +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.cc @@ -320,7 +320,7 @@ class SearchInstanceProperties private Ui::SearchPropertiesInstance { public: - SearchInstanceProperties (QStackedWidget *sw, lay::LayoutView * /*view*/, int /*cv_index*/) + SearchInstanceProperties (QStackedWidget *sw, lay::LayoutViewBase * /*view*/, int /*cv_index*/) : SearchPropertiesWidget (sw) { setupUi (this); @@ -377,7 +377,7 @@ class SearchShapeProperties protected Ui::SearchPropertiesShape { public: - SearchShapeProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchShapeProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -449,7 +449,7 @@ class SearchPolygonProperties : public SearchShapeProperties { public: - SearchPolygonProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchPolygonProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchShapeProperties (sw, view, cv_index) { // .. nothing yet .. @@ -518,7 +518,7 @@ class SearchBoxProperties private Ui::SearchPropertiesBox { public: - SearchBoxProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchBoxProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -593,7 +593,7 @@ class SearchPathProperties private Ui::SearchPropertiesPath { public: - SearchPathProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchPathProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -666,7 +666,7 @@ class SearchTextProperties private Ui::SearchPropertiesText { public: - SearchTextProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchTextProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -748,7 +748,7 @@ class ReplaceInstanceProperties private Ui::ReplacePropertiesInstance { public: - ReplaceInstanceProperties (QStackedWidget *sw, lay::LayoutView * /*view*/, int /*cv_index*/) + ReplaceInstanceProperties (QStackedWidget *sw, lay::LayoutViewBase * /*view*/, int /*cv_index*/) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -787,7 +787,7 @@ class ReplaceShapeProperties protected Ui::ReplacePropertiesShape { public: - ReplaceShapeProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceShapeProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -828,7 +828,7 @@ class ReplacePolygonProperties : public ReplaceShapeProperties { public: - ReplacePolygonProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplacePolygonProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplaceShapeProperties (sw, view, cv_index) { // .. nothing yet .. @@ -867,7 +867,7 @@ class ReplaceBoxProperties private Ui::ReplacePropertiesBox { public: - ReplaceBoxProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceBoxProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -919,7 +919,7 @@ class ReplacePathProperties private Ui::ReplacePropertiesPath { public: - ReplacePathProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplacePathProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -966,7 +966,7 @@ class ReplaceTextProperties private Ui::ReplacePropertiesText { public: - ReplaceTextProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceTextProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -1018,7 +1018,7 @@ public: // ---------------------------------------------------------------------------- -void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) +void fill_find_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) { while (sw->count () > 0) { sw->removeWidget (sw->widget (0)); @@ -1031,7 +1031,7 @@ void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) sw->addWidget (new SearchTextProperties (sw, view, cv_index)); } -void fill_replace_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) +void fill_replace_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) { while (sw->count () > 0) { sw->removeWidget (sw->widget (0)); diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.h b/src/lay/lay/laySearchReplacePropertiesWidgets.h index 0d4b0d235..59c47bfd6 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.h +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.h @@ -86,12 +86,12 @@ public: /** * @brief Fill the given stack widget with pairs of items plus properties widget */ -void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index); +void fill_find_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index); /** * @brief Fill the given stack widget with pairs of items plus properties widget */ -void fill_replace_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index); +void fill_replace_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index); /** * @brief Get an object id from a page index diff --git a/src/lay/lay/laySettingsForm.cc b/src/lay/lay/laySettingsForm.cc index 0b8f64e02..74bf43bc5 100644 --- a/src/lay/lay/laySettingsForm.cc +++ b/src/lay/lay/laySettingsForm.cc @@ -31,6 +31,7 @@ #include "layMainWindow.h" #include "layApplication.h" +#include "layPluginConfigPage.h" #include "tlExceptions.h" #include "tlLog.h" #include "dbHershey.h" diff --git a/src/lay/unit_tests/unit_tests.pro b/src/lay/unit_tests/unit_tests.pro index dc5315166..2452b866f 100644 --- a/src/lay/unit_tests/unit_tests.pro +++ b/src/lay/unit_tests/unit_tests.pro @@ -10,8 +10,8 @@ SOURCES = \ laySalt.cc \ laySessionTests.cc -INCLUDEPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC -DEPENDPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC +INCLUDEPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC +DEPENDPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC -LIBS += -L$$DESTDIR_UT -lklayout_lay -lklayout_laybasic -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_ant -lklayout_img -lklayout_rdb +LIBS += -L$$DESTDIR_UT -lklayout_lay -lklayout_laybasic -lklayout_layui -lklayout_layview -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_ant -lklayout_img -lklayout_rdb diff --git a/src/laybasic/laybasic/gsiDeclLayLayers.cc b/src/laybasic/laybasic/gsiDeclLayLayers.cc index 8fc610bee..ff03eeec6 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayers.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayers.cc @@ -22,7 +22,8 @@ #include "gsiDecl.h" -#include "layLayoutView.h" +#include "layLayerProperties.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -1221,11 +1222,6 @@ Class decl_LayerPropertiesNode ( "\n" "@return A bbox in micron units\n" ) + - method ("view", &lay::LayerPropertiesNode::view, - "@brief Gets the view this node lives in\n" - "\n" - "This reference can be nil if the node is a orphan node that lives outside a view." - ) + method ("list_index", &lay::LayerPropertiesNode::list_index, "@brief Gets the index of the layer properties list that the node lives in\n" ) + diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc similarity index 73% rename from src/laybasic/laybasic/gsiDeclLayLayoutView.cc rename to src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index e5bf11472..b13ae2f36 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -25,7 +25,7 @@ #include "gsiSignals.h" #include "gsiEnums.h" #include "rdb.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layDitherPattern.h" #include "layLineStyles.h" #include "dbSaveLayoutOptions.h" @@ -43,7 +43,7 @@ namespace gsi { -static void remove_stipple (lay::LayoutView *view, unsigned int index) +static void remove_stipple (lay::LayoutViewBase *view, unsigned int index) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -56,13 +56,13 @@ static void remove_stipple (lay::LayoutView *view, unsigned int index) } } -static void clear_stipples (lay::LayoutView *view) +static void clear_stipples (lay::LayoutViewBase *view) { lay::DitherPattern no_stipples; view->set_dither_pattern (no_stipples); } -static unsigned int add_stipple1 (lay::LayoutView *view, const std::string &name, const std::vector &data, unsigned int bits) +static unsigned int add_stipple1 (lay::LayoutViewBase *view, const std::string &name, const std::vector &data, unsigned int bits) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -78,7 +78,7 @@ static unsigned int add_stipple1 (lay::LayoutView *view, const std::string &name return index; } -static unsigned int add_stipple2 (lay::LayoutView *view, const std::string &name, const std::string &s) +static unsigned int add_stipple2 (lay::LayoutViewBase *view, const std::string &name, const std::string &s) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -92,13 +92,13 @@ static unsigned int add_stipple2 (lay::LayoutView *view, const std::string &name return index; } -static std::string get_stipple (lay::LayoutView *view, unsigned int index) +static std::string get_stipple (lay::LayoutViewBase *view, unsigned int index) { lay::DitherPattern pattern (view->dither_pattern ()); return pattern.pattern (index).to_string (); } -static void remove_line_style (lay::LayoutView *view, unsigned int index) +static void remove_line_style (lay::LayoutViewBase *view, unsigned int index) { lay::LineStyles styles (view->line_styles ()); @@ -111,13 +111,13 @@ static void remove_line_style (lay::LayoutView *view, unsigned int index) } } -static void clear_line_styles (lay::LayoutView *view) +static void clear_line_styles (lay::LayoutViewBase *view) { lay::LineStyles no_styles; view->set_line_styles (no_styles); } -static unsigned int add_line_style1 (lay::LayoutView *view, const std::string &name, unsigned int data, unsigned int bits) +static unsigned int add_line_style1 (lay::LayoutViewBase *view, const std::string &name, unsigned int data, unsigned int bits) { lay::LineStyles styles (view->line_styles ()); @@ -131,7 +131,7 @@ static unsigned int add_line_style1 (lay::LayoutView *view, const std::string &n return index; } -static unsigned int add_line_style2 (lay::LayoutView *view, const std::string &name, const std::string &str) +static unsigned int add_line_style2 (lay::LayoutViewBase *view, const std::string &name, const std::string &str) { lay::LineStyles styles (view->line_styles ()); @@ -145,93 +145,93 @@ static unsigned int add_line_style2 (lay::LayoutView *view, const std::string &n return index; } -static std::string get_line_style (lay::LayoutView *view, unsigned int index) +static std::string get_line_style (lay::LayoutViewBase *view, unsigned int index) { return view->line_styles ().style (index).to_string (); } -static void transaction (lay::LayoutView *view, const std::string &desc) +static void transaction (lay::LayoutViewBase *view, const std::string &desc) { view->manager ()->transaction (desc); } -static void commit (lay::LayoutView *view) +static void commit (lay::LayoutViewBase *view) { view->manager ()->commit (); } -static void clear_transactions (lay::LayoutView *view) +static void clear_transactions (lay::LayoutViewBase *view) { view->manager ()->clear (); } -static bool transacting (lay::LayoutView *view) +static bool transacting (lay::LayoutViewBase *view) { return view->manager ()->transacting (); } -static db::DCplxTrans viewport_trans (const lay::LayoutView *view) +static db::DCplxTrans viewport_trans (const lay::LayoutViewBase *view) { return view->viewport ().trans (); } -static int viewport_width (const lay::LayoutView *view) +static int viewport_width (const lay::LayoutViewBase *view) { return view->viewport ().width (); } -static int viewport_height (const lay::LayoutView *view) +static int viewport_height (const lay::LayoutViewBase *view) { return view->viewport ().height (); } -static std::vector selected_cells_paths (const lay::LayoutView *view, int cv_index) +static std::vector selected_cells_paths (const lay::LayoutViewBase *view, int cv_index) { - std::vector p; + std::vector p; view->selected_cells_paths (cv_index, p); return p; } -static unsigned int create_rdb (lay::LayoutView *view, const std::string &name) +static unsigned int create_rdb (lay::LayoutViewBase *view, const std::string &name) { rdb::Database *db = new rdb::Database (); db->set_name (name); return view->add_rdb (db); } -static unsigned int create_l2ndb (lay::LayoutView *view, const std::string &name) +static unsigned int create_l2ndb (lay::LayoutViewBase *view, const std::string &name) { db::LayoutToNetlist *db = new db::LayoutToNetlist (); db->set_name (name); return view->add_l2ndb (db); } -static unsigned int create_lvsdb (lay::LayoutView *view, const std::string &name) +static unsigned int create_lvsdb (lay::LayoutViewBase *view, const std::string &name) { db::LayoutVsSchematic *db = new db::LayoutVsSchematic (); db->set_name (name); return view->add_l2ndb (db); } -static db::LayoutVsSchematic *get_lvsdb (lay::LayoutView *view, unsigned int index) +static db::LayoutVsSchematic *get_lvsdb (lay::LayoutViewBase *view, unsigned int index) { db::LayoutToNetlist *db = view->get_l2ndb (index); return dynamic_cast (db); } -static unsigned int add_lvsdb (lay::LayoutView *view, db::LayoutVsSchematic *lvsdb) +static unsigned int add_lvsdb (lay::LayoutViewBase *view, db::LayoutVsSchematic *lvsdb) { return view->add_l2ndb (lvsdb); } -static unsigned int replace_lvsdb (lay::LayoutView *view, unsigned int db_index, db::LayoutVsSchematic *lvsdb) +static unsigned int replace_lvsdb (lay::LayoutViewBase *view, unsigned int db_index, db::LayoutVsSchematic *lvsdb) { return view->replace_l2ndb (db_index, lvsdb); } // this binding returns a const pointer which is not converted into a copy by RBA -static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutView *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutViewBase *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -241,7 +241,7 @@ static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutView *view, const l } } -static void replace_layer_node2 (lay::LayoutView *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static void replace_layer_node2 (lay::LayoutViewBase *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -251,7 +251,7 @@ static void replace_layer_node2 (lay::LayoutView *view, unsigned int index, cons } } -static void replace_layer_node1 (lay::LayoutView *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static void replace_layer_node1 (lay::LayoutViewBase *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -261,7 +261,7 @@ static void replace_layer_node1 (lay::LayoutView *view, const lay::LayerProperti } } -static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutView *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutViewBase *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -271,7 +271,7 @@ static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutView *view, unsigne } } -static void delete_layers1 (lay::LayoutView *view, const std::vector &iters) +static void delete_layers1 (lay::LayoutViewBase *view, const std::vector &iters) { std::vector sorted (iters); std::sort (sorted.begin (), sorted.end (), lay::CompareLayerIteratorBottomUp ()); @@ -280,7 +280,7 @@ static void delete_layers1 (lay::LayoutView *view, const std::vectorkeep (); @@ -288,7 +288,7 @@ static unsigned int show_layout1 (lay::LayoutView *view, db::Layout *layout, boo return view->add_layout (handle, add_cellview); } -static unsigned int show_layout2 (lay::LayoutView *view, db::Layout *layout, std::string &tech, bool add_cellview) +static unsigned int show_layout2 (lay::LayoutViewBase *view, db::Layout *layout, std::string &tech, bool add_cellview) { // the layout gets held by the LayoutHandle object layout->keep (); @@ -297,7 +297,7 @@ static unsigned int show_layout2 (lay::LayoutView *view, db::Layout *layout, std return view->add_layout (handle, add_cellview); } -static unsigned int show_layout3 (lay::LayoutView *view, db::Layout *layout, std::string &tech, bool add_cellview, bool initialize_layers) +static unsigned int show_layout3 (lay::LayoutViewBase *view, db::Layout *layout, std::string &tech, bool add_cellview, bool initialize_layers) { // the layout gets held by the LayoutHandle object layout->keep (); @@ -306,7 +306,7 @@ static unsigned int show_layout3 (lay::LayoutView *view, db::Layout *layout, std return view->add_layout (handle, add_cellview, initialize_layers); } -static void delete_layers2 (lay::LayoutView *view, unsigned int index, const std::vector &iters) +static void delete_layers2 (lay::LayoutViewBase *view, unsigned int index, const std::vector &iters) { std::vector sorted (iters); std::sort (sorted.begin (), sorted.end (), lay::CompareLayerIteratorBottomUp ()); @@ -315,38 +315,96 @@ static void delete_layers2 (lay::LayoutView *view, unsigned int index, const std } } -static void save_as1 (lay::LayoutView *view, unsigned int index, const std::string &filename, const db::SaveLayoutOptions &options) +static void save_as1 (lay::LayoutViewBase *view, unsigned int index, const std::string &filename, const db::SaveLayoutOptions &options) { view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -static void save_as2 (lay::LayoutView *view, unsigned int index, const std::string &filename, bool /*gzip*/, const db::SaveLayoutOptions &options) +static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::string &filename, bool /*gzip*/, const db::SaveLayoutOptions &options) { // because set_format_from_name always returns true now, we ignore the gzip option - // it's probably used only in that context. view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -#if defined(HAVE_QTBINDINGS) -static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) +static lay::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box) { - return view->get_image_with_options (width, height, linewidth, oversampling, resolution, QColor (), QColor (), QColor (), target_box, monochrome); + return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box); +} + +static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box) +{ + return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box); +} + +static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) +{ + view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); +} + +#if defined(HAVE_QTBINDINGS) +static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) +{ + return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); } #endif -static void save_image_with_options (lay::LayoutView *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) -{ - view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, QColor (), QColor (), QColor (), target_box, monochrome); -} - static std::vector -get_config_names (lay::LayoutView *view) +get_config_names (lay::LayoutViewBase *view) { std::vector names; view->get_config_names (names); return names; } +static void +send_key_press_event (lay::LayoutViewBase *view, unsigned int key, unsigned int buttons) +{ + view->view_object_widget ()->send_key_press_event (key, buttons); +} + +static void +send_mouse_move_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_move_event (pt, buttons); +} + +static void +send_leave_event (lay::LayoutViewBase *view) +{ + view->view_object_widget ()->send_leave_event (); +} + +static void +send_enter_event (lay::LayoutViewBase *view) +{ + view->view_object_widget ()->send_enter_event (); +} + +static void +send_mouse_press_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_press_event (pt, buttons); +} + +static void +send_mouse_double_clicked_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_double_clicked_event (pt, buttons); +} + +static void +send_mouse_release_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_release_event (pt, buttons); +} + +static void +send_wheel_event (lay::LayoutViewBase *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_wheel_event (delta, horizontal, pt, buttons); +} + namespace { /** @@ -393,138 +451,96 @@ namespace { } -static LayerPropertiesConstIteratorWrapper each_layer (lay::LayoutView *view) +static LayerPropertiesConstIteratorWrapper each_layer (lay::LayoutViewBase *view) { return LayerPropertiesConstIteratorWrapper (view->begin_layers ()); } -static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutView *view, unsigned int list_index) +static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutViewBase *view, unsigned int list_index) { return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index)); } -#if defined(HAVE_QTBINDINGS) -static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) -{ - lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); - if (parent) { - // transfer ownership to the parent - lv->keep (); - } - return lv; -} +#if defined(HAVE_QT) +LAYBASIC_PUBLIC Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", +#else +LAYBASIC_PUBLIC Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", #endif - -static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) -{ - return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, 0 /*parent*/, "view", options); -} - -Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", -#if defined(HAVE_QTBINDINGS) - gsi::constructor ("new", &new_view, gsi::arg ("parent"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), - "@brief Creates a standalone view\n" - "\n" - "This constructor is for special purposes only. To create a view in the context of a main window, " - "use \\MainWindow#create_view and related methods.\n" - "\n" - "@param parent The parent widget in which to embed the view\n" - "@param editable True to make the view editable\n" - "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants\n" - "\n" - "This constructor has been introduced in version 0.25.\n" - "It has been enhanced with the arguments in version 0.27.\n" - ) + -#endif - gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), - "@brief Creates a standalone view\n" - "\n" - "This constructor is for special purposes only. To create a view in the context of a main window, " - "use \\MainWindow#create_view and related methods.\n" - "\n" - "@param editable True to make the view editable\n" - "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants\n" - "\n" - "This constructor has been introduced in version 0.25.\n" - "It has been enhanced with the arguments in version 0.27.\n" - ) + - gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutView::LV_NoLayers, + gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutViewBase::LV_NoLayers, "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutView::LV_NoHierarchyPanel, + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutViewBase::LV_NoHierarchyPanel, "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutView::LV_NoLibrariesView, + gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutViewBase::LV_NoLibrariesView, "@brief With this option, no library view will be provided (see \\libraries_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutView::LV_NoEditorOptionsPanel, + gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutViewBase::LV_NoEditorOptionsPanel, "@brief With this option, no editor options panel will be provided (see \\editor_options_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView, + gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutViewBase::LV_NoBookmarksView, "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_Naked", (unsigned int) lay::LayoutView::LV_Naked, + gsi::constant ("LV_Naked", (unsigned int) lay::LayoutViewBase::LV_Naked, "@brief With this option, no separate views will be provided\n" "Use this value with the constructor's 'options' argument.\n" "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutView::LV_NoZoom, + gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutViewBase::LV_NoZoom, "@brief With this option, zooming is disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutView::LV_NoGrid, + gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutViewBase::LV_NoGrid, "@brief With this option, the grid background is not shown\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutView::LV_NoMove, + gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutViewBase::LV_NoMove, "@brief With this option, move operations are not supported\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutView::LV_NoTracker, + gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutViewBase::LV_NoTracker, "@brief With this option, mouse position tracking is not supported\n" "Use this value with the constructor's 'options' argument.\n" "This option is not useful currently as no mouse tracking support is provided.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutView::LV_NoSelection, + gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutViewBase::LV_NoSelection, "@brief With this option, objects cannot be selected\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutView::LV_NoPlugins, + gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutViewBase::LV_NoPlugins, "@brief With this option, all plugins are disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutView::LV_NoServices, + gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutViewBase::LV_NoServices, "@brief This option disables all services except the ones for pure viewing\n" "Use this value with the constructor's 'options' argument.\n" "With this option, all manipulation features are disabled, except zooming.\n" @@ -532,62 +548,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This constant has been introduced in version 0.27.\n" ) + -#if defined(HAVE_QTBINDINGS) - gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame, - "@brief Gets the layer control side widget\n" - "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " - "embed it into a different context. Please note that with embedding through 'setParent' it will be " - "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" - "\n" - "The side widget can be configured through the views configuration interface.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame, - "@brief Gets the cell view (hierarchy view) side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame, - "@brief Gets the library view side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame, - "@brief Gets the bookmarks side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + -#endif - gsi::method ("call_menu", &lay::LayoutView::menu_activated, + gsi::method ("call_menu", static_cast (&lay::LayoutViewBase::menu_activated), "@brief Calls the menu item with the provided symbol.\n" "To obtain all symbols, use get_menu_symbols.\n" "\n" "This method has been introduced in version 0.27." ) + - gsi::method ("menu_symbols", &lay::LayoutView::menu_symbols, + gsi::method ("menu_symbols", &lay::LayoutViewBase::menu_symbols, "@brief Gets all available menu symbols (see \\call_menu).\n" "NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n" "\n" "This method has been introduced in version 0.27." ) + - gsi::method ("current", &lay::LayoutView::current, - "@brief Returns the current view\n" - "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" - "\n" - "This method has been introduced in version 0.23.\n" - ) + - gsi::method ("stop_redraw", &lay::LayoutView::stop_redraw, + gsi::method ("stop_redraw", static_cast (&lay::LayoutViewBase::stop_redraw), "@brief Stops the redraw thread\n" "\n" "It is very important to stop the redraw thread before applying changes to the " "layout or the cell views and the LayoutView configuration. This is usually done automatically. " "For rare cases, where this is not the case, this method is provided.\n" ) + - gsi::method ("title=|#set_title", &lay::LayoutView::set_title, gsi::arg ("title"), + gsi::method ("title=|#set_title", static_cast (&lay::LayoutViewBase::set_title), gsi::arg ("title"), "@brief Sets the title of the view\n" "\n" "@param title The title string to use\n" @@ -596,12 +576,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "the specified title string. The title string can be reset with \\reset_title to " "the standard title again." ) + - gsi::method ("reset_title", &lay::LayoutView::reset_title, + gsi::method ("reset_title", static_cast (&lay::LayoutViewBase::reset_title), "@brief Resets the title to the standard title\n" "\n" "See \\set_title and \\title for a description about how titles are handled." ) + - gsi::method ("title", &lay::LayoutView::title, + gsi::method ("title", static_cast (&lay::LayoutViewBase::title), "@brief Returns the view's title string\n" "\n" "@return The title string\n" @@ -609,19 +589,19 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The title string is either a string composed of the file names loaded (in some " "\"readable\" manner) or a customized title string set by \\set_title." ) + - gsi::method ("save_layer_props", &lay::LayoutView::save_layer_props, gsi::arg ("fn"), + gsi::method ("save_layer_props", static_cast (&lay::LayoutViewBase::save_layer_props), gsi::arg ("fn"), "@brief Saves the layer properties\n" "\n" "Save the layer properties to the file given in \"fn\"" ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), "@brief Loads the layer properties\n" "\n" "@param fn The file name of the .lyp file to load\n" "\n" "Load the layer properties from the file given in \"fn\"" ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &, bool)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -633,7 +613,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &, int, bool)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -651,7 +631,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("min_hier_levels=", &lay::LayoutView::set_min_hier_levels, gsi::arg ("level"), + gsi::method ("min_hier_levels=", static_cast (&lay::LayoutViewBase::set_min_hier_levels), gsi::arg ("level"), "@brief Sets the minimum hierarchy level at which to display geometries\n" "\n" "@param level The minimum level above which to display something\n" @@ -659,12 +639,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the minimum hierarchy level above which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("min_hier_levels", &lay::LayoutView::get_min_hier_levels, + gsi::method ("min_hier_levels", static_cast (&lay::LayoutViewBase::get_min_hier_levels), "@brief Returns the minimum hierarchy level at which to display geometries\n" "\n" "@return The minimum level at which to display geometries" ) + - gsi::method ("max_hier_levels=", &lay::LayoutView::set_max_hier_levels, gsi::arg ("level"), + gsi::method ("max_hier_levels=", static_cast (&lay::LayoutViewBase::set_max_hier_levels), gsi::arg ("level"), "@brief Sets the maximum hierarchy level up to which to display geometries\n" "\n" "@param level The maximum level below which to display something\n" @@ -672,12 +652,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the maximum hierarchy below which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("max_hier_levels", &lay::LayoutView::get_max_hier_levels, + gsi::method ("max_hier_levels", static_cast (&lay::LayoutViewBase::get_max_hier_levels), "@brief Returns the maximum hierarchy level up to which to display geometries\n" "\n" "@return The maximum level up to which to display geometries" ) + - gsi::method ("enable_edits", &lay::LayoutView::enable_edits, gsi::arg ("enable"), + gsi::method ("enable_edits", static_cast (&lay::LayoutViewBase::enable_edits), gsi::arg ("enable"), "@brief Enables or disables edits\n" "\n" "@param enable Enable edits if set to true\n" @@ -690,17 +670,17 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "In 0.25, this method has been moved from MainWindow to LayoutView.\n" ) + - gsi::method ("is_editable?", &lay::LayoutView::is_editable, + gsi::method ("is_editable?", static_cast (&lay::LayoutViewBase::is_editable), "@brief Returns true if the view is in editable mode\n" "\n" "This read-only attribute has been added in version 0.27.5.\n" ) + - gsi::method ("reload_layout", &lay::LayoutView::reload_layout, gsi::arg ("cv"), + gsi::method ("reload_layout", static_cast (&lay::LayoutViewBase::reload_layout), gsi::arg ("cv"), "@brief Reloads the given cellview\n" "\n" "@param cv The index of the cellview to reload" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (bool)) &lay::LayoutView::create_layout, gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("add_cellview"), "@brief Creates a new, empty layout\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -710,7 +690,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview created.\n" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (const std::string &, bool)) &lay::LayoutView::create_layout, gsi::arg ("tech"), gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -720,7 +700,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been introduced in version 0.22.\n" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (const std::string &, bool, bool)) &lay::LayoutView::create_layout, gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -778,12 +758,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.22.\n" ) + - gsi::method ("erase_cellview", &lay::LayoutView::erase_cellview, gsi::arg ("index"), + gsi::method ("erase_cellview", static_cast (&lay::LayoutViewBase::erase_cellview), gsi::arg ("index"), "@brief Erases the cellview with the given index\n" "\n" "This closes the given cellview and unloads the layout associated with it, unless referred to by another cellview." ) + - gsi::method ("rename_cellview", &lay::LayoutView::rename_cellview, gsi::arg ("name"), gsi::arg ("index"), + gsi::method ("rename_cellview", static_cast (&lay::LayoutViewBase::rename_cellview), gsi::arg ("name"), gsi::arg ("index"), "@brief Renames the cellview with the given index\n" "\n" "If the name is not unique, a unique name will be constructed from the name given.\n" @@ -791,7 +771,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a layout is shared between multiple cellviews (which may happen due to a clone of the layout view\n" "for example), all cellviews are renamed.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -803,7 +783,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const db::LoadLayoutOptions &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -815,7 +795,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.18.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const std::string &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -826,7 +806,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &filename, bool add_cellview)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -835,7 +815,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview loaded.\n" ) + - gsi::method ("active_cellview", &lay::LayoutView::active_cellview_ref, + gsi::method ("active_cellview", static_cast (&lay::LayoutViewBase::active_cellview_ref), "@brief Gets the active cellview (shown in hierarchy browser)\n" "\n" "This is a convenience method which is equivalent to cellview(active_cellview_index()).\n" @@ -844,10 +824,10 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting from version 0.25, the returned object can be manipulated which will have an immediate effect " "on the display." ) + - gsi::method ("active_cellview_index", &lay::LayoutView::active_cellview_index, + gsi::method ("active_cellview_index", static_cast (&lay::LayoutViewBase::active_cellview_index), "@brief Gets the index of the active cellview (shown in hierarchy browser)\n" ) + - gsi::method ("active_setview_index=|#set_active_cellview_index", &lay::LayoutView::set_active_cellview_index, gsi::arg ("index"), + gsi::method ("active_setview_index=|#set_active_cellview_index", &lay::LayoutViewBase::set_active_cellview_index, gsi::arg ("index"), "@brief Makes the cellview with the given index the active one (shown in hierarchy browser)\n" "See \\active_cellview_index.\n" "\n" @@ -865,7 +845,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has be introduced in version 0.25.\n" ) + - gsi::method ("#get_current_cell_path", &lay::LayoutView::get_current_cell_path, gsi::arg ("cv_index"), + gsi::method ("#get_current_cell_path", static_cast (&lay::LayoutViewBase::get_current_cell_path), gsi::arg ("cv_index"), "@brief Gets the cell path of the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The \n" @@ -876,7 +856,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("#set_current_cell_path", (void (lay::LayoutView::*) (int, const lay::LayoutView::cell_path_type &)) &lay::LayoutView::set_current_cell_path, gsi::arg ("cv_index"), gsi::arg ("cell_path"), + gsi::method ("#set_current_cell_path", static_cast (&lay::LayoutViewBase::set_current_cell_path), gsi::arg ("cv_index"), gsi::arg ("cell_path"), "@brief Sets the path to the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The\n" @@ -888,10 +868,10 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("cellviews", &lay::LayoutView::cellviews, + gsi::method ("cellviews", static_cast (&lay::LayoutViewBase::cellviews), "@brief Gets the number of cellviews\n" ) + - gsi::method ("cellview", &lay::LayoutView::cellview_ref, gsi::arg ("cv_index"), + gsi::method ("cellview", static_cast (&lay::LayoutViewBase::cellview_ref), gsi::arg ("cv_index"), "@brief Gets the cellview object for a given index\n" "\n" "@param cv_index The cellview index for which to get the object for\n" @@ -899,43 +879,43 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting with version 0.25, this method returns a \\CellView object that can be manipulated to directly reflect " "any changes in the display." ) + - gsi::method ("zoom_fit", &lay::LayoutView::zoom_fit, + gsi::method ("zoom_fit", static_cast (&lay::LayoutViewBase::zoom_fit), "@brief Fits the contents of the current view into the window" ) + - gsi::method ("zoom_fit_sel", &lay::LayoutView::zoom_fit_sel, + gsi::method ("zoom_fit_sel", static_cast (&lay::LayoutViewBase::zoom_fit_sel), "@brief Fits the contents of the current selection into the window\n" "\n" "This method has been introduced in version 0.25.\n" ) + - gsi::method ("zoom_box", &lay::LayoutView::zoom_box, gsi::arg ("box"), + gsi::method ("zoom_box", static_cast (&lay::LayoutViewBase::zoom_box), gsi::arg ("box"), "@brief Sets the viewport to the given box\n" "\n" "@param box The box to which to set the view in micron coordinates\n" ) + - gsi::method ("zoom_in", &lay::LayoutView::zoom_in, + gsi::method ("zoom_in", static_cast (&lay::LayoutViewBase::zoom_in), "@brief Zooms in somewhat" ) + - gsi::method ("zoom_out", &lay::LayoutView::zoom_out, + gsi::method ("zoom_out", static_cast (&lay::LayoutViewBase::zoom_out), "@brief Zooms out somewhat" ) + - gsi::method ("pan_up", &lay::LayoutView::pan_up, + gsi::method ("pan_up", static_cast (&lay::LayoutViewBase::pan_up), "@brief Pans upward" ) + - gsi::method ("pan_down", &lay::LayoutView::pan_down, + gsi::method ("pan_down", static_cast (&lay::LayoutViewBase::pan_down), "@brief Pans down" ) + - gsi::method ("pan_left", &lay::LayoutView::pan_left, + gsi::method ("pan_left", static_cast (&lay::LayoutViewBase::pan_left), "@brief Pans to the left" ) + - gsi::method ("pan_right", &lay::LayoutView::pan_right, + gsi::method ("pan_right", static_cast (&lay::LayoutViewBase::pan_right), "@brief Pans to the right" ) + - gsi::method ("pan_center", &lay::LayoutView::pan_center, gsi::arg ("p"), + gsi::method ("pan_center", static_cast (&lay::LayoutViewBase::pan_center), gsi::arg ("p"), "@brief Pans to the given point\n" "\n" "The window is positioned such that \"p\" becomes the new center" ) + - gsi::method ("box", &lay::LayoutView::box, + gsi::method ("box", static_cast (&lay::LayoutViewBase::box), "@brief Returns the displayed box in micron space" ) + gsi::method_ext ("viewport_trans", &viewport_trans, @@ -953,20 +933,15 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@brief Return the viewport height in pixels\n" "This method was introduced in version 0.18.\n" ) + - gsi::method ("bookmark_view", &lay::LayoutView::bookmark_view, gsi::arg ("name"), - "@brief Bookmarks the current view under the given name\n" - "\n" - "@param name The name under which to bookmark the current state" - ) + - gsi::method ("add_missing_layers", &lay::LayoutView::add_missing_layers, + gsi::method ("add_missing_layers", static_cast (&lay::LayoutViewBase::add_missing_layers), "@brief Adds new layers to layer list\n" "This method was introduced in version 0.19.\n" ) + - gsi::method ("remove_unused_layers", &lay::LayoutView::remove_unused_layers, + gsi::method ("remove_unused_layers", static_cast (&lay::LayoutViewBase::remove_unused_layers), "@brief Removes unused layers from layer list\n" "This method was introduced in version 0.19.\n" ) + - gsi::method ("init_layer_properties", (void (lay::LayoutView::*) (lay::LayerProperties &) const) &lay::LayoutView::init_layer_properties, gsi::arg ("props"), + gsi::method ("init_layer_properties", (void (lay::LayoutViewBase::*) (lay::LayerProperties &) const) &lay::LayoutViewBase::init_layer_properties, gsi::arg ("props"), "@brief Fills the layer properties for a new layer\n" "\n" "This method initializes a layer properties object's color and stipples according to " @@ -977,24 +952,24 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@param props The layer properties object to initialize." ) + - gsi::method ("cancel", &lay::LayoutView::cancel, + gsi::method ("cancel", &lay::LayoutViewBase::cancel, "@brief Cancels all edit operations\n" "\n" "This method will stop all pending edit operations (i.e. drag and drop) and cancel the current " "selection. Calling this method is useful to ensure there are no potential interactions with the script's " "functionality.\n" ) + - gsi::method ("clear_selection", (void (lay::LayoutView::*) ()) &lay::LayoutView::clear_selection, + gsi::method ("clear_selection", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::clear_selection, "@brief Clears the selection of all objects (shapes, annotations, images ...)\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("select_all", (void (lay::LayoutView::*) ()) &lay::LayoutView::select, + gsi::method ("select_all", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::select, "@brief Selects all objects from the view\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("select_from", (void (lay::LayoutView::*) (const db::DPoint &, lay::Editable::SelectionMode)) &lay::LayoutView::select, gsi::arg ("point"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), + gsi::method ("select_from", (void (lay::LayoutViewBase::*) (const db::DPoint &, lay::Editable::SelectionMode)) &lay::LayoutViewBase::select, gsi::arg ("point"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), "@brief Selects the objects from a given point\n" "\n" "The mode indicates whether to add to the selection, replace the selection, remove from selection or invert the selected status of the objects " @@ -1002,7 +977,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("select_from", (void (lay::LayoutView::*) (const db::DBox &, lay::Editable::SelectionMode)) &lay::LayoutView::select, gsi::arg ("box"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), + gsi::method ("select_from", (void (lay::LayoutViewBase::*) (const db::DBox &, lay::Editable::SelectionMode)) &lay::LayoutViewBase::select, gsi::arg ("box"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), "@brief Selects the objects from a given box\n" "\n" "The mode indicates whether to add to the selection, replace the selection, remove from selection or invert the selected status of the objects " @@ -1010,12 +985,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("clear_transient_selection", &lay::LayoutView::clear_transient_selection, + gsi::method ("clear_transient_selection", static_cast (&lay::LayoutViewBase::clear_transient_selection), "@brief Clears the transient selection (mouse-over hightlights) of all objects (shapes, annotations, images ...)\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("transient_to_selection", &lay::LayoutView::transient_to_selection, + gsi::method ("transient_to_selection", static_cast (&lay::LayoutViewBase::transient_to_selection), "@brief Turns the transient selection into the actual selection\n" "\n" "The current selection is cleared before. All highlighted objects under the mouse will become selected. " @@ -1023,26 +998,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("selection_bbox", &lay::LayoutView::selection_bbox, + gsi::method ("selection_bbox", static_cast (&lay::LayoutViewBase::selection_bbox), "@brief Returns the bounding box of the current selection\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("selection_size", (size_t (lay::LayoutView::*) ()) &lay::LayoutView::selection_size, + gsi::method ("selection_size", (size_t (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::selection_size, "@brief Returns the number of selected objects\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("has_selection?", (bool (lay::LayoutView::*) ()) &lay::LayoutView::has_selection, + gsi::method ("has_selection?", (bool (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::has_selection, "@brief Indicates whether any objects are selected\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("stop", &lay::LayoutView::stop, + gsi::method ("stop", static_cast (&lay::LayoutViewBase::stop), "@brief Stops redraw thread and close any browsers\n" "This method usually does not need to be called explicitly. The redraw thread is stopped automatically." ) + - gsi::method ("#select_cell_path", (void (lay::LayoutView::*) (const lay::LayoutView::cell_path_type &, int)) &lay::LayoutView::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("#select_cell_path", (void (lay::LayoutViewBase::*) (const lay::LayoutViewBase::cell_path_type &, int)) &lay::LayoutViewBase::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Selects a cell by cell index for a certain cell view\n" "\n" "Select the current (top) cell by specifying a cell indexand the cellview index for which this cell should become the currently shown one. The path to the cell is constructed by " @@ -1052,7 +1027,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("#select_cell", (void (lay::LayoutView::*) (lay::LayoutView::cell_index_type, int)) &lay::LayoutView::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("#select_cell", (void (lay::LayoutViewBase::*) (lay::LayoutViewBase::cell_index_type, int)) &lay::LayoutViewBase::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Selects a cell by index for a certain cell view\n" "\n" "Select the current (top) cell by specifying a path (a list of cell indices from top to " @@ -1063,7 +1038,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("descend", &lay::LayoutView::descend, gsi::arg ("path"), gsi::arg ("index"), + gsi::method ("descend", static_cast &, int)> (&lay::LayoutViewBase::descend), gsi::arg ("path"), gsi::arg ("index"), "@brief Descends further into the hierarchy.\n" "\n" "Adds the given path (given as an array of InstElement objects) to the specific path of the " @@ -1073,33 +1048,33 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The path is assumed to originate from the current cell and contain specific instances sorted from " "top to bottom." ) + - gsi::method ("ascend", &lay::LayoutView::ascend, gsi::arg ("index"), + gsi::method ("ascend", static_cast (&lay::LayoutViewBase::ascend), gsi::arg ("index"), "@brief Ascends upwards in the hierarchy.\n" "\n" "Removes one element from the specific path of the cellview with the given index. Returns the element " "removed." ) + - gsi::method ("is_cell_hidden?", &lay::LayoutView::is_cell_hidden, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("is_cell_hidden?", static_cast (&lay::LayoutViewBase::is_cell_hidden), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Returns true, if the cell is hidden\n" "\n" "@return True, if the cell with \"cell_index\" is hidden for the cellview \"cv_index\"" ) + - gsi::method ("hide_cell", &lay::LayoutView::hide_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("hide_cell", static_cast (&lay::LayoutViewBase::hide_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Hides the given cell for the given cellview\n" ) + - gsi::method ("show_cell", &lay::LayoutView::show_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("show_cell", static_cast (&lay::LayoutViewBase::show_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Shows the given cell for the given cellview (cancel effect of \\hide_cell)\n" ) + - gsi::method ("show_all_cells", (void (lay::LayoutView::*) ()) &lay::LayoutView::show_all_cells, + gsi::method ("show_all_cells", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::show_all_cells, "@brief Makes all cells shown (cancel effects of \\hide_cell)" ) + - gsi::method ("show_all_cells", (void (lay::LayoutView::*) (int)) &lay::LayoutView::show_all_cells, gsi::arg ("cv_index"), + gsi::method ("show_all_cells", (void (lay::LayoutViewBase::*) (int)) &lay::LayoutViewBase::show_all_cells, gsi::arg ("cv_index"), "@brief Makes all cells shown (cancel effects of \\hide_cell) for the specified cell view\n" "Unlike \\show_all_cells, this method will only clear the hidden flag on the cell view selected by \\cv_index.\n" "\n" "This variant has been added in version 0.25." ) + - gsi::method ("update_content", &lay::LayoutView::force_update_content, + gsi::method ("update_content", static_cast (&lay::LayoutViewBase::force_update_content), "@brief Updates the layout view to the current state\n" "\n" "This method triggers an update of the hierarchy tree and layer view tree. Usually, this " @@ -1108,21 +1083,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Currently, this method should be called however, after the layer view tree has been changed by " "the \\insert_layer, \\replace_layer_node or \\delete_layer methods.\n" ) + - gsi::method ("max_hier", &lay::LayoutView::max_hier, + gsi::method ("max_hier", static_cast (&lay::LayoutViewBase::max_hier), "@brief Selects all hierarchy levels available\n" "\n" "Show the layout in full depth down to the deepest level of hierarchy. " "This method may cause a redraw." ) + -#if defined(HAVE_QTBINDINGS) - gsi::method ("get_screenshot", &lay::LayoutView::get_screenshot, + gsi::method ("resize", static_cast (&lay::LayoutViewBase::resize), + "@brief Resizes the layout view to the given dimension\n" + "\n" + "This method has been made available in all builds in 0.28.\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method ("get_screenshot", static_cast (&lay::LayoutViewBase::get_screenshot), "@brief Gets a screenshot as a \\QImage\n" "\n" "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("get_image", &lay::LayoutView::get_image, gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("get_image", static_cast (&lay::LayoutViewBase::get_image), gsi::arg ("width"), gsi::arg ("height"), "@brief Gets the layout image as a \\QImage\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1131,7 +1111,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image contains the current scene (layout, annotations etc.).\n" "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + - gsi::method_ext ("get_image_with_options", &get_image_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), + gsi::method_ext ("get_image_with_options", &get_image_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), gsi::arg ("monochrome", false), "@brief Gets the layout image as a \\QImage (with options)\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1143,14 +1123,62 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@param monochrome If true, monochrome images will be produced.\n" "\n" "The image contains the current scene (layout, annotations etc.).\n" - "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " "Monochrome images don't have background or annotation objects currently.\n" "\n" "This method has been introduced in 0.23.10.\n" ) + #endif - gsi::method ("save_screenshot", &lay::LayoutView::save_screenshot, gsi::arg ("filename"), + gsi::method ("get_screenshot_pixels", static_cast (&lay::LayoutViewBase::get_screenshot_pb), + "@brief Gets a screenshot as a \\PixelBuffer\n" + "\n" + "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " + "for the application to guarantee this condition. The image will have the size of the viewport " + "showing the current layout." + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method ("get_pixels", static_cast (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"), + "@brief Gets the layout image as a \\PixelBuffer\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method_ext ("get_pixels_with_options", &get_pixels_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), + "@brief Gets the layout image as a \\PixelBuffer (with options)\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "@param linewidth The width of a line in pixels (usually 1) or 0 for default.\n" + "@param oversampling The oversampling factor (1..3) or 0 for default.\n" + "@param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default.\n" + "@param target_box The box to draw or an empty box for default.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method_ext ("get_pixels_with_options_mono", &get_pixels_with_options_mono, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("target", db::DBox (), "current"), + "@brief Gets the layout image as a \\PixelBuffer (with options)\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "@param linewidth The width of a line in pixels (usually 1) or 0 for default.\n" + "@param target_box The box to draw or an empty box for default.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "Monochrome images don't have background or annotation objects currently.\n" + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method ("save_screenshot", static_cast (&lay::LayoutViewBase::save_screenshot), gsi::arg ("filename"), "@brief Saves a screenshot to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1160,7 +1188,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("save_image", &lay::LayoutView::save_image, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("save_image", static_cast (&lay::LayoutViewBase::save_image), gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), "@brief Saves the layout as an image to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1171,7 +1199,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + - gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), + gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), gsi::arg ("monochrome", false), "@brief Saves the layout as an image to the given file (with options)\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1221,13 +1249,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If the file name ends with a suffix \".gz\" or \".gzip\", the file is compressed with the zlib " "algorithm.\n" ) + - gsi::method ("set_layer_properties", (void (lay::LayoutView::*) (const lay::LayerPropertiesConstIterator &, const lay::LayerProperties &)) &lay::LayoutView::set_properties, gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutViewBase::set_properties), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " "given by \"props\". It will not change the hierarchy but just the properties of the given node." ) + - gsi::method ("set_layer_properties", (void (lay::LayoutView::*) (unsigned int index, const lay::LayerPropertiesConstIterator &, const lay::LayerProperties &)) &lay::LayoutView::set_properties, gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutViewBase::set_properties), gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " @@ -1235,7 +1263,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("expand_layer_properties", (void (lay::LayoutView::*) ()) &lay::LayoutView::expand_properties, + gsi::method ("expand_layer_properties", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::expand_properties, "@brief Expands the layer properties for all tabs\n" "\n" "This method will expand all wildcard specifications in the layer properties by iterating over the specified objects (i.e. layers, cellviews) and " @@ -1243,7 +1271,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method was introduced in version 0.21.\n" ) + - gsi::method ("expand_layer_properties", (void (lay::LayoutView::*) (unsigned int)) &lay::LayoutView::expand_properties, gsi::arg ("index"), + gsi::method ("expand_layer_properties", (void (lay::LayoutViewBase::*) (unsigned int)) &lay::LayoutViewBase::expand_properties, gsi::arg ("index"), "@brief Expands the layer properties for the given tab\n" "\n" "This method will expand all wildcard specifications in the layer properties by iterating over the specified objects (i.e. layers, cellviews) and " @@ -1308,13 +1336,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.22.\n" ) + - gsi::method ("delete_layer", (void (lay::LayoutView::*) (lay::LayerPropertiesConstIterator &iter)) &lay::LayoutView::delete_layer, gsi::arg ("iter"), + gsi::method ("delete_layer", (void (lay::LayoutViewBase::*) (lay::LayerPropertiesConstIterator &iter)) &lay::LayoutViewBase::delete_layer, gsi::arg ("iter"), "@brief Deletes the layer properties node specified by the iterator\n" "\n" "This method deletes the object that the iterator points to and invalidates\n" "the iterator since the object that the iterator points to is no longer valid.\n" ) + - gsi::method ("delete_layer", (void (lay::LayoutView::*) (unsigned int index, lay::LayerPropertiesConstIterator &iter)) &lay::LayoutView::delete_layer, gsi::arg ("index"), gsi::arg ("iter"), + gsi::method ("delete_layer", (void (lay::LayoutViewBase::*) (unsigned int index, lay::LayerPropertiesConstIterator &iter)) &lay::LayoutViewBase::delete_layer, gsi::arg ("index"), gsi::arg ("iter"), "@brief Deletes the layer properties node specified by the iterator\n" "\n" "This method deletes the object that the iterator points to and invalidates\n" @@ -1330,7 +1358,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "apply changes to the layer settings or even the hierarchy of layers:\n" "\n" "@code\n" - "RBA::LayoutView::current.each_layer do |lref|\n" + "RBA::LayoutViewBase::current.each_layer do |lref|\n" " # lref is a RBA::LayerPropertiesNodeRef object\n" " lref.visible = false\n" "end\n" @@ -1347,7 +1375,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method was introduced in version 0.25." ) + - gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) () const) &lay::LayoutView::begin_layers, + gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) () const) &lay::LayoutViewBase::begin_layers, "@brief Begin iterator for the layers\n" "\n" "This iterator delivers the layers of this view, either in a recursive or non-recursive\n" @@ -1358,11 +1386,11 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting from version 0.25, an alternative solution is provided with 'each_layer' which is based on the " "\\LayerPropertiesNodeRef class." ) + - gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) () const) &lay::LayoutView::end_layers, + gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) () const) &lay::LayoutViewBase::end_layers, "@brief End iterator for the layers\n" "See \\begin_layers for a description about this iterator\n" ) + - gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) (unsigned int index) const) &lay::LayoutView::begin_layers, gsi::arg ("index"), + gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) (unsigned int index) const) &lay::LayoutViewBase::begin_layers, gsi::arg ("index"), "@brief Begin iterator for the layers\n" "\n" "This iterator delivers the layers of this view, either in a recursive or non-recursive\n" @@ -1372,44 +1400,44 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) (unsigned int index) const) &lay::LayoutView::end_layers, gsi::arg ("index"), + gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) (unsigned int index) const) &lay::LayoutViewBase::end_layers, gsi::arg ("index"), "@brief End iterator for the layers\n" "See \\begin_layers for a description about this iterator\n" "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("clear_layers", (void (lay::LayoutView::*) ()) &lay::LayoutView::clear_layers, + gsi::method ("clear_layers", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::clear_layers, "@brief Clears all layers\n" ) + - gsi::method ("clear_layers", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::clear_layers, gsi::arg ("index"), + gsi::method ("clear_layers", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::clear_layers, gsi::arg ("index"), "@brief Clears all layers for the given layer properties list\n" "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("delete_layer_list", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::delete_layer_list, gsi::arg ("index"), + gsi::method ("delete_layer_list", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::delete_layer_list, gsi::arg ("index"), "@brief Deletes the given properties list\n" "At least one layer properties list must remain. This method may change the current properties list.\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("insert_layer_list", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::insert_layer_list, gsi::arg ("index"), + gsi::method ("insert_layer_list", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::insert_layer_list, gsi::arg ("index"), "@brief Inserts a new layer properties list at the given index\n" "This method inserts a new tab at the given position. The current layer properties list will be changed to " "the new list.\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("num_layer_lists", &lay::LayoutView::layer_lists, + gsi::method ("num_layer_lists", static_cast (&lay::LayoutViewBase::layer_lists), "@brief Gets the number of layer properties tabs present\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("current_layer_list", &lay::LayoutView::current_layer_list, + gsi::method ("current_layer_list", static_cast (&lay::LayoutViewBase::current_layer_list), "@brief Gets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("current_layer_list=|#set_current_layer_list", &lay::LayoutView::set_current_layer_list, gsi::arg ("index"), + gsi::method ("current_layer_list=|#set_current_layer_list", static_cast (&lay::LayoutViewBase::set_current_layer_list), gsi::arg ("index"), "@brief Sets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("rename_layer_list", &lay::LayoutView::rename_properties, gsi::arg ("index"), gsi::arg ("name"), + gsi::method ("rename_layer_list", static_cast (&lay::LayoutViewBase::rename_properties), gsi::arg ("index"), gsi::arg ("name"), "@brief Sets the title of the given layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + @@ -1499,26 +1527,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.25." ) + - gsi::method ("current_layer", &lay::LayoutView::current_layer, + gsi::method ("current_layer", static_cast (&lay::LayoutViewBase::current_layer), "@brief Gets the current layer view\n" "\n" "Returns the \\LayerPropertiesIterator pointing to the current layer view (the one that has the focus). " "If no layer view is active currently, a null iterator is returned.\n" ) + - gsi::method ("current_layer=", (void (lay::LayoutView::*) (const lay::LayerPropertiesConstIterator &l)) &lay::LayoutView::set_current_layer, gsi::arg ("iter"), + gsi::method ("current_layer=", static_cast (&lay::LayoutViewBase::set_current_layer), gsi::arg ("iter"), "@brief Sets the current layer view\n" "\n" "Specifies an \\LayerPropertiesIterator pointing to the new current layer view.\n" "\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("selected_layers", &lay::LayoutView::selected_layers, + gsi::method ("selected_layers", static_cast (lay::LayoutViewBase::*) () const> (&lay::LayoutViewBase::selected_layers), "@brief Gets the selected layers\n" "\n" "Returns an array of \\LayerPropertiesIterator objects pointing to the currently selected layers. " "If no layer view is selected currently, an empty array is returned.\n" ) + - gsi::event ("on_active_cellview_changed", &lay::LayoutView::active_cellview_changed_event, + gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutViewBase::active_cellview_changed_event), "@brief An event indicating that the active cellview has changed\n" "\n" "If the active cellview is changed by selecting a new one from the drop-down list, this event is triggered.\n" @@ -1527,7 +1555,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_active_cellview_changed/remove_active_cellview_changed) have been removed in 0.25.\n" ) + - gsi::event ("on_cellviews_changed", &lay::LayoutView::cellviews_changed_event, + gsi::event ("on_cellviews_changed", static_cast (&lay::LayoutViewBase::cellviews_changed_event), "@brief An event indicating that the cellview collection has changed\n" "\n" "If new cellviews are added or cellviews are removed, this event is triggered.\n" @@ -1536,7 +1564,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_list_observer/remove_cellview_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_cellview_changed", &lay::LayoutView::cellview_changed_event, gsi::arg ("cellview_index"), + gsi::event ("on_cellview_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::cellview_changed_event), gsi::arg ("cellview_index"), "@brief An event indicating that a cellview has changed\n" "\n" "If a cellview is modified, this event is triggered.\n" @@ -1546,7 +1574,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_observer/remove_cellview_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_file_open", &lay::LayoutView::file_open_event, + gsi::event ("on_file_open", static_cast (&lay::LayoutViewBase::file_open_event), "@brief An event indicating that a file was opened\n" "\n" "If a file is loaded, this event is triggered.\n" @@ -1556,24 +1584,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_file_open_observer/remove_file_open_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_close", &lay::LayoutView::close_event, - "@brief A event indicating that the view is about to close\n" - "\n" - "This event is triggered when the view is going to be closed entirely.\n" - "\n" - "It has been added in version 0.25." - ) + - gsi::event ("on_show", &lay::LayoutView::show_event, - "@brief A event indicating that the view is going to become visible\n" - "\n" - "It has been added in version 0.25." - ) + - gsi::event ("on_hide", &lay::LayoutView::hide_event, - "@brief A event indicating that the view is going to become invisible\n" - "\n" - "It has been added in version 0.25." - ) + - gsi::event ("on_viewport_changed", &lay::LayoutView::viewport_changed_event, + gsi::event ("on_viewport_changed", static_cast (&lay::LayoutViewBase::viewport_changed_event), "@brief An event indicating that the viewport (the visible rectangle) has changed\n" "\n" "This event is triggered after a new display rectangle was chosen - for example, because the user " @@ -1582,7 +1593,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_viewport_changed_observer/remove_viewport_changed_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_changed", &lay::LayoutView::layer_list_changed_event, gsi::arg ("flags"), + gsi::event ("on_layer_list_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_changed_event), gsi::arg ("flags"), "@brief An event indicating that the layer list has changed\n" "\n" "This event is triggered after the layer list has changed it's configuration.\n" @@ -1593,7 +1604,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_layer_list_observer/remove_layer_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_inserted", &lay::LayoutView::layer_list_inserted_event, gsi::arg ("index"), + gsi::event ("on_layer_list_inserted", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_inserted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been inserted\n" "@param index The index of the layer list that was inserted\n" "\n" @@ -1601,7 +1612,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_layer_list_deleted", &lay::LayoutView::layer_list_deleted_event, gsi::arg ("index"), + gsi::event ("on_layer_list_deleted", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_deleted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been removed\n" "@param index The index of the layer list that was removed\n" "\n" @@ -1609,7 +1620,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_current_layer_list_changed", &lay::LayoutView::current_layer_list_changed_event, gsi::arg ("index"), + gsi::event ("on_current_layer_list_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::current_layer_list_changed_event), gsi::arg ("index"), "@brief An event indicating the current layer list (the selected tab) has changed\n" "@param index The index of the new current layer list\n" "\n" @@ -1617,7 +1628,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_cell_visibility_changed", &lay::LayoutView::cell_visibility_changed_event, + gsi::event ("on_cell_visibility_changed", static_cast (&lay::LayoutViewBase::cell_visibility_changed_event), "@brief An event indicating that the visibility of one or more cells has changed\n" "\n" "This event is triggered after the visibility of one or more cells has changed.\n" @@ -1627,7 +1638,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou ) + // HINT: the cast is important to direct GSI to the LayoutView member rather than the // Editables member (in which case we get a segmentation violation ..) - gsi::event ("on_transient_selection_changed", (tl::Event (lay::LayoutView::*)) &lay::LayoutView::transient_selection_changed_event, + gsi::event ("on_transient_selection_changed", (tl::Event (lay::LayoutViewBase::*)) &lay::LayoutViewBase::transient_selection_changed_event, "@brief An event that is triggered if the transient selection is changed\n" "\n" "If the transient selection is changed, this event is triggered.\n" @@ -1637,33 +1648,33 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou ) + // HINT: the cast is important to direct GSI to the LayoutView method rather than the // Editables method (in which case we get a segmentation violation ..) - gsi::event ("on_selection_changed", (tl::Event (lay::LayoutView::*)) &lay::LayoutView::selection_changed_event, + gsi::event ("on_selection_changed", (tl::Event (lay::LayoutViewBase::*)) &lay::LayoutViewBase::selection_changed_event, "@brief An event that is triggered if the selection is changed\n" "\n" "If the selection changed, this event is triggered.\n" "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::event ("on_rdb_list_changed", &lay::LayoutView::rdb_list_changed_event, + gsi::event ("on_rdb_list_changed", static_cast (&lay::LayoutViewBase::rdb_list_changed_event), "@brief An event that is triggered the list of report databases is changed\n" "\n" "If a report database is added or removed, this event is triggered.\n" "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::method ("num_rdbs", &lay::LayoutView::num_rdbs, + gsi::method ("num_rdbs", static_cast (&lay::LayoutViewBase::num_rdbs), "@brief Gets the number of report databases loaded into this view\n" "@return The number of \\ReportDatabase objects present in this view\n" ) + - gsi::method ("remove_rdb", &lay::LayoutView::remove_rdb, gsi::arg ("index"), + gsi::method ("remove_rdb", static_cast (&lay::LayoutViewBase::remove_rdb), gsi::arg ("index"), "@brief Removes a report database with the given index\n" "@param The index of the report database to remove from this view" ) + - gsi::method ("rdb", (rdb::Database *(lay::LayoutView::*) (int index)) &lay::LayoutView::get_rdb, gsi::arg ("index"), + gsi::method ("rdb", static_cast (&lay::LayoutViewBase::get_rdb), gsi::arg ("index"), "@brief Gets the report database with the given index\n" "@return The \\ReportDatabase object or nil if the index is not valid" ) + - gsi::method ("add_rdb", &lay::LayoutView::add_rdb, gsi::arg ("db"), + gsi::method ("add_rdb", static_cast (&lay::LayoutViewBase::add_rdb), gsi::arg ("db"), "@brief Adds the given report database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the marker database browser.\n" @@ -1673,7 +1684,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_rdb", &lay::LayoutView::replace_rdb, gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_rdb", static_cast (&lay::LayoutViewBase::replace_rdb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the report database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_rdb).\n" @@ -1690,37 +1701,32 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a report database with the given name already exists, a unique name will be created.\n" "The name will be replaced by the file name when a file is loaded into the report database.\n" ) + - gsi::method ("show_rdb", &lay::LayoutView::open_rdb_browser, gsi::arg ("rdb_index"), gsi::arg ("cv_index"), - "@brief Shows a report database in the marker browser on a certain layout\n" - "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - ) + - gsi::event ("on_l2ndb_list_changed", &lay::LayoutView::l2ndb_list_changed_event, + gsi::event ("on_l2ndb_list_changed", static_cast (&lay::LayoutViewBase::l2ndb_list_changed_event), "@brief An event that is triggered the list of netlist databases is changed\n" "\n" "If a netlist database is added or removed, this event is triggered.\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("num_l2ndbs", &lay::LayoutView::num_l2ndbs, + gsi::method ("num_l2ndbs", static_cast (&lay::LayoutViewBase::num_l2ndbs), "@brief Gets the number of netlist databases loaded into this view\n" "@return The number of \\LayoutToNetlist objects present in this view\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("remove_l2ndb", &lay::LayoutView::remove_l2ndb, gsi::arg ("index"), + gsi::method ("remove_l2ndb", static_cast (&lay::LayoutViewBase::remove_l2ndb), gsi::arg ("index"), "@brief Removes a netlist database with the given index\n" "@param The index of the netlist database to remove from this view" "\n" "This method has been added in version 0.26." ) + - gsi::method ("l2ndb", (db::LayoutToNetlist *(lay::LayoutView::*) (int index)) &lay::LayoutView::get_l2ndb, gsi::arg ("index"), + gsi::method ("l2ndb", static_cast (&lay::LayoutViewBase::get_l2ndb), gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutToNetlist object or nil if the index is not valid" "\n" "This method has been added in version 0.26." ) + - gsi::method ("add_l2ndb", &lay::LayoutView::add_l2ndb, gsi::arg ("db"), + gsi::method ("add_l2ndb", static_cast (&lay::LayoutViewBase::add_l2ndb), gsi::arg ("db"), "@brief Adds the given netlist database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the netlist database browser.\n" @@ -1730,7 +1736,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_l2ndb", &lay::LayoutView::replace_l2ndb, gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_l2ndb", static_cast (&lay::LayoutViewBase::replace_l2ndb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the netlist database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_lvsdb).\n" @@ -1749,13 +1755,6 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("show_l2ndb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), - "@brief Shows a netlist database in the marker browser on a certain layout\n" - "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - "\n" - "This method has been added in version 0.26." - ) + gsi::method_ext ("lvsdb", &get_lvsdb, gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutVsSchematic object or nil if the index is not valid" @@ -1791,19 +1790,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("show_lvsdb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), - "@brief Shows a netlist database in the marker browser on a certain layout\n" - "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - "\n" - "This method has been added in version 0.26." - ) + // HINT: the cast is important to direct GSI to the LayoutView method rather than the // Plugin method (in which case we get a segmentation violation ..) // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("clear_config", (void (lay::LayoutView::*)()) &lay::LayoutView::clear_config, + gsi::method ("clear_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::clear_config, "@brief Clears the local configuration parameters\n" "\n" "See \\set_config for a description of the local configuration parameters." @@ -1824,7 +1816,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("get_config", (std::string (lay::LayoutView::*)(const std::string &name) const) &lay::LayoutView::config_get, gsi::arg ("name"), + gsi::method ("get_config", (std::string (lay::LayoutViewBase::*)(const std::string &name) const) &lay::LayoutViewBase::config_get, gsi::arg ("name"), "@brief Gets the value of a local configuration parameter\n" "\n" "@param name The name of the configuration parameter whose value shall be obtained (a string)\n" @@ -1836,7 +1828,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("set_config", (void (lay::LayoutView::*)(const std::string &name, const std::string &value)) &lay::LayoutView::config_set, gsi::arg ("name"), gsi::arg ("value"), + gsi::method ("set_config", (void (lay::LayoutViewBase::*)(const std::string &name, const std::string &value)) &lay::LayoutViewBase::config_set, gsi::arg ("name"), gsi::arg ("value"), "@brief Sets a local configuration parameter with the given name to the given value\n" "\n" "@param name The name of the configuration parameter to set\n" @@ -1851,7 +1843,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("commit_config", (void (lay::LayoutView::*)()) &lay::LayoutView::config_end, + gsi::method ("commit_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::config_end, "@brief Commits the configuration settings\n" "\n" "Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. " @@ -1896,15 +1888,74 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "invalid results." "\n" "This method was introduced in version 0.16." + ) + + gsi::method_ext ("send_key_press_event", &send_key_press_event, gsi::arg ("key"), gsi::arg ("buttons"), + "@brief Sends a key press event\n" + "\n" + "This method is intended to emulate the key press events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#key_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_move_event", &send_mouse_move_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse move event\n" + "\n" + "This method is intended to emulate the mouse move events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_press_event", &send_mouse_press_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button press event\n" + "\n" + "This method is intended to emulate the mouse button press events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_double_clicked_event", &send_mouse_double_clicked_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button double-click event\n" + "\n" + "This method is intended to emulate the mouse button double-click events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_release_event", &send_mouse_release_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button release event\n" + "\n" + "This method is intended to emulate the mouse button release events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_leave_event", &send_leave_event, + "@brief Sends a mouse window leave event\n" + "\n" + "This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. " + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_enter_event", &send_enter_event, + "@brief Sends a mouse window leave event\n" + "\n" + "This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. " + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_wheel_event", &send_wheel_event, gsi::arg ("delta"), gsi::arg ("horizontal"), gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse wheel event\n" + "\n" + "This method is intended to emulate the mouse wheel events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#wheel_event for example.\n" + "\n" + "This method was introduced in version 0.28." ), - "@brief The view object presenting one or more layout objects\n" - "\n" - "The visual part of the view is the tab panel in the main window. The non-visual part " - "are the redraw thread, the layout handles, cell lists, layer view lists etc. " - "This object controls these aspects of the view and controls the appearance of the data. " + "@hide\n" + "@alias LayoutView\n" ); -gsi::EnumIn decl_layLayoutView_SelectionMode ("lay", "SelectionMode", +gsi::EnumIn decl_layLayoutView_SelectionMode ("lay", "SelectionMode", gsi::enum_const ("Add", lay::Editable::SelectionMode::Add, "@brief Adds to any existing selection\n" ) + @@ -1923,7 +1974,7 @@ gsi::EnumIn decl_layLayoutView_Se ); // Inject the NetlistCrossReference::Status declarations into NetlistCrossReference: -gsi::ClassExt inject_SelectionMode_in_parent (decl_layLayoutView_SelectionMode.defs ()); +gsi::ClassExt inject_SelectionMode_in_parent (decl_layLayoutView_SelectionMode.defs ()); static db::Layout *get_layout (const lay::CellViewRef *cv) { @@ -1985,24 +2036,11 @@ static std::string get_technology (const lay::CellViewRef *cv) static tl::Event &get_technology_changed_event (lay::CellViewRef *cv) { if (! cv->is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cellview"))); + throw tl::Exception (tl::to_string (tr ("Not a valid cellview"))); } return (*cv)->technology_changed_event; } -static lay::CellViewRef get_active_cellview_ref () -{ - lay::LayoutView *view = lay::LayoutView::current (); - if (! view) { - return lay::CellViewRef (); - } - if (view->active_cellview_index () >= 0) { - return view->active_cellview_ref (); - } else { - return lay::CellViewRef (); - } -} - static void set_cell (lay::CellViewRef *cv, db::Cell *cell) { if (! cell) { @@ -2046,7 +2084,7 @@ static bool cv_is_cell_hidden (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } return cv->view ()->is_cell_hidden (cell->cell_index (), cv->index ()); } else { @@ -2058,7 +2096,7 @@ static void cv_hide_cell (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } cv->view ()->hide_cell (cell->cell_index (), cv->index ()); } @@ -2068,7 +2106,7 @@ static void cv_show_cell (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } cv->view ()->show_cell (cell->cell_index (), cv->index ()); } @@ -2092,22 +2130,6 @@ Class decl_CellView ("lay", "CellView", "The index will be negative if the cellview is not a valid one.\n" "This method has been added in version 0.25.\n" ) + - method ("view", &lay::CellViewRef::view, - "@brief Gets the view the cellview resides in\n" - "This reference will be nil if the cellview is not a valid one.\n" - "This method has been added in version 0.25.\n" - ) + - method ("active", &get_active_cellview_ref, - "@brief Gets the active CellView\n" - "The active CellView is the one that is selected in the current layout view. This method is " - "equivalent to\n" - "@code\n" - "RBA::LayoutView::current.active_cellview\n" - "@/code\n" - "If no CellView is active, this method returns nil.\n" - "\n" - "This method has been introduced in version 0.23." - ) + method ("is_valid?", &lay::CellViewRef::is_valid, "@brief Returns true, if the cellview is valid\n" "A cellview may become invalid if the corresponding tab is closed for example." diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index ff048605e..8ecfb49bb 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -23,13 +23,13 @@ #include "gsiDecl.h" #include "layMarker.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { static -lay::DMarker *create_marker (lay::LayoutView *view) +lay::DMarker *create_marker (lay::LayoutViewBase *view) { return new lay::DMarker (view); } @@ -37,13 +37,13 @@ lay::DMarker *create_marker (lay::LayoutView *view) static void reset_frame_color (lay::DMarker *marker) { - marker->set_frame_color (QColor ()); + marker->set_frame_color (lay::Color ()); } static void set_frame_color (lay::DMarker *marker, unsigned int color) { - marker->set_frame_color (QColor (color)); + marker->set_frame_color (lay::Color (color)); } static @@ -55,19 +55,19 @@ unsigned int get_frame_color (const lay::DMarker *marker) static bool has_frame_color (const lay::DMarker *marker) { - return marker->get_frame_color ().isValid (); + return marker->get_frame_color ().is_valid (); } static void reset_color (lay::DMarker *marker) { - marker->set_color (QColor ()); + marker->set_color (lay::Color ()); } static void set_color (lay::DMarker *marker, unsigned int color) { - marker->set_color (QColor (color)); + marker->set_color (lay::Color (color)); } static @@ -79,7 +79,7 @@ unsigned int get_color (const lay::DMarker *marker) static bool has_color (const lay::DMarker *marker) { - return marker->get_color ().isValid (); + return marker->get_color ().is_valid (); } Class decl_Marker ("lay", "Marker", diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc new file mode 100644 index 000000000..26d02c6b8 --- /dev/null +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -0,0 +1,414 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "gsiDecl.h" +#include "layPixelBuffer.h" + +#if defined(HAVE_QT) +# include +# include +#endif + +namespace gsi +{ + +// ------------------------------------------------------------------------------------- +// lay::BitmapBuffer + +static lay::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h) +{ + return new lay::PixelBuffer (w, h); +} + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) +static void fill_with_qcolor (lay::PixelBuffer *pb, QColor c) +{ + pb->fill (c.rgb ()); +} +#endif + +lay::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned int x, unsigned int y) +{ + if (x < pb->width () && y < pb->height ()) { + return pb->scan_line (y)[x]; + } else { + return lay::color_t (0); + } +} + +void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, lay::color_t c) +{ + if (! pb->transparent ()) { + c |= 0xff000000; // ensures that alpha is set properly even if not required + } + if (x < pb->width () && y < pb->height ()) { + pb->scan_line (y)[x] = c; + } +} + +static lay::PixelBuffer read_pixel_buffer (const std::string &file) +{ +#if defined(HAVE_PNG) + tl::InputStream stream (file); + return lay::PixelBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img; + img.load (tl::to_qstring (file), "PNG"); + return lay::PixelBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); + return lay::PixelBuffer (); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static lay::PixelBuffer pixel_buffer_from_png (const std::vector &data) +{ +#if defined(HAVE_PNG) + tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ()); + tl::InputStream stream (data_stream); + return lay::PixelBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + tl_assert (data.size () < std::numeric_limits::max ()); + QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ())); + return lay::PixelBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); + return lay::PixelBuffer (); +#endif +} + +static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &file) +{ +#if defined(HAVE_PNG) + tl::OutputStream stream (file); + pb->write_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + img.save (tl::to_qstring (file), "PNG"); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static std::vector pixel_buffer_to_png (const lay::PixelBuffer *pb) +{ +#if defined(HAVE_PNG) + tl::OutputMemoryStream data_stream; + { + tl::OutputStream stream (data_stream); + pb->write_png (stream); + } + return std::vector (data_stream.data (), data_stream.data () + data_stream.size ()); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + QBuffer data; + img.save (&data, "PNG"); + return std::vector (data.data ().constData (), data.data ().constEnd ()); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); +#endif +} + + +Class decl_PixelBuffer ("lay", "PixelBuffer", + gsi::constructor ("new", &create_pixel_buffer, gsi::arg ("width"), gsi::arg ("height"), + "@brief Creates a pixel buffer object\n" + "\n" + "@param width The width in pixels\n" + "@param height The height in pixels\n" + "\n" + "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." + ) + + gsi::method ("==", &lay::PixelBuffer::operator==, gsi::arg ("other"), + "@brief Returns a value indicating whether self is identical to the other image\n" + ) + + gsi::method ("!=", &lay::PixelBuffer::operator!=, gsi::arg ("other"), + "@brief Returns a value indicating whether self is not identical to the other image\n" + ) + + gsi::method ("transparent=", &lay::PixelBuffer::set_transparent, gsi::arg ("t"), + "@brief Sets a flag indicating whether the pixel buffer supports an alpha channel\n" + "\n" + "By default, the pixel buffer does not support an alpha channel.\n" + ) + + gsi::method ("transparent", &lay::PixelBuffer::transparent, + "@brief Gets a flag indicating whether the pixel buffer supports an alpha channel\n" + ) + + gsi::method ("fill", &lay::PixelBuffer::fill, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given pixel value\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given QColor\n" + ) + +#endif + gsi::method ("swap", &lay::PixelBuffer::swap, gsi::arg ("other"), + "@brief Swaps data with another PixelBuffer object\n" + ) + + gsi::method ("width", &lay::PixelBuffer::width, + "@brief Gets the width of the pixel buffer in pixels\n" + ) + + gsi::method ("height", &lay::PixelBuffer::height, + "@brief Gets the height of the pixel buffer in pixels\n" + ) + + gsi::method_ext ("set_pixel", &set_pixel_in_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"), + "@brief Sets the value of the pixel at position x, y\n" + ) + + gsi::method_ext ("pixel", &get_pixel_from_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), + "@brief Gets the value of the pixel at position x, y\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method ("to_qimage", &lay::PixelBuffer::to_image_copy, + "@brief Converts the pixel buffer to a \\QImage object" + ) + + gsi::method ("from_qimage", &lay::PixelBuffer::from_image, gsi::arg ("qimage"), + "@brief Creates a pixel buffer object from a QImage object\n" + ) + +#endif + gsi::method ("read_png", &read_pixel_buffer, gsi::arg ("file"), + "@brief Reads the pixel buffer from a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("from_png_data", &pixel_buffer_from_png, gsi::arg ("data"), + "@brief Reads the pixel buffer from a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("write_png", &write_pixel_buffer, gsi::arg ("file"), + "@brief Writes the pixel buffer to a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("to_png_data", &pixel_buffer_to_png, + "@brief Converts the pixel buffer to a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("patch", &lay::PixelBuffer::patch, gsi::arg ("other"), + "@brief Patches another pixel buffer into this one\n" + "\n" + "This method is the inverse of \\diff - it will patch the difference image created by diff into this " + "pixel buffer. Note that this method will not do true alpha blending and requires the other pixel buffer " + "to have the same format than self. Self will be modified by this operation." + ) + + gsi::method ("diff", &lay::PixelBuffer::diff, gsi::arg ("other"), + "@brief Creates a difference image\n" + "\n" + "This method is provided to support transfer of image differences - i.e. small updates instead of full images. " + "It works for non-transparent images only and generates an image with transpareny enabled and with the new pixel values for pixels that have changed. " + "The alpha value will be 0 for identical images and 255 for pixels with different values. " + "This way, the difference image can be painted over the original image to generate the new image." + ), + "@brief A simplistic pixel buffer representing an image of ARGB32 or RGB32 values\n" + "\n" + "This object is mainly provided for offline rendering of layouts in Qt-less environments.\n" + "It supports a rectangular pixel space with color values encoded in 32bit integers. It supports " + "transparency through an optional alpha channel. The color format for a pixel is " + "\"0xAARRGGBB\" where 'AA' is the alpha value which is ignored in non-transparent mode.\n" + "\n" + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG.\n" + "\n" + "This class has been introduced in version 0.28." +); + + +// ------------------------------------------------------------------------------------- +// lay::BitmapBuffer + +static lay::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h) +{ + return new lay::BitmapBuffer (w, h); +} + +bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x, unsigned int y) +{ + if (x < pb->width () && y < pb->height ()) { + return (pb->scan_line (y)[x / 8] & (0x01 << (x % 8))) != 0; + } else { + return false; + } +} + +void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c) +{ + if (x < pb->width () && y < pb->height ()) { + if (c) { + pb->scan_line (y)[x / 8] |= 0x01 << (x % 8); + } else { + pb->scan_line (y)[x / 8] &= ~(0x01 << (x % 8)); + } + } +} + +static lay::BitmapBuffer read_bitmap_buffer (const std::string &file) +{ +#if defined(HAVE_PNG) + tl::InputStream stream (file); + return lay::BitmapBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img; + img.load (tl::to_qstring (file), "PNG"); + return lay::BitmapBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); + return lay::BitmapBuffer (); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static lay::BitmapBuffer bitmap_buffer_from_png (const std::vector &data) +{ +#if defined(HAVE_PNG) + tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ()); + tl::InputStream stream (data_stream); + return lay::BitmapBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + tl_assert (data.size () < std::numeric_limits::max ()); + QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ())); + return lay::BitmapBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); + return lay::BitmapBuffer (); +#endif +} + +static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string &file) +{ +#if defined(HAVE_PNG) + tl::OutputStream stream (file); + pb->write_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + img.save (tl::to_qstring (file), "PNG"); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static std::vector bitmap_buffer_to_png (const lay::BitmapBuffer *pb) +{ +#if defined(HAVE_PNG) + tl::OutputMemoryStream data_stream; + { + tl::OutputStream stream (data_stream); + pb->write_png (stream); + } + return std::vector (data_stream.data (), data_stream.data () + data_stream.size ()); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + QBuffer data; + img.save (&data, "PNG"); + return std::vector (data.data ().constData (), data.data ().constEnd ()); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); +#endif +} + + +Class decl_BitmapBuffer ("lay", "BitmapBuffer", + gsi::constructor ("new", &create_bitmap_buffer, gsi::arg ("width"), gsi::arg ("height"), + "@brief Creates a pixel buffer object\n" + "\n" + "@param width The width in pixels\n" + "@param height The height in pixels\n" + "\n" + "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." + ) + + gsi::method ("==", &lay::BitmapBuffer::operator==, gsi::arg ("other"), + "@brief Returns a value indicating whether self is identical to the other image\n" + ) + + gsi::method ("!=", &lay::BitmapBuffer::operator!=, gsi::arg ("other"), + "@brief Returns a value indicating whether self is not identical to the other image\n" + ) + + gsi::method ("fill", &lay::BitmapBuffer::fill, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given pixel value\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given QColor\n" + ) + +#endif + gsi::method ("swap", &lay::BitmapBuffer::swap, gsi::arg ("other"), + "@brief Swaps data with another BitmapBuffer object\n" + ) + + gsi::method ("width", &lay::BitmapBuffer::width, + "@brief Gets the width of the pixel buffer in pixels\n" + ) + + gsi::method ("height", &lay::BitmapBuffer::height, + "@brief Gets the height of the pixel buffer in pixels\n" + ) + + gsi::method_ext ("set_pixel", &set_pixel_in_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"), + "@brief Sets the value of the pixel at position x, y\n" + ) + + gsi::method_ext ("pixel", &get_pixel_from_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), + "@brief Gets the value of the pixel at position x, y\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method ("to_qimage", &lay::BitmapBuffer::to_image_copy, + "@brief Converts the pixel buffer to a \\QImage object" + ) + + gsi::method ("from_qimage", &lay::BitmapBuffer::from_image, gsi::arg ("qimage"), + "@brief Creates a pixel buffer object from a QImage object\n" + ) + +#endif + gsi::method ("read_png", &read_bitmap_buffer, gsi::arg ("file"), + "@brief Reads the pixel buffer from a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("from_png_data", &bitmap_buffer_from_png, gsi::arg ("data"), + "@brief Reads the pixel buffer from a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("write_png", &write_bitmap_buffer, gsi::arg ("file"), + "@brief Writes the pixel buffer to a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("to_png_data", &bitmap_buffer_to_png, + "@brief Converts the pixel buffer to a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ), + "@brief A simplistic pixel buffer representing monochrome image\n" + "\n" + "This object is mainly provided for offline rendering of layouts in Qt-less environments.\n" + "It supports a rectangular pixel space with color values encoded in single bits.\n" + "\n" + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG.\n" + "\n" + "This class has been introduced in version 0.28." +); + +} diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 9d8cf8e1c..bce28aa52 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -25,7 +25,7 @@ #include "gsiDeclBasic.h" #include "layPlugin.h" #include "layViewObject.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCursor.h" namespace gsi @@ -40,7 +40,7 @@ namespace gsi // since PluginBase object are only allowed to be created inside the create_plugin method // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; -static lay::LayoutView *sp_view = 0; +static lay::LayoutViewBase *sp_view = 0; static lay::Dispatcher *sp_dispatcher = 0; class PluginBase @@ -51,7 +51,7 @@ public: : lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) { if (! s_in_create_plugin) { - throw tl::Exception (tl::to_string (QObject::tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); + throw tl::Exception (tl::to_string (tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); } } @@ -393,7 +393,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -402,7 +402,7 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; @@ -410,7 +410,7 @@ public: sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; sp_dispatcher = 0; @@ -912,7 +912,51 @@ Class decl_ButtonState ("lay", "ButtonState", "This class has been introduced in version 0.22.\n" ); -static std::vector +class KeyCodesNamespace { }; + +static int const_KeyEscape() { return (int) lay::KeyEscape; } +static int const_KeyTab() { return (int) lay::KeyTab; } +static int const_KeyBacktab() { return (int) lay::KeyBacktab; } +static int const_KeyBackspace() { return (int) lay::KeyBackspace; } +static int const_KeyReturn() { return (int) lay::KeyReturn; } +static int const_KeyEnter() { return (int) lay::KeyEnter; } +static int const_KeyInsert() { return (int) lay::KeyInsert; } +static int const_KeyDelete() { return (int) lay::KeyDelete; } +static int const_KeyHome() { return (int) lay::KeyHome; } +static int const_KeyEnd() { return (int) lay::KeyEnd; } +static int const_KeyDown() { return (int) lay::KeyDown; } +static int const_KeyUp() { return (int) lay::KeyUp; } +static int const_KeyLeft() { return (int) lay::KeyLeft; } +static int const_KeyRight() { return (int) lay::KeyRight; } +static int const_KeyPageUp() { return (int) lay::KeyPageUp; } +static int const_KeyPageDown() { return (int) lay::KeyPageDown; } + +Class decl_KeyCode ("lay", "KeyCode", + method ("Escape", &const_KeyEscape, "@brief Indicates the Escape key") + + method ("Tab", &const_KeyTab, "@brief Indicates the Tab key") + + method ("Backtab", &const_KeyBacktab, "@brief Indicates the Backtab key") + + method ("Backspace", &const_KeyBackspace, "@brief Indicates the Backspace key") + + method ("Return", &const_KeyReturn, "@brief Indicates the Return key") + + method ("Enter", &const_KeyEnter, "@brief Indicates the Enter key") + + method ("Insert", &const_KeyInsert, "@brief Indicates the Insert key") + + method ("Delete", &const_KeyDelete, "@brief Indicates the Delete key") + + method ("Home", &const_KeyHome, "@brief Indicates the Home key") + + method ("End", &const_KeyEnd, "@brief Indicates the End key") + + method ("Down", &const_KeyDown, "@brief Indicates the Down key") + + method ("Up", &const_KeyUp, "@brief Indicates the Up key") + + method ("Left", &const_KeyLeft, "@brief Indicates the Left key") + + method ("Right", &const_KeyRight, "@brief Indicates the Right key") + + method ("PageUp", &const_KeyPageUp, "@brief Indicates the PageUp key") + + method ("PageDown", &const_KeyPageDown, "@brief Indicates the PageDown key"), + "@brief The namespace for the some key codes.\n" + "This namespace defines some key codes understood by built-in \\LayoutView components. " + "When compiling with Qt, these codes are compatible with Qt's key codes.\n" + "The key codes are intended to be used when directly interfacing with \\LayoutView in non-Qt-based environments.\n" + "\n" + "This class has been introduced in version 0.28.\n" +); + +static std::vector get_config_names (lay::Dispatcher *dispatcher) { std::vector names; diff --git a/src/laybasic/laybasic/gtf.cc b/src/laybasic/laybasic/gtf.cc index a5b2534ae..d5eb5797e 100644 --- a/src/laybasic/laybasic/gtf.cc +++ b/src/laybasic/laybasic/gtf.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gtf.h" #include "tlException.h" @@ -1928,4 +1929,5 @@ GtfXmlHandler::warning (const QXmlParseException &ex) } +#endif diff --git a/src/laybasic/laybasic/gtf.h b/src/laybasic/laybasic/gtf.h index c0fd84c7a..98f58a099 100644 --- a/src/laybasic/laybasic/gtf.h +++ b/src/laybasic/laybasic/gtf.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_gtf #define HDR_gtf @@ -569,5 +570,4 @@ LAYBASIC_PUBLIC tl::Variant image_to_variant (const QImage &image); #endif - - +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/gtfdummy.cc b/src/laybasic/laybasic/gtfdummy.cc index ce531c855..e1acdb547 100644 --- a/src/laybasic/laybasic/gtfdummy.cc +++ b/src/laybasic/laybasic/gtfdummy.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gtf.h" @@ -35,4 +36,5 @@ void Recorder::errlog_puts (const char *s) { } } +#endif diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 248e43bb5..e7b587f9a 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layAbstractMenu.h" #include "layDispatcher.h" @@ -39,6 +40,7 @@ #include #include #include +#include #include @@ -1701,3 +1703,5 @@ AbstractMenu::get_shortcuts (const std::string &root, std::map -#include +#include "tlThreads.h" namespace lay { @@ -386,7 +385,7 @@ render_scanline_cross (const uint32_t *dp, unsigned int ds, const lay::Bitmap *p } } -static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &vo_map, const std::vector &pbitmaps_in, const std::vector &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, QMutex *mutex) +static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &vo_map, const std::vector &pbitmaps_in, const std::vector &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, tl::Mutex *mutex) { tl_assert (bm_map.size () == vo_map.size ()); @@ -422,16 +421,17 @@ static void create_precursor_bitmaps (const std::vector &view_ops_i } } -static void -bitmaps_to_image_rgb (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - bool transparent, - QMutex *mutex) +void +bitmaps_to_image (const std::vector &view_ops_in, + const std::vector &pbitmaps_in, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + PixelBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex) { + bool transparent = pimage->transparent (); + std::vector bm_map; std::vector vo_map; @@ -588,7 +588,7 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, if (masks.size () > 0) { - lay::color_t *pt = (lay::color_t *) pimage->scanLine (height - 1 - y); + lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y); uint32_t *dptr_end = dptr; unsigned int i = 0; @@ -661,14 +661,14 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, delete [] buffer; } -static void -bitmaps_to_image_mono (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - QMutex *mutex) +void +bitmaps_to_image (const std::vector &view_ops_in, + const std::vector &pbitmaps_in, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + lay::BitmapBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex) { std::vector bm_map; std::vector vo_map; @@ -825,7 +825,7 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, if (masks.size () > 0) { - lay::color_t *pt = (lay::color_t *) pimage->scanLine (height - 1 - y); + lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y); uint32_t *dptr_end = dptr; unsigned int i = 0; @@ -866,23 +866,6 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, delete [] buffer; } -void -bitmaps_to_image (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - QMutex *mutex) -{ - if (pimage->depth () <= 1) { - bitmaps_to_image_mono (view_ops_in, pbitmaps_in, dp, ls, pimage, width, height, use_bitmap_index, mutex); - } else { - bool transparent = (pimage->format () == QImage::Format_ARGB32); - bitmaps_to_image_rgb (view_ops_in, pbitmaps_in, dp, ls, pimage, width, height, use_bitmap_index, transparent, mutex); - } -} - void bitmap_to_bitmap (const lay::ViewOp &view_op, const lay::Bitmap &bitmap, unsigned char *data, diff --git a/src/laybasic/laybasic/layBitmapsToImage.h b/src/laybasic/laybasic/layBitmapsToImage.h index 88930dca3..3520fdaf5 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.h +++ b/src/laybasic/laybasic/layBitmapsToImage.h @@ -25,28 +25,28 @@ #define HDR_layBitmapsToImage #include "layViewOp.h" +#include "tlThreads.h" #include -class QMutex; -class QImage; - namespace lay { class DitherPattern; class LineStyles; class Bitmap; +class PixelBuffer; +class BitmapBuffer; /** - * @brief This function converts the given set of bitmaps to a QImage + * @brief This function converts the given set of bitmaps to a PixelBuffer * * This function uses the set of bitmaps in "pbitmaps" with the given set * of view operands in "view_ops" and converts these into the QImage * with the given width and height. * The "view_ops" and "pbitmaps" vectors must have the same size. * The QImage must be initialized to the given width and height. - * If the QMutex pointer is not 0, the mutex is locked between operations + * If the tl::Mutex pointer is not 0, the mutex is locked between operations * if the bitmap is accessed. The set of dither pattern specifies any custom * pattern that are used bz the view operands. * The "use_bitmap_index" parameter specifies whether the bitmap_index @@ -58,12 +58,26 @@ bitmaps_to_image (const std::vector &view_ops, const std::vector &pbitmaps, const lay::DitherPattern &dp, const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, + lay::PixelBuffer *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, - QMutex *mutex); + tl::Mutex *mutex); /** - * @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to QBitmap + * @brief This function converts the given set of bitmaps to a BitmapBuffer + * + * This is the monochrome version of the previous bitmaps_to_image function. + */ +LAYBASIC_PUBLIC void +bitmaps_to_image (const std::vector &view_ops, + const std::vector &pbitmaps, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + lay::BitmapBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex); + +/** + * @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to lay::BitmapBuffer * * This function converts the bitmap given the view_op into a raw byte data * field that can be passed to a QBitmap constructor. The data field is not diff --git a/src/laybasic/laybasic/layBookmarkList.cc b/src/laybasic/laybasic/layBookmarkList.cc index 595ac8b7a..79e8b2f55 100644 --- a/src/laybasic/laybasic/layBookmarkList.cc +++ b/src/laybasic/laybasic/layBookmarkList.cc @@ -20,7 +20,6 @@ */ - #include "layBookmarkList.h" #include "tlXMLParser.h" @@ -117,4 +116,3 @@ BookmarkList::propose_new_bookmark_name () const } } - diff --git a/src/laybasic/laybasic/layBookmarkList.h b/src/laybasic/laybasic/layBookmarkList.h index 839530a93..86225863d 100644 --- a/src/laybasic/laybasic/layBookmarkList.h +++ b/src/laybasic/laybasic/layBookmarkList.h @@ -20,7 +20,6 @@ */ - #ifndef HDR_layBookmarkList #define HDR_layBookmarkList @@ -207,4 +206,3 @@ private: } // namespace lay #endif - diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index 08f187383..3cef7204d 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -22,8 +22,10 @@ #include "layCellView.h" -#include "layLayoutView.h" -#include "layStream.h" +#include "layLayoutViewBase.h" +#if defined(HAVE_QT) +# include "layStream.h" +#endif #include "dbLayout.h" #include "dbWriter.h" #include "dbReader.h" @@ -64,7 +66,7 @@ LayoutHandle::LayoutHandle (db::Layout *layout, const std::string &filename) // layouts in the managed layouts space participate in spare proxy cleanup layout->do_cleanup (true); - file_watcher ().add_file (m_filename); + add_file_to_watcher (m_filename); if (! m_filename.empty ()) { rename (filename_for_caption (m_filename)); @@ -107,7 +109,23 @@ LayoutHandle::~LayoutHandle () ms_dict.erase (m_name); } - file_watcher ().remove_file (filename ()); + remove_file_from_watcher (filename ()); +} + +void +LayoutHandle::remove_file_from_watcher (const std::string &path) +{ +#if defined(HAVE_QT) + file_watcher ().remove_file (path); +#endif +} + +void +LayoutHandle::add_file_to_watcher (const std::string &path) +{ +#if defined(HAVE_QT) + file_watcher ().add_file (path); +#endif } void @@ -176,9 +194,9 @@ LayoutHandle::layout () const void LayoutHandle::set_filename (const std::string &fn) { - file_watcher ().remove_file (m_filename); + remove_file_from_watcher (m_filename); m_filename = fn; - file_watcher ().add_file (m_filename); + add_file_to_watcher (m_filename); } const std::string & @@ -274,6 +292,7 @@ LayoutHandle::set_save_options (const db::SaveLayoutOptions &options, bool valid void LayoutHandle::update_save_options (db::SaveLayoutOptions &options) { +#if defined(HAVE_QT) for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { const lay::StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); @@ -294,6 +313,7 @@ LayoutHandle::update_save_options (db::SaveLayoutOptions &options) } } +#endif } void @@ -307,7 +327,7 @@ LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode // reader options. m_load_options = db::LoadLayoutOptions (); - file_watcher ().remove_file (filename ()); + remove_file_from_watcher (filename ()); rename (filename_for_caption (fn)); @@ -331,14 +351,14 @@ LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode } if (update) { - file_watcher ().add_file (filename ()); + add_file_to_watcher (filename ()); m_dirty = false; } } catch (...) { if (update) { - file_watcher ().add_file (filename ()); + add_file_to_watcher (filename ()); } throw; @@ -368,8 +388,8 @@ LayoutHandle::load (const db::LoadLayoutOptions &options, const std::string &tec } // Update the file's data: - file_watcher ().remove_file (filename ()); - file_watcher ().add_file (filename ()); + remove_file_from_watcher (filename ()); + add_file_to_watcher (filename ()); m_save_options.set_format (reader.format ()); m_dirty = false; @@ -396,14 +416,15 @@ LayoutHandle::load () } // Update the file's data: - file_watcher ().remove_file (filename ()); - file_watcher ().add_file (filename ()); + remove_file_from_watcher (filename ()); + add_file_to_watcher (filename ()); m_save_options.set_format (reader.format ()); m_dirty = false; return new_lmap; } +#if defined(HAVE_QT) tl::FileSystemWatcher & LayoutHandle::file_watcher () { @@ -414,8 +435,10 @@ LayoutHandle::file_watcher () return *mp_file_watcher; } -std::map LayoutHandle::ms_dict; tl::FileSystemWatcher *LayoutHandle::mp_file_watcher = 0; +#endif + +std::map LayoutHandle::ms_dict; // ------------------------------------------------------------- // LayoutHandleRef implementation @@ -680,7 +703,7 @@ CellViewRef::CellViewRef () // .. nothing yet .. } -CellViewRef::CellViewRef (lay::CellView *cv, lay::LayoutView *view) +CellViewRef::CellViewRef (lay::CellView *cv, lay::LayoutViewBase *view) : mp_cv (cv), mp_view (view) { // .. nothing yet .. @@ -712,7 +735,7 @@ CellViewRef::index () const } } -lay::LayoutView * +lay::LayoutViewBase * CellViewRef::view () { return mp_view.get (); diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 758decfaf..679ca8854 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -30,20 +30,23 @@ #include #include "tlObject.h" -#include "tlFileSystemWatcher.h" -#include "layTechnology.h" #include "dbLayout.h" #include "dbMetaInfo.h" #include "dbReader.h" #include "dbSaveLayoutOptions.h" #include "dbLoadLayoutOptions.h" #include "dbInstElement.h" +#include "dbTechnology.h" #include "gsi.h" +#if defined(HAVE_QT) +# include "tlFileSystemWatcher.h" +#endif + namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief A layout handle @@ -287,10 +290,22 @@ public: */ void layout_changed (); +#if defined(HAVE_QT) /** * @brief Gets the file system watcher that delivers events when one of the layouts gets updated */ static tl::FileSystemWatcher &file_watcher (); +#endif + + /** + * @brief Removes a file from the watcher + */ + static void remove_file_from_watcher (const std::string &path); + + /** + * @brief Adds a file to the watcher + */ + static void add_file_to_watcher (const std::string &path); private: db::Layout *mp_layout; @@ -305,7 +320,9 @@ private: void on_technology_changed (); static std::map ms_dict; +#if defined(HAVE_QT) static tl::FileSystemWatcher *mp_file_watcher; +#endif }; /** @@ -574,7 +591,7 @@ public: * @param cv The reference to the target cellview * @param view The reference to the layout view */ - CellViewRef (lay::CellView *cv, lay::LayoutView *view); + CellViewRef (lay::CellView *cv, lay::LayoutViewBase *view); /** * @brief Gets the cellview index of this reference @@ -583,9 +600,9 @@ public: int index () const; /** - * @brief Gets the LayoutView the reference is pointing to + * @brief Gets the LayoutViewBase the reference is pointing to */ - lay::LayoutView *view (); + lay::LayoutViewBase *view (); /** * @brief Equality: Gives true, if the cellviews are identical @@ -742,7 +759,7 @@ public: private: tl::weak_ptr mp_cv; - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; } diff --git a/src/laybasic/laybasic/layColor.cc b/src/laybasic/laybasic/layColor.cc new file mode 100644 index 000000000..ac486cdbb --- /dev/null +++ b/src/laybasic/laybasic/layColor.cc @@ -0,0 +1,198 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layColor.h" +#include "tlString.h" +#include "tlMath.h" + +#include + +namespace lay +{ + +Color::Color () + : m_color (0) +{ + // .. nothing yet .. +} + +Color::Color (color_t color) + : m_color (color | 0xff000000) +{ + // .. nothing yet .. +} + +Color::Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha) + : m_color ((b & 0xff) | ((g & 0xff) << 8) | ((r & 0xff) << 16) | ((alpha & 0xff) << 24)) +{ + // .. nothing yet .. +} + +Color::Color (const std::string &name) +{ + m_color = 0; + + tl::Extractor ex (name.c_str ()); + + unsigned int n = 0; + + ex.test ("#"); + while (! ex.at_end ()) { + char c = tolower (*ex.get ()); + if (c >= '0' && c <= '9') { + m_color <<= 4; + m_color |= (c - '0'); + ++n; + } else if (c >= 'a' && c <= 'f') { + m_color <<= 4; + m_color |= (c - 'a') + 10; + ++n; + } + ++ex; + } + + if (n == 0) { + m_color = 0; + } else if (n <= 3) { + m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | 0xff000000; + } else if (n <= 4) { + m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | ((m_color & 0xf000) * 0x11000); + } else if (n <= 6) { + m_color |= 0xff000000; + } +} + +std::string +Color::to_string () const +{ + if (! is_valid ()) { + + return std::string (); + + } else { + + unsigned int n = 8; + if ((m_color & 0xff000000) == 0xff000000) { + n = 6; + } + + uint32_t c = m_color; + char s [10]; + s[n + 1] = 0; + s[0] = '#'; + while (n > 0) { + s [n] = "0123456789abcdef" [c & 0xf]; + c >>= 4; + --n; + } + + return std::string (s); + + } +} + +bool +Color::is_valid () const +{ + return (m_color & 0xff000000) != 0; +} + +void +Color::get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const +{ + double r = double (red ()) / 255.0; + double g = double (green ()) / 255.0; + double b = double (blue ()) / 255.0; + + double max = std::max (r, std::max (g, b)); + double min = std::min (r, std::min (g, b)); + double delta = max - min; + + value = (unsigned int) tl::round (255.0 * max, 1); + hue = 0; + saturation = 0; + + if (! tl::equal (delta, 0.0)) { + + saturation = (unsigned int) tl::round (255.0 * delta / max, 1); + double h = 0.0; + if (tl::equal (r, max)) { + h = (g - b) / delta; + } else if (tl::equal (g, max)) { + h = 2.0f + (b - r) / delta; + } else if (tl::equal (b, max)) { + h = 4.0f + (r - g) / delta; + } + h *= 60.0; + if (tl::less (h, 0.0)) { + h += 360.0; + } + + hue = (unsigned int) tl::round (h, 1); + + } +} + +static lay::Color color_d (double r, double g, double b) +{ + return lay::Color (tl::round (r * 255.0, 1), tl::round (g * 255.0, 1), tl::round (b * 255.0, 1)); +} + +lay::Color +Color::from_hsv (unsigned int hue, unsigned int saturation, unsigned int value) +{ + if (saturation == 0) { + return lay::Color (value, value, value); + } + + hue = (hue + 360) % 360; + + double h = double (hue) / 60.0; + double s = double (saturation) / 255.0; + double v = double (value) / 255.0; + + int i = int (tl::round_down (h, 1)); + double f = (i & 1) != 0 ? h - i : 1.0 - h + i; + double p = v * (1.0 - s); + double q = v * (1.0 - s * f); + + switch (i) { + case 0: + return color_d (v, q, p); + case 1: + return color_d (q, v, p); + case 2: + return color_d (p, v, q); + case 3: + return color_d (p, q, v); + case 4: + return color_d (q, p, v); + case 5: + return color_d (v, p, q); + default: + return lay::Color (); + } + +} + +} diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h new file mode 100644 index 000000000..e8d4c3d2a --- /dev/null +++ b/src/laybasic/laybasic/layColor.h @@ -0,0 +1,179 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layColor +#define HDR_layColor + +#include "laybasicCommon.h" + +#include +#include + +namespace lay +{ + +/** + * @brief The basic color type for a RGB triplet + */ +typedef uint32_t color_t; + +/** + * @brief Gets the color components from a color_t + */ +inline unsigned int alpha (color_t c) { return (c >> 24) & 0xff; } +inline unsigned int red (color_t c) { return (c >> 16) & 0xff; } +inline unsigned int green (color_t c) { return (c >> 8) & 0xff; } +inline unsigned int blue (color_t c) { return c & 0xff; } + +/** + * @brief A wrapper for a color value + * + * This class is a replacement for QColor. It offers invalid color values and + * string conversion. + */ +class LAYBASIC_PUBLIC Color +{ +public: + /** + * @brief Default constructor - creates an invalid color + */ + Color (); + + /** + * @brief Creates a color from a RGB triplet + */ + Color (color_t color); + + /** + * @brief Creates a color from a RGB triplet and alpha value + * + * An alpha value of 0 generates an invalid color. + */ + Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha = 0xff); + + /** + * @brief Creates a color value from a string + */ + Color (const std::string &name); + + /** + * @brief Comparison: equal + */ + bool operator== (const Color &color) const + { + return m_color == color.m_color; + } + + /** + * @brief Comparison: not equal + */ + bool operator!= (const Color &color) const + { + return m_color != color.m_color; + } + + /** + * @brief Comparison: less + */ + bool operator< (const Color &color) const + { + return m_color < color.m_color; + } + + /** + * @brief Gets the string value from a color + */ + std::string to_string () const; + + /** + * @brief Gets a value indicating whether the color is valid + */ + bool is_valid () const; + + /** + * @brief Gets the RGB triplet + */ + color_t rgb () const + { + return m_color; + } + + /** + * @brief Gets the alpha component + */ + unsigned int alpha () const + { + return (m_color & 0xff000000) >> 24; + } + + /** + * @brief Gets the red component + */ + unsigned int red () const + { + return (m_color & 0xff0000) >> 16; + } + + /** + * @brief Gets the green component + */ + unsigned int green () const + { + return (m_color & 0xff00) >> 8; + } + + /** + * @brief Gets the blue component + */ + unsigned int blue () const + { + return (m_color & 0xff); + } + + /** + * @brief Converts the color into monochrome "on" value + */ + bool to_mono () const + { + return (m_color & 0x8000) != 0; + } + + /** + * @brief Gets the HSV color components + * hue: 0..359 + * saturation: 0..255 + * value: 0..255 + */ + void get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const; + + /** + * @brief Creates the color from a HSV color + */ + static lay::Color from_hsv (unsigned int hue, unsigned int saturation, unsigned int value); + +private: + color_t m_color; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/layColorPalette.cc b/src/laybasic/laybasic/layColorPalette.cc index 7c5ad2bcd..e24cb73c9 100644 --- a/src/laybasic/laybasic/layColorPalette.cc +++ b/src/laybasic/laybasic/layColorPalette.cc @@ -232,16 +232,16 @@ ColorPalette::from_string (const std::string &s, bool simple) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (! simple && (colors () == 0 || luminous_colors () == 0)) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid palette - no colors and/or default colors"))); + throw tl::Exception (tl::to_string (tr ("invalid palette - no colors and/or default colors"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Color palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Color palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layConverters.cc b/src/laybasic/laybasic/layConverters.cc index 98c56cbe3..9aababc46 100644 --- a/src/laybasic/laybasic/layConverters.cc +++ b/src/laybasic/laybasic/layConverters.cc @@ -31,6 +31,7 @@ namespace lay // ---------------------------------------------------------------- // ColorConverter implementation +#if defined(HAVE_QT) std::string ColorConverter::to_string (const QColor &c) const { @@ -40,8 +41,20 @@ ColorConverter::to_string (const QColor &c) const return tl::to_string (c.name ()); } } +#endif -void +std::string +ColorConverter::to_string (const lay::Color &c) const +{ + if (! c.is_valid ()) { + return "auto"; + } else { + return c.to_string (); + } +} + +#if defined(HAVE_QT) +void ColorConverter::from_string (const std::string &s, QColor &c) const { std::string t (tl::trim (s)); @@ -51,6 +64,18 @@ ColorConverter::from_string (const std::string &s, QColor &c) const c = QColor (t.c_str ()); } } +#endif + +void +ColorConverter::from_string (const std::string &s, lay::Color &c) const +{ + std::string t (tl::trim (s)); + if (t == "auto") { + c = lay::Color (); + } else { + c = lay::Color (t); + } +} } diff --git a/src/laybasic/laybasic/layConverters.h b/src/laybasic/laybasic/layConverters.h index ed3c2b6aa..472b22026 100644 --- a/src/laybasic/laybasic/layConverters.h +++ b/src/laybasic/laybasic/layConverters.h @@ -25,8 +25,11 @@ #define HDR_layConverters #include "laybasicCommon.h" +#include "layColor.h" -#include +#if defined(HAVE_QT) +# include +#endif namespace lay { @@ -36,8 +39,12 @@ namespace lay */ struct LAYBASIC_PUBLIC ColorConverter { +#if defined(HAVE_QT) std::string to_string (const QColor &c) const; void from_string (const std::string &s, QColor &c) const; +#endif + std::string to_string (const lay::Color &c) const; + void from_string (const std::string &s, lay::Color &c) const; }; } diff --git a/src/laybasic/laybasic/layCursor.cc b/src/laybasic/laybasic/layCursor.cc index b718e62fc..b3b2b8b97 100644 --- a/src/laybasic/laybasic/layCursor.cc +++ b/src/laybasic/laybasic/layCursor.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layCursor.h" @@ -77,3 +78,4 @@ Cursor::qcursor (cursor_shape cursor) } +#endif diff --git a/src/laybasic/laybasic/layCursor.h b/src/laybasic/laybasic/layCursor.h index a3bc01ca5..43002bc37 100644 --- a/src/laybasic/laybasic/layCursor.h +++ b/src/laybasic/laybasic/layCursor.h @@ -20,13 +20,14 @@ */ - #ifndef HDR_layCursor #define HDR_layCursor #include "laybasicCommon.h" +#if defined(HAVE_QT) class QCursor; +#endif namespace lay { @@ -64,13 +65,15 @@ struct LAYBASIC_PUBLIC Cursor closed_hand = 18 }; +#if defined(HAVE_QT) /** * @brief Get the QCursor from the lay::cursor_shape enum */ static QCursor qcursor (cursor_shape cursor); +#endif + }; } #endif - diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc index 8f1280b08..740393388 100644 --- a/src/laybasic/laybasic/layDispatcher.cc +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -36,7 +36,9 @@ static Dispatcher *ms_dispatcher_instance = 0; Dispatcher::Dispatcher (Plugin *parent, bool standalone) : Plugin (parent, standalone), +#if defined(HAVE_QT) mp_menu_parent_widget (0), +#endif mp_delegate (0) { if (! parent && ! ms_dispatcher_instance) { @@ -44,22 +46,11 @@ Dispatcher::Dispatcher (Plugin *parent, bool standalone) } } -Dispatcher::Dispatcher (QWidget *menu_parent_widget, Plugin *parent, bool standalone) - : Plugin (parent, standalone), - mp_menu_parent_widget (menu_parent_widget), - mp_delegate (0) -{ - if (mp_menu_parent_widget) { - mp_menu.reset (new lay::AbstractMenu (this)); - } - if (! parent && ! ms_dispatcher_instance) { - ms_dispatcher_instance = this; - } -} - Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool standalone) : Plugin (parent, standalone), +#if defined(HAVE_QT) mp_menu_parent_widget (0), +#endif mp_delegate (delegate) { if (! parent && ! ms_dispatcher_instance) { @@ -67,19 +58,6 @@ Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool stand } } -Dispatcher::Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent, bool standalone) - : Plugin (parent, standalone), - mp_menu_parent_widget (menu_parent_widget), - mp_delegate (delegate) -{ - if (mp_menu_parent_widget) { - mp_menu.reset (new lay::AbstractMenu (this)); - } - if (! parent && ! ms_dispatcher_instance) { - ms_dispatcher_instance = this; - } -} - Dispatcher::~Dispatcher () { if (ms_dispatcher_instance == this) { @@ -87,15 +65,29 @@ Dispatcher::~Dispatcher () } } +#if defined(HAVE_QT) +void Dispatcher::set_menu_parent_widget (QWidget *menu_parent_widget) +{ + mp_menu_parent_widget = menu_parent_widget; + if (mp_menu_parent_widget) { + mp_menu.reset (new lay::AbstractMenu (this)); + } else { + mp_menu.reset (0); + } +} +#endif + bool Dispatcher::configure (const std::string &name, const std::string &value) { +#if defined(HAVE_QT) if (mp_menu) { std::vector ca = mp_menu->configure_actions (name); for (std::vector::const_iterator a = ca.begin (); a != ca.end (); ++a) { (*a)->configure (value); } } +#endif if (mp_delegate) { return mp_delegate->configure (name, value); @@ -264,7 +256,7 @@ Dispatcher::read_config (const std::string &config_file) try { config_structure (this).parse (*file, *this); } catch (tl::Exception &ex) { - std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); + std::string msg = tl::to_string (tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); throw tl::Exception (msg); } diff --git a/src/laybasic/laybasic/layDispatcher.h b/src/laybasic/laybasic/layDispatcher.h index 777092aad..05acda580 100644 --- a/src/laybasic/laybasic/layDispatcher.h +++ b/src/laybasic/laybasic/layDispatcher.h @@ -34,6 +34,10 @@ #include #include +#if defined(HAVE_QT) +class QWidget; +#endif + namespace lay { @@ -117,15 +121,6 @@ public: */ Dispatcher (Plugin *parent = 0, bool standalone = false); - /** - * @brief The constructor - * - * @param menu_parent_widget If not 0, indicates that this is a GUI mode dispatcher providing an abstract menu - * @param parent Usually 0, but a dispatcher may have parents. In this case, the dispatcher is not the actual dispatcher, but the real plugin chain's root is. - * @param standalone The standalone flag passed to the plugin constructor. - */ - Dispatcher (QWidget *menu_parent_widget, Plugin *parent = 0, bool standalone = false); - /** * @brief The root constructor * @@ -133,14 +128,6 @@ public: */ Dispatcher (DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); - /** - * @brief The root constructor - * - * @param menu_parent_widget If not 0, indicates that this is a GUI mode dispatcher providing an abstract menu - * @param delegate The notification receiver for dispatcher events - */ - Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); - /** * @brief Destructor */ @@ -216,6 +203,7 @@ public: } } +#if defined(HAVE_QT) /** * @brief Gets the parent widget */ @@ -224,6 +212,11 @@ public: return mp_menu_parent_widget; } + /** + * @brief Sets the parent widget + */ + void set_menu_parent_widget (QWidget *pw); + /** * @brief Returns true, if the dispatcher supplies a user interface */ @@ -238,6 +231,14 @@ public: { return (dispatcher () == this) ? mp_menu.get () : dispatcher ()->menu (); } +#else + + /** + * @brief Returns true, if the dispatcher supplies a user interface + */ + bool has_ui () { return false; } + +#endif protected: // capture the configuration events so we can change the value of the configuration actions @@ -248,8 +249,10 @@ private: Dispatcher (const Dispatcher &); Dispatcher &operator= (const Dispatcher &); +#if defined(HAVE_QT) std::unique_ptr mp_menu; QWidget *mp_menu_parent_widget; +#endif DispatcherDelegate *mp_delegate; }; diff --git a/src/laybasic/laybasic/layDisplayState.cc b/src/laybasic/laybasic/layDisplayState.cc index 2a06334cd..11faee3e7 100644 --- a/src/laybasic/laybasic/layDisplayState.cc +++ b/src/laybasic/laybasic/layDisplayState.cc @@ -190,7 +190,7 @@ DisplayState::cellview (unsigned int index, lay::LayoutHandle *layout_h) const cell_path.push_back (pci.second); valid_path = true; } else { - tl::warn << tl::to_string (QObject::tr ("Cellname cannot be reconstructed: ")) << *cn; + tl::warn << tl::to_string (tr ("Cellname cannot be reconstructed: ")) << *cn; valid_path = false; break; } @@ -215,8 +215,8 @@ DisplayState::cellview (unsigned int index, lay::LayoutHandle *layout_h) const pc = &layout_h->layout ().cell (ie.second.inst_ptr.cell_index ()); valid_path = true; } else { - tl::warn << tl::to_string (QObject::tr ("Specific instance cannot be reconstructed: instantiated cell is ")) << ci->cell_name - << tl::to_string (QObject::tr (", parent cell is ")) << layout_h->layout ().cell_name (pc->cell_index ()); + tl::warn << tl::to_string (tr ("Specific instance cannot be reconstructed: instantiated cell is ")) << ci->cell_name + << tl::to_string (tr (", parent cell is ")) << layout_h->layout ().cell_name (pc->cell_index ()); valid_path = false; } } diff --git a/src/laybasic/laybasic/layDitherPattern.cc b/src/laybasic/laybasic/layDitherPattern.cc index 0e24576bc..ede9eee47 100644 --- a/src/laybasic/laybasic/layDitherPattern.cc +++ b/src/laybasic/laybasic/layDitherPattern.cc @@ -26,6 +26,7 @@ #include "tlAssert.h" #include +#include #include namespace lay @@ -555,6 +556,8 @@ DitherPatternInfo::operator< (const DitherPatternInfo &d) const return m_order_index < d.m_order_index; } +#if defined(HAVE_QT) + // TODO including a scaling algorithm in this formula, or give more resolution to the dither QBitmap DitherPatternInfo::get_bitmap (int width, int height) const @@ -593,6 +596,8 @@ DitherPatternInfo::get_bitmap (int width, int height) const return bitmap; } +#endif + void DitherPatternInfo::set_pattern (const uint32_t *pt, unsigned int w, unsigned int h) { @@ -771,8 +776,8 @@ struct ReplaceDitherPatternOp DitherPatternInfo m_old, m_new; }; -DitherPattern::DitherPattern () - : QObject (), db::Object (0) +DitherPattern::DitherPattern () : + db::Object (0) { for (unsigned int d = 0; d < sizeof (dither_strings) / sizeof (dither_strings [0]); d += 2) { m_pattern.push_back (DitherPatternInfo ()); @@ -786,8 +791,8 @@ DitherPattern::~DitherPattern () // .. nothing yet .. } -DitherPattern::DitherPattern (const DitherPattern &p) - : QObject (), db::Object (0) +DitherPattern::DitherPattern (const DitherPattern &p) : + db::Object (0) { m_pattern = p.m_pattern; } @@ -807,6 +812,7 @@ DitherPattern::operator= (const DitherPattern &p) return *this; } +#if defined(HAVE_QT) QBitmap DitherPattern::get_bitmap (unsigned int i, int width, int height) const { @@ -816,6 +822,7 @@ DitherPattern::get_bitmap (unsigned int i, int width, int height) const return m_pattern [1].get_bitmap (width, height); } } +#endif const DitherPatternInfo & DitherPattern::pattern (unsigned int i) const @@ -831,11 +838,8 @@ DitherPattern::pattern (unsigned int i) const void DitherPattern::replace_pattern (unsigned int i, const DitherPatternInfo &p) { - bool chg = false; - while (i >= count ()) { m_pattern.push_back (DitherPatternInfo ()); - chg = true; } if (m_pattern [i] != p) { @@ -843,12 +847,6 @@ DitherPattern::replace_pattern (unsigned int i, const DitherPatternInfo &p) manager ()->queue (this, new ReplaceDitherPatternOp (i, m_pattern [i], p)); } m_pattern [i] = p; - chg = true; - } - - // if something has changed emit the signal - if (chg) { - emit changed (); } } diff --git a/src/laybasic/laybasic/layDitherPattern.h b/src/laybasic/laybasic/layDitherPattern.h index 5373c72d0..9c86eb2e1 100644 --- a/src/laybasic/laybasic/layDitherPattern.h +++ b/src/laybasic/laybasic/layDitherPattern.h @@ -27,8 +27,10 @@ #include "laybasicCommon.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif #include "dbObject.h" @@ -126,6 +128,7 @@ public: m_order_index = oi; } +#if defined(HAVE_QT) /** * @brief Get a monochrome bitmap object for this pattern * @@ -133,6 +136,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (int width = -1, int height = -1) const; +#endif /** * @brief Gets the the dither pattern @@ -225,11 +229,9 @@ private: * replaced with a new pattern, except for the first pattern which * cannot be changed. */ -class LAYBASIC_PUBLIC DitherPattern - : public QObject, public db::Object +class LAYBASIC_PUBLIC DitherPattern : + public db::Object { -Q_OBJECT - public: typedef std::vector pattern_vector; typedef pattern_vector::const_iterator iterator; @@ -272,8 +274,9 @@ public: return m_pattern != p.m_pattern; } +#if defined(HAVE_QT) /** - * @brief Get a monochrome bitmap object for this pattern + * @brief Gets a monochrome bitmap object for this pattern * * If the index is not valid, an empty bitmap is returned. * @@ -282,6 +285,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (unsigned int i, int width = -1, int height = -1) const; +#endif /** * @brief Deliver the pattern with the given index @@ -373,12 +377,6 @@ public: */ static const DitherPattern &default_pattern (); -signals: - /** - * @brief This signal is emitted if a pattern is changed - */ - void changed (); - private: std::vector m_pattern; }; diff --git a/src/laybasic/laybasic/layDragDropData.cc b/src/laybasic/laybasic/layDragDropData.cc new file mode 100644 index 000000000..e145c0c9a --- /dev/null +++ b/src/laybasic/laybasic/layDragDropData.cc @@ -0,0 +1,112 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#include "layDragDropData.h" + +#include +#include + +namespace lay +{ + +// --------------------------------------------------------------- +// Implementation of DragDropDataBase + +const char *drag_drop_mime_type () +{ + return "application/klayout-ddd"; +} + +QMimeData * +DragDropDataBase::to_mime_data () const +{ + QMimeData *mimeData = new QMimeData(); + mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ()); + return mimeData; +} + +// --------------------------------------------------------------- +// Implementation of CellDragDropData + +QByteArray +CellDragDropData::serialized () const +{ + QByteArray data; + QDataStream stream (&data, QIODevice::WriteOnly); + + stream << QString::fromUtf8 ("CellDragDropData"); + stream << (quintptr) mp_layout; + stream << (quintptr) mp_library; + stream << m_cell_index; + stream << m_is_pcell; + stream << int (m_pcell_params.size ()); + for (std::vector::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) { + stream << tl::to_qstring (i->to_parsable_string ()); + } + + return data; +} + +bool +CellDragDropData::deserialize (const QByteArray &ba) +{ + QDataStream stream (const_cast (&ba), QIODevice::ReadOnly); + + QString tag; + stream >> tag; + + if (tag == QString::fromUtf8 ("CellDragDropData")) { + + quintptr p = 0; + stream >> p; + mp_layout = reinterpret_cast (p); + stream >> p; + mp_library = reinterpret_cast (p); + stream >> m_cell_index; + stream >> m_is_pcell; + + m_pcell_params.clear (); + int n = 0; + stream >> n; + while (n-- > 0) { + QString s; + stream >> s; + std::string stl_s = tl::to_string (s); + tl::Extractor ex (stl_s.c_str ()); + m_pcell_params.push_back (tl::Variant ()); + ex.read (m_pcell_params.back ()); + } + + return true; + + } else { + + return false; + + } +} + +} + +#endif diff --git a/src/laybasic/laybasic/layDragDropData.h b/src/laybasic/laybasic/layDragDropData.h new file mode 100644 index 000000000..78bc31fa0 --- /dev/null +++ b/src/laybasic/laybasic/layDragDropData.h @@ -0,0 +1,174 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#ifndef HDR_layDragDropData +#define HDR_layDragDropData + +#include "laybasicCommon.h" + +#include "dbLayout.h" +#include "dbLibrary.h" + +#include +#include + +#include + +namespace lay +{ + +LAYBASIC_PUBLIC const char *drag_drop_mime_type (); + +/** + * @brief A helper class required to store the drag/drop data + * + * Drag/drop data is basically a collection of key/value pairs. + * A category string is provided to identify the kind of data. + */ + +class LAYBASIC_PUBLIC DragDropDataBase +{ +public: + /** + * @brief Default constructor + */ + DragDropDataBase () { } + + /** + * @brief Dtor + */ + virtual ~DragDropDataBase () { } + + /** + * @brief Serializes itself to an QByteArray + */ + virtual QByteArray serialized () const = 0; + + /** + * @brief Try deserialization from an QByteArray + * + * Returns false, if deserialization failed. + */ + virtual bool deserialize (const QByteArray &ba) = 0; + + /** + * @brief Create a QMimeData object from the object + */ + QMimeData *to_mime_data () const; +}; + +/** + * @brief Drag/drop data for a cell + */ + +class LAYBASIC_PUBLIC CellDragDropData + : public DragDropDataBase +{ +public: + /** + * @brief Default ctor + */ + CellDragDropData () + : mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false) + { + // .. nothing yet .. + } + + /** + * @brief Specifies drag & drop of a cell + * + * @param layout the layout where the cell lives in + * @param cell_index The index of the cell + */ + CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector &pcell_params = std::vector ()) + : mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params) + { + // .. nothing yet .. + } + + /** + * @brief Gets the layout object where the cell lives in + */ + const db::Layout *layout () const + { + return mp_layout; + } + + /** + * @brief Gets the layout object where the cell lives in + */ + const db::Library *library () const + { + return mp_library; + } + + /** + * @brief PCell parameters + */ + const std::vector &pcell_params () const + { + return m_pcell_params; + } + + /** + * @brief Gets the index of the cell + */ + db::cell_index_type cell_index () const + { + return m_cell_index; + } + + /** + * @brief Gets a value indicating whether the cell is a pcell + */ + bool is_pcell () const + { + return m_is_pcell; + } + + /** + * @brief Serializes itself to an QByteArray + */ + virtual QByteArray serialized () const; + + /** + * @brief Try deserialization from an QByteArray + * + * Returns false, if deserialization failed. + */ + bool deserialize (const QByteArray &ba); + +private: + const db::Layout *mp_layout; + const db::Library *mp_library; + db::cell_index_type m_cell_index; + bool m_is_pcell; + std::vector m_pcell_params; +}; + +} + +#endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layDrawing.h b/src/laybasic/laybasic/layDrawing.h index a52c71da1..20791ca70 100644 --- a/src/laybasic/laybasic/layDrawing.h +++ b/src/laybasic/laybasic/layDrawing.h @@ -34,8 +34,6 @@ #include "layViewOp.h" #include "dbTrans.h" -#include - namespace lay { @@ -123,7 +121,7 @@ public: /** * @brief Get the current appearance */ - virtual std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor active) const = 0; + virtual std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const = 0; private: unsigned int m_num_planes; diff --git a/src/laybasic/laybasic/layEditable.cc b/src/laybasic/laybasic/layEditable.cc index a391c6845..c90cc7663 100644 --- a/src/laybasic/laybasic/layEditable.cc +++ b/src/laybasic/laybasic/layEditable.cc @@ -25,7 +25,9 @@ #include "dbClipboard.h" #include "tlAssert.h" -#include "layPropertiesDialog.h" +#if defined(HAVE_QT) +# include "layPropertiesDialog.h" +#endif #include #include @@ -72,25 +74,29 @@ Editable::~Editable () // Editables implementation Editables::Editables (db::Manager *manager) - : db::Object (manager), mp_properties_dialog (0), m_move_selection (false), m_any_move_operation (false) + : db::Object (manager), m_move_selection (false), m_any_move_operation (false) { - // .. nothing yet .. +#if defined(HAVE_QT) + mp_properties_dialog = 0; +#endif } Editables::~Editables () { cancel_edits (); +#if defined(HAVE_QT) if (mp_properties_dialog) { delete mp_properties_dialog; mp_properties_dialog = 0; } +#endif } void Editables::del (db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Delete")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Delete")))); if (has_selection ()) { @@ -169,9 +175,9 @@ Editables::selection_catch_bbox () } void -Editables::transform (const db::DCplxTrans &tr, db::Transaction *transaction) +Editables::transform (const db::DCplxTrans &t, db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Transform")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Transform")))); if (has_selection ()) { @@ -183,7 +189,7 @@ Editables::transform (const db::DCplxTrans &tr, db::Transaction *transaction) manager ()->queue (this, new db::Op ()); for (iterator e = begin (); e != end (); ++e) { - e->transform (tr); + e->transform (t); } } catch (...) { @@ -597,7 +603,7 @@ Editables::move_transform (const db::DPoint &p, db::DFTrans t, lay::angle_constr void Editables::end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Move")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move")))); if (m_any_move_operation) { @@ -660,10 +666,12 @@ Editables::edit_cancel () void Editables::cancel_edits () { +#if defined(HAVE_QT) // close the property dialog if (mp_properties_dialog) { mp_properties_dialog->hide (); } +#endif // cancel any edit operations for (iterator e = begin (); e != end (); ++e) { @@ -671,6 +679,7 @@ Editables::cancel_edits () } } +#if defined(HAVE_QT) void Editables::show_properties (QWidget *parent) { @@ -686,6 +695,7 @@ Editables::show_properties (QWidget *parent) mp_properties_dialog = new lay::PropertiesDialog (parent, manager (), this); mp_properties_dialog->show (); } +#endif } diff --git a/src/laybasic/laybasic/layEditable.h b/src/laybasic/laybasic/layEditable.h index f1f54f164..40721d5a0 100644 --- a/src/laybasic/laybasic/layEditable.h +++ b/src/laybasic/laybasic/layEditable.h @@ -37,14 +37,18 @@ #include #include +#if defined(HAVE_QT) class QWidget; +#endif namespace lay { class Editables; +#if defined(HAVE_QT) class PropertiesPage; class PropertiesDialog; +#endif /** * @brief The "editable" interface @@ -353,6 +357,7 @@ public: return false; } +#if defined(HAVE_QT) /** * @brief Create a "properties page" object * @@ -368,6 +373,7 @@ public: { return 0; } +#endif /** * @brief Destruction callback by the properties page @@ -584,10 +590,12 @@ public: return m_editables.end (); } +#if defined(HAVE_QT) /** * @brief The "show properties" operation */ void show_properties (QWidget *parent); +#endif /** * @brief An event triggered if the selection changed @@ -643,7 +651,9 @@ private: tl::shared_collection m_editables; std::set m_enabled; +#if defined(HAVE_QT) lay::PropertiesDialog *mp_properties_dialog; +#endif bool m_move_selection; bool m_any_move_operation; db::DBox m_last_selected_point; diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 388bd4487..ea6f5fcff 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -22,10 +22,14 @@ #include "layEditorServiceBase.h" #include "layViewport.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" #include "layConverters.h" +#if defined(HAVE_QT) +# include +#endif + namespace lay { @@ -59,11 +63,11 @@ public: uint32_t cursor_color (lay::ViewObjectCanvas &canvas) const { - QColor color; + lay::Color color; if (mp_service) { color = mp_service->tracking_cursor_color (); } - if (! color.isValid ()) { + if (! color.is_valid ()) { color = canvas.foreground_color (); } return color.rgb (); @@ -202,7 +206,7 @@ private: // -------------------------------------------------------------------------------------- -EditorServiceBase::EditorServiceBase (lay::LayoutView *view) +EditorServiceBase::EditorServiceBase (LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), @@ -263,7 +267,7 @@ EditorServiceBase::configure (const std::string &name, const std::string &value) if (name == cfg_tracking_cursor_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); if (color != m_cursor_color) { @@ -298,4 +302,13 @@ EditorServiceBase::deactivated () clear_mouse_cursors (); } +void +EditorServiceBase::show_error (tl::Exception &ex) +{ + tl::error << ex.msg (); +#if defined(HAVE_QT) + QMessageBox::critical (widget (), tr ("Error"), tl::to_qstring (ex.msg ())); +#endif +} + } diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index d088c22fe..166f85245 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - EditorServiceBase (lay::LayoutView *view); + EditorServiceBase (lay::LayoutViewBase *view); /** * @brief Destructor @@ -92,7 +92,7 @@ public: /** * @brief Gets the tracking cursor color */ - QColor tracking_cursor_color () const + lay::Color tracking_cursor_color () const { return m_cursor_color; } @@ -121,6 +121,11 @@ public: return m_tracking_position; } + /** + * @brief Shows an error where an exception is not applicable + */ + void show_error (tl::Exception &ex); + protected: virtual bool configure (const std::string &name, const std::string &value); virtual void deactivated (); @@ -128,7 +133,7 @@ protected: private: // The marker representing the mouse cursor std::vector m_mouse_cursor_markers; - QColor m_cursor_color; + lay::Color m_cursor_color; bool m_cursor_enabled; bool m_has_tracking_position; db::DPoint m_tracking_position; diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index 7fa2d4589..214705fc4 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -86,7 +86,7 @@ Finder::closer (double d) } void -Finder::start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) +Finder::start (lay::LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) { m_layers = layers; m_region = region; @@ -265,9 +265,9 @@ struct LPContextCompareOp }; bool -ShapeFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) +ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -330,9 +330,9 @@ ShapeFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) } bool -ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) +ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -349,7 +349,7 @@ ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, co } bool -ShapeFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) +ShapeFinder::find_internal (lay::LayoutViewBase *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) { m_cv_index = cv_index; @@ -624,9 +624,9 @@ InstFinder::InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, b } bool -InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) +InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -641,9 +641,9 @@ InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) } bool -InstFinder::find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -655,7 +655,7 @@ InstFinder::find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxT } bool -InstFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { diff --git a/src/laybasic/laybasic/layFinder.h b/src/laybasic/laybasic/layFinder.h index 166842421..a89f73a48 100644 --- a/src/laybasic/laybasic/layFinder.h +++ b/src/laybasic/laybasic/layFinder.h @@ -29,7 +29,7 @@ #include #include "tlVector.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbBoxConvert.h" #include "dbLayout.h" #include "dbBox.h" @@ -136,7 +136,7 @@ protected: return m_max_level; } - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -153,7 +153,7 @@ protected: * path of instantiations up to the top cell is maintained and accessible by * the path() accessor. */ - void start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); + void start (LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); /** * @brief Provide a basic edge test facility @@ -186,7 +186,7 @@ private: int m_min_level, m_max_level; std::vector m_path; const db::Layout *mp_layout; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; db::Box m_region; std::vector m_layers; @@ -214,8 +214,8 @@ public: ShapeFinder (bool point_mode, bool top_level_sel, db::ShapeIterator::flags_type flags, const std::set *excludes = 0); - bool find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); - bool find (lay::LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -262,13 +262,13 @@ protected: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int /*level*/); - bool find_internal (lay::LayoutView *view, - unsigned int cv_index, - const std::set *prop_sel, - bool inv_prop_sel, + bool find_internal (LayoutViewBase *view, + unsigned int cv_index, + const std::set *prop_sel, + bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, - const std::vector &layers, + const std::vector &layers, const db::DBox ®ion_mu); const std::set *mp_excludes; @@ -300,8 +300,8 @@ public: InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, bool enclose_inst = true, const std::set *excludes = 0, bool visible_layers = false); - bool find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); - bool find (lay::LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -315,7 +315,7 @@ public: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int level); - bool find_internal (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); + bool find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); unsigned int m_cv_index; db::cell_index_type m_topcell; @@ -326,7 +326,7 @@ private: bool m_enclose_insts; bool m_visible_layers; std::vector m_visible_layer_indexes; - lay::LayoutView *mp_view; + LayoutViewBase *mp_view; tl::AbsoluteProgress *mp_progress; }; diff --git a/src/laybasic/laybasic/layFixedFont.h b/src/laybasic/laybasic/layFixedFont.h index fecff4abe..8803a4fe8 100644 --- a/src/laybasic/laybasic/layFixedFont.h +++ b/src/laybasic/laybasic/layFixedFont.h @@ -3,6 +3,8 @@ #ifndef HDR_layFixedFont #define HDR_layFixedFont +#include "laybasicCommon.h" + #include namespace lay @@ -12,7 +14,7 @@ namespace lay * @brief A descriptor class for a fixed font */ -class FixedFont +class LAYBASIC_PUBLIC FixedFont { public: /** diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index d24c08a62..7855cc1de 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -22,7 +22,7 @@ #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layConverters.h" #include "tlXMLParser.h" #include "tlException.h" @@ -404,7 +404,7 @@ class LayerSourceEval : public tl::Eval { public: - LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutView *view, bool real) + LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutViewBase *view, bool real) : m_lp (lp), mp_view (view), m_real (real) { // .. nothing yet .. @@ -415,14 +415,14 @@ public: return m_lp.source (m_real); } - const lay::LayoutView *view () const + const lay::LayoutViewBase *view () const { return mp_view; } private: const lay::LayerProperties &m_lp; - const lay::LayoutView *mp_view; + const lay::LayoutViewBase *mp_view; bool m_real; }; @@ -439,7 +439,7 @@ public: void execute (const tl::ExpressionParserContext &context, tl::Variant &out, const std::vector &vv) const { if (vv.size () != 0) { - throw tl::EvalError (tl::to_string (QObject::tr ("Layer source function must not have arguments")), context); + throw tl::EvalError (tl::to_string (tr ("Layer source function must not have arguments")), context); } out = tl::Variant (); @@ -480,7 +480,7 @@ private: }; std::string -LayerProperties::display_string (const lay::LayoutView *view, bool real, bool always_show_source) const +LayerProperties::display_string (const lay::LayoutViewBase *view, bool real, bool always_show_source) const { refresh (); @@ -592,7 +592,7 @@ LayerProperties::need_realize (unsigned int flags, bool /*force*/) } void -LayerProperties::do_realize (const LayoutView *view) const +LayerProperties::do_realize (const LayoutViewBase *view) const { m_layer_index = -1; m_cellview_index = -1; @@ -712,10 +712,9 @@ LayerPropertiesNode::operator== (const LayerPropertiesNode &d) const return m_children == d.m_children; } -LayoutView * -LayerPropertiesNode::view () const +LayoutViewBase *LayerPropertiesNode::view() const { - return const_cast (mp_view.get ()); + return const_cast (mp_view.get ()); } unsigned int @@ -804,7 +803,7 @@ LayerPropertiesNode::bbox () const } void -LayerPropertiesNode::attach_view (LayoutView *view, unsigned int list_index) +LayerPropertiesNode::attach_view (LayoutViewBase *view, unsigned int list_index) { mp_view.reset (view); m_list_index = list_index; @@ -1335,7 +1334,7 @@ static LayerPropertiesNode expand_wildcard_layout (const LayerPropertiesNode &so } static std::vector -expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList ¤t_props, lay::LayoutView *view, unsigned int list_index) +expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList ¤t_props, lay::LayoutViewBase *view, unsigned int list_index) { std::vector new_props; @@ -1651,7 +1650,7 @@ struct UIntColorConverter if (c == 0) { return ""; } else { - return ColorConverter::to_string (QColor (c & 0xffffff)); + return ColorConverter::to_string (lay::Color (c | 0xff000000)); } } @@ -1660,7 +1659,7 @@ struct UIntColorConverter if (s.empty ()) { c = 0; } else { - QColor qc; + lay::Color qc; ColorConverter::from_string (s, qc); c = qc.rgb () | 0xff000000; } @@ -1858,7 +1857,7 @@ LayerPropertiesList::save (tl::OutputStream &os, const std::vector (mp_view.get ()); + return const_cast (mp_view.get ()); } unsigned int diff --git a/src/laybasic/laybasic/layLayerProperties.h b/src/laybasic/laybasic/layLayerProperties.h index 6f9c6d760..1b6bffcdc 100644 --- a/src/laybasic/laybasic/layLayerProperties.h +++ b/src/laybasic/laybasic/layLayerProperties.h @@ -48,7 +48,7 @@ namespace tl { namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesList; class LayerPropertiesNode; @@ -700,7 +700,7 @@ public: * If it is set to false, the view's always_show_source attribute with determine whether the source is * shown. */ - std::string display_string (const lay::LayoutView *view, bool real, bool always_with_source = false) const; + std::string display_string (const lay::LayoutViewBase *view, bool real, bool always_with_source = false) const; /** * @brief The source specification @@ -717,7 +717,7 @@ public: * * This method may throw an exception if the specification * is not valid. In order to make the layer usable, the properties - * object must be "realized" with respect to a LayoutView object. + * object must be "realized" with respect to a LayoutViewBase object. */ void set_source (const std::string &s); @@ -725,7 +725,7 @@ public: * @brief Load the source specification * * In order to make the layer usable, the properties - * object must be "realized" with respect to a LayoutView object. + * object must be "realized" with respect to a LayoutViewBase object. */ void set_source (const lay::ParsedLayerSource &s); @@ -887,7 +887,7 @@ protected: * * @param view The view the properties refer to or 0 if there is no view. */ - void do_realize (const LayoutView *view) const; + void do_realize (const LayoutViewBase *view) const; /** * @brief Tell, if a realize of the visual properties is needed @@ -1170,14 +1170,13 @@ public: * This method attaches the properties node and it's children to a view. * This enables the node to realize itself against the view, i.e. * compute the actual property selection set. - * This method is supposed to be */ - void attach_view (LayoutView *view, unsigned int list_index); + void attach_view (LayoutViewBase *view, unsigned int list_index); /** * @brief Gets the layout view the node lives in */ - LayoutView *view () const; + LayoutViewBase *view () const; /** * @brief Gets the index of the layer properties list that node lives in @@ -1214,7 +1213,7 @@ protected: private: // A reference to the view - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; unsigned int m_list_index; // the parent node tl::weak_ptr mp_parent; @@ -1912,12 +1911,12 @@ public: * "load" automatically attaches the view. * This method has the side effect of recomputing the layer source parameters. */ - void attach_view (lay::LayoutView *view, unsigned int list_index); + void attach_view (LayoutViewBase *view, unsigned int list_index); /** * @brief Gets the layout view this list is attached to */ - lay::LayoutView *view () const; + lay::LayoutViewBase *view () const; /** * @brief Gets the layout list @@ -1925,7 +1924,7 @@ public: unsigned int list_index () const; private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; unsigned int m_list_index; layer_list m_layer_properties; lay::DitherPattern m_dither_pattern; diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 152644176..22bddfc51 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -20,23 +20,23 @@ */ - -#include -#include -#include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif #include "tlTimer.h" #include "tlLog.h" #include "tlAssert.h" #include "layLayoutCanvas.h" #include "layRedrawThread.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" -#include "gtf.h" +#if defined(HAVE_QT) +# include "gtf.h" +#endif #include "layBitmapsToImage.h" @@ -132,15 +132,15 @@ std::string ImageCacheEntry::to_string () const // ---------------------------------------------------------------------------- static void -blowup (const QImage &src, QImage &dest, unsigned int os) +blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os) { unsigned int ymax = src.height (); unsigned int xmax = src.width (); for (unsigned int y = 0; y < ymax; ++y) { for (unsigned int i = 0; i < os; ++i) { - const uint32_t *psrc = (const uint32_t *) src.scanLine (y); - uint32_t *pdest = (uint32_t *) dest.scanLine (y * os + i); + const uint32_t *psrc = (const uint32_t *) src.scan_line (y); + uint32_t *pdest = (uint32_t *) dest.scan_line (y * os + i); for (unsigned int x = 0; x < xmax; ++x) { for (unsigned int j = 0; j < os; ++j) { *pdest++ = *psrc; @@ -152,7 +152,7 @@ blowup (const QImage &src, QImage &dest, unsigned int os) } static void -subsample (const QImage &src, QImage &dest, unsigned int os, double g) +subsample (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os, double g) { // TODO: this is probably not compatible with the endianess of SPARC .. @@ -197,7 +197,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) { - const unsigned char *psrc = src.scanLine (y * os); + const unsigned char *psrc = (const unsigned char *) src.scan_line (y * os); unsigned short *pdest = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -224,7 +224,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) for (unsigned int i = 1; i < os; ++i) { - const unsigned char *psrc = src.scanLine (y * os + i); + const unsigned char *psrc = (const unsigned char *) src.scan_line (y * os + i); unsigned short *pdest = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -245,7 +245,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) { - unsigned char *pdest = dest.scanLine (y); + unsigned char *pdest = (unsigned char *) dest.scan_line (y); const unsigned short *psrc = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -274,10 +274,16 @@ invert (unsigned char *data, unsigned int width, unsigned int height) } } -LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *name) +#if defined(HAVE_QT) +LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name) : lay::ViewObjectWidget (parent, name), +#else +LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) + : lay::ViewObjectWidget (), +#endif mp_view (view), - mp_image (0), mp_image_bg (0), mp_pixmap (0), + mp_image (0), mp_image_bg (0), + mp_image_fg (0), m_background (0), m_foreground (0), m_active (0), m_oversampling (1), m_dpr (1), @@ -285,12 +291,15 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char * m_redraw_clearing (false), m_redraw_force_update (true), m_update_image (true), + m_drawing_finished (false), m_do_update_image_dm (this, &LayoutCanvas::do_update_image), m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), m_image_cache_size (1) { +#if defined(HAVE_QT) #if QT_VERSION > 0x050000 m_dpr = devicePixelRatio (); +#endif #endif // The gamma value used for subsampling: something between 1.8 and 2.2. @@ -302,11 +311,15 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char * mp_redraw_thread = new lay::RedrawThread (this, view); +#if defined(HAVE_QT) setBackgroundRole (QPalette::NoRole); - set_colors (palette ().color (QPalette::Normal, QPalette::Window), - palette ().color (QPalette::Normal, QPalette::Text), - palette ().color (QPalette::Normal, QPalette::Mid)); + set_colors (lay::Color (palette ().color (QPalette::Normal, QPalette::Window).rgb ()), + lay::Color (palette ().color (QPalette::Normal, QPalette::Text).rgb ()), + lay::Color (palette ().color (QPalette::Normal, QPalette::Mid).rgb ())); setAttribute (Qt::WA_NoSystemBackground); +#else + set_colors (0xffffffff, 0xff000000, 0xffc0c0c0); +#endif } LayoutCanvas::~LayoutCanvas () @@ -322,9 +335,9 @@ LayoutCanvas::~LayoutCanvas () delete mp_image_bg; mp_image_bg = 0; } - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } if (mp_redraw_thread) { delete mp_redraw_thread; @@ -338,24 +351,24 @@ void LayoutCanvas::key_event (unsigned int key, unsigned int buttons) { if (! (buttons & lay::ShiftButton)) { - if (int (key) == Qt::Key_Down) { - emit down_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Up) { - emit up_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Left) { - emit left_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Right) { - emit right_arrow_key_pressed (); + if (int (key) == lay::KeyDown) { + down_arrow_key_pressed (); + } else if (int (key) == lay::KeyUp) { + up_arrow_key_pressed (); + } else if (int (key) == lay::KeyLeft) { + left_arrow_key_pressed (); + } else if (int (key) == lay::KeyRight) { + right_arrow_key_pressed (); } } else { - if (int (key) == Qt::Key_Down) { - emit down_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Up) { - emit up_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Left) { - emit left_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Right) { - emit right_arrow_key_pressed_with_shift (); + if (int (key) == lay::KeyDown) { + down_arrow_key_pressed_with_shift (); + } else if (int (key) == lay::KeyUp) { + up_arrow_key_pressed_with_shift (); + } else if (int (key) == lay::KeyLeft) { + left_arrow_key_pressed_with_shift (); + } else if (int (key) == lay::KeyRight) { + right_arrow_key_pressed_with_shift (); } } } @@ -378,7 +391,7 @@ LayoutCanvas::set_oversampling (unsigned int os) } void -LayoutCanvas::set_colors (QColor background, QColor foreground, QColor active) +LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Color active) { m_background = background.rgb (); m_foreground = foreground.rgb (); @@ -433,13 +446,10 @@ LayoutCanvas::prepare_drawing () if (mp_image) { delete mp_image; } - mp_image = new QImage (m_viewport_l.width (), m_viewport_l.height (), QImage::Format_RGB32); -#if QT_VERSION > 0x050000 - mp_image->setDevicePixelRatio (double (m_dpr)); -#endif - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ()); + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } } @@ -546,12 +556,13 @@ LayoutCanvas::update_image () void LayoutCanvas::free_resources () { - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } } +#if defined(HAVE_QT) void LayoutCanvas::paintEvent (QPaintEvent *) { @@ -576,7 +587,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) if (mp_image_bg) { delete mp_image_bg; } - mp_image_bg = new QImage (*mp_image); + mp_image_bg = new lay::PixelBuffer (*mp_image); } else { // else reuse the saved image @@ -586,9 +597,9 @@ LayoutCanvas::paintEvent (QPaintEvent *) // render the main bitmaps to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, *mp_image, m_viewport_l.width (), m_viewport_l.height ()); - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } m_update_image = false; @@ -598,51 +609,44 @@ LayoutCanvas::paintEvent (QPaintEvent *) // create a base pixmap consisting of the layout with background // and static foreground objects - if (! mp_pixmap || needs_update_static () || - mp_image->size ().width () != mp_pixmap->size ().width () * int (m_oversampling) || - mp_image->size ().height () != mp_pixmap->size ().height () * int (m_oversampling)) { + if (! mp_image_fg || needs_update_static () || + int (mp_image->width ()) != (int) mp_image_fg->width () * int (m_oversampling) || + int (mp_image->height ()) != (int) mp_image_fg->height () * int (m_oversampling)) { - if (mp_pixmap) { - delete mp_pixmap; + if (mp_image_fg) { + delete mp_image_fg; } clear_fg_bitmaps (); do_render (m_viewport_l, *this, true); - mp_pixmap = new QPixmap (); + mp_image_fg = new lay::PixelBuffer (); if (fg_bitmaps () > 0) { - QImage full_image (*mp_image); -#if QT_VERSION > 0x050000 - full_image.setDevicePixelRatio (double (m_dpr)); -#endif + lay::PixelBuffer full_image (*mp_image); bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex); // render the foreground parts .. if (m_oversampling == 1) { - *mp_pixmap = QPixmap::fromImage (full_image); // Qt 4.6.0 workaround + *mp_image_fg = full_image; } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), mp_image->format ()); -#if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); -#endif + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (mp_image->transparent ()); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - *mp_pixmap = QPixmap::fromImage (subsampled_image); // Qt 4.6.0 workaround + *mp_image_fg = subsampled_image; } } else if (m_oversampling == 1) { - *mp_pixmap = QPixmap::fromImage (*mp_image); + *mp_image_fg = *mp_image; } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), mp_image->format ()); -#if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); -#endif + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (mp_image->transparent ()); subsample (*mp_image, subsampled_image, m_oversampling, m_gamma); - *mp_pixmap = QPixmap::fromImage (subsampled_image); + *mp_image_fg = subsampled_image; } @@ -656,28 +660,36 @@ LayoutCanvas::paintEvent (QPaintEvent *) // produce the pixmap first and then overdraw with dynamic content. QPainter painter (this); - painter.drawPixmap (QPoint (0, 0), *mp_pixmap); + QImage img = mp_image_fg->to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + painter.drawImage (QPoint (0, 0), img); if (fg_bitmaps () > 0) { - QImage full_image (mp_image->size ().width (), mp_image->size ().height (), QImage::Format_ARGB32); + lay::PixelBuffer full_image (mp_image->width (), mp_image->height ()); + full_image.set_transparent (true); full_image.fill (0); -#if QT_VERSION > 0x050000 - full_image.setDevicePixelRatio (double (m_dpr)); -#endif bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex); // render the foreground parts .. if (m_oversampling == 1) { - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (full_image)); - } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), QImage::Format_ARGB32); + QImage img = full_image.to_image (); #if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); + img.setDevicePixelRatio (double (m_dpr)); #endif + painter.drawImage (QPoint (0, 0), img); + } else { + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (true); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (subsampled_image)); + QImage img = subsampled_image.to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + painter.drawImage (QPoint (0, 0), img); } } @@ -692,20 +704,22 @@ LayoutCanvas::paintEvent (QPaintEvent *) } } +#endif class DetachedViewObjectCanvas : public BitmapViewObjectCanvas { public: - DetachedViewObjectCanvas (QColor bg, QColor fg, QColor ac, unsigned int width_l, unsigned int height_l, double resolution, QImage *img) + DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img) : BitmapViewObjectCanvas (width_l, height_l, resolution), m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img) { // TODO: Good choice? m_gamma = 2.0; - if (img->width () != int (width_l) || img->height () != int (height_l)) { - mp_image_l = new QImage (width_l, height_l, img->format ()); + if (img->width () != width_l || img->height () != height_l) { + mp_image_l = new lay::PixelBuffer (width_l, height_l); + mp_image_l->set_transparent (img->transparent ()); mp_image_l->fill (bg.rgb ()); } else { mp_image_l = 0; @@ -722,24 +736,24 @@ public: } } - QColor background_color () const + lay::Color background_color () const { return m_bg; } - QColor foreground_color () const + lay::Color foreground_color () const { return m_fg; } - QColor active_color () const + lay::Color active_color () const { return m_ac; } - virtual QImage &bg_image () + virtual lay::PixelBuffer *bg_image () { - return mp_image_l ? *mp_image_l : *mp_image; + return mp_image_l ? mp_image_l : mp_image; } void transfer_to_image (const lay::DitherPattern &dp, const lay::LineStyles &ls, unsigned int width, unsigned int height) @@ -764,20 +778,62 @@ public: } private: - QColor m_bg, m_fg, m_ac; - QImage *mp_image; - QImage *mp_image_l; + lay::Color m_bg, m_fg, m_ac; + lay::PixelBuffer *mp_image; + lay::PixelBuffer *mp_image_l; double m_gamma; }; -QImage +/** + * @brief A simplistic monochrome canvas + * + * NOTE: this canvas does not support background painting (currently the background objects + * do not support monochrome background painting anyway). + * Nor does it support subsampling (that would mean grayscale). + */ +class DetachedViewObjectCanvasMono + : public BitmapViewObjectCanvas +{ +public: + DetachedViewObjectCanvasMono (bool bg, bool fg, bool ac, unsigned int width, unsigned int height) + : BitmapViewObjectCanvas (width, height, 1.0), + m_bg (bg), m_fg (fg), m_ac (ac) + { + // .. nothing yet .. + } + + ~DetachedViewObjectCanvasMono () + { + clear_fg_bitmaps (); + } + + lay::Color background_color () const + { + return m_bg ? 0xffffffff : 0; + } + + lay::Color foreground_color () const + { + return m_fg ? 0xffffffff : 0; + } + + lay::Color active_color () const + { + return m_ac ? 0xffffffff : 0; + } + +private: + bool m_bg, m_fg, m_ac; +}; + +lay::PixelBuffer LayoutCanvas::image (unsigned int width, unsigned int height) { - return image_with_options (width, height, -1, -1, -1.0, QColor (), QColor (), QColor (), db::DBox (), false); + return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox ()); } -QImage -LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool is_mono) +lay::PixelBuffer +LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { if (oversampling <= 0) { oversampling = m_oversampling; @@ -788,30 +844,25 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l if (resolution <= 0.0) { resolution = 1.0 / oversampling; } - if (background == QColor ()) { + if (! background.is_valid ()) { background = background_color (); } - if (foreground == QColor ()) { + if (! foreground.is_valid ()) { foreground = foreground_color (); } - if (active == QColor ()) { + if (! active.is_valid ()) { active = active_color (); } // TODO: for other architectures MonoLSB may not be the right format - QImage img (width, height, is_mono ? QImage::Format_MonoLSB : QImage::Format_RGB32); + lay::PixelBuffer img (width, height); // this may happen for BIG images: - if (img.width () != int (width) || img.height () != int (height)) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to create an image with size %dx%d pixels")), width, height); + if (img.width () != width || img.height () != height) { + throw tl::Exception (tl::to_string (tr ("Unable to create an image with size %dx%d pixels")), width, height); } - if (is_mono) { - // in mono mode the background's color is white for green > 128 and black otherwise - img.fill ((background.rgb () & 0x8000) >> 15); - } else { - img.fill (background.rgb ()); - } + img.fill (background.rgb ()); // provide canvas objects for the layout bitmaps and the foreground/background objects BitmapRedrawThreadCanvas rd_canvas; @@ -839,41 +890,75 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l redraw_thread.stop (); // safety // paint the background objects. It uses "img" to paint on. - if (! is_mono) { + do_render_bg (vp, vo_canvas); - do_render_bg (vp, vo_canvas); + // paint the layout bitmaps + rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, *vo_canvas.bg_image (), vp.width (), vp.height ()); - // paint the layout bitmaps - rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, vo_canvas.bg_image (), vp.width (), vp.height ()); + // subsample current image to provide the background for the foreground objects + vo_canvas.make_background (); - // subsample current image to provide the background for the foreground objects - vo_canvas.make_background (); + // render the foreground parts .. + do_render (vp, vo_canvas, true); + vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - // render the foreground parts .. - do_render (vp, vo_canvas, true); - vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - - do_render (vp, vo_canvas, false); - vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - - } else { - - // TODO: Painting of background objects??? - // paint the layout bitmaps - rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, vo_canvas.bg_image (), vp.width (), vp.height ()); - - } + do_render (vp, vo_canvas, false); + vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); return img; } -QImage +lay::BitmapBuffer +LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background_c, lay::Color foreground_c, lay::Color active_c, const db::DBox &target_box) +{ + if (linewidth <= 0) { + linewidth = 1; + } + + bool background = background_c.is_valid () ? background_c.to_mono () : background_color ().to_mono (); + bool foreground = foreground_c.is_valid () ? foreground_c.to_mono () : foreground_color ().to_mono (); + bool active = active_c.is_valid () ? active_c.to_mono () : active_color ().to_mono (); + + // provide canvas objects for the layout bitmaps and the foreground/background objects + BitmapRedrawThreadCanvas rd_canvas; + DetachedViewObjectCanvasMono vo_canvas (background, foreground, active, width, height); + + // compute the new viewport + db::DBox tb (target_box); + if (tb.empty ()) { + tb = m_viewport.target_box (); + } + Viewport vp (width, height, tb); + vp.set_global_trans (m_viewport.global_trans ()); + + std::vector view_ops (m_view_ops); + if (linewidth > 1) { + for (std::vector::iterator vo = view_ops.begin (); vo != view_ops.end (); ++vo) { + vo->width (std::min (31, vo->width () * linewidth)); + } + } + + lay::RedrawThread redraw_thread (&rd_canvas, mp_view); + + // render the layout + redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true); + redraw_thread.stop (); // safety + + lay::BitmapBuffer img (width, height); + img.fill (background); + + rd_canvas.to_image_mono (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, img, vp.width (), vp.height ()); + + return img; +} + +lay::PixelBuffer LayoutCanvas::screenshot () { // if required, start the redraw thread .. prepare_drawing (); - QImage img (m_viewport.width (), m_viewport.height (), QImage::Format_RGB32); + lay::PixelBuffer img (m_viewport.width (), m_viewport.height ()); img.fill (m_background); DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr), &img); @@ -882,7 +967,7 @@ LayoutCanvas::screenshot () do_render_bg (m_viewport_l, vo_canvas); // paint the layout bitmaps - to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, vo_canvas.bg_image (), m_viewport_l.width (), m_viewport_l.height ()); + to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, *vo_canvas.bg_image (), m_viewport_l.width (), m_viewport_l.height ()); // subsample current image to provide the background for the foreground objects vo_canvas.make_background (); @@ -897,18 +982,46 @@ LayoutCanvas::screenshot () return img; } +#if defined(HAVE_QT) void LayoutCanvas::resizeEvent (QResizeEvent *) { - // clear the image cache - m_image_cache.clear (); + do_resize (width (), height ()); +} +#endif - // set the viewport to the new size - m_viewport.set_size (width () * m_dpr, height () * m_dpr); - m_viewport_l.set_size (width () * m_oversampling * m_dpr, height () * m_oversampling * m_dpr); - mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); - do_redraw_all (true); - viewport_changed_event (); +void +LayoutCanvas::resize (unsigned int width, unsigned int height) +{ + // pass down to the basic view object canvas + lay::ViewObjectWidget::resize (width, height); + + // don't wait until the layout system informs us - which may never take place when + // the widget isn't shown. + do_resize (width, height); +} + +void +LayoutCanvas::do_resize (unsigned int width, unsigned int height) +{ + unsigned int w = width * m_dpr, h = height * m_dpr; + unsigned int wl = width * m_oversampling * m_dpr, hl = height * m_oversampling * m_dpr; + + if (m_viewport.width () != w || m_viewport.height () != h || + m_viewport_l.width () != wl || m_viewport_l.height () != hl) { + + // clear the image cache + m_image_cache.clear (); + + // set the viewport to the new size + m_viewport.set_size (width * m_dpr, height * m_dpr); + m_viewport_l.set_size (width * m_oversampling * m_dpr, height * m_oversampling * m_dpr); + + mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); + do_redraw_all (true); + viewport_changed_event (); + + } } void @@ -955,6 +1068,14 @@ LayoutCanvas::zoom_trans (const db::DCplxTrans &trans) update_viewport (); } +bool +LayoutCanvas::drawing_finished () +{ + bool f = m_drawing_finished; + m_drawing_finished = false; + return f; +} + void LayoutCanvas::do_end_of_drawing () { @@ -971,6 +1092,8 @@ LayoutCanvas::do_end_of_drawing () } set_default_cursor (lay::Cursor::none); + + m_drawing_finished = true; } void @@ -979,6 +1102,7 @@ LayoutCanvas::do_update_image () update_image (); } +#if defined(HAVE_QT) bool LayoutCanvas::event (QEvent *e) { @@ -987,7 +1111,7 @@ LayoutCanvas::event (QEvent *e) // GTF probe event // record the contents (the screenshot) as ASCII text if (gtf::Recorder::instance () && gtf::Recorder::instance ()->recording ()) { - gtf::Recorder::instance ()->probe (this, gtf::image_to_variant (screenshot ())); + gtf::Recorder::instance ()->probe (this, gtf::image_to_variant (screenshot ().to_image_copy ())); } e->accept (); @@ -997,6 +1121,7 @@ LayoutCanvas::event (QEvent *e) return QWidget::event (e); } } +#endif void LayoutCanvas::redraw_all () diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 34660f835..c66ac1fcd 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -24,30 +24,31 @@ #ifndef HDR_layLayoutCanvas #define HDR_layLayoutCanvas -#include -#include -#include -#include - -#include - +#include "laybasicCommon.h" #include "dbTrans.h" #include "dbBox.h" #include "layViewport.h" #include "layViewOp.h" #include "layViewObject.h" #include "layBitmap.h" +#include "layColor.h" #include "layDrawing.h" #include "layDitherPattern.h" #include "layLineStyles.h" #include "layRedrawThreadCanvas.h" #include "layRedrawLayerInfo.h" #include "tlDeferredExecution.h" +#include "tlThreads.h" + +#include +#include +#include +#include namespace lay { -class LayoutView; +class LayoutViewBase; class RedrawThread; /** @@ -132,19 +133,25 @@ private: * and to manage the auxiliary objects like rulers etc. */ -class LayoutCanvas +class LAYBASIC_PUBLIC LayoutCanvas : public lay::ViewObjectWidget, public lay::BitmapViewObjectCanvas, public lay::BitmapRedrawThreadCanvas, public lay::Drawings { +#if defined(HAVE_QT) Q_OBJECT +#endif public: - LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *name = "canvas"); +#if defined(HAVE_QT) + LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name = "canvas"); +#else + LayoutCanvas (lay::LayoutViewBase *view); +#endif ~LayoutCanvas (); - void set_colors (QColor background, QColor foreground, QColor active); + void set_colors (lay::Color background, lay::Color foreground, lay::Color active); /** * @brief Set the view ops for the layers @@ -165,14 +172,13 @@ public: return m_view_ops; } - QImage screenshot (); - QImage image (unsigned int width, unsigned int height); - QImage image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + lay::PixelBuffer screenshot (); + lay::PixelBuffer image (unsigned int width, unsigned int height); + lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); + lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box); void update_image (); - virtual void paintEvent (QPaintEvent *); - /** * @brief Specifies the global transformation which is always applied first */ @@ -290,33 +296,33 @@ public: /** * @brief Reimplementation of ViewObjectCanvas: Background color */ - QColor background_color () const + lay::Color background_color () const { - return QColor (m_background); + return lay::Color (m_background); } /** * @brief Reimplementation of ViewObjectCanvas: Foreground color */ - QColor foreground_color () const + lay::Color foreground_color () const { - return QColor (m_foreground); + return lay::Color (m_foreground); } /** * @brief Reimplementation of ViewObjectCanvas: Active color */ - QColor active_color () const + lay::Color active_color () const { - return QColor (m_active); + return lay::Color (m_active); } /** * @brief Reimplementation of ViewObjectCanvas: background image */ - QImage &bg_image () + lay::PixelBuffer *bg_image () { - return *mp_image; + return mp_image; } /** @@ -337,27 +343,37 @@ public: return m_viewport; } + /** + * @brief Resizes the canvas object in the Qt-less case + */ + void resize (unsigned int width, unsigned int height); + + /** + * @brief Gets (and resets) a flag indicating that drawing has finished + */ + bool drawing_finished (); + /** * @brief An event indicating that the viewport was changed. * If the viewport (the rectangle that is shown) changes, this event is fired. */ tl::Event viewport_changed_event; -signals: - void left_arrow_key_pressed (); - void up_arrow_key_pressed (); - void right_arrow_key_pressed (); - void down_arrow_key_pressed (); - void left_arrow_key_pressed_with_shift (); - void up_arrow_key_pressed_with_shift (); - void right_arrow_key_pressed_with_shift (); - void down_arrow_key_pressed_with_shift (); + // key events + tl::Event left_arrow_key_pressed; + tl::Event up_arrow_key_pressed; + tl::Event right_arrow_key_pressed; + tl::Event down_arrow_key_pressed; + tl::Event left_arrow_key_pressed_with_shift; + tl::Event up_arrow_key_pressed_with_shift; + tl::Event right_arrow_key_pressed_with_shift; + tl::Event down_arrow_key_pressed_with_shift; private: - lay::LayoutView *mp_view; - QImage *mp_image; - QImage *mp_image_bg; - QPixmap *mp_pixmap; + lay::LayoutViewBase *mp_view; + lay::PixelBuffer *mp_image; + lay::PixelBuffer *mp_image_bg; + lay::PixelBuffer *mp_image_fg; db::DBox m_precious_box; lay::Viewport m_viewport, m_viewport_l; lay::color_t m_background; @@ -374,6 +390,7 @@ private: bool m_redraw_clearing; bool m_redraw_force_update; bool m_update_image; + bool m_drawing_finished; std::vector m_need_redraw_layer; std::vector m_layers; @@ -384,10 +401,14 @@ private: std::vector m_image_cache; size_t m_image_cache_size; - QMutex m_mutex; + tl::Mutex m_mutex; +#if defined(HAVE_QT) + virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); +#endif + virtual void key_event (unsigned int key, unsigned int buttons); // implementation of the lay::Drawings interface @@ -399,6 +420,7 @@ private: void do_update_image (); void do_end_of_drawing (); void do_redraw_all (bool force_redraw = true); + void do_resize (unsigned int width, unsigned int height); void prepare_drawing (); }; diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutViewBase.cc similarity index 70% rename from src/laybasic/laybasic/layLayoutView.cc rename to src/laybasic/laybasic/layLayoutViewBase.cc index d780fd482..f6f1da238 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -25,16 +25,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "laybasicConfig.h" #include "tlInternational.h" #include "tlExpression.h" @@ -43,12 +34,11 @@ #include "tlLog.h" #include "tlAssert.h" #include "tlExceptions.h" -#include "layLayoutView.h" +#include "tlDeferredExecution.h" +#include "layLayoutViewBase.h" #include "layViewOp.h" #include "layViewObject.h" -#include "laybasicConfig.h" #include "layConverters.h" -#include "layGridNet.h" #include "layMove.h" #include "layZoomBox.h" #include "layMouseTracker.h" @@ -56,29 +46,26 @@ #include "layFixedFont.h" #include "laySelector.h" #include "layLayoutCanvas.h" -#include "layLayerControlPanel.h" -#include "layHierarchyControlPanel.h" -#include "layLibrariesView.h" -#include "layBrowser.h" #include "layRedrawThread.h" #include "layRedrawThreadWorker.h" #include "layParsedLayerSource.h" -#include "layBookmarkManagementForm.h" -#include "layNetlistBrowserDialog.h" -#include "layBookmarksView.h" -#include "layEditorOptionsFrame.h" -#include "layEditorOptionsPages.h" #include "dbClipboard.h" #include "dbLayout.h" #include "dbLayoutUtils.h" #include "dbManager.h" #include "dbLibrary.h" #include "rdb.h" -#include "rdbMarkerBrowserDialog.h" #include "dbLayoutToNetlist.h" +#include "dbTechnology.h" #include "tlXMLParser.h" #include "gsi.h" -#include "gtf.h" + +#if defined(HAVE_QT) +# include +#endif + +// Enable this if you have both Qt and libpng and want to use libpng for saving images: +// #define PREFER_LIBPNG_FOR_SAVE 1 #include @@ -246,49 +233,64 @@ struct OpDeleteLayerProps // ------------------------------------------------------------- -const int timer_interval = 500; +const double animation_interval = 0.5; -static LayoutView *ms_current = 0; - -LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), - lay::Dispatcher (this, plugin_parent, false /*not standalone*/), +LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : +#if defined(HAVE_QT) + QFrame (0), +#endif + lay::Dispatcher (plugin_parent, false /*not standalone*/), + mp_ui (0), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), - dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); - - setObjectName (QString::fromUtf8(name)); - init (manager, parent); + init (manager); } -LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), +#if defined(HAVE_QT) +LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : +#else +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : +#endif +#if defined(HAVE_QT) + QFrame (parent), +#endif lay::Dispatcher (plugin_parent, false /*not standalone*/), + mp_ui (ui), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), - dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); + init (manager); +} - setObjectName (QString::fromUtf8 (name)); +#if defined(HAVE_QT) +LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : +#else +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : +#endif +#if defined(HAVE_QT) + QFrame (parent), +#endif + lay::Dispatcher (plugin_parent, false /*not standalone*/), + mp_ui (ui), + m_editable (editable), + m_options (options), + m_annotation_shapes (manager) +{ + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); m_annotation_shapes = source->m_annotation_shapes; - init (manager, parent); + init (manager); // set the handle reference and clear all cell related stuff m_cellviews = source->cellview_list (); @@ -314,10 +316,6 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); } - bookmarks (source->bookmarks ()); - - set_active_cellview_index (source->active_cellview_index ()); - // copy the title m_title = source->m_title; @@ -326,85 +324,27 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit finish_cellviews_changed (); } -bool -LayoutView::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == mp_min_hier_spbx || obj == mp_max_hier_spbx) { - - // Makes the min/max spin boxes accept only numeric and some control keys .. - QKeyEvent *keyEvent = dynamic_cast(event); - if (keyEvent && - keyEvent->key () != Qt::Key_Home && - keyEvent->key () != Qt::Key_End && - keyEvent->key () != Qt::Key_Delete && - keyEvent->key () != Qt::Key_Backspace && - (keyEvent->key () < Qt::Key_0 || keyEvent->key () > Qt::Key_9)) { - return true; - } else { - return false; - } - - } else { - return QFrame::eventFilter (obj, event); - } -} - void -LayoutView::init_menu () -{ - // make the plugins create their menu items - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - // TODO: get rid of the const_cast hack - const_cast (&*cls)->init_menu (dispatcher ()); - } - - // if not in editable mode, hide all entries from "edit_mode" group and show all from the "view_mode" group and vice versa - std::vector edit_mode_grp = menu ()->group ("edit_mode"); - for (std::vector::const_iterator g = edit_mode_grp.begin (); g != edit_mode_grp.end (); ++g) { - menu ()->action (*g)->set_visible (is_editable ()); - } - std::vector view_mode_grp = menu ()->group ("view_mode"); - for (std::vector::const_iterator g = view_mode_grp.begin (); g != view_mode_grp.end (); ++g) { - menu ()->action (*g)->set_visible (! is_editable ()); - } -} - -void -LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) +LayoutViewBase::init (db::Manager *mgr) { manager (mgr); - if (dispatcher () == this) { - // if we're the root dispatcher initialize the menu and build the context menus. No other menus are built so far. - init_menu (); - menu ()->build (0, 0); - } + m_active_cellview_index = -1; + m_active_cellview_changed_event_enabled = true; m_annotation_shapes.manager (mgr); m_visibility_changed = false; - m_active_cellview_changed_event_enabled = true; m_disabled_edits = 0; m_synchronous = false; m_drawing_workers = 1; - mp_control_panel = 0; - mp_control_frame = 0; - mp_hierarchy_panel = 0; - mp_hierarchy_frame = 0; - mp_libraries_view = 0; - mp_bookmarks_view = 0; - mp_libraries_frame = 0; - mp_editor_options_frame = 0; - mp_bookmarks_frame = 0; - mp_min_hier_spbx = 0; - mp_max_hier_spbx = 0; m_from_level = 0; m_pan_distance = 0.15; m_wheel_mode = 0; m_paste_display_mode = 2; m_guiding_shape_visible = true; m_guiding_shape_line_width = 1; - m_guiding_shape_color = QColor (); + m_guiding_shape_color = lay::Color (); m_guiding_shape_vertex_size = 5; m_to_level = 0; m_ctx_dimming = 50; @@ -430,7 +370,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_no_stipples = false; m_stipple_offset = true; m_fit_new_cell = true; - m_full_hier_new_cell = true; + m_full_hier_new_cell = false; m_clear_ruler_new_cell = false; m_dbu_coordinates = false; m_absolute_coordinates = false; @@ -439,7 +379,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_drop_small_cells_cond = DSC_Max; m_draw_array_border_instances = false; m_dirty = false; - m_activated = true; + m_prop_changed = false; m_animated = false; m_phase = 0; m_palette = lay::ColorPalette::default_palette (); @@ -458,9 +398,6 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_transient_selection_mode = true; m_sel_inside_pcells = false; m_add_other_layers = false; - m_always_show_source = false; - m_always_show_ld = true; - m_always_show_layout_index = false; m_search_range = 5; m_search_range_box = 0; @@ -468,108 +405,11 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); m_current_layer_list = 0; - QVBoxLayout *vbl = new QVBoxLayout (this); - vbl->setContentsMargins (0, 0, 0, 0); - vbl->setSpacing (0); - - mp_canvas = new lay::LayoutCanvas (this, this); - vbl->addWidget (mp_canvas); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ())); - - if ((m_options & LV_NoHierarchyPanel) == 0 && (m_options & LV_Naked) == 0) { - - QFrame *hierarchy_frame = new QFrame (0); - hierarchy_frame->setObjectName (QString::fromUtf8 ("left")); - mp_hierarchy_frame = hierarchy_frame; - QVBoxLayout *left_frame_ly = new QVBoxLayout (hierarchy_frame); - left_frame_ly->setContentsMargins (0, 0, 0, 0); - left_frame_ly->setSpacing (0); - - mp_hierarchy_panel = new lay::HierarchyControlPanel (this, hierarchy_frame, "hcp"); - left_frame_ly->addWidget (mp_hierarchy_panel, 1 /*stretch*/); - - connect (mp_hierarchy_panel, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int))); - connect (mp_hierarchy_panel, SIGNAL (active_cellview_changed (int)), this, SLOT (active_cellview_changed (int))); - connect (mp_hierarchy_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); - - QFrame *levels_frame = new QFrame (hierarchy_frame); - levels_frame->setObjectName (QString::fromUtf8 ("lvl_frame")); - left_frame_ly->addWidget (levels_frame); - QHBoxLayout *levels_frame_ly = new QHBoxLayout (levels_frame); - levels_frame_ly->setContentsMargins (1, 1, 1, 1); - QLabel *level_l1 = new QLabel (tl::to_qstring (" " + tl::to_string (QObject::tr ("Levels"))), levels_frame); - levels_frame_ly->addWidget (level_l1); - mp_min_hier_spbx = new QSpinBox (levels_frame); - mp_min_hier_spbx->setObjectName (QString::fromUtf8 ("min_lvl")); - levels_frame_ly->addWidget (mp_min_hier_spbx); - QLabel *level_l2 = new QLabel (QString::fromUtf8 (".."), levels_frame); - levels_frame_ly->addWidget (level_l2); - mp_max_hier_spbx = new QSpinBox (levels_frame); - mp_max_hier_spbx->setObjectName (QString::fromUtf8 ("max_lvl")); - levels_frame_ly->addWidget (mp_max_hier_spbx); - - mp_min_hier_spbx->installEventFilter (this); - mp_max_hier_spbx->installEventFilter (this); - - mp_min_hier_spbx->setMaximum (0); - mp_min_hier_spbx->setMinimum (-1000); - mp_min_hier_spbx->setValue (0); - mp_max_hier_spbx->setMaximum (999); - mp_max_hier_spbx->setValue (0); - mp_max_hier_spbx->setMinimum (-1000); - - connect (mp_min_hier_spbx, SIGNAL (valueChanged (int)), this, SLOT (min_hier_changed (int))); - connect (mp_max_hier_spbx, SIGNAL (valueChanged (int)), this, SLOT (max_hier_changed (int))); - - } - - if ((m_options & LV_NoBookmarksView) == 0 && (m_options & LV_Naked) == 0) { - - QFrame *bookmarks_frame = new QFrame (0); - bookmarks_frame->setObjectName (QString::fromUtf8 ("bookmarks_frame")); - mp_bookmarks_frame = bookmarks_frame; - QVBoxLayout *left_frame_ly = new QVBoxLayout (bookmarks_frame); - left_frame_ly->setContentsMargins (0, 0, 0, 0); - left_frame_ly->setSpacing (0); - - mp_bookmarks_view = new lay::BookmarksView (this, bookmarks_frame, "bookmarks"); - left_frame_ly->addWidget (mp_bookmarks_view, 1 /*stretch*/); - - connect (mp_bookmarks_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); - - } - - if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) { - - mp_libraries_frame = new QFrame (0); - mp_libraries_frame->setObjectName (QString::fromUtf8 ("libs_frame")); - QVBoxLayout *left_frame_ly = new QVBoxLayout (mp_libraries_frame); - left_frame_ly->setContentsMargins (0, 0, 0, 0); - left_frame_ly->setSpacing (0); - - mp_libraries_view = new lay::LibrariesView (this, mp_libraries_frame, "libs"); - left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/); - - connect (mp_libraries_view, SIGNAL (active_library_changed (int)), this, SLOT (active_library_changed (int))); - connect (mp_libraries_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); - - } - - if ((m_options & LV_NoEditorOptionsPanel) == 0 && (m_options & LV_Naked) == 0) { - - mp_editor_options_frame = new lay::EditorOptionsFrame (0); - mp_editor_options_frame->populate (this); - - connect (mp_editor_options_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); - - } +#if defined(HAVE_QT) + mp_canvas = new lay::LayoutCanvas (widget (), this); +#else + mp_canvas = new lay::LayoutCanvas (this); +#endif // occupy services and editables: // these services get deleted by the canvas destructor automatically: @@ -586,47 +426,13 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) mp_move_service = new lay::MoveService (this); } - if ((m_options & LV_NoLayers) == 0 && (m_options & LV_Naked) == 0) { - - mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); - mp_control_frame = mp_control_panel; - - connect (mp_control_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); - connect (mp_control_panel, SIGNAL (tab_changed ()), this, SLOT (layer_tab_changed ())); - connect (mp_control_panel, SIGNAL (order_changed ()), this, SLOT (layer_order_changed ())); - connect (mp_control_panel, SIGNAL (current_layer_changed (const lay::LayerPropertiesConstIterator &)), this, SLOT (current_layer_changed_slot (const lay::LayerPropertiesConstIterator &))); - /* - connect (mp_control_panel, SIGNAL (marked_changed ()), this, SLOT (prop_changed ())); - connect (mp_control_panel, SIGNAL (width_changed ()), this, SLOT (prop_changed ())); - connect (mp_control_panel, SIGNAL (animation_changed ()), this, SLOT (prop_changed ())); - connect (mp_control_panel, SIGNAL (visibility_changed ()), this, SLOT (visibility_changed ())); - connect (mp_control_panel, SIGNAL (transparency_changed ()), this, SLOT (prop_changed ())); - connect (mp_control_panel, SIGNAL (stipple_changed ()), this, SLOT (prop_changed ())); - connect (mp_control_panel, SIGNAL (color_changed ()), this, SLOT (prop_changed ())); - */ - - } - - mp_timer = new QTimer (this); - connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); - mp_timer->start (timer_interval); - create_plugins (); - - config_setup (); } -LayoutView::~LayoutView () +LayoutViewBase::~LayoutViewBase () { - close_event (); - - if (ms_current == this) { - ms_current = 0; - } - // detach all observers - // This is to prevent signals to partially destroyed observers that own a LayoutView - close_event.clear (); + // This is to prevent signals to partially destroyed observers that own a LayoutViewBase layer_list_changed_event.clear (); layer_list_deleted_event.clear (); layer_list_inserted_event.clear (); @@ -677,144 +483,56 @@ LayoutView::~LayoutView () stop (); - // because LayoutView and LayoutCanvas both control lifetimes of + // because LayoutViewBase and LayoutCanvas both control lifetimes of // ruler objects for example, it is safer to explicitly delete the // LayoutCanvas object here: delete mp_canvas; mp_canvas = 0; - - if (mp_control_frame) { - delete mp_control_frame; - } - mp_control_panel = 0; - mp_control_frame = 0; - - if (mp_hierarchy_frame) { - delete mp_hierarchy_frame; - } - mp_hierarchy_frame = 0; - mp_hierarchy_panel = 0; - - if (mp_libraries_frame) { - delete mp_libraries_frame; - } - mp_libraries_frame = 0; - mp_libraries_view = 0; - - if (mp_editor_options_frame) { - delete mp_editor_options_frame; - } - mp_editor_options_frame = 0; - - if (mp_bookmarks_frame) { - delete mp_bookmarks_frame; - } - mp_bookmarks_frame = 0; - mp_bookmarks_view = 0; } -lay::EditorOptionsPages *LayoutView::editor_options_pages () +void LayoutViewBase::resize (unsigned int width, unsigned int height) { - if (! mp_editor_options_frame) { - return 0; - } else { - return mp_editor_options_frame->pages_widget (); - } + mp_canvas->resize (width, height); } -void LayoutView::do_setup_editor_options_pages () -{ - // initialize the editor option pages - lay::EditorOptionsPages *eo_pages = editor_options_pages (); - if (eo_pages) { - for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { - (*op)->setup (this); - } - } -} - -void LayoutView::side_panel_destroyed () -{ - if (sender () == mp_control_frame) { - mp_control_frame = 0; - mp_control_panel = 0; - } else if (sender () == mp_hierarchy_frame) { - mp_hierarchy_frame = 0; - mp_hierarchy_panel = 0; - } else if (sender () == mp_libraries_frame) { - mp_libraries_frame = 0; - mp_libraries_view = 0; - } else if (sender () == mp_editor_options_frame) { - mp_editor_options_frame = 0; - } else if (sender () == mp_bookmarks_frame) { - mp_bookmarks_frame = 0; - mp_bookmarks_view = 0; - } -} - -void LayoutView::hideEvent (QHideEvent *) -{ - hide_event (); -} - -void LayoutView::showEvent (QShowEvent *) -{ - show_event (); -} - -void LayoutView::set_current () -{ - set_current (this); -} - -void LayoutView::set_current (lay::LayoutView *view) -{ - if (ms_current != view) { - if (ms_current) { - ms_current->deactivate (); - } - ms_current = view; - if (ms_current) { - ms_current->activate (); - } - } -} - -LayoutView *LayoutView::current () -{ - return ms_current; -} - -void LayoutView::update_event_handlers () +void LayoutViewBase::update_event_handlers () { tl::Object::detach_from_all_events (); for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { // TODO: get rid of the const_cast hack - const_cast ((*p)->plugin_declaration ())->editable_enabled_changed_event.add (this, &LayoutView::signal_plugin_enabled_changed); + const_cast ((*p)->plugin_declaration ())->editable_enabled_changed_event.add (this, &LayoutViewBase::signal_plugin_enabled_changed); } for (unsigned int i = 0; i < cellviews (); ++i) { - cellview (i)->layout ().hier_changed_event.add (this, &LayoutView::signal_hier_changed); - cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutView::signal_bboxes_from_layer_changed, i); - cellview (i)->layout ().dbu_changed_event.add (this, &LayoutView::signal_bboxes_changed); - cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutView::signal_prop_ids_changed); - cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutView::signal_layer_properties_changed); - cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutView::signal_cell_name_changed); - cellview (i)->apply_technology_with_sender_event.add (this, &LayoutView::signal_apply_technology); + cellview (i)->layout ().hier_changed_event.add (this, &LayoutViewBase::signal_hier_changed); + cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutViewBase::signal_bboxes_from_layer_changed, i); + cellview (i)->layout ().dbu_changed_event.add (this, &LayoutViewBase::signal_bboxes_changed); + cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutViewBase::signal_prop_ids_changed); + cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutViewBase::signal_layer_properties_changed); + cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutViewBase::signal_cell_name_changed); + cellview (i)->apply_technology_with_sender_event.add (this, &LayoutViewBase::signal_apply_technology); } - annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutView::signal_annotations_changed); + annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutViewBase::signal_annotations_changed); - mp_canvas->viewport_changed_event.add (this, &LayoutView::viewport_changed); + mp_canvas->viewport_changed_event.add (this, &LayoutViewBase::viewport_changed); + mp_canvas->left_arrow_key_pressed.add (this, &LayoutViewBase::pan_left); + mp_canvas->up_arrow_key_pressed.add (this, &LayoutViewBase::pan_up); + mp_canvas->right_arrow_key_pressed.add (this, &LayoutViewBase::pan_right); + mp_canvas->down_arrow_key_pressed.add (this, &LayoutViewBase::pan_down); + mp_canvas->left_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_left_fast); + mp_canvas->up_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_up_fast); + mp_canvas->right_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_right_fast); + mp_canvas->down_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_down_fast); } -void LayoutView::viewport_changed () +void LayoutViewBase::viewport_changed () { viewport_changed_event (); } -bool LayoutView::accepts_drop (const std::string &path_or_url) const +bool LayoutViewBase::accepts_drop (const std::string &path_or_url) const { for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if ((*p)->accepts_drop (path_or_url)) { @@ -824,7 +542,7 @@ bool LayoutView::accepts_drop (const std::string &path_or_url) const return false; } -void LayoutView::drop_url (const std::string &path_or_url) +void LayoutViewBase::drop_url (const std::string &path_or_url) { for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if ((*p)->accepts_drop (path_or_url)) { @@ -834,7 +552,44 @@ void LayoutView::drop_url (const std::string &path_or_url) } } -lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) +void LayoutViewBase::clear_plugins () +{ + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + delete *p; + } + mp_plugins.clear (); + mp_active_plugin = 0; +} + +void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) +{ + clear_plugins (); + + // create the plugins + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + if (&*cls != except_this) { + + // TODO: clean solution. The following is a HACK: + if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { + // ant and img are created always + create_plugin (&*cls); + } else if ((options () & LV_NoPlugins) == 0) { + // others: only create unless LV_NoPlugins is set + create_plugin (&*cls); + } else if ((options () & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { + // except grid net plugin which is created on request + create_plugin (&*cls); + } + + } + + } + + mode (default_mode ()); +} + +lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) { lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); if (p) { @@ -856,40 +611,7 @@ lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) return p; } -void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - delete *p; - } - mp_plugins.clear (); - - // create the plugins - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - - if (&*cls != except_this) { - - // TODO: clean solution. The following is a HACK: - if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { - // ant and img are created always - create_plugin (&*cls); - } else if ((m_options & LV_NoPlugins) == 0) { - // others: only create unless LV_NoPlugins is set - create_plugin (&*cls); - } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { - // except grid net plugin which is created on request - create_plugin (&*cls); - } - - } - - } - - dm_setup_editor_option_pages (); - - mode (default_mode ()); -} - -Plugin *LayoutView::get_plugin_by_name (const std::string &name) const +Plugin *LayoutViewBase::get_plugin_by_name (const std::string &name) const { lay::PluginDeclaration *decl = 0; for (tl::Registrar::iterator cls = tl::Registrar::begin (); !decl && cls != tl::Registrar::end (); ++cls) { @@ -909,85 +631,37 @@ Plugin *LayoutView::get_plugin_by_name (const std::string &name) const return 0; } -namespace { - -class GotoBookmarkAction - : public lay::Action -{ -public: - GotoBookmarkAction (lay::LayoutView *view, size_t id, const std::string &title) - : Action (), mp_view (view), m_id (id) - { - set_title (title); - } - - void triggered () - { - if (mp_view) { - mp_view->goto_view (mp_view->bookmarks ().state (m_id)); - } - } - -private: - tl::weak_ptr mp_view; - size_t m_id; -}; - -} - void -LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) -{ - std::string bm_menu = "bookmark_menu.goto_bookmark_menu"; - - if (menu.is_valid (bm_menu)) { - - menu.clear_menu (bm_menu); - - Action *goto_bookmark_action = menu.action (bm_menu); - - if (view && view->bookmarks ().size () > 0) { - - goto_bookmark_action->set_enabled (true); - - const lay::BookmarkList &bookmarks = view->bookmarks (); - for (size_t i = 0; i < bookmarks.size (); ++i) { - Action *action = new GotoBookmarkAction (view, i, bookmarks.name (i)); - menu.insert_item (bm_menu + ".end", tl::sprintf ("bookmark_%d", i + 1), action); - } - - } else { - goto_bookmark_action->set_enabled (false); - } - - } -} - -void -LayoutView::set_drawing_workers (int workers) +LayoutViewBase::set_drawing_workers (int workers) { m_drawing_workers = std::max (0, std::min (100, workers)); } void -LayoutView::set_synchronous (bool s) +LayoutViewBase::set_synchronous (bool s) { m_synchronous = s; } +void +LayoutViewBase::message (const std::string & /*s*/, int /*timeout*/) +{ + // .. nothing yet .. +} + bool -LayoutView::is_dirty () const +LayoutViewBase::is_dirty () const { return m_dirty; } std::string -LayoutView::title () const +LayoutViewBase::title () const { if (! m_title.empty ()) { return m_title; } else if (cellviews () == 0) { - return tl::to_string (QObject::tr ("")); + return tl::to_string (tr ("")); } else { int cv_index = active_cellview_index (); @@ -1015,26 +689,26 @@ LayoutView::title () const } } -void -LayoutView::set_title (const std::string &t) +void +LayoutViewBase::set_title (const std::string &t) { if (m_title != t) { m_title = t; - emit title_changed (); + emit_title_changed (); } } -void -LayoutView::reset_title () +void +LayoutViewBase::reset_title () { if (! m_title.empty ()) { m_title = ""; - emit title_changed (); + emit_title_changed (); } } bool -LayoutView::configure (const std::string &name, const std::string &value) +LayoutViewBase::configure (const std::string &name, const std::string &value) { lay::Dispatcher::configure (name, value); @@ -1052,106 +726,9 @@ LayoutView::configure (const std::string &name, const std::string &value) tl::from_string (value, m_add_other_layers); return false; // not taken - let others set it too. - } else if (name == cfg_layers_always_show_source) { - - bool a = false; - tl::from_string (value, a); - if (a != m_always_show_source) { - m_always_show_source = a; - layer_list_changed_event (4); - } - - return true; - - } else if (name == cfg_layers_always_show_ld) { - - tl::from_string (value, m_always_show_ld); - update_content (); - return true; - - } else if (name == cfg_layers_always_show_layout_index) { - - tl::from_string (value, m_always_show_layout_index); - update_content (); - return true; - - } else if (name == cfg_flat_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_flat (f); - } - return true; - - } else if (name == cfg_split_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_split_mode (f); - } - return true; - - } else if (name == cfg_split_lib_views) { - - bool f; - tl::from_string (value, f); - if (mp_libraries_view) { - mp_libraries_view->set_split_mode (f); - } - return true; - - } else if (name == cfg_bookmarks_follow_selection) { - - bool f; - tl::from_string (value, f); - if (mp_bookmarks_view) { - mp_bookmarks_view->follow_selection (f); - } - return true; - - } else if (name == cfg_current_lib_view) { - - if (mp_libraries_view) { - mp_libraries_view->select_active_lib_by_name (value); - } - return true; - - } else if (name == cfg_cell_list_sorting) { - - if (mp_hierarchy_panel) { - if (value == "by-name") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByName); - } else if (value == "by-area") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByArea); - } else if (value == "by-area-reverse") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByAreaReverse); - } - } - return true; - - } else if (name == cfg_hide_empty_layers) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_hide_empty_layers (f); - } - return true; - - } else if (name == cfg_test_shapes_in_view) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_test_shapes_in_view (f); - } - return true; - } else if (name == cfg_background_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); background_color (color); // do not take - let others receive the background color events as well @@ -1196,7 +773,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_ctx_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); ctx_color (color); return true; @@ -1217,7 +794,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_child_ctx_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); child_ctx_color (color); return true; @@ -1301,14 +878,14 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_cell_box_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); cell_box_color (color); return true; } else if (name == cfg_text_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); text_color (color); return true; @@ -1427,14 +1004,14 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_guiding_shape_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); guiding_shapes_color (color); return true; } else if (name == cfg_guiding_shape_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); guiding_shapes_color (color); return true; @@ -1589,7 +1166,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_sel_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); // Change the color @@ -1671,15 +1248,13 @@ LayoutView::configure (const std::string &name, const std::string &value) } void -LayoutView::config_finalize () +LayoutViewBase::config_finalize () { - // It's important that the editor option pages are updated last - because the - // configuration change may trigger other configuration changes - dm_setup_editor_option_pages (); + // .. nothing yet .. } void -LayoutView::enable_edits (bool enable) +LayoutViewBase::enable_edits (bool enable) { // enable or disable these services: if (mp_selection_service) { @@ -1708,97 +1283,12 @@ LayoutView::enable_edits (bool enable) } if (edits_enabled () != is_enabled) { - emit edits_enabled_changed (); - } -} - -bool -LayoutView::set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &lp) -{ - bool ok = set_current_layer (cv_index, lp); - if (ok) { - return true; - } - - if (! mp_control_panel) { - return false; - } - - const lay::CellView &cv = cellview (cv_index); - if (! cv.is_valid ()) { - return false; - } - - if (QMessageBox::question (this, tr ("Create Layer"), tr ("Layer %1 does not exist yet. Create it now?").arg (tl::to_qstring (lp.to_string ()))) == QMessageBox::Yes) { - - lay::LayerPropertiesNode lpn; - lpn.set_source (lay::ParsedLayerSource (lp, cv_index)); - init_layer_properties (lpn); - - transaction (tl::to_string (QObject::tr ("Create new layer"))); - set_current_layer (lay::LayerPropertiesConstIterator (& insert_layer (end_layers (), lpn))); - commit (); - - return true; - - } - - return false; -} - -bool -LayoutView::set_current_layer (unsigned int cv_index, const db::LayerProperties &lp) -{ - // rename the ones that got shifted. - lay::LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (l->source (true).cv_index () == int (cv_index) && l->source (true).layer_props ().log_equal (lp)) { - set_current_layer (l); - return true; - } - ++l; - } - return false; -} - -void -LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) -{ - if (mp_control_panel) { - mp_control_panel->set_current_layer (l); - } -} - -lay::LayerPropertiesConstIterator -LayoutView::current_layer () const -{ - if (mp_control_panel) { - return mp_control_panel->current_layer (); - } else { - return lay::LayerPropertiesConstIterator (); - } -} - -std::vector -LayoutView::selected_layers () const -{ - if (mp_control_panel) { - return mp_control_panel->selected_layers (); - } else { - return std::vector (); - } -} - -void -LayoutView::set_selected_layers (const std::vector &sel) -{ - if (mp_control_panel) { - mp_control_panel->set_selection (sel); + emit_edits_enabled_changed (); } } void -LayoutView::set_line_styles (const lay::LineStyles &styles) +LayoutViewBase::set_line_styles (const lay::LineStyles &styles) { if (mp_canvas->line_styles () != styles) { @@ -1819,7 +1309,7 @@ LayoutView::set_line_styles (const lay::LineStyles &styles) } void -LayoutView::set_dither_pattern (const lay::DitherPattern &pattern) +LayoutViewBase::set_dither_pattern (const lay::DitherPattern &pattern) { if (mp_canvas->dither_pattern () != pattern) { @@ -1840,7 +1330,7 @@ LayoutView::set_dither_pattern (const lay::DitherPattern &pattern) } const LayerPropertiesList & -LayoutView::get_properties (unsigned int index) const +LayoutViewBase::get_properties (unsigned int index) const { if (index >= layer_lists ()) { static lay::LayerPropertiesList empty; @@ -1851,7 +1341,7 @@ LayoutView::get_properties (unsigned int index) const } void -LayoutView::set_current_layer_list (unsigned int index) +LayoutViewBase::set_current_layer_list (unsigned int index) { if (index != m_current_layer_list && index < layer_lists ()) { m_current_layer_list = index; @@ -1861,7 +1351,7 @@ LayoutView::set_current_layer_list (unsigned int index) } void -LayoutView::insert_layer_list (unsigned index, const LayerPropertiesList &props) +LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &props) { if (index > layer_lists ()) { return; @@ -1873,6 +1363,8 @@ LayoutView::insert_layer_list (unsigned index, const LayerPropertiesList &props) manager ()->clear (); } + clear_layer_selection (); + m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); m_layer_properties_lists [index]->attach_view (this, index); merge_dither_pattern (*m_layer_properties_lists [index]); @@ -1884,11 +1376,11 @@ LayoutView::insert_layer_list (unsigned index, const LayerPropertiesList &props) redraw (); - dm_prop_changed (); + m_prop_changed = true; } void -LayoutView::delete_layer_list (unsigned index) +LayoutViewBase::delete_layer_list (unsigned index) { if (index >= layer_lists ()) { return; @@ -1900,6 +1392,8 @@ LayoutView::delete_layer_list (unsigned index) manager ()->clear (); } + clear_layer_selection (); + delete m_layer_properties_lists [index]; m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); @@ -1926,11 +1420,11 @@ LayoutView::delete_layer_list (unsigned index) } layer_list_deleted_event (index); - dm_prop_changed (); + m_prop_changed = true; } void -LayoutView::rename_properties (unsigned int index, const std::string &new_name) +LayoutViewBase::rename_properties (unsigned int index, const std::string &new_name) { if (index >= layer_lists ()) { return; @@ -1947,8 +1441,61 @@ LayoutView::rename_properties (unsigned int index, const std::string &new_name) layer_list_changed_event (4); } +bool +LayoutViewBase::set_current_layer (unsigned int cv_index, const db::LayerProperties &lp) +{ + // rename the ones that got shifted. + lay::LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (l->source (true).cv_index () == int (cv_index) && l->source (true).layer_props ().log_equal (lp)) { + set_current_layer (l); + return true; + } + ++l; + } + return false; +} + void -LayoutView::merge_dither_pattern (lay::LayerPropertiesList &props) +LayoutViewBase::clear_layer_selection () +{ + m_current_layer = lay::LayerPropertiesConstIterator (); + m_selected_layers.clear (); +} + +void +LayoutViewBase::set_current_layer (const lay::LayerPropertiesConstIterator &l) +{ + m_current_layer = l; + m_selected_layers.clear (); + m_selected_layers.push_back (l); +} + +lay::LayerPropertiesConstIterator +LayoutViewBase::current_layer () const +{ + return m_current_layer; +} + +std::vector +LayoutViewBase::selected_layers () const +{ + return m_selected_layers; +} + +void +LayoutViewBase::set_selected_layers (const std::vector &sel) +{ + m_selected_layers = sel; + if (sel.empty ()) { + m_current_layer = lay::LayerPropertiesConstIterator (); + } else { + m_current_layer = sel.front (); + } +} + +void +LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) { { lay::DitherPattern dp (dither_pattern ()); @@ -1999,8 +1546,26 @@ LayoutView::merge_dither_pattern (lay::LayerPropertiesList &props) } } +bool +LayoutViewBase::always_show_source () const +{ + return false; +} + +bool +LayoutViewBase::always_show_ld () const +{ + return true; +} + +bool +LayoutViewBase::always_show_layout_index () const +{ + return false; +} + void -LayoutView::set_properties (unsigned int index, const LayerPropertiesList &props) +LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &props) { // If index is not a valid tab index, don't do anything except for the case of // index 0 in which the first entry is created (this can happen as a result of @@ -2024,8 +1589,8 @@ LayoutView::set_properties (unsigned int index, const LayerPropertiesList &props manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } *m_layer_properties_lists [index] = props; @@ -2034,30 +1599,27 @@ LayoutView::set_properties (unsigned int index, const LayerPropertiesList &props merge_dither_pattern (*m_layer_properties_lists [index]); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (3); - redraw (); - - dm_prop_changed (); - + m_prop_changed = true; } } void -LayoutView::expand_properties () +LayoutViewBase::expand_properties () { expand_properties (std::map (), false); } void -LayoutView::expand_properties (unsigned int index) +LayoutViewBase::expand_properties (unsigned int index) { expand_properties (index, std::map (), false); } void -LayoutView::expand_properties (const std::map &map_cv_index, bool add_default) +LayoutViewBase::expand_properties (const std::map &map_cv_index, bool add_default) { for (unsigned int i = 0; i < cellviews (); ++i) { expand_properties (i, map_cv_index, add_default); @@ -2065,7 +1627,7 @@ LayoutView::expand_properties (const std::map &map_cv_index, bool add_ } void -LayoutView::expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default) +LayoutViewBase::expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default) { if (index < m_layer_properties_lists.size ()) { m_layer_properties_lists [index]->expand (map_cv_index, add_default); @@ -2073,7 +1635,7 @@ LayoutView::expand_properties (unsigned int index, const std::map &map } void -LayoutView::replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &node) +LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &node) { if (index >= layer_lists ()) { return; @@ -2088,29 +1650,26 @@ LayoutView::replace_layer_node (unsigned int index, const LayerPropertiesConstIt manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } + if (index == current_layer_list ()) { + begin_layer_updates (); + } LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); *non_const_iter = node; non_const_iter->attach_view (this, index); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (2); - // TODO: check, if redraw is actually necessary (this is complex!) redraw (); - - dm_prop_changed (); - + m_prop_changed = true; } } } void -LayoutView::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props) +LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props) { if (index >= layer_lists ()) { return; @@ -2146,14 +1705,14 @@ LayoutView::set_properties (unsigned int index, const LayerPropertiesConstIterat // perform the callbacks asynchronously to collect the necessary calls instead // of executing them immediately. - dm_prop_changed (); + m_prop_changed = true; } } } const LayerPropertiesNode & -LayoutView::insert_layer (unsigned int index, const LayerPropertiesConstIterator &before, const LayerPropertiesNode &node) +LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIterator &before, const LayerPropertiesNode &node) { tl_assert (index < layer_lists ()); @@ -2163,24 +1722,25 @@ LayoutView::insert_layer (unsigned int index, const LayerPropertiesConstIterator manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } const LayerPropertiesNode &ret = m_layer_properties_lists [index]->insert (LayerPropertiesIterator (*m_layer_properties_lists [index], before.uint ()), node); // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } return ret; } void -LayoutView::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter) +LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter) { if (index >= layer_lists ()) { return; @@ -2188,8 +1748,8 @@ LayoutView::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter lay::LayerPropertiesNode orig = *iter; - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } // delete the element @@ -2203,38 +1763,29 @@ LayoutView::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } // invalidate the iterator so it can be used to refer to the next element iter.invalidate (); } -void -LayoutView::signal_selection_changed () -{ - if (selection_size () > 1) { - message (tl::sprintf (tl::to_string (QObject::tr ("selected: %ld objects")), selection_size ())); - } - - lay::Editables::signal_selection_changed (); -} - void -LayoutView::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) +LayoutViewBase::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) { tl_assert (index < cellviews ()); - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Saving"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Saving"))); cellview (index)->save_as (filename, om, options, update, keep_backups); cellview_changed (index); } void -LayoutView::redo (db::Op *op) +LayoutViewBase::redo (db::Op *op) { tl_assert (! transacting ()); @@ -2319,7 +1870,7 @@ LayoutView::redo (db::Op *op) } void -LayoutView::undo (db::Op *op) +LayoutViewBase::undo (db::Op *op) { tl_assert (! transacting ()); @@ -2407,7 +1958,7 @@ LayoutView::undo (db::Op *op) } void -LayoutView::signal_hier_changed () +LayoutViewBase::signal_hier_changed () { // schedule a redraw request for all layers redraw (); @@ -2416,7 +1967,7 @@ LayoutView::signal_hier_changed () } void -LayoutView::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index) +LayoutViewBase::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index) { if (layer_index == std::numeric_limits::max ()) { @@ -2439,7 +1990,7 @@ LayoutView::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned in } void -LayoutView::signal_bboxes_changed () +LayoutViewBase::signal_bboxes_changed () { // schedule a redraw request for all layers redraw (); @@ -2449,14 +2000,14 @@ LayoutView::signal_bboxes_changed () } void -LayoutView::signal_cell_name_changed () +LayoutViewBase::signal_cell_name_changed () { cell_visibility_changed_event (); // HINT: that is not what actually is intended, but it serves the function ... redraw (); // needs redraw } void -LayoutView::signal_layer_properties_changed () +LayoutViewBase::signal_layer_properties_changed () { // recompute the source // TODO: this is a side effect of this method - provide a special method for this purpose @@ -2469,7 +2020,7 @@ LayoutView::signal_layer_properties_changed () } void -LayoutView::signal_prop_ids_changed () +LayoutViewBase::signal_prop_ids_changed () { // inform the layer list observers that they need to recompute the property selectors layer_list_changed_event (1); @@ -2482,7 +2033,7 @@ LayoutView::signal_prop_ids_changed () } void -LayoutView::signal_plugin_enabled_changed () +LayoutViewBase::signal_plugin_enabled_changed () { for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if ((*p)->editable_interface ()) { @@ -2492,7 +2043,7 @@ LayoutView::signal_plugin_enabled_changed () } void -LayoutView::signal_annotations_changed () +LayoutViewBase::signal_annotations_changed () { // schedule a redraw request for the annotation shapes redraw_deco_layer (); @@ -2501,7 +2052,7 @@ LayoutView::signal_annotations_changed () } void -LayoutView::finish_cellviews_changed () +LayoutViewBase::finish_cellviews_changed () { update_event_handlers (); @@ -2511,7 +2062,7 @@ LayoutView::finish_cellviews_changed () } std::list::iterator -LayoutView::cellview_iter (int cv_index) +LayoutViewBase::cellview_iter (int cv_index) { std::list::iterator i = m_cellviews.begin (); while (cv_index > 0 && i != m_cellviews.end ()) { @@ -2523,7 +2074,7 @@ LayoutView::cellview_iter (int cv_index) } std::list::const_iterator -LayoutView::cellview_iter (int cv_index) const +LayoutViewBase::cellview_iter (int cv_index) const { std::list::const_iterator i = m_cellviews.begin (); while (cv_index > 0 && i != m_cellviews.end ()) { @@ -2535,7 +2086,7 @@ LayoutView::cellview_iter (int cv_index) const } void -LayoutView::erase_cellview (unsigned int index) +LayoutViewBase::erase_cellview (unsigned int index) { if (index >= m_cellviews.size ()) { return; @@ -2551,9 +2102,7 @@ LayoutView::erase_cellview (unsigned int index) manager ()->clear (); } - if (mp_control_panel) { - mp_control_panel->begin_updates (); - } + begin_layer_updates (); m_cellviews.erase (cellview_iter (int (index))); @@ -2561,6 +2110,10 @@ LayoutView::erase_cellview (unsigned int index) m_hidden_cells.erase (m_hidden_cells.begin () + index); } + if (m_current_cell_per_cellview.size () > index) { + m_current_cell_per_cellview.erase (m_current_cell_per_cellview.begin () + index); + } + for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { // remove all references to the cellview @@ -2586,6 +2139,8 @@ LayoutView::erase_cellview (unsigned int index) m_display_states.clear (); m_display_state_ptr = 0; + end_layer_updates (); + // signal to the observers that something has changed layer_list_changed_event (3); @@ -2594,12 +2149,12 @@ LayoutView::erase_cellview (unsigned int index) update_content (); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } void -LayoutView::clear_cellviews () +LayoutViewBase::clear_cellviews () { // issue to event that signals a change in the cellviews cellviews_about_to_change_event (); @@ -2616,6 +2171,9 @@ LayoutView::clear_cellviews () set_properties (lay::LayerPropertiesList ()); m_cellviews.clear (); + m_hidden_cells.clear (); + m_current_cell_per_cellview.clear (); + // clear the history, store path and zoom box m_display_states.clear (); m_display_state_ptr = 0; @@ -2623,12 +2181,12 @@ LayoutView::clear_cellviews () finish_cellviews_changed (); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } const CellView & -LayoutView::cellview (unsigned int index) const +LayoutViewBase::cellview (unsigned int index) const { static const CellView empty; if (index >= m_cellviews.size ()) { @@ -2639,7 +2197,7 @@ LayoutView::cellview (unsigned int index) const } CellViewRef -LayoutView::cellview_ref (unsigned int index) +LayoutViewBase::cellview_ref (unsigned int index) { if (index >= m_cellviews.size ()) { return CellViewRef (); @@ -2649,7 +2207,7 @@ LayoutView::cellview_ref (unsigned int index) } int -LayoutView::index_of_cellview (const lay::CellView *cv) const +LayoutViewBase::index_of_cellview (const lay::CellView *cv) const { int index = 0; for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end (); ++i, ++index) { @@ -2661,7 +2219,7 @@ LayoutView::index_of_cellview (const lay::CellView *cv) const } void -LayoutView::set_layout (const lay::CellView &cv, unsigned int cvindex) +LayoutViewBase::set_layout (const lay::CellView &cv, unsigned int cvindex) { // issue to event that signals a change in the cellviews cellviews_about_to_change_event (); @@ -2690,17 +2248,15 @@ LayoutView::set_layout (const lay::CellView &cv, unsigned int cvindex) // since the hierarchy panel may hold cellviews, we explicitly request an initialization // of the tree. This will release such references. This way, set_layout guarantees that // the layouts are released as far as possible. This is important for reload () for example. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (cvindex); - } + update_content_for_cv (cvindex); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } void -LayoutView::signal_apply_technology (lay::LayoutHandle *layout_handle) +LayoutViewBase::signal_apply_technology (lay::LayoutHandle *layout_handle) { // find the cellview which issued the event for (unsigned int i = 0; i < cellviews (); ++i) { @@ -2737,26 +2293,41 @@ LayoutView::signal_apply_technology (lay::LayoutHandle *layout_handle) } } +void +LayoutViewBase::bookmarks (const BookmarkList &b) +{ + m_bookmarks = b; + bookmarks_changed (); +} + +void +LayoutViewBase::bookmark_view (const std::string &name) +{ + DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), cellview_list ()); + m_bookmarks.add (name, state); + bookmarks_changed (); +} + void -LayoutView::load_layer_props (const std::string &fn) +LayoutViewBase::load_layer_props (const std::string &fn) { do_load_layer_props (fn, false, -1, false); } void -LayoutView::load_layer_props (const std::string &fn, bool add_default) +LayoutViewBase::load_layer_props (const std::string &fn, bool add_default) { do_load_layer_props (fn, false, -1, add_default); } void -LayoutView::load_layer_props (const std::string &fn, int cv_index, bool add_default) +LayoutViewBase::load_layer_props (const std::string &fn, int cv_index, bool add_default) { do_load_layer_props (fn, true, cv_index, add_default); } void -LayoutView::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) +LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) { std::vector props; bool single_list = false; @@ -2783,7 +2354,7 @@ LayoutView::do_load_layer_props (const std::string &fn, bool map_cv, int cv_inde p->expand (cv_map, add_default); } - transaction (tl::to_string (QObject::tr ("Load layer properties"))); + transaction (tl::to_string (tr ("Load layer properties"))); if (single_list) { @@ -2832,7 +2403,7 @@ LayoutView::do_load_layer_props (const std::string &fn, bool map_cv, int cv_inde } void -LayoutView::save_layer_props (const std::string &fn) +LayoutViewBase::save_layer_props (const std::string &fn) { tl::OutputStream os (fn, tl::OutputStream::OM_Plain); @@ -2857,7 +2428,7 @@ LayoutView::save_layer_props (const std::string &fn) } void -LayoutView::add_new_layers (const std::vector &layer_ids, int cv_index) +LayoutViewBase::add_new_layers (const std::vector &layer_ids, int cv_index) { if (cv_index >= 0 && cv_index < int (cellviews ())) { @@ -2907,13 +2478,13 @@ LayoutView::add_new_layers (const std::vector &layer_ids, int cv_ } void -LayoutView::init_layer_properties (LayerProperties &p) const +LayoutViewBase::init_layer_properties (LayerProperties &p) const { init_layer_properties (p, get_properties ()); } void -LayoutView::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const +LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const { lay::color_t c = 0; if (m_palette.luminous_colors () > 0) { @@ -2933,138 +2504,266 @@ LayoutView::init_layer_properties (LayerProperties &p, const LayerPropertiesList p.set_marked (false); } +#if defined(HAVE_QT) QImage -LayoutView::get_screenshot () +LayoutViewBase::get_screenshot () { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); + return mp_canvas->screenshot ().to_image_copy (); +} +#endif + +lay::PixelBuffer +LayoutViewBase::get_screenshot_pb () +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + return mp_canvas->screenshot (); } -void -LayoutView::save_screenshot (const std::string &fn) +static std::vector > +png_texts (const lay::LayoutViewBase *view, const db::DBox &box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); + std::vector > texts; // Unfortunately the PNG writer does not allow writing of long strings. // We separate the description into a set of keys: - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); + for (unsigned int i = 0; i < view->cellviews (); ++i) { + if (view->cellview (i).is_valid ()) { + std::string name = view->cellview (i)->layout ().cell_name (view->cellview (i).cell_index ()); + texts.push_back (std::make_pair (std::string ("Cell") + tl::to_string (int (i) + 1), name)); } } - db::DBox b (box ()); - std::string desc; - desc += tl::micron_to_string (b.left ()) + "," + tl::micron_to_string (b.bottom ()); - desc += "/"; - desc += tl::micron_to_string (b.right ()) + "," + tl::micron_to_string (b.top ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc)); + texts.push_back (std::make_pair (std::string ("Rect"), box.to_string ())); + + return texts; +} + +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) +void +LayoutViewBase::save_screenshot (const std::string &fn) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); + + QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); + + std::vector > texts = png_texts (this, box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); + } // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - if (! writer.write (mp_canvas->screenshot ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + if (! writer.write (mp_canvas->screenshot ().to_image ())) { + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } tl::log << "Saved screen shot to " << fn; } - -QImage -LayoutView::get_image (unsigned int width, unsigned int height) +#else +void +LayoutViewBase::save_screenshot (const std::string &fn) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + tl::OutputStream stream (fn); + lay::PixelBuffer img = mp_canvas->screenshot (); + img.set_texts (png_texts (this, box ())); + img.write_png (stream); + + tl::log << "Saved screen shot to " << fn; +} +#endif + +#if defined(HAVE_QT) +QImage +LayoutViewBase::get_image (unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); + return mp_canvas->image (width, height).to_image_copy (); +} +#endif + +lay::PixelBuffer +LayoutViewBase::get_pixels (unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + return mp_canvas->image (width, height); } -QImage -LayoutView::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool monochrome) +#if defined(HAVE_QT) +QImage +LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome); + if (monochrome) { + return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image_copy (); + } else { + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image_copy (); + } +} +#endif + +lay::PixelBuffer +LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); } -void -LayoutView::save_image (const std::string &fn, unsigned int width, unsigned int height) +lay::BitmapBuffer +LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box); +} + +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) +void +LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); } - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - if (! writer.write (mp_canvas->image (width, height))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + if (! writer.write (mp_canvas->image (width, height).to_image ())) { + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } - tl::log << "Saved screen shot to " << fn; + tl::log << "Saved image to " << fn; } - -void -LayoutView::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool monochrome) +#else +void +LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); + + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + tl::OutputStream stream (fn); + lay::PixelBuffer img = mp_canvas->image (width, height); + std::vector > texts = png_texts (this, vp.box ()); + img.set_texts (texts); + img.write_png (stream); + + tl::log << "Saved image to " << fn; +} +#endif + +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) +void +LayoutViewBase::save_image_with_options (const std::string &fn, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); + } - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + if (monochrome) { + if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image ())) { + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } + } else { + if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) { + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } + tl::log << "Saved image to " << fn; +} +#else +void +LayoutViewBase::save_image_with_options (const std::string &fn, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - + std::vector > texts = png_texts (this, vp.box ()); + // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + + tl::OutputStream stream (fn); + if (monochrome) { + + lay::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box); + img.set_texts (texts); + img.write_png (stream); + + } else { + + lay::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); + img.set_texts (texts); + img.write_png (stream); + } - tl::log << "Saved screen shot to " << fn; + tl::log << "Saved image to " << fn; } +#endif void -LayoutView::reload_layout (unsigned int cv_index) +LayoutViewBase::reload_layout (unsigned int cv_index) { stop (); cancel_esc (); @@ -3141,8 +2840,8 @@ LayoutView::reload_layout (unsigned int cv_index) } { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename; - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); + tl::log << tl::to_string (tr ("Loading file: ")) << filename; + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading"))); // Load with the previous options again. db::LoadLayoutOptions options (cvorg->load_options ()); @@ -3153,7 +2852,7 @@ LayoutView::reload_layout (unsigned int cv_index) // implicitly at some other time. This may throw an exception // if the operation was cancelled. { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Sorting"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Sorting"))); cv->layout ().update (); } @@ -3187,6 +2886,11 @@ LayoutView::reload_layout (unsigned int cv_index) } } + // clear the current cell (NOTE: this is for providing a cell target for some UI functions only) + if (m_current_cell_per_cellview.size () > cv_index) { + m_current_cell_per_cellview [cv_index] = cell_path_type (); + } + // Determine which layers to create as new layers. New layer need to be created // if these have not been present in the original layout and there are no layer views // referring to them. @@ -3215,17 +2919,16 @@ LayoutView::reload_layout (unsigned int cv_index) set_properties (new_props); goto_view (state); - } unsigned int -LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers) +LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers) { unsigned int cv_index = 0; try { - m_active_cellview_changed_event_enabled = false; + enable_active_cellview_changed_event (false); stop_redraw (); @@ -3305,15 +3008,8 @@ LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, boo } // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } + if (cv_index == 0) { + ensure_layer_selected (); } // signal to any observers @@ -3334,25 +3030,22 @@ LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, boo set_active_cellview_index (cv_index); } - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true); } catch (...) { update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true, true); throw; } - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - return cv_index; } unsigned int -LayoutView::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers) +LayoutViewBase::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers) { const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); @@ -3367,13 +3060,13 @@ LayoutView::create_layout (const std::string &technology, bool add_cellview, boo } unsigned int -LayoutView::load_layout (const std::string &filename, const std::string &technology, bool add_cellview) +LayoutViewBase::load_layout (const std::string &filename, const std::string &technology, bool add_cellview) { return load_layout (filename, db::LoadLayoutOptions (), technology, add_cellview); } unsigned int -LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview) +LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview) { stop (); @@ -3391,11 +3084,11 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption try { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading"))); // load the file { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename << tl::to_string (QObject::tr (" with technology: ")) << technology; + tl::log << tl::to_string (tr ("Loading file: ")) << filename << tl::to_string (tr (" with technology: ")) << technology; lmap = cv->load (options, technology); } @@ -3431,7 +3124,7 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption try { - m_active_cellview_changed_event_enabled = false; + enable_active_cellview_changed_event (false); // select the cell with the largest area as the first top cell db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); @@ -3482,15 +3175,8 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption create_initial_layer_props (cv_index, lyp_file, add_other_layers); // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } + if (cv_index == 0) { + ensure_layer_selected (); } // signal to any observers @@ -3503,25 +3189,22 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption } update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true); } catch (...) { update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true, true /*silent*/); throw; } - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - return cv_index; } void -LayoutView::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing) +LayoutViewBase::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing) { std::vector props; bool loaded = false; @@ -3539,15 +3222,15 @@ LayoutView::create_initial_layer_props (int cv_index, const std::string &lyp_fil } catch (...) { props.clear (); tl::XMLFileSource in (lyp_file); - tl::log << tl::to_string (QObject::tr ("Loading layer properties file: ")) << lyp_file; + tl::log << tl::to_string (tr ("Loading layer properties file: ")) << lyp_file; lay::LayerPropertiesList::load (in, props); loaded = true; } } catch (tl::Exception &ex) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: ")) << ex.msg (); + tl::warn << tl::to_string (tr ("Initialization of layers failed: ")) << ex.msg (); } catch (...) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: unspecific error")); + tl::warn << tl::to_string (tr ("Initialization of layers failed: unspecific error")); } } @@ -3591,7 +3274,7 @@ LayoutView::create_initial_layer_props (int cv_index, const std::string &lyp_fil } void -LayoutView::merge_layer_props (const std::vector &props) +LayoutViewBase::merge_layer_props (const std::vector &props) { lay::LayerPropertiesList p0; if (layer_lists () > 0) { @@ -3652,7 +3335,7 @@ LayoutView::merge_layer_props (const std::vector &prop } void -LayoutView::pop_state () +LayoutViewBase::pop_state () { if (m_display_state_ptr > 0) { m_display_states.erase (m_display_states.begin () + m_display_state_ptr, m_display_states.end ()); @@ -3661,14 +3344,14 @@ LayoutView::pop_state () } void -LayoutView::clear_states () +LayoutViewBase::clear_states () { m_display_states.clear (); m_display_state_ptr = 0; } void -LayoutView::store_state () +LayoutViewBase::store_state () { // erase all states after the current position if (m_display_state_ptr + 1 < m_display_states.size ()) { @@ -3683,13 +3366,28 @@ LayoutView::store_state () } db::DBox -LayoutView::box () const +LayoutViewBase::box () const { return mp_canvas->viewport ().box (); } +#if defined(HAVE_QT) +QWidget * +LayoutViewBase::widget () +{ + return this; +} +#endif + +LayoutView * +LayoutViewBase::get_ui () +{ + return mp_ui; +} + +// NOTE: this methods needs to be called "frequently" void -LayoutView::timer () +LayoutViewBase::timer () { bool dirty = false; for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end () && ! dirty; ++i) { @@ -3698,48 +3396,43 @@ LayoutView::timer () if (dirty != m_dirty) { m_dirty = dirty; - emit dirty_changed (); + emit_dirty_changed (); } - if (m_animated) { - set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } + if (m_prop_changed) { + do_prop_changed (); + m_prop_changed = false; + } + + tl::Clock current_time = tl::Clock::current (); + if ((current_time - m_last_checked).seconds () > animation_interval) { + m_last_checked = current_time; if (m_animated) { - ++m_phase; + set_view_ops (); + do_set_phase (int (m_phase)); + if (m_animated) { + ++m_phase; + } } } } -bool -LayoutView::layer_model_updated () -{ - // because check_updated is called in the initialization phase, we check if the pointers - // to the widgets are non-null: - if (mp_control_panel) { - return mp_control_panel->model_updated (); - } else { - return false; - } -} - void -LayoutView::force_update_content () +LayoutViewBase::force_update_content () { set_view_ops (); } void -LayoutView::update_content () +LayoutViewBase::update_content () { - if (m_activated) { + if (is_activated ()) { set_view_ops (); } } void -LayoutView::zoom_fit_sel () +LayoutViewBase::zoom_fit_sel () { db::DBox bbox = selection_bbox (); if (! bbox.empty ()) { @@ -3750,7 +3443,7 @@ LayoutView::zoom_fit_sel () } db::DBox -LayoutView::full_box () const +LayoutViewBase::full_box () const { // compute the bounding box over all layers // this will trigger the update procedures of the layout objects if not done yet .. @@ -3776,20 +3469,20 @@ LayoutView::full_box () const } void -LayoutView::zoom_fit () +LayoutViewBase::zoom_fit () { mp_canvas->zoom_box (full_box (), true /*precious*/); store_state (); } void -LayoutView::ensure_selection_visible () +LayoutViewBase::ensure_selection_visible () { ensure_visible (selection_bbox ()); } void -LayoutView::ensure_visible (const db::DBox &bbox) +LayoutViewBase::ensure_visible (const db::DBox &bbox) { db::DBox new_box = bbox + viewport ().box (); mp_canvas->zoom_box (new_box); @@ -3797,7 +3490,7 @@ LayoutView::ensure_visible (const db::DBox &bbox) } void -LayoutView::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair &levels) +LayoutViewBase::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair &levels) { mp_canvas->zoom_box (bbox); set_hier_levels_basic (levels); @@ -3805,76 +3498,76 @@ LayoutView::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair< } void -LayoutView::zoom_box (const db::DBox &bbox) +LayoutViewBase::zoom_box (const db::DBox &bbox) { mp_canvas->zoom_box (bbox); store_state (); } void -LayoutView::set_global_trans (const db::DCplxTrans &trans) +LayoutViewBase::set_global_trans (const db::DCplxTrans &trans) { mp_canvas->set_global_trans (trans); store_state (); } void -LayoutView::zoom_trans (const db::DCplxTrans &trans) +LayoutViewBase::zoom_trans (const db::DCplxTrans &trans) { mp_canvas->zoom_trans (trans); store_state (); } void -LayoutView::pan_left () +LayoutViewBase::pan_left () { shift_window (1.0, -m_pan_distance, 0.0); } void -LayoutView::pan_right () +LayoutViewBase::pan_right () { shift_window (1.0, m_pan_distance, 0.0); } void -LayoutView::pan_up () +LayoutViewBase::pan_up () { shift_window (1.0, 0.0, m_pan_distance); } void -LayoutView::pan_down () +LayoutViewBase::pan_down () { shift_window (1.0, 0.0, -m_pan_distance); } void -LayoutView::pan_left_fast () +LayoutViewBase::pan_left_fast () { shift_window (1.0, -m_pan_distance * fast_factor, 0.0); } void -LayoutView::pan_right_fast () +LayoutViewBase::pan_right_fast () { shift_window (1.0, m_pan_distance * fast_factor, 0.0); } void -LayoutView::pan_up_fast () +LayoutViewBase::pan_up_fast () { shift_window (1.0, 0.0, m_pan_distance * fast_factor); } void -LayoutView::pan_down_fast () +LayoutViewBase::pan_down_fast () { shift_window (1.0, 0.0, -m_pan_distance * fast_factor); } void -LayoutView::pan_center (const db::DPoint &p) +LayoutViewBase::pan_center (const db::DPoint &p) { db::DBox b = mp_canvas->viewport ().box (); db::DVector d (b.width () * 0.5, b.height () * 0.5); @@ -3882,19 +3575,19 @@ LayoutView::pan_center (const db::DPoint &p) } void -LayoutView::zoom_in () +LayoutViewBase::zoom_in () { shift_window (zoom_factor, 0.0, 0.0); } void -LayoutView::zoom_out () +LayoutViewBase::zoom_out () { shift_window (1.0 / zoom_factor, 0.0, 0.0); } void -LayoutView::shift_window (double f, double dx, double dy) +LayoutViewBase::shift_window (double f, double dx, double dy) { db::DBox b = mp_canvas->viewport ().box (); @@ -3910,7 +3603,7 @@ LayoutView::shift_window (double f, double dx, double dy) } void -LayoutView::goto_window (const db::DPoint &p, double s) +LayoutViewBase::goto_window (const db::DPoint &p, double s) { if (s > 1e-6) { db::DBox b (p.x () - s * 0.5, p.y () - s * 0.5, p.x () + s * 0.5, p.y () + s * 0.5); @@ -3923,19 +3616,19 @@ LayoutView::goto_window (const db::DPoint &p, double s) } void -LayoutView::redraw_layer (unsigned int index) +LayoutViewBase::redraw_layer (unsigned int index) { do_redraw (index); } void -LayoutView::redraw_cell_boxes () +LayoutViewBase::redraw_cell_boxes () { do_redraw (lay::draw_boxes_queue_entry); } void -LayoutView::redraw_deco_layer () +LayoutViewBase::redraw_deco_layer () { // redraw background annotations (images etc.) mp_canvas->touch_bg (); @@ -3945,7 +3638,7 @@ LayoutView::redraw_deco_layer () } void -LayoutView::redraw () +LayoutViewBase::redraw () { std::vector layers; @@ -3967,7 +3660,7 @@ LayoutView::redraw () } void -LayoutView::cancel_edits () +LayoutViewBase::cancel_edits () { // cancel all drag and pending edit operations such as move operations. mp_canvas->drag_cancel (); @@ -3975,7 +3668,7 @@ LayoutView::cancel_edits () } void -LayoutView::cancel () +LayoutViewBase::cancel () { // cancel all drags and pending edit operations such as move operations. cancel_edits (); @@ -3986,65 +3679,14 @@ LayoutView::cancel () } void -LayoutView::cancel_esc () +LayoutViewBase::cancel_esc () { cancel (); switch_mode (default_mode ()); } void -LayoutView::bookmark_current_view () -{ - QString proposed_name = tl::to_qstring (m_bookmarks.propose_new_bookmark_name ()); - - while (true) { - bool ok = false; - QString text = QInputDialog::getText (this, QObject::tr ("Enter Bookmark Name"), QObject::tr ("Bookmark name"), - QLineEdit::Normal, proposed_name, &ok); - if (! ok) { - break; - } else if (text.isEmpty ()) { - QMessageBox::critical (this, QObject::tr ("Error"), QObject::tr ("Enter a name for the bookmark")); - } else { - bookmark_view (tl::to_string (text)); - break; - } - } -} - -void -LayoutView::manage_bookmarks () -{ - std::set selected_bm; - if (mp_bookmarks_frame->isVisible ()) { - selected_bm = mp_bookmarks_view->selected_bookmarks (); - } - - BookmarkManagementForm dialog (this, "bookmark_form", bookmarks (), selected_bm); - if (dialog.exec ()) { - bookmarks (dialog.bookmarks ()); - } -} - -void -LayoutView::bookmarks (const BookmarkList &b) -{ - m_bookmarks = b; - mp_bookmarks_view->refresh (); - emit menu_needs_update (); -} - -void -LayoutView::bookmark_view (const std::string &name) -{ - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); - m_bookmarks.add (name, state); - mp_bookmarks_view->refresh (); - emit menu_needs_update (); -} - -void -LayoutView::goto_view (const DisplayState &state) +LayoutViewBase::goto_view (const DisplayState &state) { mp_canvas->zoom_box (state.box ()); @@ -4063,13 +3705,13 @@ LayoutView::goto_view (const DisplayState &state) } void -LayoutView::save_view (DisplayState &state) const +LayoutViewBase::save_view (DisplayState &state) const { state = DisplayState (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); } void -LayoutView::do_redraw (int layer) +LayoutViewBase::do_redraw (int layer) { std::vector layers; layers.push_back (layer); @@ -4078,7 +3720,7 @@ LayoutView::do_redraw (int layer) } void -LayoutView::do_prop_changed () +LayoutViewBase::do_prop_changed () { if (m_visibility_changed) { @@ -4098,22 +3740,10 @@ LayoutView::do_prop_changed () update_content (); } -void -LayoutView::layer_tab_changed () -{ - update_content (); -} - -void -LayoutView::layer_order_changed () -{ - update_content (); -} - void -LayoutView::set_view_ops () +LayoutViewBase::set_view_ops () { - bool bright_background = (mp_canvas->background_color ().green () > 128); + bool bright_background = (mp_canvas->background_color ().to_mono ()); int brightness_for_context = ((bright_background ? m_ctx_dimming : -m_ctx_dimming) * 256) / 100; int brightness_for_child_context = ((bright_background ? m_child_ctx_dimming : -m_child_ctx_dimming) * 256) / 100; @@ -4128,11 +3758,11 @@ LayoutView::set_view_ops () std::vector view_ops; view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after); - lay::color_t box_color; - if (! m_box_color.isValid ()) { - box_color = mp_canvas->foreground_color ().rgb (); + lay::Color box_color; + if (! m_box_color.is_valid ()) { + box_color = mp_canvas->foreground_color (); } else { - box_color = m_box_color.rgb (); + box_color = m_box_color; } // cell boxes @@ -4141,10 +3771,10 @@ LayoutView::set_view_ops () lay::ViewOp vop; // context level - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { vop = lay::ViewOp (m_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color, brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); } // fill, frame, text, vertex @@ -4154,10 +3784,10 @@ LayoutView::set_view_ops () view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); // child level - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { vop = lay::ViewOp (m_child_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color, brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); } // fill, frame, text, vertex @@ -4167,7 +3797,7 @@ LayoutView::set_view_ops () view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); // current level - vop = lay::ViewOp (box_color, lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (box_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); // fill, frame, text, vertex view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); @@ -4187,8 +3817,8 @@ LayoutView::set_view_ops () // produce the ViewOps for the guiding shapes - color_t gs_color = box_color; - if (m_guiding_shape_color.isValid ()) { + color_t gs_color = box_color.rgb (); + if (m_guiding_shape_color.is_valid ()) { gs_color = m_guiding_shape_color.rgb (); } @@ -4202,7 +3832,7 @@ LayoutView::set_view_ops () if (ctx == 0) { // context planes - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_ctx_color.rgb (); } else { frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_context); @@ -4215,7 +3845,7 @@ LayoutView::set_view_ops () } else if (ctx == 1) { // child level planes (if used) - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_child_ctx_color.rgb (); } else { frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_child_context); @@ -4318,12 +3948,12 @@ LayoutView::set_view_ops () if (ctx == 0) { // context planes - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_ctx_color.rgb (); } else { fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_context); frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_context); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_context); } else { text_color = frame_color; @@ -4337,12 +3967,12 @@ LayoutView::set_view_ops () } else if (ctx == 1) { // child level planes (if used) - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_child_ctx_color.rgb (); } else { fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_child_context); frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_child_context); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_child_context); } else { text_color = frame_color; @@ -4358,7 +3988,7 @@ LayoutView::set_view_ops () // current level planes fill_color = l->eff_fill_color (true /*real*/); frame_color = l->eff_frame_color (true /*real*/); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = m_text_color.rgb (); } else { text_color = frame_color; @@ -4405,7 +4035,7 @@ LayoutView::set_view_ops () } void -LayoutView::guiding_shapes_visible (bool v) +LayoutViewBase::guiding_shapes_visible (bool v) { if (v != m_guiding_shape_visible) { m_guiding_shape_visible = v; @@ -4414,7 +4044,7 @@ LayoutView::guiding_shapes_visible (bool v) } void -LayoutView::guiding_shapes_color (QColor c) +LayoutViewBase::guiding_shapes_color (lay::Color c) { if (c != m_guiding_shape_color) { m_guiding_shape_color = c; @@ -4423,7 +4053,7 @@ LayoutView::guiding_shapes_color (QColor c) } void -LayoutView::guiding_shapes_line_width (int v) +LayoutViewBase::guiding_shapes_line_width (int v) { if (v != m_guiding_shape_line_width) { m_guiding_shape_line_width = v; @@ -4432,7 +4062,7 @@ LayoutView::guiding_shapes_line_width (int v) } void -LayoutView::guiding_shapes_vertex_size (int v) +LayoutViewBase::guiding_shapes_vertex_size (int v) { if (v != m_guiding_shape_vertex_size) { m_guiding_shape_vertex_size = v; @@ -4441,7 +4071,7 @@ LayoutView::guiding_shapes_vertex_size (int v) } void -LayoutView::draw_array_border_instances (bool m) +LayoutViewBase::draw_array_border_instances (bool m) { if (m != m_draw_array_border_instances) { m_draw_array_border_instances = m; @@ -4450,7 +4080,7 @@ LayoutView::draw_array_border_instances (bool m) } void -LayoutView::drop_small_cells (bool m) +LayoutViewBase::drop_small_cells (bool m) { if (m != m_drop_small_cells) { m_drop_small_cells = m; @@ -4459,7 +4089,7 @@ LayoutView::drop_small_cells (bool m) } void -LayoutView::drop_small_cells_value (unsigned int s) +LayoutViewBase::drop_small_cells_value (unsigned int s) { if (s != m_drop_small_cells_value) { m_drop_small_cells_value = s; @@ -4468,7 +4098,7 @@ LayoutView::drop_small_cells_value (unsigned int s) } void -LayoutView::drop_small_cells_cond (drop_small_cells_cond_type t) +LayoutViewBase::drop_small_cells_cond (drop_small_cells_cond_type t) { if (t != m_drop_small_cells_cond) { m_drop_small_cells_cond = t; @@ -4477,7 +4107,7 @@ LayoutView::drop_small_cells_cond (drop_small_cells_cond_type t) } void -LayoutView::cell_box_color (QColor c) +LayoutViewBase::cell_box_color (lay::Color c) { if (c != m_box_color) { m_box_color = c; @@ -4486,7 +4116,7 @@ LayoutView::cell_box_color (QColor c) } void -LayoutView::cell_box_text_transform (bool xform) +LayoutViewBase::cell_box_text_transform (bool xform) { if (xform != m_box_text_transform) { m_box_text_transform = xform; @@ -4495,7 +4125,7 @@ LayoutView::cell_box_text_transform (bool xform) } void -LayoutView::cell_box_text_font (unsigned int f) +LayoutViewBase::cell_box_text_font (unsigned int f) { if (f != m_box_font) { m_box_font = f; @@ -4504,24 +4134,10 @@ LayoutView::cell_box_text_font (unsigned int f) } bool -LayoutView::set_hier_levels_basic (std::pair l) +LayoutViewBase::set_hier_levels_basic (std::pair l) { if (l != get_hier_levels ()) { - if (mp_min_hier_spbx) { - mp_min_hier_spbx->blockSignals (true); - mp_min_hier_spbx->setValue (l.first); - mp_min_hier_spbx->setMaximum (l.second); - mp_min_hier_spbx->blockSignals (false); - } - - if (mp_max_hier_spbx) { - mp_max_hier_spbx->blockSignals (true); - mp_max_hier_spbx->setValue (l.second); - mp_max_hier_spbx->setMinimum (l.first); - mp_max_hier_spbx->blockSignals (false); - } - m_from_level = l.first; m_to_level = l.second; @@ -4538,7 +4154,7 @@ LayoutView::set_hier_levels_basic (std::pair l) } void -LayoutView::set_hier_levels (std::pair l) +LayoutViewBase::set_hier_levels (std::pair l) { if (set_hier_levels_basic (l)) { store_state (); @@ -4546,30 +4162,16 @@ LayoutView::set_hier_levels (std::pair l) } std::pair -LayoutView::get_hier_levels () const +LayoutViewBase::get_hier_levels () const { return std::make_pair (m_from_level, m_to_level); } -void -LayoutView::min_hier_changed (int i) -{ - mp_max_hier_spbx->setMinimum (i); - set_hier_levels (std::make_pair (i, m_to_level)); -} - -void -LayoutView::max_hier_changed (int i) -{ - mp_min_hier_spbx->setMaximum (i); - set_hier_levels (std::make_pair (m_from_level, i)); -} - /** * @brief set the maximum hierarchy level to the number of levels available */ void -LayoutView::max_hier () +LayoutViewBase::max_hier () { // determine the maximum level of hierarchies int max_level = max_hier_level (); @@ -4584,7 +4186,7 @@ LayoutView::max_hier () * @brief determine the maximum hierarchy level */ int -LayoutView::max_hier_level () const +LayoutViewBase::max_hier_level () const { int max_level = 0; for (std::list ::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv) { @@ -4602,32 +4204,32 @@ LayoutView::max_hier_level () const * @brief Returns a value indicating whether the maximum level is shown */ bool -LayoutView::has_max_hier () const +LayoutViewBase::has_max_hier () const { int ml = max_hier_level (); return ml > 0 && m_to_level >= ml; } void -LayoutView::set_palette (const lay::ColorPalette &p) +LayoutViewBase::set_palette (const lay::ColorPalette &p) { m_palette = p; } void -LayoutView::set_palette (const lay::StipplePalette &p) +LayoutViewBase::set_palette (const lay::StipplePalette &p) { m_stipple_palette = p; } void -LayoutView::set_palette (const lay::LineStylePalette &p) +LayoutViewBase::set_palette (const lay::LineStylePalette &p) { m_line_style_palette = p; } void -LayoutView::ctx_color (QColor c) +LayoutViewBase::ctx_color (lay::Color c) { if (c != m_ctx_color) { m_ctx_color = c; @@ -4636,7 +4238,7 @@ LayoutView::ctx_color (QColor c) } void -LayoutView::ctx_dimming (int d) +LayoutViewBase::ctx_dimming (int d) { if (d != m_ctx_dimming) { m_ctx_dimming = d; @@ -4645,7 +4247,7 @@ LayoutView::ctx_dimming (int d) } void -LayoutView::ctx_hollow (bool h) +LayoutViewBase::ctx_hollow (bool h) { if (h != m_ctx_hollow) { m_ctx_hollow = h; @@ -4654,7 +4256,7 @@ LayoutView::ctx_hollow (bool h) } void -LayoutView::child_ctx_color (QColor c) +LayoutViewBase::child_ctx_color (lay::Color c) { if (c != m_child_ctx_color) { m_child_ctx_color = c; @@ -4663,7 +4265,7 @@ LayoutView::child_ctx_color (QColor c) } void -LayoutView::child_ctx_dimming (int d) +LayoutViewBase::child_ctx_dimming (int d) { if (d != m_child_ctx_dimming) { m_child_ctx_dimming = d; @@ -4672,7 +4274,7 @@ LayoutView::child_ctx_dimming (int d) } void -LayoutView::child_ctx_hollow (bool h) +LayoutViewBase::child_ctx_hollow (bool h) { if (h != m_child_ctx_hollow) { m_child_ctx_hollow = h; @@ -4681,7 +4283,7 @@ LayoutView::child_ctx_hollow (bool h) } void -LayoutView::child_ctx_enabled (bool f) +LayoutViewBase::child_ctx_enabled (bool f) { if (f != m_child_ctx_enabled) { m_child_ctx_enabled = f; @@ -4691,7 +4293,7 @@ LayoutView::child_ctx_enabled (bool f) } void -LayoutView::abstract_mode_width (double w) +LayoutViewBase::abstract_mode_width (double w) { if (fabs (w - m_abstract_mode_width) > 1e-6) { m_abstract_mode_width = w; @@ -4702,7 +4304,7 @@ LayoutView::abstract_mode_width (double w) } void -LayoutView::abstract_mode_enabled (bool e) +LayoutViewBase::abstract_mode_enabled (bool e) { if (e != m_abstract_mode_enabled) { m_abstract_mode_enabled = e; @@ -4710,44 +4312,38 @@ LayoutView::abstract_mode_enabled (bool e) } } +lay::Color +LayoutViewBase::default_background_color () +{ + return lay::Color (0, 0, 0); // black. +} + +void +LayoutViewBase::do_set_background_color (lay::Color /*color*/, lay::Color /*contrast*/) +{ + // .. nothing yet .. +} + void -LayoutView::background_color (QColor c) +LayoutViewBase::background_color (lay::Color c) { if (c == mp_canvas->background_color ()) { return; } // replace by "real" background color if required - if (! c.isValid ()) { - c = palette ().color (QPalette::Normal, QPalette::Base); + if (! c.is_valid ()) { + c = default_background_color (); } - QColor contrast; - if (c.green () > 128) { - contrast = QColor (0, 0, 0); + lay::Color contrast; + if (c.to_mono ()) { + contrast = lay::Color (0, 0, 0); } else { - contrast = QColor (255, 255, 255); + contrast = lay::Color (255, 255, 255); } - if (mp_control_panel) { - mp_control_panel->set_background_color (c); - mp_control_panel->set_text_color (contrast); - } - - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_background_color (c); - mp_hierarchy_panel->set_text_color (contrast); - } - - if (mp_libraries_view) { - mp_libraries_view->set_background_color (c); - mp_libraries_view->set_text_color (contrast); - } - - if (mp_bookmarks_view) { - mp_bookmarks_view->set_background_color (c); - mp_bookmarks_view->set_text_color (contrast); - } + do_set_background_color (c, contrast); if (mp_selection_service) { mp_selection_service->set_colors (c, contrast); @@ -4772,19 +4368,19 @@ LayoutView::background_color (QColor c) } void -LayoutView::dbu_coordinates (bool f) +LayoutViewBase::dbu_coordinates (bool f) { m_dbu_coordinates = f; } void -LayoutView::absolute_coordinates (bool f) +LayoutViewBase::absolute_coordinates (bool f) { m_absolute_coordinates = f; } void -LayoutView::select_cellviews_fit (const std::list &cvs) +LayoutViewBase::select_cellviews_fit (const std::list &cvs) { if (m_cellviews != cvs) { @@ -4812,7 +4408,121 @@ LayoutView::select_cellviews_fit (const std::list &cvs) } void -LayoutView::active_cellview_changed (int index) +LayoutViewBase::cellview_changed (unsigned int index) +{ + update_content_for_cv (index); + + cellview_changed_event (index); + + if (m_title.empty ()) { + emit_title_changed (); + } +} + +const lay::CellView & +LayoutViewBase::active_cellview () const +{ + return cellview ((unsigned int) active_cellview_index ()); +} + +lay::CellViewRef +LayoutViewBase::active_cellview_ref () +{ + return cellview_ref ((unsigned int) active_cellview_index ()); +} + +int +LayoutViewBase::active_cellview_index () const +{ + return m_active_cellview_index; +} + +void +LayoutViewBase::set_active_cellview_index (int index) +{ + if (index >= 0 && index < int (cellviews ())) { + if (m_active_cellview_index != index) { + m_active_cellview_index = index; + active_cellview_changed (index); + } + } else { + m_active_cellview_index = -1; + } +} + +void +LayoutViewBase::selected_cells_paths (int /*cv_index*/, std::vector & /*paths*/) const +{ + // TODO: not implemented yet as there is no setter so far. + // (but it is implemented in the UI version where it is bound to the hierarchy control panel) +} + +void +LayoutViewBase::current_cell_path (int cv_index, cell_path_type &path) const +{ + if (cv_index >= 0 && cv_index < int (m_current_cell_per_cellview.size ())) { + path = m_current_cell_per_cellview [cv_index]; + } else { + path = cell_path_type (); + } +} + +void +LayoutViewBase::set_current_cell_path (int cv_index, const cell_path_type &path) +{ + if (cv_index >= 0) { + while (cv_index <= int (m_current_cell_per_cellview.size ())) { + m_current_cell_per_cellview.push_back (cell_path_type ()); + } + m_current_cell_per_cellview [cv_index] = path; + } +} + +void +LayoutViewBase::do_change_active_cellview () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::enable_active_cellview_changed_event (bool enable, bool silent) +{ + if (m_active_cellview_changed_event_enabled == enable) { + return; + } + + m_active_cellview_changed_event_enabled = enable; + if (enable) { + + if (!silent && ! m_active_cellview_changed_events.empty ()) { + + // deliver stored events + + // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) + cancel_esc (); + + // we need to setup the editor option pages because the technology may have changed + do_change_active_cellview (); + + active_cellview_changed_event (); + for (std::set::const_iterator i = m_active_cellview_changed_events.begin (); i != m_active_cellview_changed_events.end (); ++i) { + active_cellview_changed_with_index_event (*i); + } + + // Because the title reflects the active one, emit a title changed event + if (title_string ().empty ()) { + emit_title_changed (); + } + + } + + } + + m_active_cellview_changed_events.clear (); +} + +void +LayoutViewBase::active_cellview_changed (int index) { if (m_active_cellview_changed_event_enabled) { @@ -4820,48 +4530,23 @@ LayoutView::active_cellview_changed (int index) cancel_esc (); // we need to setup the editor option pages because the technology may have changed - dm_setup_editor_option_pages (); + do_change_active_cellview (); active_cellview_changed_event (); active_cellview_changed_with_index_event (index); // Because the title reflects the active one, emit a title changed event - if (m_title.empty ()) { - emit title_changed (); + if (title_string ().empty ()) { + emit_title_changed (); } + } else { + m_active_cellview_changed_events.insert (index); } } void -LayoutView::active_library_changed (int /*index*/) -{ - std::string lib_name; - if (mp_libraries_view->active_lib ()) { - lib_name = mp_libraries_view->active_lib ()->get_name (); - } - - // commit the new active library to the other views and persist this state - // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) - dispatcher ()->config_set (cfg_current_lib_view, lib_name); -} - -void -LayoutView::cellview_changed (unsigned int index) -{ - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (index); - } - - cellview_changed_event (index); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::select_cell_dispatch (const cell_path_type &path, int cellview_index) +LayoutViewBase::select_cell_dispatch (const cell_path_type &path, int cellview_index) { bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); if (m_clear_ruler_new_cell) { @@ -4887,7 +4572,7 @@ LayoutView::select_cell_dispatch (const cell_path_type &path, int cellview_index } void -LayoutView::select_cell_fit (const cell_path_type &path, int index) +LayoutViewBase::select_cell_fit (const cell_path_type &path, int index) { if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { @@ -4909,7 +4594,7 @@ LayoutView::select_cell_fit (const cell_path_type &path, int index) } void -LayoutView::select_cell_fit (cell_index_type cell_index, int index) +LayoutViewBase::select_cell_fit (cell_index_type cell_index, int index) { if (index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->cell_index () != cell_index) { @@ -4930,7 +4615,7 @@ LayoutView::select_cell_fit (cell_index_type cell_index, int index) } void -LayoutView::select_cellviews (const std::list &cvs) +LayoutViewBase::select_cellviews (const std::list &cvs) { if (m_cellviews != cvs) { @@ -4955,7 +4640,7 @@ LayoutView::select_cellviews (const std::list &cvs) } void -LayoutView::select_cellview (int index, const CellView &cv) +LayoutViewBase::select_cellview (int index, const CellView &cv) { if (index < 0 || index >= int (m_cellviews.size ())) { return; @@ -4977,7 +4662,7 @@ LayoutView::select_cellview (int index, const CellView &cv) } void -LayoutView::select_cell (const cell_path_type &path, int index) +LayoutViewBase::select_cell (const cell_path_type &path, int index) { if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { @@ -4998,7 +4683,7 @@ LayoutView::select_cell (const cell_path_type &path, int index) } void -LayoutView::select_cell (cell_index_type cell_index, int index) +LayoutViewBase::select_cell (cell_index_type cell_index, int index) { if (index >= 0 && int (m_cellviews.size ()) > index && (! cellview_iter (index)->is_valid () || cellview_iter (index)->cell_index () != cell_index)) { @@ -5018,7 +4703,7 @@ LayoutView::select_cell (cell_index_type cell_index, int index) } bool -LayoutView::is_cell_hidden (cell_index_type ci, int cellview_index) const +LayoutViewBase::is_cell_hidden (cell_index_type ci, int cellview_index) const { if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { return m_hidden_cells [cellview_index].find (ci) != m_hidden_cells [cellview_index].end (); @@ -5027,8 +4712,8 @@ LayoutView::is_cell_hidden (cell_index_type ci, int cellview_index) const } } -const std::set & -LayoutView::hidden_cells (int cellview_index) const +const std::set & +LayoutViewBase::hidden_cells (int cellview_index) const { if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { return m_hidden_cells[cellview_index]; @@ -5039,7 +4724,7 @@ LayoutView::hidden_cells (int cellview_index) const } void -LayoutView::hide_cell (cell_index_type ci, int cellview_index) +LayoutViewBase::hide_cell (cell_index_type ci, int cellview_index) { if (cellview_index < 0) { return; @@ -5059,7 +4744,7 @@ LayoutView::hide_cell (cell_index_type ci, int cellview_index) } void -LayoutView::show_cell (cell_index_type ci, int cellview_index) +LayoutViewBase::show_cell (cell_index_type ci, int cellview_index) { if (cellview_index < 0) { return; @@ -5078,7 +4763,7 @@ LayoutView::show_cell (cell_index_type ci, int cellview_index) } void -LayoutView::show_all_cells (int cv_index) +LayoutViewBase::show_all_cells (int cv_index) { if (cv_index < 0 || cv_index >= int (m_hidden_cells.size ())) { return; @@ -5099,7 +4784,7 @@ LayoutView::show_all_cells (int cv_index) } void -LayoutView::show_all_cells () +LayoutViewBase::show_all_cells () { bool any = false; @@ -5125,7 +4810,7 @@ LayoutView::show_all_cells () } void -LayoutView::min_inst_label_size (int px) +LayoutViewBase::min_inst_label_size (int px) { if (m_min_size_for_label != px) { m_min_size_for_label = px; @@ -5134,7 +4819,7 @@ LayoutView::min_inst_label_size (int px) } void -LayoutView::text_visible (bool vis) +LayoutViewBase::text_visible (bool vis) { if (m_text_visible != vis) { m_text_visible = vis; @@ -5144,7 +4829,7 @@ LayoutView::text_visible (bool vis) } void -LayoutView::show_properties_as_text (bool sp) +LayoutViewBase::show_properties_as_text (bool sp) { if (m_show_properties != sp) { m_show_properties = sp; @@ -5153,7 +4838,7 @@ LayoutView::show_properties_as_text (bool sp) } void -LayoutView::bitmap_caching (bool l) +LayoutViewBase::bitmap_caching (bool l) { if (m_bitmap_caching != l) { m_bitmap_caching = l; @@ -5162,7 +4847,7 @@ LayoutView::bitmap_caching (bool l) } void -LayoutView::text_lazy_rendering (bool l) +LayoutViewBase::text_lazy_rendering (bool l) { if (m_text_lazy_rendering != l) { m_text_lazy_rendering = l; @@ -5171,7 +4856,7 @@ LayoutView::text_lazy_rendering (bool l) } void -LayoutView::cell_box_visible (bool vis) +LayoutViewBase::cell_box_visible (bool vis) { if (m_cell_box_visible != vis) { m_cell_box_visible = vis; @@ -5180,7 +4865,7 @@ LayoutView::cell_box_visible (bool vis) } void -LayoutView::text_font (unsigned int f) +LayoutViewBase::text_font (unsigned int f) { if (m_text_font != f) { m_text_font = f; @@ -5189,7 +4874,7 @@ LayoutView::text_font (unsigned int f) } void -LayoutView::default_text_size (double fs) +LayoutViewBase::default_text_size (double fs) { if (m_default_text_size != fs) { m_default_text_size = fs; @@ -5198,37 +4883,37 @@ LayoutView::default_text_size (double fs) } void -LayoutView::clear_ruler_new_cell (bool f) +LayoutViewBase::clear_ruler_new_cell (bool f) { m_clear_ruler_new_cell = f; } void -LayoutView::full_hier_new_cell (bool f) +LayoutViewBase::full_hier_new_cell (bool f) { m_full_hier_new_cell = f; } double -LayoutView::pan_distance () const +LayoutViewBase::pan_distance () const { return m_pan_distance; } void -LayoutView::pan_distance (double pd) +LayoutViewBase::pan_distance (double pd) { m_pan_distance = pd; } void -LayoutView::fit_new_cell (bool f) +LayoutViewBase::fit_new_cell (bool f) { m_fit_new_cell = f; } void -LayoutView::apply_text_trans (bool f) +LayoutViewBase::apply_text_trans (bool f) { if (m_apply_text_trans != f) { m_apply_text_trans = f; @@ -5237,7 +4922,7 @@ LayoutView::apply_text_trans (bool f) } void -LayoutView::offset_stipples (bool f) +LayoutViewBase::offset_stipples (bool f) { if (m_stipple_offset != f) { m_stipple_offset = f; @@ -5246,19 +4931,17 @@ LayoutView::offset_stipples (bool f) } void -LayoutView::no_stipples (bool f) +LayoutViewBase::no_stipples (bool f) { if (m_no_stipples != f) { m_no_stipples = f; - if (mp_control_panel) { - mp_control_panel->set_no_stipples (m_no_stipples); - } + do_set_no_stipples (f); update_content (); } } void -LayoutView::show_markers (bool f) +LayoutViewBase::show_markers (bool f) { if (m_show_markers != f) { m_show_markers = f; @@ -5267,7 +4950,7 @@ LayoutView::show_markers (bool f) } void -LayoutView::text_color (QColor c) +LayoutViewBase::text_color (lay::Color c) { if (m_text_color != c) { m_text_color = c; @@ -5276,32 +4959,27 @@ LayoutView::text_color (QColor c) } bool -LayoutView::has_selection () +LayoutViewBase::has_selection () { - if (mp_control_panel && mp_control_panel->has_focus ()) { - return mp_control_panel->has_selection (); - } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - return mp_hierarchy_panel->has_selection (); - } else { - return lay::Editables::has_selection (); - } + return lay::Editables::has_selection (); } void -LayoutView::paste () +LayoutViewBase::do_paste () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::paste () { clear_selection (); { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste"))); + db::Transaction trans (manager (), tl::to_string (tr ("Paste"))); // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -5321,20 +4999,15 @@ LayoutView::paste () } void -LayoutView::paste_interactive () +LayoutViewBase::paste_interactive () { clear_selection (); - std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (QObject::tr ("Paste and move")))); + std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (tr ("Paste and move")))); { // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -5348,49 +5021,58 @@ LayoutView::paste_interactive () } void -LayoutView::copy () +LayoutViewBase::copy () { - if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - mp_hierarchy_panel->copy (); - } else if (mp_control_panel && mp_control_panel->has_focus ()) { - mp_control_panel->copy (); - } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - lay::Editables::copy (); - + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); } + + lay::Editables::copy (); } void -LayoutView::cut () +LayoutViewBase::cut () { - if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - // TODO: currently the hierarchy panel's cut function does it's own transaction handling. - // Otherwise the cut function is not working propertly. - mp_hierarchy_panel->cut (); - } else if (mp_control_panel && mp_control_panel->has_focus ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); - mp_control_panel->cut (); - } else { + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); + } - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); + db::Transaction trans (manager (), tl::to_string (tr ("Cut"))); + lay::Editables::cut (); +} + +void +LayoutViewBase::remove_unused_layers () +{ + bool any_deleted; + do { + + std::vector sel; + + lay::LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (! l->has_children () && l->bbox ().empty ()) { + sel.push_back (l); + } + ++l; } - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); - lay::Editables::cut (); + std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); + any_deleted = false; + for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { + delete_layer (*s); + any_deleted = true; + } - } + } while (any_deleted); + + emit_layer_order_changed (); } void -LayoutView::add_missing_layers () +LayoutViewBase::add_missing_layers () { std::set present; LayerPropertiesConstIterator l = begin_layers (); @@ -5423,11 +5105,11 @@ LayoutView::add_missing_layers () } } - emit layer_order_changed (); + emit_layer_order_changed (); } LayerState -LayoutView::layer_snapshot () const +LayoutViewBase::layer_snapshot () const { LayerState state; LayerPropertiesConstIterator l = begin_layers (); @@ -5441,13 +5123,13 @@ LayoutView::layer_snapshot () const } void -LayoutView::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) +LayoutViewBase::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) { current_layer_changed_event (iter); } void -LayoutView::add_new_layers (const LayerState &state) +LayoutViewBase::add_new_layers (const LayerState &state) { std::vector actual; for (unsigned int cv = 0; cv < cellviews (); ++cv) { @@ -5479,20 +5161,12 @@ LayoutView::add_new_layers (const LayerState &state) } if (needs_update) { - emit layer_order_changed (); + emit_layer_order_changed (); } } void -LayoutView::remove_unused_layers () -{ - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); - } -} - -void -LayoutView::prev_display_state () +LayoutViewBase::prev_display_state () { if (m_display_state_ptr > 0) { m_display_state_ptr--; @@ -5501,13 +5175,13 @@ LayoutView::prev_display_state () } bool -LayoutView::has_prev_display_state () +LayoutViewBase::has_prev_display_state () { return m_display_state_ptr > 0; } void -LayoutView::next_display_state () +LayoutViewBase::next_display_state () { if (m_display_state_ptr + 1 < m_display_states.size ()) { m_display_state_ptr++; @@ -5516,139 +5190,106 @@ LayoutView::next_display_state () } bool -LayoutView::has_next_display_state () +LayoutViewBase::has_next_display_state () { return m_display_state_ptr + 1 < m_display_states.size (); } -const lay::CellView & -LayoutView::active_cellview () const +void +LayoutViewBase::current_pos (double /*x*/, double /*y*/) { - return cellview ((unsigned int) active_cellview_index ()); -} - -lay::CellViewRef -LayoutView::active_cellview_ref () -{ - return cellview_ref ((unsigned int) active_cellview_index ()); -} - -int -LayoutView::active_cellview_index () const -{ - return mp_hierarchy_panel->active (); -} - -void -LayoutView::set_active_cellview_index (int index) -{ - if (index >= 0 && index < int (m_cellviews.size ())) { - mp_hierarchy_panel->select_active (index); - } -} - -void -LayoutView::selected_cells_paths (int cv_index, std::vector &paths) const -{ - mp_hierarchy_panel->selected_cells (cv_index, paths); + // .. nothing yet .. } void -LayoutView::current_cell_path (int cv_index, cell_path_type &path) const -{ - mp_hierarchy_panel->current_cell (cv_index, path); -} - -void -LayoutView::set_current_cell_path (int cv_index, const cell_path_type &path) -{ - mp_hierarchy_panel->set_current_cell (cv_index, path); -} - -void -LayoutView::activate () -{ - if (! m_activated) { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->browser_interface () && (*p)->browser_interface ()->active ()) { - (*p)->browser_interface ()->show (); - } - } - mp_timer->start (timer_interval); - m_activated = true; - update_content (); - } -} - -void -LayoutView::deactivate () -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->browser_interface ()) { - (*p)->browser_interface ()->hide (); - } - } - - emit clear_current_pos (); - mp_canvas->free_resources (); - mp_timer->stop (); - m_activated = false; -} - -void -LayoutView::deactivate_all_browsers () -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->browser_interface ()) { - (*p)->browser_interface ()->deactivate (); - } - } -} - -void -LayoutView::current_pos (double x, double y) -{ - if (m_activated) { - if (dbu_coordinates ()) { - double dx = 0.0, dy = 0.0; - if (active_cellview_index () >= 0) { - double dbu = cellview (active_cellview_index ())->layout ().dbu (); - dx = x / dbu; - dy = y / dbu; - } - emit current_pos_changed (dx, dy, true); - } else { - emit current_pos_changed (x, y, false); - } - } -} - -void -LayoutView::stop_redraw () +LayoutViewBase::stop_redraw () { mp_canvas->stop_redraw (); } void -LayoutView::stop () +LayoutViewBase::free_resources () +{ + mp_canvas->free_resources (); +} + +void +LayoutViewBase::stop () { stop_redraw (); deactivate_all_browsers (); } +void +LayoutViewBase::begin_layer_updates () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::end_layer_updates () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::ensure_layer_selected () +{ + if (current_layer () == lay::LayerPropertiesConstIterator ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + set_current_layer (li); + } + } +} + +void +LayoutViewBase::do_set_no_stipples (bool /*no_stipples*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::do_set_phase (int /*phase*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::deactivate_all_browsers () +{ + // .. nothing yet .. +} + +bool +LayoutViewBase::is_activated () const +{ + return true; +} + +void +LayoutViewBase::switch_mode (int m) +{ + mode (m); +} + void -LayoutView::mode (int m) +LayoutViewBase::mode (int m) { if (m != m_mode) { m_mode = m; - lay::Plugin *active_plugin = 0; + mp_active_plugin = 0; if (m > 0) { for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if ((*p)->plugin_declaration ()->id () == m) { - active_plugin = *p; + mp_active_plugin = *p; mp_canvas->activate ((*p)->view_service_interface ()); break; } @@ -5660,62 +5301,46 @@ LayoutView::mode (int m) mp_canvas->activate (mp_move_service); } - lay::EditorOptionsPages *eo_pages = editor_options_pages (); - if (eo_pages) { - - // TODO: this is very inefficient as each "activate" will regenerate the tabs - for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { - bool is_active = false; - if ((*op)->plugin_declaration () == 0) { - is_active = true; - } else if (active_plugin && active_plugin->plugin_declaration () == (*op)->plugin_declaration ()) { - is_active = true; - } - (*op)->activate (is_active); - } - - } - } } bool -LayoutView::is_move_mode () const +LayoutViewBase::is_move_mode () const { return m_mode == -1; } bool -LayoutView::is_selection_mode () const +LayoutViewBase::is_selection_mode () const { return m_mode == 0; } unsigned int -LayoutView::intrinsic_mouse_modes (std::vector *descriptions) +LayoutViewBase::intrinsic_mouse_modes (std::vector *descriptions) { if (descriptions) { - descriptions->push_back ("select\t" + tl::to_string (QObject::tr ("Select")) + "<:select.png>"); - descriptions->push_back ("move\t" + tl::to_string (QObject::tr ("Move")) + "<:move.png>"); + descriptions->push_back ("select\t" + tl::to_string (tr ("Select")) + "<:select.png>"); + descriptions->push_back ("move\t" + tl::to_string (tr ("Move")) + "<:move.png>"); } return 2; } int -LayoutView::default_mode () +LayoutViewBase::default_mode () { return 0; // TODO: any generic scheme? is select, should be ruler.. } std::vector -LayoutView::menu_symbols () +LayoutViewBase::menu_symbols () { // TODO: currently these are all symbols from all plugins return lay::PluginDeclaration::menu_symbols (); } void -LayoutView::menu_activated (const std::string &symbol) +LayoutViewBase::menu_activated (const std::string &symbol) { // Try the plugin declarations if the view is the top-level dispatcher if (dispatcher () == this) { @@ -5732,22 +5357,28 @@ LayoutView::menu_activated (const std::string &symbol) } } -void -LayoutView::rename_cellview (const std::string &name, int cellview_index) +void +LayoutViewBase::update_content_for_cv (int /*cellview_index*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::rename_cellview (const std::string &name, int cellview_index) { if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { if ((*cellview_iter (cellview_index))->name () != name) { (*cellview_iter (cellview_index))->rename (name); - mp_hierarchy_panel->do_update_content (cellview_index); + update_content_for_cv (cellview_index); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } } } std::vector -LayoutView::cv_transform_variants (int cv_index) const +LayoutViewBase::cv_transform_variants (int cv_index) const { std::set trns_variants; for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { @@ -5762,7 +5393,7 @@ LayoutView::cv_transform_variants (int cv_index) const } std::vector -LayoutView::cv_transform_variants (int cv_index, unsigned int layer) const +LayoutViewBase::cv_transform_variants (int cv_index, unsigned int layer) const { if (cellview (cv_index)->layout ().is_valid_layer (layer)) { std::set trns_variants; @@ -5782,7 +5413,7 @@ LayoutView::cv_transform_variants (int cv_index, unsigned int layer) const } std::map > -LayoutView::cv_transform_variants_by_layer (int cv_index) const +LayoutViewBase::cv_transform_variants_by_layer (int cv_index) const { std::map > tv_map; @@ -5805,7 +5436,7 @@ LayoutView::cv_transform_variants_by_layer (int cv_index) const } std::set< std::pair > -LayoutView::cv_transform_variants () const +LayoutViewBase::cv_transform_variants () const { std::set< std::pair > box_variants; for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { @@ -5822,7 +5453,7 @@ LayoutView::cv_transform_variants () const } db::InstElement -LayoutView::ascend (int index) +LayoutViewBase::ascend (int index) { tl_assert (int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()); @@ -5851,7 +5482,7 @@ LayoutView::ascend (int index) } void -LayoutView::descend (const std::vector &path, int index) +LayoutViewBase::descend (const std::vector &path, int index) { if (! path.empty () && index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()) { @@ -5874,43 +5505,37 @@ LayoutView::descend (const std::vector &path, int index) } bool -LayoutView::is_editable () const +LayoutViewBase::is_editable () const { return m_editable; } unsigned int -LayoutView::search_range () +LayoutViewBase::search_range () { return m_search_range; } void -LayoutView::set_search_range (unsigned int sr) +LayoutViewBase::set_search_range (unsigned int sr) { m_search_range = sr; } unsigned int -LayoutView::search_range_box () +LayoutViewBase::search_range_box () { return m_search_range_box; } void -LayoutView::set_search_range_box (unsigned int sr) +LayoutViewBase::set_search_range_box (unsigned int sr) { m_search_range_box = sr; } -void -LayoutView::message (const std::string &s, int timeout) -{ - emit show_message (s, timeout * 1000); -} - db::cell_index_type -LayoutView::new_cell (int cv_index, const std::string &cell_name) +LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) { db::cell_index_type new_ci (0); @@ -5918,10 +5543,10 @@ LayoutView::new_cell (int cv_index, const std::string &cell_name) db::Layout &layout = cellview (cv_index)->layout (); if (! cell_name.empty () && layout.cell_by_name (cell_name.c_str ()).first) { - throw tl::Exception (tl::to_string (QObject::tr ("A cell with that name already exists: %s")), cell_name); + throw tl::Exception (tl::to_string (tr ("A cell with that name already exists: %s")), cell_name); } - transaction (tl::to_string (QObject::tr ("New cell"))); + transaction (tl::to_string (tr ("New cell"))); new_ci = layout.add_cell (cell_name.empty () ? 0 : cell_name.c_str ()); commit (); @@ -5930,15 +5555,6 @@ LayoutView::new_cell (int cv_index, const std::string &cell_name) return new_ci; } -void -LayoutView::switch_mode (int m) -{ - if (m_mode != m) { - mode (m); - emit mode_change (m); - } -} - template static void make_unique_name (T *object, Iter from, Iter to) { @@ -5966,7 +5582,7 @@ static void make_unique_name (T *object, Iter from, Iter to) } unsigned int -LayoutView::add_l2ndb (db::LayoutToNetlist *l2ndb) +LayoutViewBase::add_l2ndb (db::LayoutToNetlist *l2ndb) { make_unique_name (l2ndb, m_l2ndbs.begin (), m_l2ndbs.end ()); m_l2ndbs.push_back (l2ndb); @@ -5980,7 +5596,7 @@ LayoutView::add_l2ndb (db::LayoutToNetlist *l2ndb) } unsigned int -LayoutView::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) +LayoutViewBase::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) { tl_assert (l2ndb != 0); @@ -6006,7 +5622,7 @@ LayoutView::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) } db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) +LayoutViewBase::get_l2ndb (int index) { if (index >= 0 && index < int (m_l2ndbs.size ())) { return m_l2ndbs [index]; @@ -6015,17 +5631,8 @@ LayoutView::get_l2ndb (int index) } } -void -LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) -{ - lay::NetlistBrowserDialog *l2ndb_browser = get_plugin (); - if (l2ndb_browser) { - l2ndb_browser->load (l2ndb_index, cv_index); - } -} - const db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) const +LayoutViewBase::get_l2ndb (int index) const { if (index >= 0 && index < int (m_l2ndbs.size ())) { return m_l2ndbs [index]; @@ -6035,7 +5642,7 @@ LayoutView::get_l2ndb (int index) const } void -LayoutView::remove_l2ndb (unsigned int index) +LayoutViewBase::remove_l2ndb (unsigned int index) { if (index < (unsigned int) (m_l2ndbs.size ())) { delete m_l2ndbs [index]; @@ -6045,7 +5652,7 @@ LayoutView::remove_l2ndb (unsigned int index) } unsigned int -LayoutView::add_rdb (rdb::Database *rdb) +LayoutViewBase::add_rdb (rdb::Database *rdb) { make_unique_name (rdb, m_rdbs.begin (), m_rdbs.end ()); m_rdbs.push_back (rdb); @@ -6059,7 +5666,7 @@ LayoutView::add_rdb (rdb::Database *rdb) } unsigned int -LayoutView::replace_rdb (unsigned int db_index, rdb::Database *rdb) +LayoutViewBase::replace_rdb (unsigned int db_index, rdb::Database *rdb) { tl_assert (rdb != 0); @@ -6085,7 +5692,7 @@ LayoutView::replace_rdb (unsigned int db_index, rdb::Database *rdb) } rdb::Database * -LayoutView::get_rdb (int index) +LayoutViewBase::get_rdb (int index) { if (index >= 0 && index < int (m_rdbs.size ())) { return m_rdbs [index]; @@ -6094,17 +5701,8 @@ LayoutView::get_rdb (int index) } } -void -LayoutView::open_rdb_browser (int rdb_index, int cv_index) -{ - rdb::MarkerBrowserDialog *rdb_browser = get_plugin (); - if (rdb_browser) { - rdb_browser->load (rdb_index, cv_index); - } -} - const rdb::Database * -LayoutView::get_rdb (int index) const +LayoutViewBase::get_rdb (int index) const { if (index >= 0 && index < int (m_rdbs.size ())) { return m_rdbs [index]; @@ -6114,7 +5712,7 @@ LayoutView::get_rdb (int index) const } void -LayoutView::remove_rdb (unsigned int index) +LayoutViewBase::remove_rdb (unsigned int index) { if (index < (unsigned int) (m_rdbs.size ())) { delete m_rdbs [index]; @@ -6123,16 +5721,4 @@ LayoutView::remove_rdb (unsigned int index) } } -QSize -LayoutView::sizeHint () const -{ - if ((m_options & LV_Naked) != 0) { - return QSize (200, 200); - } else if ((m_options & LV_NoLayers) != 0 || (m_options & LV_NoHierarchyPanel) != 0 || (m_options & LV_NoLibrariesView) != 0) { - return QSize (400, 200); - } else { - return QSize (600, 200); - } -} - } // namespace lay diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutViewBase.h similarity index 88% rename from src/laybasic/laybasic/layLayoutView.h rename to src/laybasic/laybasic/layLayoutViewBase.h index 0ad398392..46ede53ed 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -21,8 +21,8 @@ */ -#ifndef HDR_layLayoutView -#define HDR_layLayoutView +#ifndef HDR_layLayoutViewBase +#define HDR_layLayoutViewBase #include "laybasicCommon.h" @@ -33,12 +33,9 @@ #include #include -#include -#include - #include "layLayerProperties.h" -#include "layAbstractMenu.h" #include "layAnnotationShapes.h" +#include "layBookmarkList.h" #include "layDispatcher.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" @@ -50,13 +47,15 @@ #include "layPlugin.h" #include "layDisplayState.h" #include "layBookmarkList.h" -#include "layEditorOptionsFrame.h" #include "gsi.h" #include "tlException.h" #include "tlEvents.h" +#include "tlTimer.h" #include "dbInstElement.h" -class QSpinBox; +#if defined(HAVE_QT) +# include +#endif namespace rdb { class Database; @@ -71,24 +70,22 @@ namespace db { namespace lay { -class AbstractMenu; -class LayerControlPanel; -class HierarchyControlPanel; -class LibrariesView; -class BookmarksView; +class LayoutView; class MouseTracker; class ZoomService; class SelectionService; class MoveService; -class Browser; -class ColorButton; -class ConfigureAction; + +#if defined(HAVE_QT) +class LayerControlPanel; +class HierarchyControlPanel; class EditorOptionsPages; +#endif /** * @brief Stores a layer reference to create layers which have been added by some action * - * This object is delivered by LayoutView::layer_snapshot and can be used in add_missing_layers + * This object is delivered by LayoutViewBase::layer_snapshot and can be used in add_missing_layers * to create new layer views for layers which have been created between layer_snapshot and * add_missing_layers. */ @@ -157,17 +154,16 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties * It is composed of a canvas and controls to control the appearance. * It manages the layer display list, bookmark list etc. */ -class LAYBASIC_PUBLIC LayoutView - : public QFrame, +class LAYBASIC_PUBLIC LayoutViewBase : +#if defined(HAVE_QT) + public QFrame, +#endif public lay::Editables, public lay::Dispatcher { -Q_OBJECT - public: typedef lay::CellView::unspecific_cell_path_type cell_path_type; typedef lay::CellView::cell_index_type cell_index_type; - typedef std::pair bookmark_type; /** * @brief Define some options for the view @@ -191,37 +187,49 @@ public: enum drop_small_cells_cond_type { DSC_Max = 0, DSC_Min = 1, DSC_Sum = 2 }; + /** + * @brief Stand-alone Constructor + */ + LayoutViewBase (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + /** * @brief Constructor */ - LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); +#if defined(HAVE_QT) + LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#else + LayoutViewBase (lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#endif /** * @brief Constructor (clone from another view) */ - LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); +#if defined(HAVE_QT) + LayoutViewBase (QWidget *widget, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#else + LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#endif /** * @brief Destructor */ - ~LayoutView (); + ~LayoutViewBase (); /** - * @brief Makes this view the current one + * @brief Gets the current mode */ - void set_current (); + int mode () const + { + return m_mode; + } /** - * @brief Makes the given view the current one + * @brief Switches the application's mode * - * The argument can be 0 which means there is no current view. + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. */ - static void set_current (LayoutView *); - - /** - * @brief Gets the current view - */ - static LayoutView *current (); + virtual void switch_mode (int m); /** * @brief Determine if there is something to copy @@ -229,68 +237,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for content providers in the tree views for example. */ - bool has_selection (); - - /** - * @brief Gets the container with the layer control panel - */ - QWidget *layer_control_frame () - { - return mp_control_frame; - } - - /** - * @brief Gets the layer control panel - */ - lay::LayerControlPanel *control_panel () - { - return mp_control_panel; - } - - /** - * @brief Gets the container with the hierarchy control panel - */ - QWidget *hierarchy_control_frame () - { - return mp_hierarchy_frame; - } - - /** - * @brief Gets the hierarchy panel - */ - lay::HierarchyControlPanel *hierarchy_panel () - { - return mp_hierarchy_panel; - } - - /** - * @brief Gets the container with the libraries view - */ - QWidget *libraries_frame () - { - return mp_libraries_frame; - } - - /** - * @brief Gets the container with the bookmarks view - */ - QWidget *bookmarks_frame () - { - return mp_bookmarks_frame; - } - - /** - * @brief Gets the container with the editor options - */ - QWidget *editor_options_frame () - { - return mp_editor_options_frame; - } - - /** - * @brief Gets the editor options pages widget - */ - lay::EditorOptionsPages *editor_options_pages (); + virtual bool has_selection (); /** * @brief Pastes from clipboard @@ -311,7 +258,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for copy providers in the tree views for example. */ - void copy (); + virtual void copy (); /** * @brief Cuts to clipboard @@ -319,7 +266,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for cut & copy providers in the tree views for example. */ - void cut (); + virtual void cut (); /** * @brief Gets the explicit title string of the view @@ -333,19 +280,9 @@ public: } /** - * @brief Gets the window title of the view + * @brief Display a status message */ - std::string title () const; - - /** - * @brief Sets the window title to an explicit string - */ - void set_title (const std::string &t); - - /** - * @brief Resets the explicit title and enable the automatic naming - */ - void reset_title (); + void message (const std::string &s = "", int timeout = 10); /** * @brief The "dirty" flag indicates that one of the layout has been modified @@ -354,6 +291,21 @@ public: */ bool is_dirty () const; + /** + * @brief Returns true, if the layer source shall be shown always in the layer properties tree + */ + virtual bool always_show_source () const; + + /** + * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree + */ + virtual bool always_show_ld () const; + + /** + * @brief Returns true, if the layout index shall be shown always in the layer properties tree + */ + virtual bool always_show_layout_index () const; + /** * @brief Fill the layer properties for a new layer * @@ -506,6 +458,11 @@ public: return get_properties (index).end_const_recursive (); } + /** + * @brief Rename a layer properties list + */ + void rename_properties (unsigned int index, const std::string &new_name); + /** * @brief Replace the current layer properties list */ @@ -514,11 +471,6 @@ public: set_properties (current_layer_list (), list); } - /** - * @brief Rename a layer properties list - */ - void rename_properties (unsigned int index, const std::string &new_name); - /** * @brief Replace the specified layer properties list */ @@ -592,6 +544,45 @@ public: insert_layer_list (index, LayerPropertiesList ()); } + /** + * @brief Sets the currently active layer by layer properties and cell view index + * + * This method will look up that layer in the layer view tree and select that layer. + * This method will also select this layer. + * + * Returns false if the layer is not a valid one. + */ + bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); + + /** + * @brief Sets the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. This method will also select this layer. + */ + virtual void set_current_layer (const lay::LayerPropertiesConstIterator &l); + + /** + * @brief Retrieve the index of the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. + * This method returns a null iterator, if no layer is active. + */ + virtual lay::LayerPropertiesConstIterator current_layer () const; + + /** + * @brief Return the layers that are selected in the layer browser + * + * Returns an empty list if no layer is selected. + */ + virtual std::vector selected_layers () const; + + /** + * @brief Sets the layers that are selected in the layer browser + */ + virtual void set_selected_layers (const std::vector &sel); + /** * @brief Set the custom dither pattern */ @@ -690,21 +681,6 @@ public: */ tl::Event file_open_event; - /** - * @brief An event signalling that the view is going to close - */ - tl::Event close_event; - - /** - * @brief An event signalling that the view is going to become visible - */ - tl::Event show_event; - - /** - * @brief An event signalling that the view is going to become invisible - */ - tl::Event hide_event; - /** * @brief An event signalling that the viewport has changed. * @@ -762,66 +738,6 @@ public: */ tl::Event cell_visibility_changed_event; - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. - */ - tl::Event active_cellview_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. The integer parameter is the index of the - * new cellview. - */ - tl::event active_cellview_changed_with_index_event; - - /** - * @brief Sets the currently active layer by layer properties and cell view index - * - * This method will look up that layer in the layer view tree and select that layer. - * This method will also select this layer. - * - * Returns false if the layer is not a valid one. - */ - bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); - - /** - * @brief Sets the currently active layer by layer properties and cell view index - * - * If the layer does not exist, the user will be asked whether to create the layer. - * Returns false if the layer is not a valid one and the user defined to create the layer. - */ - bool set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &properties); - - /** - * @brief Sets the currently active layer - * - * The active layer is the one that is active in the layer - * browser panel. This method will also select this layer. - */ - void set_current_layer (const lay::LayerPropertiesConstIterator &l); - - /** - * @brief Retrieve the index of the currently active layer - * - * The active layer is the one that is active in the layer - * browser panel. - * This method returns a null iterator, if no layer is active. - */ - lay::LayerPropertiesConstIterator current_layer () const; - - /** - * @brief Return the layers that are selected in the layer browser - * - * Returns an empty list if no layer is selected. - */ - std::vector selected_layers () const; - - /** - * @brief Sets the layers that are selected in the layer browser - */ - void set_selected_layers (const std::vector &sel); - /** * @brief Save the given cellview into the given file (with options) * If "update" is true, the cell view's properties will be updated (options, filename etc.). @@ -894,15 +810,40 @@ public: */ void load_layer_props (const std::string &fn, int cv_index, bool add_default); + /** + * @brief Bookmark the current view under the given name + */ + void bookmark_view (const std::string &name); + + /** + * @brief Obtain the bookmarks list + */ + const BookmarkList &bookmarks () const + { + return m_bookmarks; + } + + /** + * @brief Set the bookmarks list + */ + void bookmarks (const BookmarkList &b); + /** * @brief Save the screen content to a file */ void save_screenshot (const std::string &fn); +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object */ QImage get_screenshot (); +#endif + + /** + * @brief Gets the screen content as a lay::PixelBuffer object + */ + lay::PixelBuffer get_screenshot_pb (); /** * @brief Save an image file with the given width and height @@ -918,19 +859,27 @@ public: * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or QColor() for default - * @param foreground The foreground color or QColor() for default - * @param active The active color or QColor() for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome); +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object with the given width and height */ QImage get_image (unsigned int width, unsigned int height); +#endif + /** + * @brief Gets the screen content as a lay::PixelBuffer object + */ + lay::PixelBuffer get_pixels (unsigned int width, unsigned int height); + +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object with the given width and height * @@ -939,13 +888,46 @@ public: * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or QColor() for default - * @param foreground The foreground color or QColor() for default - * @param active The active color or QColor() for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); +#endif + + /** + * @brief Get the screen content as a lay::PixelBuffer object with the given width and height + * + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + */ + lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); + + /** + * @brief Get the screen content as a monochrome lay::BitmapBuffer object with the given options + * + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + * + * The colors will are converted to "on" pixels with a green channel value >= 50%. + */ + lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); /** * @brief Hierarchy level selection setter @@ -1002,12 +984,12 @@ public: /** * @brief Cell box/label color setter */ - void cell_box_color (QColor c); + void cell_box_color (lay::Color c); /** * @brief Cell box/label getter */ - QColor cell_box_color () const + lay::Color cell_box_color () const { return m_box_color; } @@ -1200,12 +1182,12 @@ public: /** * @brief Text object color */ - void text_color (QColor c); + void text_color (lay::Color c); /** * @brief Text object color */ - QColor text_color () const + lay::Color text_color () const { return m_text_color; } @@ -1463,86 +1445,10 @@ public: unsigned int add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers = true); /** - * @brief Pass the current position from the mouse tracker to the status bar + * @brief Indicates the current position */ - void current_pos (double x, double y); + virtual void current_pos (double x, double y); - /** - * @brief Get the index of the active cellview (shown in hierarchy browser) - */ - int active_cellview_index () const; - - /** - * @brief Get the index of the active cellview (shown in hierarchy browser) - */ - const lay::CellView &active_cellview () const; - - /** - * @brief Gets a cellview reference to the active cellview - */ - lay::CellViewRef active_cellview_ref (); - - /** - * @brief Select a certain cellview for the active one - */ - void set_active_cellview_index (int index); - - /** - * @brief Cell paths of the selected cells - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * current path is returned for the cellview given by cv_index. - */ - void selected_cells_paths (int cv_index, std::vector &paths) const; - - /** - * @brief Cell path of the current cell - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * current path is returned for the cellview given by cv_index. - */ - void current_cell_path (int cv_index, cell_path_type &path) const; - - /** - * @brief Cell path of the current cell - * - * This method version is provided for automation purposes mainly. - */ - cell_path_type get_current_cell_path (int cv_index) const - { - cell_path_type r; - current_cell_path (cv_index, r); - return r; - } - - /** - * @brief Cell path of the current cell in the active cellview - * - * This is a convenience function returning the path for the active cellview. - */ - void current_cell_path (cell_path_type &path) const - { - current_cell_path (active_cellview_index (), path); - } - - /** - * @brief Set the path to the current cell - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * cell given by the path is highlighted and scrolled into view. - */ - void set_current_cell_path (int cv_index, const cell_path_type &path); - - /** - * @brief Set the path to the current cell is the current cellview - * - * This is a convenience function setting the path for the active cellview. - */ - void set_current_cell_path (const cell_path_type &path) - { - set_current_cell_path (active_cellview_index (), path); - } - /** * @brief Obtain the number of cellviews */ @@ -1634,11 +1540,6 @@ public: */ db::DBox box () const; - /** - * @brief Display a status message - */ - void message (const std::string &s = "", int timeout = 10); - /** * @brief Create a new cell with the given in the given cellview * @@ -1648,50 +1549,14 @@ public: */ db::cell_index_type new_cell (int cv_index, const std::string &cell_name); - /** - * @brief Bookmark the current view under the given name - */ - void bookmark_view (const std::string &name); - - /** - * @brief Asks for a bookmark name and bookmark the current view under this name - */ - void bookmark_current_view (); - - /** - * @brief Show the bookmark management form - */ - void manage_bookmarks (); - - /** - * @brief Obtain the bookmarks list - */ - const BookmarkList &bookmarks () const - { - return m_bookmarks; - } - - /** - * @brief Set the bookmarks list - */ - void bookmarks (const BookmarkList &b); - std::pair redo_available (); std::pair undo_available (); /** * @brief Select a certain mode (by index) */ - void mode (int m); + virtual void mode (int m); - /** - * @brief Switches the application's mode - * - * Switches the mode on application level. Use this method to initiate - * a mode switch from the view. - */ - void switch_mode (int m); - /** * @brief Test, if the view is currently in move mode. */ @@ -1707,12 +1572,6 @@ public: */ static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - /** - * @brief Updates the menu for the given view - * If the view is 0, the menu shall be updated to reflect "no view active" - */ - static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); - /** * @brief Query the default mode */ @@ -1800,6 +1659,32 @@ public: return mp_canvas; } +#if defined(HAVE_QT) + /** + * @brief Gets the layer control panel + */ + virtual lay::LayerControlPanel *control_panel () + { + return 0; + } + + /** + * @brief Gets the hierarchy panel + */ + virtual lay::HierarchyControlPanel *hierarchy_panel () + { + return 0; + } + + /** + * @brief Gets the hierarchy panel + */ + virtual lay::EditorOptionsPages *editor_options_pages () + { + return 0; + } +#endif + /** * @brief Get the current viewport */ @@ -1808,10 +1693,15 @@ public: return mp_canvas->viewport (); } + /** + * @brief Resizes the view to the given width and height in pixels + */ + void resize (unsigned int width, unsigned int height); + /** * @brief Background color property */ - QColor background_color () const + lay::Color background_color () const { return mp_canvas->background_color (); } @@ -1819,7 +1709,7 @@ public: /** * @brief Foreground color property */ - QColor foreground_color () const + lay::Color foreground_color () const { return mp_canvas->foreground_color (); } @@ -1827,7 +1717,7 @@ public: /** * @brief Active color property */ - QColor active_color () const + lay::Color active_color () const { return mp_canvas->active_color (); } @@ -1887,7 +1777,7 @@ public: /** * @brief Gets the guiding shapes color */ - QColor guiding_shapes_color () const + lay::Color guiding_shapes_color () const { return m_guiding_shape_color; } @@ -1895,7 +1785,7 @@ public: /** * @brief Sets the guiding shapes color */ - void guiding_shapes_color (QColor c); + void guiding_shapes_color (lay::Color c); /** * @brief Gets the guiding shapes line width @@ -2005,6 +1895,15 @@ public: */ virtual void drop_url (const std::string &path_or_url); + /** + * @brief Returns true if the layer control panels model got updated + * Internally used by CellTreeModel to synchronize + */ + virtual bool layer_model_updated () + { + return false; + } + /** * @brief Gets a list of all plugins */ @@ -2117,7 +2016,96 @@ public: */ db::InstElement ascend (int cellview_index); - /** + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + const lay::CellView &active_cellview () const; + + /** + * @brief Gets a cellview reference to the active cellview + */ + lay::CellViewRef active_cellview_ref (); + + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + virtual int active_cellview_index () const; + + /** + * @brief Select a certain cellview for the active one + */ + virtual void set_active_cellview_index (int index); + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. + */ + tl::Event active_cellview_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. The integer parameter is the index of the + * new cellview. + */ + tl::event active_cellview_changed_with_index_event; + + /** + * @brief Cell paths of the selected cells + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + virtual void selected_cells_paths (int cv_index, std::vector &paths) const; + + /** + * @brief Cell path of the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + virtual void current_cell_path (int cv_index, cell_path_type &path) const; + + /** + * @brief Cell path of the current cell + * + * This method version is provided for automation purposes mainly. + */ + cell_path_type get_current_cell_path (int cv_index) const + { + cell_path_type r; + current_cell_path (cv_index, r); + return r; + } + + /** + * @brief Cell path of the current cell in the active cellview + * + * This is a convenience function returning the path for the active cellview. + */ + void current_cell_path (cell_path_type &path) const + { + current_cell_path (active_cellview_index (), path); + } + + /** + * @brief Set the path to the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * cell given by the path is highlighted and scrolled into view. + */ + virtual void set_current_cell_path (int cv_index, const cell_path_type &path); + + /** + * @brief Set the path to the current cell is the current cellview + * + * This is a convenience function setting the path for the active cellview. + */ + void set_current_cell_path (const cell_path_type &path) + { + set_current_cell_path (active_cellview_index (), path); + } + + /** * @brief Select a cell by path for a certain cell view and fit cell */ void select_cell_fit (const cell_path_type &path, int cellview_index); @@ -2198,16 +2186,6 @@ public: */ void merge_layer_props (const std::vector &props); - /** - * @brief Internal method: check, if the layer tree is and an consistent state. - * - * This method is used by the layer tree model to check, if the tree has been brought into - * a consistent state. - * HINT: for the layout this is solved more consistently with the "under construction" attribute - * of the layout. There is no equivalent object for the layer tree currently. - */ - bool layer_model_updated (); - /** * @brief Get the "select inside PCells" selection mode * @@ -2231,7 +2209,7 @@ public: /** * @brief Get the default color for markers */ - QColor default_marker_color () const + lay::Color default_marker_color () const { return m_marker_color; } @@ -2326,6 +2304,11 @@ public: */ void add_missing_layers (); + /** + * @brief Remove unused layers + */ + void remove_unused_layers (); + /** * @brief Add layers which are not part of the LayerState */ @@ -2336,35 +2319,6 @@ public: */ LayerState layer_snapshot () const; - /** - * @brief Remove unused layers - */ - void remove_unused_layers (); - - /** - * @brief Returns true, if the layer source shall be shown always in the layer properties tree - */ - bool always_show_source () const - { - return m_always_show_source; - } - - /** - * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree - */ - bool always_show_ld () const - { - return m_always_show_ld; - } - - /** - * @brief Returns true, if the layout index shall be shown always in the layer properties tree - */ - bool always_show_layout_index () const - { - return m_always_show_layout_index; - } - /** * @brief Add a marker database * @@ -2402,11 +2356,6 @@ public: */ const rdb::Database *get_rdb (int index) const; - /** - * @brief Open the RDB browser for a given database and associated cv index - */ - void open_rdb_browser (int rdb_index, int cv_index); - /** * @brief Remove the marker database with the given index * @@ -2424,6 +2373,11 @@ public: return (unsigned int) m_rdbs.size (); } + /** + * @brief Open the RDB browser for a given database and associated cv index + */ + virtual void open_rdb_browser (int /*rdb_index*/, int /*cv_index*/) { } + /** * @brief An event signalling a change in the marker database list * @@ -2468,11 +2422,6 @@ public: */ const db::LayoutToNetlist *get_l2ndb (int index) const; - /** - * @brief Open the L2NDB browser for a given database and associated cv index - */ - void open_l2ndb_browser (int l2ndb_index, int cv_index); - /** * @brief Remove the netlist database with the given index * @@ -2490,6 +2439,11 @@ public: return (unsigned int) m_l2ndbs.size (); } + /** + * @brief Open the L2NDB browser for a given database and associated cv index + */ + virtual void open_l2ndb_browser (int /*l2ndb_index*/, int /*cv_index*/) { } + /** * @brief An event signalling a change in the netlist database list * @@ -2497,11 +2451,6 @@ public: */ tl::Event l2ndb_list_changed_event; - /** - * @brief Deliver a size hint (reimplementation of QWidget) - */ - QSize sizeHint () const; - /** * @brief Ensure the given box is visible */ @@ -2520,6 +2469,21 @@ public: return mp_canvas->global_trans (); } + /** + * @brief Gets the window title of the view + */ + std::string title () const; + + /** + * @brief Sets the window title to an explicit string + */ + void set_title (const std::string &t); + + /** + * @brief Resets the explicit title and enable the automatic naming + */ + void reset_title (); + /** * @brief Removes the previous state from the stack */ @@ -2566,13 +2530,6 @@ public: lay::SelectionService *selection_service () const { return mp_selection_service; } lay::MoveService *move_service () const { return mp_move_service; } - /** - * @brief Create all plugins - * - * If plugins already exist, they are deleted and created again - */ - void create_plugins (const lay::PluginDeclaration *except_this = 0); - /** * @brief Gets the full field box * @@ -2581,7 +2538,16 @@ public: */ db::DBox full_box () const; -public slots: + /** + * @brief Gets called when a menu item is activated + */ + void menu_activated (const std::string &symbol); + + /** + * @brief Gets all available menu symbols + */ + static std::vector menu_symbols (); + /** * @brief Store the current state on the "previous states" stack */ @@ -2664,15 +2630,34 @@ public slots: void redraw_layer (unsigned int index); void redraw_deco_layer (); void redraw_cell_boxes (); - void layer_tab_changed (); - void layer_order_changed (); void timer (); - void menu_activated (const std::string &symbol); - static std::vector menu_symbols (); - void deactivate_all_browsers (); - void min_hier_changed (int i); - void max_hier_changed (int i); + virtual void deactivate_all_browsers (); + +#if defined(HAVE_QT) + /** + * @brief Gets the QWidget interface + */ + QWidget *widget (); +#endif + + /** + * @brief Gets the LayoutView interface + */ + LayoutView *ui () + { + return get_ui (); + } + + /** + * @brief Gets the LayoutView interface (const version) + */ + const LayoutView *ui () const + { + return const_cast (this)->get_ui (); + } + +private: // event handlers used to connect to the layout object's events void signal_hier_changed (); void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index); @@ -2684,93 +2669,12 @@ public slots: void signal_plugin_enabled_changed (); void signal_apply_technology (lay::LayoutHandle *layout_handle); -private slots: - void active_cellview_changed (int index); - void active_library_changed (int index); - void side_panel_destroyed (); - -signals: - /** - * @brief This signal is emitted when the title changes - */ - void title_changed (); - - /** - * @brief This signal is emitted when the "dirty" flag changes - */ - void dirty_changed (); - - /** - * @brief This signal is emitted when the view wants to show a message for the given time (of infinitely for ms == 0) - */ - void show_message (const std::string &s, int ms); - - /** - * @brief This signal is emitted when the view wants to indicate a mouse position change - */ - void current_pos_changed (double x, double y, bool dbu_units); - - /** - * @brief This signal is emitted when the view wants to clear the mouse position - */ - void clear_current_pos (); - - /** - * @brief This signal is sent when the "edits_enabled" state has changed - */ - void edits_enabled_changed (); - - /** - * @brief This signal is sent when the view wants to update the menu - */ - void menu_needs_update (); - - /** - * @brief The view initiated a mode change - */ - void mode_change (int m); - - /** - * @brief The current layer changed - */ - void current_layer_changed (const lay::LayerPropertiesConstIterator &l); - -protected: - /** - * @brief Establish the view operations - */ - void set_view_ops (); - - /** - * @brief Deactivate the view - * - * A view gets "deactivated" if it is no longer the current one. - * This is the opposite operation than activation. - */ - void deactivate (); - - /** - * @brief Activate the view - * - * This method gets called when the view becomes the current one. - */ - void activate (); - private: + lay::LayoutView *mp_ui; bool m_editable; int m_disabled_edits; unsigned int m_options; - QTimer *mp_timer; lay::LayoutCanvas *mp_canvas; - QFrame *mp_left_frame; - lay::LayerControlPanel *mp_control_panel; - lay::HierarchyControlPanel *mp_hierarchy_panel; - lay::LibrariesView *mp_libraries_view; - lay::BookmarksView *mp_bookmarks_view; - QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_bookmarks_frame; - lay::EditorOptionsFrame *mp_editor_options_frame; - QSpinBox *mp_min_hier_spbx; - QSpinBox *mp_max_hier_spbx; std::list m_cellviews; lay::AnnotationShapes m_annotation_shapes; std::vector > m_hidden_cells; @@ -2779,9 +2683,6 @@ private: tl::vector m_l2ndbs; std::string m_def_lyp_file; bool m_add_other_layers; - bool m_always_show_source; - bool m_always_show_ld; - bool m_always_show_layout_index; bool m_synchronous; int m_drawing_workers; @@ -2790,15 +2691,15 @@ private: int m_paste_display_mode; int m_wheel_mode; bool m_guiding_shape_visible; - QColor m_guiding_shape_color; + lay::Color m_guiding_shape_color; int m_guiding_shape_line_width; int m_guiding_shape_vertex_size; - QColor m_ctx_color; + lay::Color m_ctx_color; int m_ctx_dimming; bool m_ctx_hollow; - QColor m_child_ctx_color; + lay::Color m_child_ctx_color; int m_child_ctx_dimming; bool m_child_ctx_hollow; bool m_child_ctx_enabled; @@ -2806,13 +2707,13 @@ private: double m_abstract_mode_width; bool m_abstract_mode_enabled; - QColor m_box_color; + lay::Color m_box_color; bool m_box_text_transform; unsigned int m_box_font; int m_min_size_for_label; bool m_cell_box_visible; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_dither_pattern; @@ -2830,7 +2731,7 @@ private: bool m_text_lazy_rendering; bool m_bitmap_caching; bool m_show_properties; - QColor m_text_color; + lay::Color m_text_color; bool m_apply_text_trans; double m_default_text_size; unsigned int m_text_font; @@ -2851,7 +2752,7 @@ private: bool m_absolute_coordinates; bool m_dirty; - bool m_activated; + bool m_prop_changed; bool m_animated; unsigned int m_phase; @@ -2862,11 +2763,11 @@ private: std::vector m_display_states; unsigned int m_display_state_ptr; + BookmarkList m_bookmarks; + std::vector m_layer_properties_lists; unsigned int m_current_layer_list; - BookmarkList m_bookmarks; - // service and editable management int m_mode; @@ -2878,24 +2779,33 @@ private: std::vector mp_plugins; - bool m_visibility_changed; + lay::Plugin *mp_active_plugin; + + int m_active_cellview_index; bool m_active_cellview_changed_event_enabled; - tl::DeferredMethod dm_prop_changed; + std::set m_active_cellview_changed_events; - tl::DeferredMethod dm_setup_editor_option_pages; + lay::LayerPropertiesConstIterator m_current_layer; + std::vector m_selected_layers; - void init (db::Manager *mgr, QWidget *parent); - void init_menu (); + std::vector m_current_cell_per_cellview; + + bool m_visibility_changed; + + tl::Clock m_clock, m_last_checked; + + void init (db::Manager *mgr); void do_prop_changed (); void do_redraw (int layer); void do_redraw (); - void background_color (QColor c); - void ctx_color (QColor c); + void set_view_ops (); + void background_color (lay::Color c); + void ctx_color (lay::Color c); void ctx_dimming (int percent); void ctx_hollow (bool h); - void child_ctx_color (QColor c); + void child_ctx_color (lay::Color c); void child_ctx_dimming (int percent); void child_ctx_hollow (bool h); void child_ctx_enabled (bool e); @@ -2903,33 +2813,70 @@ private: void abstract_mode_enabled (bool e); bool has_max_hier () const; int max_hier_level () const; - bool set_hier_levels_basic (std::pair l); - - void do_setup_editor_options_pages (); void update_event_handlers (); void viewport_changed (); void cellview_changed (unsigned int index); - bool configure (const std::string &name, const std::string &value); - void config_finalize (); - void do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default); void finish_cellviews_changed (); void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; void merge_dither_pattern (lay::LayerPropertiesList &props); - // overrides Editables method to display a message - void signal_selection_changed (); +protected: + unsigned int options () const + { + return m_options; + } - bool eventFilter(QObject *obj, QEvent *ev); - void showEvent (QShowEvent *); - void hideEvent (QHideEvent *); + lay::Plugin *active_plugin () const + { + return mp_active_plugin; + } - lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); + virtual LayoutView *get_ui (); + + lay::LayoutCanvas *canvas () + { + return mp_canvas; + } + + bool configure (const std::string &name, const std::string &value); + void config_finalize (); std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; + + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); + void clear_plugins (); + virtual void create_plugins (const lay::PluginDeclaration *except_this = 0); + + void free_resources (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); + virtual void begin_layer_updates (); + virtual void end_layer_updates (); + virtual void clear_layer_selection (); + virtual void do_set_no_stipples (bool no_stipples); + virtual void do_set_phase (int phase); + virtual bool is_activated () const; + virtual void do_change_active_cellview (); + virtual void update_content_for_cv (int cv_index); + virtual bool set_hier_levels_basic (std::pair l); + + virtual void bookmarks_changed () { } + + void ensure_layer_selected (); + + void enable_active_cellview_changed_event (bool enable, bool silent = false); + void active_cellview_changed (int index); + + virtual void emit_edits_enabled_changed () { } + virtual void emit_title_changed () { } + virtual void emit_dirty_changed () { } + virtual void emit_layer_order_changed () { } }; } diff --git a/src/laybasic/laybasic/layLineStylePalette.cc b/src/laybasic/laybasic/layLineStylePalette.cc index a6b56f6a8..ab8ec99de 100644 --- a/src/laybasic/laybasic/layLineStylePalette.cc +++ b/src/laybasic/laybasic/layLineStylePalette.cc @@ -149,16 +149,16 @@ LineStylePalette::from_string (const std::string &s) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (styles () == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid line style palette - no styles"))); + throw tl::Exception (tl::to_string (tr ("invalid line style palette - no styles"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Line style palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Line style palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layLineStyles.cc b/src/laybasic/laybasic/layLineStyles.cc index f31fcc1ab..e086f19ae 100644 --- a/src/laybasic/laybasic/layLineStyles.cc +++ b/src/laybasic/laybasic/layLineStyles.cc @@ -27,6 +27,7 @@ #include #include +#include namespace lay { @@ -162,6 +163,7 @@ LineStyleInfo::is_bit_set (unsigned int n) const return (pattern () [(n / 32) % pattern_stride ()] & (1 << (n % 32))) != 0; } +#if defined(HAVE_QT) QBitmap LineStyleInfo::get_bitmap (int width, int height) const { @@ -196,6 +198,7 @@ LineStyleInfo::get_bitmap (int width, int height) const return bitmap; } +#endif void LineStyleInfo::set_pattern (uint32_t pt, unsigned int w) @@ -351,8 +354,8 @@ struct ReplaceLineStyleOp LineStyleInfo m_old, m_new; }; -LineStyles::LineStyles () - : QObject (), db::Object (0) +LineStyles::LineStyles () : + db::Object (0) { for (unsigned int d = 0; d < sizeof (style_strings) / sizeof (style_strings [0]); d += 2) { m_styles.push_back (LineStyleInfo ()); @@ -361,17 +364,17 @@ LineStyles::LineStyles () } } +LineStyles::LineStyles (const LineStyles &p) : + db::Object (0) +{ + m_styles = p.m_styles; +} + LineStyles::~LineStyles () { // .. nothing yet .. } -LineStyles::LineStyles (const LineStyles &p) - : QObject (), db::Object (0) -{ - m_styles = p.m_styles; -} - LineStyles & LineStyles::operator= (const LineStyles &p) { @@ -415,11 +418,6 @@ LineStyles::replace_style (unsigned int i, const LineStyleInfo &p) m_styles [i] = p; chg = true; } - - // if something has changed emit the signal - if (chg) { - emit changed (); - } } unsigned int diff --git a/src/laybasic/laybasic/layLineStyles.h b/src/laybasic/laybasic/layLineStyles.h index 5e506dfa5..5cd760f3a 100644 --- a/src/laybasic/laybasic/layLineStyles.h +++ b/src/laybasic/laybasic/layLineStyles.h @@ -27,8 +27,10 @@ #include "laybasicCommon.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif #include "dbObject.h" @@ -141,6 +143,7 @@ public: return m_pattern; } +#if defined(HAVE_QT) /** * @brief Get a monochrome bitmap object for this pattern * @@ -148,6 +151,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (int width = -1, int height = -1) const; +#endif /** * @brief Replaces the pattern string @@ -215,11 +219,9 @@ private: * replaced with a new pattern, except for the first styles which * cannot be changed. */ -class LAYBASIC_PUBLIC LineStyles - : public QObject, public db::Object +class LAYBASIC_PUBLIC LineStyles : + public db::Object { -Q_OBJECT - public: typedef std::vector pattern_vector; typedef pattern_vector::const_iterator iterator; @@ -352,12 +354,6 @@ public: */ static const LineStyles &default_style (); -signals: - /** - * @brief This signal is emitted if a style is changed - */ - void changed (); - private: std::vector m_styles; }; diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index ac08e6d95..93b298099 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -29,7 +29,7 @@ #include "layCanvasPlane.h" #include "layViewOp.h" #include "layRenderer.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlAssert.h" namespace lay @@ -37,7 +37,7 @@ namespace lay // ------------------------------------------------------------------------ -void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, const db::CplxTrans &tr, lay::Renderer &r, +void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, const db::CplxTrans &trans, lay::Renderer &r, unsigned int font, lay::CanvasPlane *fill, lay::CanvasPlane *contour, lay::CanvasPlane *vertex, lay::CanvasPlane *text, bool cell_name_text_transform, int min_size_for_label, bool draw_outline, size_t max_shapes) { @@ -83,29 +83,29 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, db::Vector av(a), bv(b); // fallback to simpler representation using a description text - db::CplxTrans tbox (tr * inst.complex_trans ()); + db::CplxTrans tbox (trans * inst.complex_trans ()); // one representative instance r.draw (cell_box, tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (av * long (amax - 1))) * tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (bv * long (bmax - 1))) * tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (av * long (amax - 1) + bv * long (bmax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (av * long (amax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (bv * long (bmax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (av * long (amax - 1) + bv * long (bmax - 1))) * tbox, fill, contour, 0, text); db::DBox cb (tbox * cell_box); db::DPolygon p; db::DPoint points[] = { db::DPoint (cb.lower_left ()), - db::DPoint (cb.lower_left () + tr * (av * long (amax - 1))), - db::DPoint (cb.lower_left () + tr * (av * long (amax - 1) + bv * long (bmax - 1))), - db::DPoint (cb.lower_left () + tr * (bv * long (bmax - 1))), + db::DPoint (cb.lower_left () + trans * (av * long (amax - 1))), + db::DPoint (cb.lower_left () + trans * (av * long (amax - 1) + bv * long (bmax - 1))), + db::DPoint (cb.lower_left () + trans * (bv * long (bmax - 1))), }; p.assign_hull (points, points + sizeof (points) / sizeof (points[0])); r.draw (p, fill, contour, 0, text); if (text) { - db::DBox arr_box (db::DPoint (), db::DPoint () + tr * (av * long (amax - 1) + bv * long (bmax - 1))); + db::DBox arr_box (db::DPoint (), db::DPoint () + trans * (av * long (amax - 1) + bv * long (bmax - 1))); arr_box *= cb; - r.draw (arr_box, tl::sprintf (tl::to_string (QObject::tr ("Array %ldx%ld")), amax, bmax), db::Font (font), db::HAlignCenter, db::VAlignCenter, db::DFTrans (db::DFTrans::r0), 0, 0, 0, text); + r.draw (arr_box, tl::sprintf (tl::to_string (tr ("Array %ldx%ld")), amax, bmax), db::Font (font), db::HAlignCenter, db::VAlignCenter, db::DFTrans (db::DFTrans::r0), 0, 0, 0, text); } } else { @@ -113,7 +113,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { // fallback to simpler representation using a description text - db::CplxTrans tbox (tr * inst.complex_trans ()); + db::CplxTrans tbox (trans * inst.complex_trans ()); r.draw (cell_box, tbox, fill, contour, 0, 0); @@ -149,7 +149,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, while (! shapes.at_end ()) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - r.draw (*shapes, tr * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); + r.draw (*shapes, trans * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); } ++shapes; @@ -167,7 +167,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, while (! shapes.at_end ()) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - r.draw (*shapes, tr * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); + r.draw (*shapes, trans * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); } ++shapes; @@ -179,7 +179,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, if (render_origins && vertex) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - db::DPoint dp = db::DPoint () + (tr * inst.complex_trans (*arr)).disp (); + db::DPoint dp = db::DPoint () + (trans * inst.complex_trans (*arr)).disp (); r.draw (db::DEdge (dp, dp), 0, 0, vertex, 0); } @@ -188,7 +188,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, // ------------------------------------------------------------------------ -MarkerBase::MarkerBase (lay::LayoutView *view) +MarkerBase::MarkerBase (lay::LayoutViewBase *view) : lay::ViewObject (view->view_object_widget ()), m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) { @@ -196,7 +196,7 @@ MarkerBase::MarkerBase (lay::LayoutView *view) } void -MarkerBase::set_frame_color (QColor color) +MarkerBase::set_frame_color (lay::Color color) { if (color != m_frame_color) { m_frame_color = color; @@ -205,7 +205,7 @@ MarkerBase::set_frame_color (QColor color) } void -MarkerBase::set_color (QColor color) +MarkerBase::set_color (lay::Color color) { if (color != m_color) { m_color = color; @@ -292,16 +292,16 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: int basic_width = int(0.5 + 1.0 / resolution); // obtain bitmaps - QColor color = m_color; - if (! color.isValid ()) { + lay::Color color = m_color; + if (! color.is_valid ()) { color = mp_view->default_marker_color (); } - if (! color.isValid ()) { + if (! color.is_valid ()) { color = canvas.foreground_color (); } - QColor frame_color = m_frame_color; - if (! frame_color.isValid ()) { + lay::Color frame_color = m_frame_color; + if (! frame_color.is_valid ()) { frame_color = color; } @@ -372,7 +372,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: // ------------------------------------------------------------------------ -GenericMarkerBase::GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index) +GenericMarkerBase::GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index) : MarkerBase (view), mp_trans_vector (0), mp_view (view), m_cv_index (cv_index) { // .. nothing yet .. @@ -496,7 +496,7 @@ GenericMarkerBase::dbu () const // ------------------------------------------------------------------------ -InstanceMarker::InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +InstanceMarker::InstanceMarker (LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes), m_inst () { // .. nothing yet .. @@ -576,7 +576,7 @@ InstanceMarker::item_bbox () const // ------------------------------------------------------------------------ -ShapeMarker::ShapeMarker (lay::LayoutView *view, unsigned int cv_index) +ShapeMarker::ShapeMarker (LayoutViewBase *view, unsigned int cv_index) : GenericMarkerBase (view, cv_index), m_shape () { // .. nothing yet .. @@ -643,7 +643,7 @@ ShapeMarker::item_bbox () const // ------------------------------------------------------------------------ -Marker::Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +Marker::Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes) { m_type = None; @@ -1135,7 +1135,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas) // ------------------------------------------------------------------------ -DMarker::DMarker (lay::LayoutView *view) +DMarker::DMarker (LayoutViewBase *view) : MarkerBase (view), mp_view (view) { m_type = None; diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index c3a140a87..2cc4a4133 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -41,12 +41,10 @@ #include "dbArray.h" #include "gsi.h" -#include - namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief The marker base class @@ -61,14 +59,14 @@ public: /** * @brief The constructor */ - MarkerBase (lay::LayoutView *view); + MarkerBase (lay::LayoutViewBase *view); /** * @brief Get the color by which the marker is drawn * * If the color is invalid, the marker is drawn with the canvases foreground color. */ - QColor get_color () const + lay::Color get_color () const { return m_color; } @@ -78,14 +76,14 @@ public: * * If the color is invalid, the marker is drawn with the canvases foreground color. */ - void set_color (QColor color); + void set_color (lay::Color color); /** * @brief Get the color by which the marker's frame is drawn * * If the color is invalid, the marker's frame is drawn with the fill color. */ - QColor get_frame_color () const + lay::Color get_frame_color () const { return m_frame_color; } @@ -95,7 +93,7 @@ public: * * If the color is invalid, the marker's frame is drawn with the fill color. */ - void set_frame_color (QColor color); + void set_frame_color (lay::Color color); /** * @brief Get the line width with which the marker is drawn @@ -228,13 +226,13 @@ public: protected: void get_bitmaps (const Viewport &vp, ViewObjectCanvas &canvas, lay::CanvasPlane *&fill, lay::CanvasPlane *&frame, lay::CanvasPlane *&vertex, lay::CanvasPlane *&text); - QColor m_color; - QColor m_frame_color; + lay::Color m_color; + lay::Color m_frame_color; char m_line_width, m_vertex_size, m_halo; bool m_text_enabled; lay::ViewOp::Shape m_vertex_shape; int m_line_style, m_dither_pattern, m_frame_pattern; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -254,7 +252,7 @@ public: /** * @brief The constructor */ - GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index); + GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -323,7 +321,7 @@ public: /** * @brief Gets the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -346,7 +344,7 @@ public: private: db::CplxTrans m_trans; std::vector *mp_trans_vector; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; /** @@ -369,7 +367,7 @@ public: /** * @brief The constructor */ - ShapeMarker (lay::LayoutView *view, unsigned int cv_index); + ShapeMarker (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -420,7 +418,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + InstanceMarker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -510,7 +508,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -745,7 +743,7 @@ public: /** * @brief The constructor */ - DMarker (lay::LayoutView *view); + DMarker (lay::LayoutViewBase *view); /** * @brief The destructor @@ -808,7 +806,7 @@ private: void *any; } m_object; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index 73caa324b..9afc48058 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -23,12 +23,12 @@ #include "layMouseTracker.h" #include "layLayoutCanvas.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { -MouseTracker::MouseTracker (lay::LayoutView *view) +MouseTracker::MouseTracker (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view) { widget ()->grab_mouse (this, false); diff --git a/src/laybasic/laybasic/layMouseTracker.h b/src/laybasic/laybasic/layMouseTracker.h index 3e826606b..2eb5c33e5 100644 --- a/src/laybasic/laybasic/layMouseTracker.h +++ b/src/laybasic/laybasic/layMouseTracker.h @@ -31,17 +31,17 @@ class QMouseEvent; namespace lay { class LayoutCanvas; -class LayoutView; +class LayoutViewBase; class MouseTracker : public lay::ViewService { public: - MouseTracker (lay::LayoutView *view); + MouseTracker (lay::LayoutViewBase *view); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 5347b8999..bc22b0332 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -24,7 +24,7 @@ #include "layMove.h" #include "layEditable.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySelector.h" #include "laybasicConfig.h" @@ -34,9 +34,8 @@ namespace lay // ------------------------------------------------------------- // MoveService implementation -MoveService::MoveService (lay::LayoutView *view) - : QObject (), - lay::ViewService (view->view_object_widget ()), +MoveService::MoveService (lay::LayoutViewBase *view) + : lay::ViewService (view->view_object_widget ()), m_dragging (false), m_dragging_transient (false), mp_editables (view), @@ -90,13 +89,13 @@ bool MoveService::key_event (unsigned int key, unsigned int /*buttons*/) { double dx = 0.0, dy = 0.0; - if (int (key) == Qt::Key_Down) { + if (int (key) == lay::KeyDown) { dy = -1.0; - } else if (int (key) == Qt::Key_Up) { + } else if (int (key) == lay::KeyUp) { dy = 1.0; - } else if (int (key) == Qt::Key_Left) { + } else if (int (key) == lay::KeyLeft) { dx = -1.0; - } else if (int (key) == Qt::Key_Right) { + } else if (int (key) == lay::KeyRight) { dx = 1.0; } diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index 0bea3f5a9..e46162970 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -20,32 +20,25 @@ */ - - #ifndef HDR_layMove #define HDR_layMove +#include "laybasicCommon.h" #include "dbManager.h" #include "layViewObject.h" -#include -#include - #include namespace lay { class Editables; -class LayoutView; +class LayoutViewBase; -class MoveService - : public QObject, +class LAYBASIC_PUBLIC MoveService : public lay::ViewService { -Q_OBJECT - public: - MoveService (lay::LayoutView *view); + MoveService (lay::LayoutViewBase *view); ~MoveService (); virtual bool configure (const std::string &name, const std::string &value); @@ -67,7 +60,7 @@ private: bool m_dragging; bool m_dragging_transient; lay::Editables *mp_editables; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; double m_global_grid; db::DPoint m_shift; db::DPoint m_mouse_pos; diff --git a/src/lay/lay/layNativePlugin.cc b/src/laybasic/laybasic/layNativePlugin.cc similarity index 100% rename from src/lay/lay/layNativePlugin.cc rename to src/laybasic/laybasic/layNativePlugin.cc diff --git a/src/lay/lay/layNativePlugin.h b/src/laybasic/laybasic/layNativePlugin.h similarity index 84% rename from src/lay/lay/layNativePlugin.h rename to src/laybasic/laybasic/layNativePlugin.h index c3922bc70..b57c2b201 100644 --- a/src/lay/lay/layNativePlugin.h +++ b/src/laybasic/laybasic/layNativePlugin.h @@ -23,7 +23,7 @@ #ifndef HDR_layNativePlugin #define HDR_layNativePlugin -#include "layCommon.h" +#include "laybasicCommon.h" /** * @brief A struct to hold the data of the plugin @@ -84,12 +84,12 @@ struct klp_method_t { }; * @brief The gsi API functions wrapped for the native API */ extern "C" { - LAY_PUBLIC const klp_class_t *klp_class_by_name (const char *name); - LAY_PUBLIC void *klp_create (const klp_class_t *cls); - LAY_PUBLIC void klp_destroy (const klp_class_t *cls, void *obj); - LAY_PUBLIC void *klp_clone (const klp_class_t *cls, const void *source); - LAY_PUBLIC void klp_assign (const klp_class_t *cls, void *target, const void *source); - LAY_PUBLIC void klp_require_api_version (const char *version); + LAYBASIC_PUBLIC const klp_class_t *klp_class_by_name (const char *name); + LAYBASIC_PUBLIC void *klp_create (const klp_class_t *cls); + LAYBASIC_PUBLIC void klp_destroy (const klp_class_t *cls, void *obj); + LAYBASIC_PUBLIC void *klp_clone (const klp_class_t *cls, const void *source); + LAYBASIC_PUBLIC void klp_assign (const klp_class_t *cls, void *target, const void *source); + LAYBASIC_PUBLIC void klp_require_api_version (const char *version); } diff --git a/src/laybasic/laybasic/layNetColorizer.cc b/src/laybasic/laybasic/layNetColorizer.cc new file mode 100644 index 000000000..46639fa40 --- /dev/null +++ b/src/laybasic/laybasic/layNetColorizer.cc @@ -0,0 +1,153 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layNetColorizer.h" +#include "dbNet.h" +#include "dbCircuit.h" + +namespace lay +{ + +// ---------------------------------------------------------------------------------- +// NetColorizer implementation + +NetColorizer::NetColorizer () +{ + m_auto_colors_enabled = false; + m_update_needed = false; + m_signals_enabled = true; +} + +void +NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors) +{ + m_marker_color = marker_color; + if (auto_colors) { + m_auto_colors = *auto_colors; + m_auto_colors_enabled = true; + } else { + m_auto_colors_enabled = false; + } + + emit_colors_changed (); +} + +bool +NetColorizer::has_color_for_net (const db::Net *net) +{ + return net != 0 && (m_auto_colors_enabled || m_custom_color.find (net) != m_custom_color.end ()); +} + +void +NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color) +{ + m_custom_color[net] = color; + emit_colors_changed (); +} + +void +NetColorizer::reset_color_of_net (const db::Net *net) +{ + m_custom_color.erase (net); + emit_colors_changed (); +} + +void +NetColorizer::clear () +{ + m_net_index_by_object.clear (); + m_custom_color.clear (); + emit_colors_changed (); +} + +void +NetColorizer::begin_changes () +{ + if (m_signals_enabled) { + m_update_needed = false; + m_signals_enabled = false; + } +} + +void +NetColorizer::end_changes () +{ + if (! m_signals_enabled) { + m_signals_enabled = true; + if (m_update_needed) { + colors_changed (); + } + m_update_needed = false; + } +} + +void +NetColorizer::emit_colors_changed () +{ + if (! m_signals_enabled) { + m_update_needed = true; + } else { + colors_changed (); + } +} + +lay::Color +NetColorizer::color_of_net (const db::Net *net) const +{ + if (! net) { + return lay::Color (); + } + + std::map::const_iterator c = m_custom_color.find (net); + if (c != m_custom_color.end ()) { + return c->second; + } + + if (m_auto_colors_enabled) { + + const db::Circuit *circuit = net->circuit (); + + size_t index = 0; + + std::map::iterator cc = m_net_index_by_object.find (net); + if (cc == m_net_index_by_object.end ()) { + + size_t i = 0; + for (db::Circuit::const_net_iterator n = circuit->begin_nets (); n != circuit->end_nets (); ++n, ++i) { + m_net_index_by_object.insert (std::make_pair (n.operator-> (), i)); + if (n.operator-> () == net) { + index = i; + } + } + + } else { + index = cc->second; + } + + return m_auto_colors.color_by_index ((unsigned int) index); + + } else { + return lay::Color (); + } +} + +} diff --git a/src/laybasic/laybasic/layNetColorizer.h b/src/laybasic/laybasic/layNetColorizer.h new file mode 100644 index 000000000..489a4ed7b --- /dev/null +++ b/src/laybasic/laybasic/layNetColorizer.h @@ -0,0 +1,85 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layNetColorizer +#define HDR_layNetColorizer + +#include "laybasicCommon.h" +#include "layColorPalette.h" +#include "layColor.h" +#include "tlEvents.h" + +#include +#include + +namespace db +{ + class Net; +} + +namespace lay +{ + +// ---------------------------------------------------------------------------------- +// NetColorizer definition + +class LAYBASIC_PUBLIC NetColorizer + : public tl::Object +{ +public: + NetColorizer (); + + void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors); + bool has_color_for_net (const db::Net *net); + void set_color_of_net (const db::Net *net, const lay::Color &color); + void reset_color_of_net (const db::Net *net); + void clear (); + + lay::Color color_of_net (const db::Net *net) const; + + const lay::Color &marker_color () const + { + return m_marker_color; + } + + void begin_changes (); + void end_changes (); + + tl::Event colors_changed; + +private: + lay::Color m_marker_color; + lay::ColorPalette m_auto_colors; + bool m_auto_colors_enabled; + std::map m_custom_color; + bool m_update_needed; + bool m_signals_enabled; + mutable std::map m_net_index_by_object; + + void emit_colors_changed (); +}; + +} // namespace lay + +#endif + diff --git a/src/laybasic/laybasic/layObjectInstPath.cc b/src/laybasic/laybasic/layObjectInstPath.cc index 48ec1167e..8d8f5a870 100644 --- a/src/laybasic/laybasic/layObjectInstPath.cc +++ b/src/laybasic/laybasic/layObjectInstPath.cc @@ -26,7 +26,6 @@ #include "layObjectInstPath.h" #include "layCellView.h" -#include "layLayoutView.h" #include "tlException.h" namespace lay { diff --git a/src/laybasic/laybasic/layObjectInstPath.h b/src/laybasic/laybasic/layObjectInstPath.h index 91d3ef681..13c4ca095 100644 --- a/src/laybasic/laybasic/layObjectInstPath.h +++ b/src/laybasic/laybasic/layObjectInstPath.h @@ -31,8 +31,6 @@ #include #include -#include - #include "dbInstElement.h" #include "dbClipboardData.h" #include "dbClipboard.h" diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index da2c51a16..66130f12f 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -22,7 +22,7 @@ #include "layParsedLayerSource.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlString.h" #include "tlGlobPattern.h" @@ -415,7 +415,7 @@ extract_base (tl::Extractor &ex) } else if (ex.test ("!=")) { eq = false; } else { - ex.error (tl::to_string (QObject::tr ("'==' or '!=' operator expected"))); + ex.error (tl::to_string (tr ("'==' or '!=' operator expected"))); } ex.read (v); return new PropertySelectorEqual (n, v, eq); @@ -1163,7 +1163,7 @@ ParsedLayerSource::to_string () const } std::string -ParsedLayerSource::display_string (const lay::LayoutView *view) const +ParsedLayerSource::display_string (const lay::LayoutViewBase *view) const { std::string r; @@ -1376,7 +1376,7 @@ ParsedLayerSource::parse_from_string (const char *cp) if (sp == "CellFrame" || sp == "cellframe" || sp == "CF" || sp == "cell-frame") { m_special_purpose = SP_CellFrame; } else { - throw tl::Exception (tl::to_string (QObject::tr ("Invalid special purpose '%s'")), sp); + throw tl::Exception (tl::to_string (tr ("Invalid special purpose '%s'")), sp); } } else if (x.test ("(")) { diff --git a/src/laybasic/laybasic/layParsedLayerSource.h b/src/laybasic/laybasic/layParsedLayerSource.h index e3bbfa511..e2c7936bf 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.h +++ b/src/laybasic/laybasic/layParsedLayerSource.h @@ -43,7 +43,7 @@ namespace lay { class LayerProperties; -class LayoutView; +class LayoutViewBase; class PropertySelectorBase; /** @@ -640,7 +640,7 @@ public: * This method delivers a display version that may be abbreviated and is supposed * to be used in the layer list display. */ - std::string display_string (const lay::LayoutView *view) const; + std::string display_string (const lay::LayoutViewBase *view) const; /** * @brief Comparison (equality) diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc new file mode 100644 index 000000000..f5584d0e2 --- /dev/null +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -0,0 +1,820 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layPixelBuffer.h" +#include "tlAssert.h" +#include "tlLog.h" + +#if defined(HAVE_PNG) +# include +#endif + +#include + +namespace lay +{ + +// ----------------------------------------------------------------------------------------------------- +// Exceptions + +PixelBufferReadError::PixelBufferReadError (const char *msg) + : tl::Exception (tl::to_string (tr ("PNG read error: ")) + std::string (msg)) +{ + // .. nothing yet .. +} + +PixelBufferReadError::PixelBufferReadError (const std::string &msg) + : tl::Exception (tl::to_string (tr ("PNG read error: ")) + msg) +{ + // .. nothing yet .. +} + +PixelBufferWriteError::PixelBufferWriteError (const char *msg) + : tl::Exception (tl::to_string (tr ("PNG write error: ")) + std::string (msg)) +{ + // .. nothing yet .. +} + +PixelBufferWriteError::PixelBufferWriteError (const std::string &msg) + : tl::Exception (tl::to_string (tr ("PNG write error: ")) + msg) +{ + // .. nothing yet .. +} + +#if defined(HAVE_PNG) + +static void png_read_warn_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + tl::warn << tl::to_string (tr ("Warning reading PNG: ")) << error_message; +} + +static void png_read_error_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + throw PixelBufferReadError (error_message); +} + +static void png_write_warn_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + tl::warn << tl::to_string (tr ("Warning writing PNG: ")) << error_message; +} + +static void png_write_error_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + throw PixelBufferReadError (error_message); +} + +static void read_from_stream_f (png_structp png_ptr, png_bytep bytes, size_t length) +{ + tl::InputStream *stream = (tl::InputStream *) png_get_io_ptr (png_ptr); + try { + memcpy (bytes, stream->get (length), length); + } catch (tl::Exception &ex) { + png_error (png_ptr, ex.msg ().c_str ()); + } +} + +static void write_to_stream_f (png_structp png_ptr, png_bytep bytes, size_t length) +{ + tl::OutputStream *stream = (tl::OutputStream *) png_get_io_ptr (png_ptr); + try { + stream->put ((const char *) bytes, length); + } catch (tl::Exception &ex) { + png_error (png_ptr, ex.msg ().c_str ()); + } +} + +static void flush_stream_f (png_structp png_ptr) +{ + tl::OutputStream *stream = (tl::OutputStream *) png_get_io_ptr (png_ptr); + stream->flush (); +} + +#endif + +// ----------------------------------------------------------------------------------------------------- +// PixelBuffer implementation + +PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data) + : m_data () +{ + m_width = w; + m_height = h; + m_transparent = false; + m_data.reset (new ImageData (data, w * h)); +} + +PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride) + : m_data () +{ + m_width = w; + m_height = h; + m_transparent = false; + + tl_assert ((stride % sizeof (lay::color_t)) == 0); + stride /= sizeof (lay::color_t); + + lay::color_t *d = new lay::color_t [w * h]; + lay::color_t *new_data = d; + + if (data) { + for (unsigned int i = 0; i < h; ++i) { + for (unsigned int j = 0; j < w; ++j) { + *d++ = *data++; + } + if (stride > w) { + data += stride - w; + } + } + } + + m_data.reset (new ImageData (new_data, w * h)); +} + +PixelBuffer::PixelBuffer () +{ + m_width = 0; + m_height = 0; + m_transparent = false; +} + +PixelBuffer::PixelBuffer (const PixelBuffer &other) +{ + operator= (other); +} + +PixelBuffer::PixelBuffer (PixelBuffer &&other) +{ + swap (other); +} + +PixelBuffer::~PixelBuffer () +{ + // .. nothing yet .. +} + +bool +PixelBuffer::operator== (const PixelBuffer &other) const +{ + if (width () != other.width () || height () != other.height ()) { + return false; + } + if (transparent () != other.transparent ()) { + return false; + } + + lay::color_t m = transparent () ? 0xffffffff : 0xffffff; + for (unsigned int i = 0; i < other.height (); ++i) { + const lay::color_t *d = scan_line (i); + const lay::color_t *de = d + width (); + const lay::color_t *dd = other.scan_line (i); + while (d != de) { + if (((*d++ ^ *dd++) & m) != 0) { + return false; + } + } + } + + return true; +} + +PixelBuffer & +PixelBuffer::operator= (const PixelBuffer &other) +{ + if (this != &other) { + m_width = other.m_width; + m_height = other.m_height; + m_data = other.m_data; + m_transparent = other.m_transparent; + m_texts = other.m_texts; + } + return *this; +} + +PixelBuffer & +PixelBuffer::operator= (PixelBuffer &&other) +{ + if (this != &other) { + swap (other); + } + return *this; +} + +void +PixelBuffer::set_transparent (bool f) +{ + m_transparent = f; +} + +void +PixelBuffer::swap (PixelBuffer &other) +{ + if (this == &other) { + return; + } + + std::swap (m_width, other.m_width); + std::swap (m_height, other.m_height); + std::swap (m_transparent, other.m_transparent); + m_data.swap (other.m_data); + m_texts.swap (other.m_texts); +} + +void +PixelBuffer::fill (lay::color_t c) +{ + if (! transparent ()) { + c |= 0xff000000; // ensures that alpha is properly set + } + + color_t *d = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + *d++ = c; + } + } +} + +color_t * +PixelBuffer::scan_line (unsigned int n) +{ + tl_assert (n < m_height); + return m_data->data () + n * m_width; +} + +const color_t * +PixelBuffer::scan_line (unsigned int n) const +{ + tl_assert (n < m_height); + return m_data->data () + n * m_width; +} + +color_t * +PixelBuffer::data () +{ + return m_data->data (); +} + +const color_t * +PixelBuffer::data () const +{ + return m_data->data (); +} + +#if defined(HAVE_QT) +QImage +PixelBuffer::to_image () const +{ + return QImage ((const uchar *) data (), m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); +} + +QImage +PixelBuffer::to_image_copy () const +{ + QImage img (m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); +#if QT_VERSION < 0x050000 + memcpy (img.bits (), data (), img.byteCount ()); +#else + memcpy (img.bits (), data (), img.sizeInBytes ()); +#endif + return img; +} + +PixelBuffer +PixelBuffer::from_image (const QImage &img) +{ + if (img.format () != QImage::Format_ARGB32 && img.format () != QImage::Format_RGB32) { + QImage img_argb32 = img.convertToFormat (QImage::Format_ARGB32); + return PixelBuffer (img_argb32.width (), img_argb32.height (), (const lay::color_t *) img_argb32.bits ()); + } else { + return PixelBuffer (img.width (), img.height (), (const lay::color_t *) img.bits ()); + } +} +#endif + +void +PixelBuffer::patch (const PixelBuffer &other) +{ + tl_assert (width () == other.width ()); + tl_assert (height () == other.height ()); + tl_assert (other.transparent ()); + + const color_t *d = other.data (); + color_t *dd = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + color_t c = *d++; + if ((c & 0x80000000) != 0) { + *dd = c; + } + ++dd; + } + } +} + +PixelBuffer +PixelBuffer::diff (const PixelBuffer &other) const +{ + tl_assert (width () == other.width ()); + tl_assert (height () == other.height ()); + + PixelBuffer res (m_width, m_height); + res.set_transparent (true); + + const color_t *d2 = other.data (); + const color_t *d1 = data (); + color_t *dd = res.data (); + + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + if (((*d1 ^ *d2) & 0xffffff) != 0) { + *dd++ = *d2 | 0xff000000; + } else { + *dd++ = 0; + } + ++d1; + ++d2; + } + } + + return res; +} + +#if defined(HAVE_PNG) + +PixelBuffer +PixelBuffer::read_png (tl::InputStream &input) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, &png_read_error_f, &png_read_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f); + png_set_bgr (png_ptr); // compatible with lay::color_t + + png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + PixelBuffer res (png_get_image_width (png_ptr, info_ptr), png_get_image_height (png_ptr, info_ptr)); + + unsigned int fmt = png_get_color_type (png_ptr, info_ptr); + unsigned int bd = png_get_bit_depth (png_ptr, info_ptr); + + if (fmt == PNG_COLOR_TYPE_RGBA && bd == 8) { + + tl_assert (png_get_rowbytes (png_ptr, info_ptr) == res.width () * sizeof (lay::color_t)); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], sizeof (lay::color_t) * res.width ()); + } + + res.set_transparent (true); + + } else if (fmt == PNG_COLOR_TYPE_RGB && bd == 8) { + + // RGB has 3 bytes per pixel which need to be transformed into RGB32 + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width () * 3); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + lay::color_t b = *d++; + lay::color_t g = *d++; + lay::color_t r = *d++; + *c++ = 0xff000000 | ((r << 8 | g) << 8) | b; + } + } + + } else if (fmt == PNG_COLOR_TYPE_GRAY_ALPHA && bd == 8) { + + // GA format has 2 bytes per pixel (alpha, gray) which need to be transformed into ARGB + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width () * 2); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + lay::color_t g = *d++; + lay::color_t a = *d++; + *c++ = (a << 24) | ((g << 8 | g) << 8) | g; + } + } + + res.set_transparent (true); + + } else if (fmt == PNG_COLOR_TYPE_GRAY && bd == 8) { + + // G format has 1 byte per pixel (gray) which need to be transformed into ARGB + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width ()); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + lay::color_t g = *d++; + *c++ = 0xff000000 | ((g << 8 | g) << 8) | g; + } + } + + } else { + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG reader supports 8 bit G, GA, RGB or RGBA files only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); + + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + return res; +} + +void +PixelBuffer::write_png (tl::OutputStream &output) const +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, &png_write_error_f, &png_write_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f); + png_set_bgr (png_ptr); // compatible with lay::color_t + + unsigned int bd = 8; // bit depth + unsigned int fmt = transparent () ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB; + + png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + std::vector tptrs; + for (auto i = m_texts.begin (); i != m_texts.end (); ++i) { + tptrs.push_back (png_text ()); + tptrs.back ().compression = PNG_TEXT_COMPRESSION_NONE; + tptrs.back ().key = const_cast (i->first.c_str ()); + tptrs.back ().text = const_cast (i->second.c_str ()); + } + png_set_text (png_ptr, info_ptr, tptrs.begin ().operator-> (), m_texts.size ()); + + png_write_info (png_ptr, info_ptr); + + if (transparent ()) { + + for (unsigned int i = 0; i < height (); ++i) { + png_write_row (png_ptr, png_const_bytep (scan_line (i))); + } + + } else { + + std::unique_ptr buffer (new uint8_t [width () * 3]); + + for (unsigned int i = 0; i < height (); ++i) { + uint8_t *d = buffer.get (); + const lay::color_t *s = scan_line (i); + const lay::color_t *se = s + width (); + while (s != se) { + lay::color_t c = *s++; + *d++ = c & 0xff; + c >>= 8; + *d++ = c & 0xff; + c >>= 8; + *d++ = c & 0xff; + } + png_write_row (png_ptr, png_const_bytep (buffer.get ())); + } + + } + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); +} + +#endif + +// ----------------------------------------------------------------------------------------------------- +// BitmapBuffer implementation + +static unsigned int +stride_from_width (unsigned int w) +{ + // Qt needs 32bit-aligned data + return 4 * ((w + 31) / 32); +} + +BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data) +{ + m_width = w; + m_height = h; + m_stride = stride_from_width (w); + m_data.reset (new MonoImageData (data, m_stride * h)); +} + +BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride) +{ + m_width = w; + m_height = h; + m_stride = stride_from_width (w); + + uint8_t *d = new uint8_t [m_stride * h]; + uint8_t *new_data = d; + + if (data) { + for (unsigned int i = 0; i < h; ++i) { + memcpy (d, data, m_stride); + d += m_stride; + data += m_stride; + if (stride > m_stride) { + data += stride - m_stride; + } + } + } + + m_data.reset (new MonoImageData (new_data, m_stride * h)); +} + +BitmapBuffer::BitmapBuffer () +{ + m_width = 0; + m_height = 0; + m_stride = 0; +} + +BitmapBuffer::BitmapBuffer (const BitmapBuffer &other) +{ + operator= (other); +} + +BitmapBuffer::BitmapBuffer (BitmapBuffer &&other) +{ + swap (other); +} + +BitmapBuffer::~BitmapBuffer () +{ + // .. nothing yet .. +} + +bool +BitmapBuffer::operator== (const BitmapBuffer &other) const +{ + if (width () != other.width () || height () != other.height ()) { + return false; + } + + for (unsigned int i = 0; i < other.height (); ++i) { + const uint8_t *d = scan_line (i); + const uint8_t *dd = other.scan_line (i); + unsigned int bits_left = width (); + while (bits_left >= 8) { + if (*d++ != *dd++) { + return false; + } + bits_left -= 8; + } + if (bits_left > 0) { + unsigned int m = (0x01 << bits_left) - 1; + if (((*d ^ *dd) & m) != 0) { + return false; + } + } + } + + return true; +} + +BitmapBuffer & +BitmapBuffer::operator= (const BitmapBuffer &other) +{ + if (this != &other) { + m_width = other.m_width; + m_height = other.m_height; + m_stride = other.m_stride; + m_data = other.m_data; + m_texts = other.m_texts; + } + return *this; +} + +BitmapBuffer & +BitmapBuffer::operator= (BitmapBuffer &&other) +{ + if (this != &other) { + swap (other); + } + return *this; +} + +void +BitmapBuffer::swap (BitmapBuffer &other) +{ + if (this == &other) { + return; + } + + std::swap (m_width, other.m_width); + std::swap (m_height, other.m_height); + std::swap (m_stride, other.m_stride); + m_data.swap (other.m_data); + m_texts.swap (other.m_texts); +} + +void +BitmapBuffer::fill (bool value) +{ + uint8_t c = value ? 0xff : 0; + uint8_t *d = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_stride; ++j) { + *d++ = c; + } + } +} + +uint8_t * +BitmapBuffer::scan_line (unsigned int n) +{ + tl_assert (n < m_height); + return m_data->data () + n * m_stride; +} + +const uint8_t * +BitmapBuffer::scan_line (unsigned int n) const +{ + tl_assert (n < m_height); + return m_data->data () + n * m_stride; +} + +uint8_t * +BitmapBuffer::data () +{ + return m_data->data (); +} + +const uint8_t * +BitmapBuffer::data () const +{ + return m_data->data (); +} + +#if defined(HAVE_QT) +QImage +BitmapBuffer::to_image () const +{ + QImage img = QImage ((const uchar *) data (), m_width, m_height, QImage::Format_MonoLSB); + img.setColor (0, 0xff000000); + img.setColor (1, 0xffffffff); + return img; +} + +QImage +BitmapBuffer::to_image_copy () const +{ + QImage img (m_width, m_height, QImage::Format_MonoLSB); +#if QT_VERSION < 0x050000 + memcpy (img.bits (), data (), img.byteCount ()); +#else + memcpy (img.bits (), data (), img.sizeInBytes ()); +#endif + return img; +} + +BitmapBuffer +BitmapBuffer::from_image (const QImage &img) +{ + if (img.format () != QImage::Format_MonoLSB) { + QImage img_monolsb = img.convertToFormat (QImage::Format_MonoLSB); + return BitmapBuffer (img_monolsb.width (), img_monolsb.height (), (const uint8_t *) img_monolsb.bits ()); + } else { + return BitmapBuffer (img.width (), img.height (), (const uint8_t *) img.bits ()); + } +} +#endif + +#if defined(HAVE_PNG) + +BitmapBuffer +BitmapBuffer::read_png (tl::InputStream &input) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, &png_read_error_f, &png_read_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f); + png_set_packswap (png_ptr); // compatible with BitmapBuffer + + png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + BitmapBuffer res (png_get_image_width (png_ptr, info_ptr), png_get_image_height (png_ptr, info_ptr)); + + unsigned int fmt = png_get_color_type (png_ptr, info_ptr); + unsigned int bd = png_get_bit_depth (png_ptr, info_ptr); + + if ((fmt == PNG_COLOR_TYPE_GRAY || fmt == PNG_COLOR_TYPE_PALETTE) && bd == 1) { + + // TODO: evaluate palette? + + size_t rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == (res.width () + 7) / 8); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], rb); + } + + } else { + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG bitmap reader supports monochrome files only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); + + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + return res; +} + +void +BitmapBuffer::write_png (tl::OutputStream &output) const +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, &png_write_error_f, &png_write_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f); + png_set_packswap (png_ptr); // compatible with BitmapBuffer + + unsigned int bd = 1; // bit depth + unsigned int fmt = PNG_COLOR_TYPE_GRAY; + + png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + std::vector tptrs; + for (auto i = m_texts.begin (); i != m_texts.end (); ++i) { + tptrs.push_back (png_text ()); + tptrs.back ().compression = PNG_TEXT_COMPRESSION_NONE; + tptrs.back ().key = const_cast (i->first.c_str ()); + tptrs.back ().text = const_cast (i->second.c_str ()); + } + png_set_text (png_ptr, info_ptr, tptrs.begin ().operator-> (), m_texts.size ()); + + png_write_info (png_ptr, info_ptr); + + for (unsigned int i = 0; i < height (); ++i) { + png_write_row (png_ptr, png_const_bytep (scan_line (i))); + } + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); +} + +#endif + + +} diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h new file mode 100644 index 000000000..943d445c0 --- /dev/null +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -0,0 +1,558 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layPixelBuffer +#define HDR_layPixelBuffer + +#include "laybasicCommon.h" +#include "layColor.h" +#include "tlCopyOnWrite.h" +#include "tlStream.h" +#include "tlException.h" + +#include +#include + +#if defined(HAVE_QT) +# include +#endif + +namespace lay +{ + +/** + * @brief An exception thrown when a PNG read error occurs + */ +class LAYBASIC_PUBLIC PixelBufferReadError + : public tl::Exception +{ +public: + PixelBufferReadError (const char *msg); + PixelBufferReadError (const std::string &msg); +}; + +/** + * @brief An exception thrown when a PNG write error occurs + */ +class LAYBASIC_PUBLIC PixelBufferWriteError + : public tl::Exception +{ +public: + PixelBufferWriteError (const char *msg); + PixelBufferWriteError (const std::string &msg); +}; + +/** + * @brief An 32bit RGB/RGBA image class + * + * This class substitutes QImage in Qt-less applications. + * It provides 32bit RGBA pixels with the format used by lay::Color. + */ +class LAYBASIC_PUBLIC PixelBuffer +{ +public: + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data and will take ownership over the + * data block. + * + * The size of the data block needs to be w*h elements. + */ + PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data); + + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data. A copy of the data is created. + * + * "stride" specifies the stride (distance between two rows of data). + * The size of the data block needs to be stride*h elements or w*h if stride is not given. + */ + PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0); + + /** + * @brief Default constructor + */ + PixelBuffer (); + + /** + * @brief Copy constructor + */ + PixelBuffer (const PixelBuffer &other); + + /** + * @brief Move constructor + */ + PixelBuffer (PixelBuffer &&other); + + /** + * @brief Destructor + */ + ~PixelBuffer (); + + /** + * @brief Equality + */ + bool operator== (const PixelBuffer &other) const; + + /** + * @brief Inequality + */ + bool operator!= (const PixelBuffer &other) const + { + return !operator== (other); + } + + /** + * @brief Assignment + */ + PixelBuffer &operator= (const PixelBuffer &other); + + /** + * @brief Move constructor + */ + PixelBuffer &operator= (PixelBuffer &&other); + + /** + * @brief Sets a value indicating whether an alpha channel is present + */ + void set_transparent (bool f); + + /** + * @brief Gets a value indicating whether an alpha channel is present + */ + bool transparent () const + { + return m_transparent; + } + + /** + * @brief Swaps this image with another one + */ + void swap (PixelBuffer &other); + + /** + * @brief Gets the images width + */ + unsigned int width () const + { + return m_width; + } + + /** + * @brief Gets the images width + */ + unsigned int height () const + { + return m_height; + } + + /** + * @brief Gets the image stride (number of bytes per row) + */ + unsigned int stride () const + { + return sizeof (lay::color_t) * m_width; + } + + /** + * @brief Fills the image with the given color + */ + void fill (lay::color_t); + + /** + * @brief Gets the scanline for row n + */ + color_t *scan_line (unsigned int n); + + /** + * @brief Gets the scanline for row n (const version) + */ + const color_t *scan_line (unsigned int n) const; + + /** + * @brief Gets the data pointer + */ + color_t *data (); + + /** + * @brief Gets the data pointer (const version) + */ + const color_t *data () const; + +#if defined(HAVE_QT) + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a reference, i.e. the QImage is valid only + * during the lifetime of the PixelBuffer. + */ + QImage to_image () const; + + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a copy and the QImage is independent of the + * PixelBuffer. + */ + QImage to_image_copy () const; + + /** + * @brief Creates a pixel buffer from a QImage object + */ + static PixelBuffer from_image (const QImage &img); +#endif + +#if defined(HAVE_PNG) + /** + * @brief Creates a PixelBuffer object from a PNG file + * Throws a PixelBufferReadError if an error occurs. + */ + static PixelBuffer read_png (tl::InputStream &input); + + /** + * @brief Writes the PixelBuffer object to a PNG file + * Throws a PixelBufferWriteError if an error occurs. + */ + void write_png (tl::OutputStream &output) const; +#endif + + /** + * @brief Overlays the other image with this one + * + * This feature does not implement real alpha blending. Instead all + * pixels with an alpha value >= 128 from the other image are patched into this image. + */ + void patch (const PixelBuffer &other); + + /** + * @brief Generates the image difference + * + * This feature produces a binary-alpha image of *this and other. The + * result can be patched into this image to render the same image than + * "other". The difference image will contains the pixels from other which + * are different from *this. + * + * alpha values from this and other are ignored. + */ + PixelBuffer diff (const PixelBuffer &other) const; + + /** + * @brief Gets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + const std::vector > &texts () const + { + return m_texts; + } + + /** + * @brief Sets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + void set_texts (const std::vector > &texts) + { + m_texts = texts; + } + +private: + class ImageData + { + public: + ImageData () + : mp_data (0), m_length (0) + { + // .. nothing yet .. + } + + ImageData (lay::color_t *data, size_t length) + : mp_data (data), m_length (length) + { + // .. nothing yet .. + } + + ImageData (const ImageData &other) + { + m_length = other.length (); + mp_data = new lay::color_t [other.length ()]; + memcpy (mp_data, other.data (), m_length * sizeof (lay::color_t)); + } + + ~ImageData () + { + delete[] mp_data; + mp_data = 0; + } + + size_t length () const { return m_length; } + lay::color_t *data () { return mp_data; } + const lay::color_t *data () const { return mp_data; } + + private: + lay::color_t *mp_data; + size_t m_length; + + ImageData &operator= (const ImageData &other); + }; + + unsigned int m_width, m_height; + bool m_transparent; + tl::copy_on_write_ptr m_data; + std::vector > m_texts; +}; + +/** + * @brief An monochrome image class + * + * This class substitutes QImage for monochrome images in Qt-less applications. + */ + +class LAYBASIC_PUBLIC BitmapBuffer +{ +public: + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data and will take ownership over the + * data block. + * + * Lines are byte-aligned. + */ + BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data); + + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data. A copy of the data is created. + * + * "stride" specifies the stride (distance in bytes between two rows of data). + * The size of the data block needs to be stride*h elements or bytes(w)*h if stride is not given. + */ + BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0); + + /** + * @brief Default constructor + */ + BitmapBuffer (); + + /** + * @brief Copy constructor + */ + BitmapBuffer (const BitmapBuffer &other); + + /** + * @brief Move constructor + */ + BitmapBuffer (BitmapBuffer &&other); + + /** + * @brief Equality + */ + bool operator== (const BitmapBuffer &other) const; + + /** + * @brief Inequality + */ + bool operator!= (const BitmapBuffer &other) const + { + return !operator== (other); + } + + /** + * @brief Destructor + */ + ~BitmapBuffer (); + + /** + * @brief Assignment + */ + BitmapBuffer &operator= (const BitmapBuffer &other); + + /** + * @brief Move constructor + */ + BitmapBuffer &operator= (BitmapBuffer &&other); + + /** + * @brief Swaps this image with another one + */ + void swap (BitmapBuffer &other); + + /** + * @brief Gets the images width + */ + unsigned int width () const + { + return m_width; + } + + /** + * @brief Gets the images width + */ + unsigned int height () const + { + return m_height; + } + + /** + * @brief Gets the image stride (number of bytes per row) + */ + unsigned int stride () const + { + return m_stride; + } + + /** + * @brief Fills the image with the given color + */ + void fill (bool value); + + /** + * @brief Gets the scanline for row n + */ + uint8_t *scan_line (unsigned int n); + + /** + * @brief Gets the scanline for row n (const version) + */ + const uint8_t *scan_line (unsigned int n) const; + + /** + * @brief Gets the data pointer + */ + uint8_t *data (); + + /** + * @brief Gets the data pointer (const version) + */ + const uint8_t *data () const; + +#if defined(HAVE_QT) + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a reference, i.e. the QImage is valid only + * during the lifetime of the BitmapBuffer. + */ + QImage to_image () const; + + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a copy and the QImage is independent of the + * BitmapBuffer. + */ + QImage to_image_copy () const; + + /** + * @brief Creates a pixel buffer from a QImage object + */ + static BitmapBuffer from_image (const QImage &img); +#endif + +#if defined(HAVE_PNG) + /** + * @brief Creates a PixelBuffer object from a PNG file + * Throws a PixelBufferReadError if an error occurs. + */ + static BitmapBuffer read_png (tl::InputStream &input); + + /** + * @brief Writes the PixelBuffer object to a PNG file + * Throws a PixelBufferWriteError if an error occurs. + */ + void write_png (tl::OutputStream &output) const; +#endif + + /** + * @brief Gets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + const std::vector > &texts () const + { + return m_texts; + } + + /** + * @brief Sets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + void set_texts (const std::vector > &texts) + { + m_texts = texts; + } + +private: + class MonoImageData + { + public: + MonoImageData () + : mp_data (0), m_length (0) + { + // .. nothing yet .. + } + + MonoImageData (uint8_t *data, size_t length) + : mp_data (data), m_length (length) + { + // .. nothing yet .. + } + + MonoImageData (const MonoImageData &other) + { + m_length = other.length (); + mp_data = new uint8_t [other.length ()]; + memcpy (mp_data, other.data (), m_length * sizeof (uint8_t)); + } + + ~MonoImageData () + { + delete[] mp_data; + mp_data = 0; + } + + size_t length () const { return m_length; } + uint8_t *data () { return mp_data; } + const uint8_t *data () const { return mp_data; } + + private: + uint8_t *mp_data; + size_t m_length; + + MonoImageData &operator= (const MonoImageData &other); + }; + + unsigned int m_width, m_height; + unsigned int m_stride; + tl::copy_on_write_ptr m_data; + std::vector > m_texts; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/layPixelBufferPainter.cc b/src/laybasic/laybasic/layPixelBufferPainter.cc new file mode 100644 index 000000000..068c2968e --- /dev/null +++ b/src/laybasic/laybasic/layPixelBufferPainter.cc @@ -0,0 +1,171 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layPixelBufferPainter.h" + +#include "layFixedFont.h" +#include "layPixelBuffer.h" + +namespace lay +{ + +PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution) + : mp_img (&img), + m_resolution (resolution), m_width (width), m_height (height) +{ + // .. nothing yet .. +} + +void +PixelBufferPainter::set (const db::Point &p, lay::Color c) +{ + if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { + ((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb (); + } +} + +void +PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + if (p1.x () == p2.x ()) { + + int x = p1.x (); + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + if ((y2 >= 0 || y1 < m_height) && x >= 0 && x < m_width) { + y1 = std::max (y1, 0); + y2 = std::min (y2, m_height - 1); + for (int y = y1; y <= y2; ++y) { + ((unsigned int *) mp_img->scan_line (y)) [x] = c.rgb (); + } + } + + } else if (p1.y () == p2.y ()) { + + int y = p1.y (); + int x1 = std::min (p1.x (), p2.x ()); + int x2 = std::max (p1.x (), p2.x ()); + if ((x2 >= 0 || x1 < m_width) && y >= 0 && y < m_height) { + x1 = std::max (x1, 0); + x2 = std::min (x2, m_width - 1); + unsigned int *sl = (unsigned int *) mp_img->scan_line (y) + x1; + for (int x = x1; x <= x2; ++x) { + *sl++ = c.rgb (); + } + } + + } else { + // TODO: not implemented yet. + } +} + +void +PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + for (int y = y1; y <= y2; ++y) { + draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c); + } +} + +void +PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + int x1 = std::min (p1.x (), p2.x ()); + int x2 = std::max (p1.x (), p2.x ()); + draw_line (db::Point (x1, y1), db::Point (x2, y1), c); + draw_line (db::Point (x1, y2), db::Point (x2, y2), c); + draw_line (db::Point (x1, y1), db::Point (x1, y2), c); + draw_line (db::Point (x2, y1), db::Point (x2, y2), c); +} + +void +PixelBufferPainter::draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign) +{ + const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + int x = p.x (), y = p.y (); + + if (halign < 0) { + x -= ff.width () * int (strlen (t)); + } else if (halign == 0) { + x -= ff.width () * int (strlen (t)) / 2; + } + + if (valign < 0) { + y += ff.height (); + } else if (valign == 0) { + y += ff.height () / 2; + } + + // TODO: simple implementation + for (; *t; ++t) { + + unsigned char ch = *t; + + if (x < -int (ff.width ()) || x >= int (mp_img->width ()) || y < 0 || y >= int (mp_img->height () + ff.height ())) { + continue; + } + + if (ch < ff.first_char () || (ch - ff.first_char ()) >= ff.n_chars ()) { + continue; + } + + const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height () * ff.stride (); + for (unsigned int i = 0; i < ff.height (); ++i, dc += ff.stride ()) { + + int iy = y - ff.height () + i + 1; + if (iy >= 0 || iy < int (mp_img->height ())) { + + uint32_t *d = (uint32_t *) mp_img->scan_line (y - ff.height () + i); + uint32_t m = 1; + int ix = x; + const uint32_t *ds = dc; + + for (unsigned int j = 0; j < ff.width (); ++j, ++ix) { + + if ((*ds & m) && ix >= 0 && ix < int (mp_img->width ())) { + d[ix] = c.rgb (); + } + + m <<= 1; + // word wrap + if (m == 0) { + ++ds; + m = 1; + } + + } + + } + + } + + x += ff.width (); + + } + +} + +} diff --git a/src/laybasic/laybasic/layPixelBufferPainter.h b/src/laybasic/laybasic/layPixelBufferPainter.h new file mode 100644 index 000000000..45da9d309 --- /dev/null +++ b/src/laybasic/laybasic/layPixelBufferPainter.h @@ -0,0 +1,61 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layPixelBufferPainter +#define HDR_layPixelBufferPainter + +#include "laybasicCommon.h" + +#include "layColor.h" +#include "dbPoint.h" + +namespace lay { + +class PixelBuffer; + +/** + * @brief A very simplistic painter for lay::PixelBuffer + * + * This painter supports very few primitives currently and is used to paint the + * background grid for example. + */ +class LAYBASIC_PUBLIC PixelBufferPainter +{ +public: + PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution); + + void set (const db::Point &p, lay::Color c); + void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c); + void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c); + void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c); + void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign); + +private: + lay::PixelBuffer *mp_img; + double m_resolution; + int m_width, m_height; +}; + +} + +#endif + diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 15685bf13..819d2c131 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -33,12 +33,13 @@ #include "tlExceptions.h" #include "tlClassRegistry.h" +#if defined(HAVE_QT) #include "gtf.h" +#endif #include #include #include -#include namespace lay { @@ -61,6 +62,7 @@ PluginDeclaration::~PluginDeclaration () } } +#if defined(HAVE_QT) void PluginDeclaration::toggle_editable_enabled () { @@ -68,6 +70,7 @@ PluginDeclaration::toggle_editable_enabled () set_editable_enabled (! editable_enabled ()); END_PROTECTED } +#endif std::vector PluginDeclaration::menu_symbols () @@ -93,6 +96,8 @@ PluginDeclaration::menu_symbols () return symbols; } +#if defined(HAVE_QT) + namespace { class GenericMenuAction @@ -276,14 +281,18 @@ PluginDeclaration::remove_menu_items (Dispatcher *dispatcher) m_menu_actions.clear (); } +#endif + void PluginDeclaration::set_editable_enabled (bool f) { if (f != m_editable_enabled) { m_editable_enabled = f; +#if defined(HAVE_QT) if (mp_editable_mode_action.get ()) { mp_editable_mode_action->set_checked (f); } +#endif editable_enabled_changed_event (); } } @@ -358,7 +367,7 @@ Plugin::config_set (const std::string &name, const std::string &value) return; } } catch (tl::Exception &ex) { - tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); + tl::error << tl::to_string (tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } } } @@ -481,7 +490,7 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f return true; } } catch (tl::Exception &ex) { - tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); + tl::error << tl::to_string (tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } // propagate to all children (not only the first that takes it!) diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 59b356d2f..84244ce2c 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -26,13 +26,13 @@ #include "laybasicCommon.h" -#include - #include "tlString.h" #include "tlClassRegistry.h" #include "tlDeferredExecution.h" #include "gsiObject.h" -#include "layAbstractMenu.h" +#if defined(HAVE_QT) +# include "layAbstractMenu.h" +#endif #include #include @@ -48,54 +48,16 @@ namespace lay class Plugin; class Dispatcher; -class LayoutView; -class Browser; +class LayoutViewBase; class ViewService; class Editable; class Drawing; class TechnologyComponentProvider; +#if defined(HAVE_QT) +class Browser; class EditorOptionsPage; - -/** - * @brief The base class for configuration pages - * - * This interface defines some services the configuration page - * must provide (i.e. setup, commit) - */ -class LAYBASIC_PUBLIC ConfigPage - : public QFrame -{ -public: - ConfigPage (QWidget *parent) - : QFrame (parent) - { - // .. nothing else .. - } - - /** - * @brief Load the page - * - * The implementation is supposed to fetch the configuration from the - * Plugin object provided and load the widgets accordingly. - */ - virtual void setup (Dispatcher * /*root*/) - { - // the default implementation does nothing. - } - - /** - * @brief Commit the page - * - * The implementation is supposed to read the configuration (and - * throw exceptions if the configuration something is invalid) - * and commit the changes through - */ - virtual void commit (Dispatcher * /*root*/) - { - // the default implementation does nothing. - } - -}; +class ConfigPage; +#endif /** * @brief A menu entry declaration @@ -184,11 +146,15 @@ LAYBASIC_PUBLIC MenuEntry config_menu_item (const std::string &menu_name, const * mechanism (instantiate a tl::Registrar::Class * object). */ -class LAYBASIC_PUBLIC PluginDeclaration - : public QObject, +class LAYBASIC_PUBLIC PluginDeclaration : +#if defined(HAVE_QT) + public QObject, +#endif public gsi::ObjectBase { -Q_OBJECT +#if defined(HAVE_QT) +Q_OBJECT +#endif public: /** @@ -211,6 +177,7 @@ public: // the default implementation does not add any options } +#if defined(HAVE_QT) /** * @brief Fetch the configuration page for the configuration dialog * @@ -222,7 +189,7 @@ public: { return 0; } - + /** * @brief Fetch the configuration pages for the configuration dialog * @@ -235,6 +202,7 @@ public: { return std::vector > (); } +#endif /** * @brief The global configuration @@ -334,7 +302,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutViewBase * /*view*/) const { return 0; } @@ -352,6 +320,7 @@ public: return false; } +#if defined(HAVE_QT) /** * @brief Gets the editor options pages * @@ -360,10 +329,11 @@ public: * * The new pages are returned in the "pages" vector. The layout view will take ownership of these pages. */ - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*dispatcher*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*dispatcher*/) const { // .. no pages in the default implementation .. } +#endif /** * @brief Tells if the plugin implements a "lay::ViewService" active mouse mode @@ -381,8 +351,8 @@ public: /** * @brief Specifies the primary mouse modes * - * These are built-in modes from the LayoutView. This method is intended for - * the LayoutView's standard modes only. + * These are built-in modes from the LayoutViewBase. This method is intended for + * the LayoutViewBase's standard modes only. */ virtual void implements_primary_mouse_modes (std::vector > > & /*modes*/) { @@ -416,6 +386,14 @@ public: return m_id; } + /** + * @brief Gets the available menu symbols from all plugins + * + * This does not mean all symbols will be available. + */ + static std::vector menu_symbols (); + +#if defined(HAVE_QT) /** * @brief Creates the menu resources for this plugin * @@ -425,17 +403,11 @@ public: */ void init_menu (lay::Dispatcher *dispatcher); - /** - * @brief Gets the available menu symbols from all plugins - * - * This does not mean all symbols will be available. - */ - static std::vector menu_symbols (); - /** * @brief Removes the menu resources associated with this plugin */ void remove_menu_items (lay::Dispatcher *dispatcher); +#endif /** * @brief Enables this editable part of the plugin @@ -483,14 +455,18 @@ public: */ tl::Event editable_enabled_changed_event; +#if defined(HAVE_QT) private slots: void toggle_editable_enabled (); +#endif private: int m_id; +#if defined(HAVE_QT) tl::weak_ptr mp_editable_mode_action; tl::weak_ptr mp_mouse_mode_action; tl::weak_collection m_menu_actions; +#endif bool m_editable_enabled; }; @@ -730,6 +706,7 @@ public: // .. this implementation does nothing .. } +#if defined(HAVE_QT) /** * @brief Return the lay::Browser interface if this object has one * @@ -740,6 +717,7 @@ public: { return 0; } +#endif /** * @brief Return the lay::ViewService interface if this object has one diff --git a/src/laybasic/laybasic/layPluginConfigPage.cc b/src/laybasic/laybasic/layPluginConfigPage.cc new file mode 100644 index 000000000..2cc95aa98 --- /dev/null +++ b/src/laybasic/laybasic/layPluginConfigPage.cc @@ -0,0 +1,36 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#include "laybasicCommon.h" + +#include "layPluginConfigPage.h" + +namespace lay +{ + +// .. nothing yet .. + +} + +#endif diff --git a/src/laybasic/laybasic/layPluginConfigPage.h b/src/laybasic/laybasic/layPluginConfigPage.h new file mode 100644 index 000000000..73c40b82a --- /dev/null +++ b/src/laybasic/laybasic/layPluginConfigPage.h @@ -0,0 +1,83 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#ifndef HDR_layPluginConfigPage +#define HDR_layPluginConfigPage + +#include "laybasicCommon.h" + +#include + +namespace lay +{ + +class Dispatcher; + +/** + * @brief The base class for configuration pages + * + * This interface defines some services the configuration page + * must provide (i.e. setup, commit) + */ +class LAYBASIC_PUBLIC ConfigPage + : public QFrame +{ +public: + ConfigPage (QWidget *parent) + : QFrame (parent) + { + // .. nothing else .. + } + + /** + * @brief Load the page + * + * The implementation is supposed to fetch the configuration from the + * Plugin object provided and load the widgets accordingly. + */ + virtual void setup (Dispatcher * /*root*/) + { + // the default implementation does nothing. + } + + /** + * @brief Commit the page + * + * The implementation is supposed to read the configuration (and + * throw exceptions if the configuration something is invalid) + * and commit the changes through + */ + virtual void commit (Dispatcher * /*root*/) + { + // the default implementation does nothing. + } + +}; + +} + +#endif + + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layProperties.cc b/src/laybasic/laybasic/layProperties.cc index 8f9696e13..fa3ca2360 100644 --- a/src/laybasic/laybasic/layProperties.cc +++ b/src/laybasic/laybasic/layProperties.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layProperties.h" @@ -41,3 +42,4 @@ PropertiesPage::~PropertiesPage () } +#endif diff --git a/src/laybasic/laybasic/layProperties.h b/src/laybasic/laybasic/layProperties.h index 36124cc7d..07c6ffe98 100644 --- a/src/laybasic/laybasic/layProperties.h +++ b/src/laybasic/laybasic/layProperties.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layProperties #define HDR_layProperties @@ -237,3 +238,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layPropertiesDialog.cc b/src/laybasic/laybasic/layPropertiesDialog.cc index b42d3c367..09d8a697b 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.cc +++ b/src/laybasic/laybasic/layPropertiesDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layPropertiesDialog.h" @@ -349,3 +350,4 @@ PropertiesDialog::reject () } +#endif diff --git a/src/laybasic/laybasic/layPropertiesDialog.h b/src/laybasic/laybasic/layPropertiesDialog.h index 4aad302c6..85faaf991 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.h +++ b/src/laybasic/laybasic/layPropertiesDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layPropertiesDialog #define HDR_layPropertiesDialog @@ -103,3 +104,4 @@ protected: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layRedrawThread.cc b/src/laybasic/laybasic/layRedrawThread.cc index b0902a379..478437441 100644 --- a/src/laybasic/laybasic/layRedrawThread.cc +++ b/src/laybasic/laybasic/layRedrawThread.cc @@ -21,9 +21,6 @@ */ -#include -#include - #include "layRedrawThread.h" #include "layRedrawThreadWorker.h" #include "tlLog.h" @@ -39,7 +36,7 @@ namespace lay // ------------------------------------------------------------- // RedrawThread implementation -RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutView *view) +RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, LayoutViewBase *view) : tl::Object () { m_initial_update = false; @@ -63,7 +60,7 @@ RedrawThread::~RedrawThread () void RedrawThread::layout_changed () { if (is_running () && tl::verbosity () >= 30) { - tl::info << tl::to_string (QObject::tr ("Layout changed: redraw thread stopped")); + tl::info << tl::to_string (tr ("Layout changed: redraw thread stopped")); } // if something changed on the layouts we observe, stop the redraw thread @@ -228,9 +225,9 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v { if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Preparing to draw")); + tl::info << tl::to_string (tr ("Preparing to draw")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Preparing to draw"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Preparing to draw"))); // detach from all layout objects tl::Object::detach_from_all_events (); diff --git a/src/laybasic/laybasic/layRedrawThread.h b/src/laybasic/laybasic/layRedrawThread.h index 4658b8c85..dadba6755 100644 --- a/src/laybasic/laybasic/layRedrawThread.h +++ b/src/laybasic/laybasic/layRedrawThread.h @@ -28,19 +28,16 @@ #include #include -#include -#include -#include - #include "dbBox.h" #include "dbTrans.h" #include "dbLayout.h" #include "layRenderer.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layRedrawThreadCanvas.h" #include "layRedrawLayerInfo.h" #include "layCanvasPlane.h" #include "tlTimer.h" +#include "tlThreads.h" #include "tlThreadedWorkers.h" namespace lay { @@ -55,7 +52,7 @@ class RedrawThread public tl::JobBase { public: - RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutView *view); + RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutViewBase *view); virtual ~RedrawThread (); void commit (const std::vector &layers, const lay::Viewport &vp, double resolution); @@ -116,12 +113,12 @@ private: db::DFTrans m_stored_fp; lay::RedrawThreadCanvas *mp_canvas; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_start_recursion_sentinel; tl::Clock m_clock; - QMutex m_initial_wait_lock; - QWaitCondition m_initial_wait_cond; + tl::Mutex m_initial_wait_lock; + tl::WaitCondition m_initial_wait_cond; std::unique_ptr m_main_timer; }; diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.cc b/src/laybasic/laybasic/layRedrawThreadCanvas.cc index 94125b20a..9b72833b7 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.cc +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.cc @@ -27,8 +27,6 @@ #include "layDrawing.h" #include "layBitmap.h" -#include - namespace lay { @@ -393,8 +391,8 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in unlock (); } -void -BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, QColor background, QColor foreground, QColor active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height) +void +BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height) { if (width > m_width) { width = m_width; @@ -413,5 +411,26 @@ BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, c } } +void +BitmapRedrawThreadCanvas::to_image_mono (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height) +{ + if (width > m_width) { + width = m_width; + } + if (height > m_height) { + height = m_height; + } + + unsigned int all_one = 0xffffffff; + + // convert the plane data to image data + bitmaps_to_image (view_ops, mp_plane_buffers, dp, ls, &img, width, height, true, &mutex ()); + + // convert the planes of the "drawing" objects too: + std::vector >::const_iterator bt = mp_drawing_plane_buffers.begin (); + for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end () && bt != mp_drawing_plane_buffers.end (); ++d, ++bt) { + bitmaps_to_image (d->get_view_ops (*this, background ? all_one : 0, foreground ? all_one : 0, active ? all_one : 0), *bt, dp, ls, &img, width, height, true, &mutex ()); + } } +} diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index b765b3fcd..77614c628 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -29,14 +29,11 @@ #include "dbTrans.h" #include "layViewOp.h" #include "layBitmapRenderer.h" +#include "layPixelBuffer.h" +#include "tlThreads.h" #include -#include -#include - -class QImage; - namespace lay { class CanvasPlane; @@ -152,7 +149,7 @@ public: /** * @brief Access to the mutex object */ - QMutex &mutex () + tl::Mutex &mutex () { return m_mutex; } @@ -187,7 +184,7 @@ public: virtual lay::Renderer *create_renderer () = 0; private: - QMutex m_mutex; + tl::Mutex m_mutex; double m_resolution; unsigned int m_width, m_height; }; @@ -320,9 +317,14 @@ public: } /** - * @brief Transfer the content to an QImage + * @brief Transfer the content to a PixelBuffer */ - void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, QColor background, QColor foreground, QColor active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height); + void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height); + + /** + * @brief Transfer the content to a BitmapBuffer (monochrome) + */ + void to_image_mono (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height); /** * @brief Gets the current bitmap data as a BitmapCanvasData object diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index b63e15b2a..16c97bc60 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -23,6 +23,7 @@ #include "layRedrawThreadWorker.h" #include "layRedrawThread.h" +#include "layBitmap.h" namespace lay { @@ -69,7 +70,7 @@ RedrawThreadWorker::RedrawThreadWorker (RedrawThread *redraw_thread) m_default_text_size = 0.0; m_drop_small_cells = false; m_drop_small_cells_value = 0; - m_drop_small_cells_cond = lay::LayoutView::DSC_Min; + m_drop_small_cells_cond = lay::LayoutViewBase::DSC_Min; m_draw_array_border_instances = false; m_abstract_mode_width = 0; m_child_context_enabled = false; @@ -194,9 +195,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) m_layer = li.layer_index; if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing layer: ")) << mp_layout->get_properties (m_layer).name; + tl::info << tl::to_string (tr ("Drawing layer: ")) << mp_layout->get_properties (m_layer).name; } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing layer"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing layer"))); // configure renderer .. mp_renderer->set_xfill (m_xfill); @@ -220,9 +221,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // if no specific layer is assigned, draw cell boxes with the style given if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing custom frames")); + tl::info << tl::to_string (tr ("Drawing custom frames")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing frames"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing frames"))); for (std::set< std::pair >::const_iterator b = m_box_variants.begin (); b != m_box_variants.end (); ++b) { if (b->second == li.cellview_index) { @@ -245,9 +246,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // draw the bounding boxes if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing frames and guiding shapes")); + tl::info << tl::to_string (tr ("Drawing frames and guiding shapes")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing frames and guiding shapes"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing frames and guiding shapes"))); // No xfill for cell boxes mp_renderer->set_xfill (false); @@ -416,9 +417,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // draw the decorations if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing decorations")); + tl::info << tl::to_string (tr ("Drawing decorations")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing decorations"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing decorations"))); m_buffers.clear (); mp_canvas->initialize_plane (m_planes[0], m_nlayers * planes_per_layer + special_planes_before); @@ -496,7 +497,7 @@ RedrawThreadWorker::finish () } void -RedrawThreadWorker::setup (LayoutView *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans) +RedrawThreadWorker::setup (LayoutViewBase *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans) { m_redraw_region = redraw_region; m_vp_trans = vp_trans; @@ -2096,9 +2097,9 @@ RedrawThreadWorker::drop_cell (const db::Cell &cell, const db::CplxTrans &trans) db::DBox bbox = trans * cell.bbox (); double value = 0; - if (m_drop_small_cells_cond == lay::LayoutView::DSC_Min) { + if (m_drop_small_cells_cond == lay::LayoutViewBase::DSC_Min) { value = std::min (bbox.width (), bbox.height ()); - } else if (m_drop_small_cells_cond == lay::LayoutView::DSC_Max) { + } else if (m_drop_small_cells_cond == lay::LayoutViewBase::DSC_Max) { value = std::max (bbox.width (), bbox.height ()); } else { value = bbox.width () + bbox.height (); @@ -2172,7 +2173,7 @@ RedrawThreadWorker::iterate_variants (const std::vector &redraw_region m_from_level = fl; if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Cell variant cache hits/misses: ")) << m_cache_hits << "/" << m_cache_misses; + tl::info << tl::to_string (tr ("Cell variant cache hits/misses: ")) << m_cache_hits << "/" << m_cache_misses; } } else { diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.h b/src/laybasic/laybasic/layRedrawThreadWorker.h index 545772118..256ad2ac0 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.h +++ b/src/laybasic/laybasic/layRedrawThreadWorker.h @@ -25,7 +25,7 @@ #define HDR_layRedrawThreadWorker #include "dbLayout.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlThreadedWorkers.h" #include "tlTimer.h" @@ -168,7 +168,7 @@ public: RedrawThreadWorker (RedrawThread *redraw_thread); virtual ~RedrawThreadWorker (); - void setup (LayoutView *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans); + void setup (LayoutViewBase *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans); void finish (); protected: @@ -221,7 +221,7 @@ private: double m_default_text_size; bool m_drop_small_cells; unsigned int m_drop_small_cells_value; - lay::LayoutView::drop_small_cells_cond_type m_drop_small_cells_cond; + lay::LayoutViewBase::drop_small_cells_cond_type m_drop_small_cells_cond; bool m_draw_array_border_instances; double m_abstract_mode_width; bool m_child_context_enabled; @@ -231,7 +231,7 @@ private: std::set , lay::CellVariantCacheCompare> *mp_cell_var_cache; unsigned int m_cache_hits, m_cache_misses; std::set > m_box_variants; - std::vector > m_hidden_cells; + std::vector > m_hidden_cells; std::vector m_cellviews; const db::Layout *mp_layout; int m_cv_index; diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 1c85416c1..1db1fd427 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -24,12 +24,14 @@ #include "laySelector.h" #include "layRubberBox.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlLog.h" #include "tlException.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace lay { @@ -37,8 +39,10 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutView *view) - : QObject (), +SelectionService::SelectionService (lay::LayoutViewBase *view) : +#if defined(HAVE_QT) + QObject (), +#endif lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), @@ -48,9 +52,11 @@ SelectionService::SelectionService (lay::LayoutView *view) m_hover_wait (false), m_mouse_in_window (false) { +#if defined(HAVE_QT) m_timer.setInterval (100 /*hover time*/); m_timer.setSingleShot (true); connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ())); +#endif } SelectionService::~SelectionService () @@ -62,7 +68,7 @@ SelectionService::~SelectionService () } void -SelectionService::set_colors (QColor /*background*/, QColor color) +SelectionService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { @@ -81,7 +87,9 @@ void SelectionService::hover_reset () { if (m_hover_wait) { +#if defined(HAVE_QT) m_timer.stop (); +#endif m_hover_wait = false; } if (m_hover) { @@ -90,6 +98,7 @@ SelectionService::hover_reset () } } +#if defined(HAVE_QT) void SelectionService::timeout () { @@ -98,6 +107,7 @@ SelectionService::timeout () mp_view->clear_transient_selection (); mp_view->transient_select (m_hover_point); } +#endif void SelectionService::reset_box () @@ -155,7 +165,9 @@ SelectionService::mouse_move_event (const db::DPoint &p, unsigned int buttons, b mp_box->set_points (m_p1, m_p2); } else if (m_mouse_in_window && mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } @@ -173,10 +185,12 @@ SelectionService::mouse_double_click_event (const db::DPoint & /*p*/, unsigned i reset_box (); } +#if defined(HAVE_QT) if (prio && (buttons & lay::LeftButton) != 0) { mp_view->show_properties (QApplication::activeWindow ()); return true; } +#endif return false; } @@ -230,13 +244,17 @@ SelectionService::mouse_click_event (const db::DPoint &p, unsigned int buttons, // add a transient selection trigger to capture the "next" selection. if (mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -273,7 +291,9 @@ SelectionService::mouse_release_event (const db::DPoint & /*p*/, unsigned int /* mp_view->select (db::DBox (m_p1, m_p2), mode); } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -301,4 +321,3 @@ SelectionService::begin (const db::DPoint &pos) } } - diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index 85ba64d76..ad81060b3 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -30,26 +30,32 @@ #include "layViewObject.h" #include "layEditable.h" -#include -#include +#if defined (HAVE_QT) +# include +# include +#endif namespace lay { class RubberBox; -class LayoutView; +class LayoutViewBase; class LayoutCanvas; -class LAYBASIC_PUBLIC SelectionService - : public QObject, +class LAYBASIC_PUBLIC SelectionService : +#if defined (HAVE_QT) + public QObject, +#endif public lay::ViewService { +#if defined (HAVE_QT) Q_OBJECT +#endif public: - SelectionService (lay::LayoutView *view); + SelectionService (lay::LayoutViewBase *view); ~SelectionService (); - void set_colors (QColor background, QColor color); + void set_colors (lay::Color background, lay::Color color); void begin (const db::DPoint &pos); bool dragging () const { return mp_box != 0; } @@ -72,23 +78,27 @@ public: */ void hover_reset (); +#if defined (HAVE_QT) public slots: void timeout (); +#endif private: virtual void deactivated (); db::DPoint m_p1, m_p2; db::DPoint m_current_position; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; unsigned int m_buttons; - QTimer m_timer; bool m_hover; bool m_hover_wait; db::DPoint m_hover_point; bool m_mouse_in_window; +#if defined (HAVE_QT) + QTimer m_timer; +#endif void reset_box (); }; diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index f7a92dca6..c123da738 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -23,7 +23,7 @@ #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbEdge.h" @@ -129,12 +129,12 @@ int draw_round (double x) } } -QPoint draw_round (db::DPoint p, int h) +db::Point draw_round (db::DPoint p, int h) { - return QPoint (draw_round (p.x ()), h - 1 - draw_round (p.y ())); + return db::Point (draw_round (p.x ()), h - 1 - draw_round (p.y ())); } -std::pair +std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h) { std::pair dp = draw_round_dbl (p1, p2, h); @@ -282,7 +282,7 @@ public: * This will run the finder on the given view. * "search_range" is the search range in micron units. */ - void find (lay::LayoutView *view, double search_range) + void find (lay::LayoutViewBase *view, double search_range) { if (! view) { return; @@ -586,7 +586,7 @@ private: } void - do_find (lay::LayoutView *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) + do_find (lay::LayoutViewBase *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) { db::Box touch_box = t.inverted () * m_region; @@ -727,7 +727,7 @@ private: }; static PointSnapToObjectResult -do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) +do_obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) { db::DPoint dp (pt); @@ -792,7 +792,7 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri } static TwoPointSnapToObjectResult -do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) +do_obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) { db::DPoint dp1 (pt1); db::DPoint dp2 (pt2); @@ -915,13 +915,13 @@ make_cutlines (lay::angle_constraint_type snap_mode, const db::DPoint &p1, std:: } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) { return do_obj_snap (view, pt, grid, snap_range, std::vector ()); } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) { std::vector cutlines; make_cutlines (snap_mode, p1, cutlines); @@ -929,19 +929,19 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); @@ -950,7 +950,7 @@ obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index 506f19e60..eaa26ae4c 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -27,7 +27,9 @@ #include "laybasicCommon.h" +#if defined(HAVE_QT) #include +#endif #include #include @@ -39,7 +41,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; /** * @brief An angle constraint type @@ -152,7 +154,7 @@ namespace lay * @param grid Either (0,0) to disable grid snapping or a (gx,gy) value for the (potentially anisotropic grid) * @param snap_range The search range for objects */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); /** * @brief combined grid-, projection- and object snapping provided to implementing "magnetic features" @@ -160,7 +162,7 @@ namespace lay * This is a convenience method that creates the projection axes from a reference point and an angle mode. * "pr" is the reference point, "pt" is the point to snap. */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); /** * @brief A structure describing the snap result for a two-sided object snap (distance measurement) @@ -206,7 +208,7 @@ namespace lay * This method basically implements "auto measure". The first value of the returned pair * is true if such an edge could be found. Otherwise it's false. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than obj_snap, but delivers two points on two opposite sides of the initial points @@ -216,14 +218,14 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint * * Measurements will be confined to the direction specified. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint @@ -232,7 +234,7 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Reduce a given vector according to the angle constraint @@ -247,12 +249,12 @@ namespace lay /** * @brief rounding (and height-transformation) of a double point */ - LAYBASIC_PUBLIC QPoint draw_round (db::DPoint p, int h); + LAYBASIC_PUBLIC db::Point draw_round (db::DPoint p, int h); /** * @brief rounding (and height-transformation) of a two-point vector */ - LAYBASIC_PUBLIC std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h); + LAYBASIC_PUBLIC std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h); /** * @brief rounding (and height-transformation) of a two-point vector diff --git a/src/laybasic/laybasic/layStipplePalette.cc b/src/laybasic/laybasic/layStipplePalette.cc index 72e0898e2..b3f8e1469 100644 --- a/src/laybasic/laybasic/layStipplePalette.cc +++ b/src/laybasic/laybasic/layStipplePalette.cc @@ -205,16 +205,16 @@ StipplePalette::from_string (const std::string &s) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (stipples () == 0 || standard_stipples () == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid palette - no stipples and/or standard stipples"))); + throw tl::Exception (tl::to_string (tr ("invalid palette - no stipples and/or standard stipples"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Stipple palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Stipple palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layStream.cc b/src/laybasic/laybasic/layStream.cc index 64a59d6c6..e467be83e 100644 --- a/src/laybasic/laybasic/layStream.cc +++ b/src/laybasic/laybasic/layStream.cc @@ -20,11 +20,11 @@ */ +#if defined(HAVE_QT) #include "layStream.h" #include "layPlugin.h" #include "laybasicConfig.h" -#include "layTechnology.h" #include "dbStream.h" #include "dbLoadLayoutOptions.h" #include "dbSaveLayoutOptions.h" @@ -84,3 +84,4 @@ const StreamWriterPluginDeclaration *StreamWriterPluginDeclaration::plugin_for_f } +#endif diff --git a/src/laybasic/laybasic/layStream.h b/src/laybasic/laybasic/layStream.h index 6d3facfd3..963775132 100644 --- a/src/laybasic/laybasic/layStream.h +++ b/src/laybasic/laybasic/layStream.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layStream_h #define HDR_layStream_h @@ -31,6 +32,8 @@ #include "tlXMLWriter.h" #include "dbLoadLayoutOptions.h" +#include + namespace db { class StreamFormatDeclaration; @@ -273,3 +276,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 7a3ecb3a0..bd4694ab5 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -20,16 +20,20 @@ */ - -#include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +# include +#endif #include "layViewObject.h" #include "layCanvasPlane.h" #include "layBitmap.h" +#if defined(HAVE_QT) +# include "layDragDropData.h" +#endif #include "tlException.h" #include "tlAlgorithm.h" #include "tlExceptions.h" @@ -43,86 +47,10 @@ namespace lay // event rather than a single click event: const int click_tolerance = 5; -// --------------------------------------------------------------- -// Implementation of DragDropDataBase - -const char *drag_drop_mime_type () -{ - return "application/klayout-ddd"; -} - -QMimeData * -DragDropDataBase::to_mime_data () const -{ - QMimeData *mimeData = new QMimeData(); - mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ()); - return mimeData; -} - -// --------------------------------------------------------------- -// Implementation of CellDragDropData - -QByteArray -CellDragDropData::serialized () const -{ - QByteArray data; - QDataStream stream (&data, QIODevice::WriteOnly); - - stream << QString::fromUtf8 ("CellDragDropData"); - stream << (quintptr) mp_layout; - stream << (quintptr) mp_library; - stream << m_cell_index; - stream << m_is_pcell; - stream << int (m_pcell_params.size ()); - for (std::vector::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) { - stream << tl::to_qstring (i->to_parsable_string ()); - } - - return data; -} - -bool -CellDragDropData::deserialize (const QByteArray &ba) -{ - QDataStream stream (const_cast (&ba), QIODevice::ReadOnly); - - QString tag; - stream >> tag; - - if (tag == QString::fromUtf8 ("CellDragDropData")) { - - quintptr p = 0; - stream >> p; - mp_layout = reinterpret_cast (p); - stream >> p; - mp_library = reinterpret_cast (p); - stream >> m_cell_index; - stream >> m_is_pcell; - - m_pcell_params.clear (); - int n = 0; - stream >> n; - while (n-- > 0) { - QString s; - stream >> s; - std::string stl_s = tl::to_string (s); - tl::Extractor ex (stl_s.c_str ()); - m_pcell_params.push_back (tl::Variant ()); - ex.read (m_pcell_params.back ()); - } - - return true; - - } else { - - return false; - - } -} - // --------------------------------------------------------------- // A helper function to convert a Qt modifier/buttons to klayout buttons +#if defined(HAVE_QT) static unsigned int qt_to_buttons (Qt::MouseButtons b, Qt::KeyboardModifiers m) { @@ -139,6 +67,7 @@ qt_to_buttons (Qt::MouseButtons b, Qt::KeyboardModifiers m) ((m & Qt::ControlModifier) != 0 ? ControlButton : 0) | ((m & Qt::AltModifier) != 0 ? AltButton : 0); } +#endif // --------------------------------------------------------------- // BackgroundViewObject implementation @@ -278,8 +207,9 @@ ViewService::set_cursor (lay::Cursor::cursor_shape cursor) } // --------------------------------------------------------------- -// ViewObject implementation +// ViewObjectWidget implementation +#if defined(HAVE_QT) ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) : QWidget (parent), m_view_objects_dismissed (false), @@ -291,7 +221,10 @@ ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) m_in_mouse_move (false), m_mouse_inside (false), m_cursor (lay::Cursor::none), - m_default_cursor (lay::Cursor::none) + m_default_cursor (lay::Cursor::none), + m_widget_width (0), + m_widget_height (0), + m_image_updated (false) { setMouseTracking (true); setObjectName (QString::fromUtf8 (name)); @@ -299,6 +232,25 @@ ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) m_objects.changed ().add (this, &ViewObjectWidget::objects_changed); } +#else +ViewObjectWidget::ViewObjectWidget () + : m_view_objects_dismissed (false), + m_needs_update_static (false), + m_needs_update_bg (false), + mp_active_service (0), + m_mouse_pressed_state (false), + m_mouse_buttons (0), + m_in_mouse_move (false), + m_mouse_inside (false), + m_cursor (lay::Cursor::none), + m_default_cursor (lay::Cursor::none), + m_widget_width (500), + m_widget_height (500), + m_image_updated (false) +{ + m_objects.changed ().add (this, &ViewObjectWidget::objects_changed); +} +#endif ViewObjectWidget::~ViewObjectWidget () { @@ -371,6 +323,7 @@ ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) { if (cursor != m_default_cursor) { m_default_cursor = cursor; +#if defined(HAVE_QT) if (m_cursor == lay::Cursor::none) { if (m_default_cursor == lay::Cursor::none) { unsetCursor (); @@ -378,6 +331,7 @@ ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) setCursor (lay::Cursor::qcursor (m_default_cursor)); } } +#endif } } @@ -385,7 +339,7 @@ void ViewObjectWidget::ensure_entered () { if (! m_mouse_inside) { - enterEvent (0); + send_enter_event (); } } @@ -398,6 +352,7 @@ ViewObjectWidget::begin_mouse_event (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::end_mouse_event () { +#if defined(HAVE_QT) if (m_cursor == lay::Cursor::none) { if (m_default_cursor == lay::Cursor::none) { unsetCursor (); @@ -407,8 +362,350 @@ ViewObjectWidget::end_mouse_event () } else if (m_cursor != lay::Cursor::keep) { setCursor (lay::Cursor::qcursor (m_cursor)); } +#endif } +void +ViewObjectWidget::send_key_press_event (unsigned int key, unsigned int buttons) +{ + bool done = false; + if (mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->key_event (key, buttons)); + } + + if (! done) { + key_event (key, buttons); + } +} + +void +ViewObjectWidget::do_mouse_move () +{ + m_in_mouse_move = true; + + if (m_mouse_pressed_state && + (abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) { + + begin_mouse_event (lay::Cursor::none); + + m_mouse_pressed_state = false; + + bool done = false; + + db::DPoint p = pixel_to_um (m_mouse_pressed); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false)); + svc = next; + } + + if (! done) { + mouse_press_event (p, m_mouse_buttons); + } + + end_mouse_event (); + + } + + if (! m_mouse_pressed_state) { + + begin_mouse_event (lay::Cursor::none); + + bool done = false; + + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false)); + svc = next; + } + + if (! done) { + mouse_move_event (p, m_mouse_buttons); + } + + end_mouse_event (); + + } + + m_in_mouse_move = false; +} + +void +ViewObjectWidget::send_mouse_move_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + m_mouse_pos = pt; + m_mouse_buttons = buttons; + do_mouse_move (); +} + +void +ViewObjectWidget::send_leave_event () +{ + try { + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->leave_event (true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->leave_event (true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->leave_event (false)); + svc = next; + } + + if (! done) { + leave_event (); + } + + end_mouse_event (); + + m_mouse_inside = false; + + } catch (...) { + m_mouse_inside = false; + throw; + } +} + +void +ViewObjectWidget::send_enter_event () +{ + m_mouse_inside = true; + + begin_mouse_event (); + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->enter_event (true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->enter_event (true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->enter_event (false)); + svc = next; + } + + if (! done) { + enter_event (); + } + + end_mouse_event (); +} + +void +ViewObjectWidget::send_mouse_press_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); +#if defined(HAVE_QT) + setFocus (); +#endif + + m_mouse_pos = pt; + m_mouse_pressed = m_mouse_pos; + + m_mouse_buttons = buttons; + + m_mouse_pressed_state = true; +} + +void +ViewObjectWidget::send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + begin_mouse_event (lay::Cursor::none); + +#if defined(HAVE_QT) + setFocus (); +#endif + + bool done = false; + + m_mouse_pos = pt; + m_mouse_pressed = m_mouse_pos; + m_mouse_pressed_state = false; + + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false)); + svc = next; + } + + if (! done) { + mouse_double_click_event (p, buttons); + } + + end_mouse_event (); +} + +void +ViewObjectWidget::send_mouse_release_event (const db::DPoint &pt, unsigned int /*buttons*/) +{ + try { + + ensure_entered (); + begin_mouse_event (); + + bool done = false; + + m_mouse_pos = pt; + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + if (m_mouse_pressed_state) { + done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true); + } else { + done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true); + } + g = gg; + } + + if (! done && mp_active_service && mp_active_service->enabled ()) { + if (m_mouse_pressed_state) { + done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true); + } else { + done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true); + } + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + if ((*svc)->enabled ()) { + if (m_mouse_pressed_state) { + done = (*svc)->mouse_click_event (p, m_mouse_buttons, false); + } else { + done = (*svc)->mouse_release_event (p, m_mouse_buttons, false); + } + } + svc = next; + } + + if (! done) { + if (m_mouse_pressed_state) { + mouse_click_event (p, m_mouse_buttons); + } else { + mouse_release_event (p, m_mouse_buttons); + } + } + + end_mouse_event (); + + m_mouse_pressed_state = false; + + } catch (...) { + m_mouse_pressed_state = false; + throw; + } +} + +void +ViewObjectWidget::send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + begin_mouse_event (); + + db::DPoint p = pixel_to_um (pt); + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false)); + svc = next; + } + + if (! done) { + wheel_event (delta, horizontal, p, buttons); + } + + end_mouse_event (); +} + + +#if defined(HAVE_QT) + bool ViewObjectWidget::focusNextPrevChild (bool /*next*/) { @@ -419,18 +716,8 @@ void ViewObjectWidget::keyPressEvent (QKeyEvent *e) { BEGIN_PROTECTED - unsigned int buttons = qt_to_buttons (Qt::MouseButtons (), e->modifiers ()); - - bool done = false; - if (mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->key_event ((unsigned int) e->key(), buttons)); - } - - if (! done) { - key_event ((unsigned int) e->key (), buttons); - } - + send_key_press_event ((unsigned int) e->key (), buttons); END_PROTECTED } @@ -460,7 +747,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drag_enter_event (p, dd); service_iterator svc = begin_services (); @@ -505,7 +792,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drag_move_event (p, dd); service_iterator svc = begin_services (); @@ -529,7 +816,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drop_event (p, dd); service_iterator svc = begin_services (); @@ -549,137 +836,33 @@ void ViewObjectWidget::mouseMoveEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - m_mouse_pos = e->pos (); - m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - do_mouse_move (); + + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif + + send_mouse_move_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); + END_PROTECTED } void -ViewObjectWidget::do_mouse_move () -{ - m_in_mouse_move = true; - - if (m_mouse_pressed_state && - (abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) { - - begin_mouse_event (lay::Cursor::none); - - m_mouse_pressed_state = false; - - bool done = false; - - db::DPoint p = pixel_to_um (m_mouse_pressed); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false)); - svc = next; - } - - if (! done) { - mouse_press_event (p, m_mouse_buttons); - } - - end_mouse_event (); - - } - - if (! m_mouse_pressed_state) { - - begin_mouse_event (lay::Cursor::none); - - bool done = false; - - db::DPoint p = pixel_to_um (m_mouse_pos); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false)); - svc = next; - } - - if (! done) { - mouse_move_event (p, m_mouse_buttons); - } - - end_mouse_event (); - - } - - m_in_mouse_move = false; -} - -void ViewObjectWidget::mouseDoubleClickEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (lay::Cursor::none); - setFocus (); + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - bool done = false; + send_mouse_double_clicked_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); - m_mouse_pos = e->pos (); - m_mouse_pressed = e->pos (); - m_mouse_pressed_state = false; - - unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - db::DPoint p = pixel_to_um (e->pos ()); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false)); - svc = next; - } - - if (! done) { - mouse_double_click_event (p, buttons); - } - - end_mouse_event (); END_PROTECTED } @@ -691,209 +874,117 @@ ViewObjectWidget::enterEvent (QEvent * /*event*/) #endif { BEGIN_PROTECTED - m_mouse_inside = true; - - begin_mouse_event (); - - bool done = false; - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->enter_event (true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->enter_event (true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->enter_event (false)); - svc = next; - } - - if (! done) { - enter_event (); - } - - end_mouse_event (); + send_enter_event (); END_PROTECTED } -void +void ViewObjectWidget::leaveEvent (QEvent * /*event*/) { -BEGIN_PROTECTED - begin_mouse_event (); - - bool done = false; - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->leave_event (true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->leave_event (true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->leave_event (false)); - svc = next; - } - - if (! done) { - leave_event (); - } - - end_mouse_event (); +BEGIN_PROTECTED + send_leave_event (); END_PROTECTED - - m_mouse_inside = false; } void ViewObjectWidget::wheelEvent (QWheelEvent *e) { -BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (); +BEGIN_PROTECTED + db::DPoint p; #if QT_VERSION < 0x60000 int delta = e->delta (); - db::DPoint p = pixel_to_um (e->pos ()); + p = db::DPoint (e->pos ().x (), e->pos ().y ()); bool horizontal = (e->orientation () == Qt::Horizontal); #else int delta = e->angleDelta ().y (); - db::DPoint p = pixel_to_um (e->position ()); + p = db::DPoint (e->position ().x (), e->position ().y ()); bool horizontal = false; #endif e->ignore (); - bool done = false; + send_wheel_event (delta, horizontal, p, qt_to_buttons (e->buttons (), e->modifiers ())); - unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false)); - svc = next; - } - - if (! done) { - wheel_event (delta, horizontal, p, buttons); - } - - end_mouse_event (); END_PROTECTED } void ViewObjectWidget::mousePressEvent (QMouseEvent *e) { - ensure_entered (); - setFocus (); +BEGIN_PROTECTED - m_mouse_pos = e->pos (); - m_mouse_pressed = e->pos (); + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - m_mouse_pressed_state = true; + send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); + +END_PROTECTED } void ViewObjectWidget::mouseReleaseEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (); - bool done = false; + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - m_mouse_pos = e->pos (); - db::DPoint p = pixel_to_um (e->pos ()); + send_mouse_release_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - if (m_mouse_pressed_state) { - done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true); - } else { - done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true); - } - g = gg; - } - - if (! done && mp_active_service && mp_active_service->enabled ()) { - if (m_mouse_pressed_state) { - done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true); - } else { - done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true); - } - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - if ((*svc)->enabled ()) { - if (m_mouse_pressed_state) { - done = (*svc)->mouse_click_event (p, m_mouse_buttons, false); - } else { - done = (*svc)->mouse_release_event (p, m_mouse_buttons, false); - } - } - svc = next; - } - - if (! done) { - if (m_mouse_pressed_state) { - mouse_click_event (p, m_mouse_buttons); - } else { - mouse_release_event (p, m_mouse_buttons); - } - } - - end_mouse_event (); END_PROTECTED +} - m_mouse_pressed_state = false; +#endif + +void +ViewObjectWidget::resize (unsigned int w, unsigned int h) +{ + m_widget_width = w; + m_widget_height = h; +#if defined(HAVE_QT) + QWidget::resize (w, h); +#endif +} + +int +ViewObjectWidget::widget_height () const +{ +#if defined(HAVE_QT) + return height (); +#else + return m_widget_height; +#endif +} + +int +ViewObjectWidget::widget_width () const +{ +#if defined(HAVE_QT) + return width (); +#else + return m_widget_width; +#endif } db::DPoint -ViewObjectWidget::pixel_to_um (const QPoint &pt) const +ViewObjectWidget::pixel_to_um (const db::Point &pt) const { - return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ()); + return m_trans.inverted () * db::DPoint (pt.x (), widget_height () - 1 - pt.y ()); } db::DPoint -ViewObjectWidget::pixel_to_um (const QPointF &pt) const +ViewObjectWidget::pixel_to_um (const db::DPoint &pt) const { - return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ()); + return m_trans.inverted () * db::DPoint (pt.x (), widget_height () - 1 - pt.y ()); } void @@ -1018,6 +1109,23 @@ ViewObjectWidget::thaw (ViewObject *obj) } } +#if !defined(HAVE_QT) +void +ViewObjectWidget::update () +{ + // NOTE: this does not need to be thread-safe as we make sure (as in Qt) that update() is always called from the main thread. + m_image_updated = true; +} + +bool +ViewObjectWidget::image_updated () +{ + bool f = m_image_updated; + m_image_updated = false; + return f; +} +#endif + void ViewObjectWidget::touch () { @@ -1057,7 +1165,7 @@ db::DBox ViewObjectWidget::mouse_event_viewport () const { db::DPoint p1 = m_trans.inverted () * db::DPoint (0, 0); - db::DPoint p2 = m_trans.inverted () * db::DPoint (width (), height ()); + db::DPoint p2 = m_trans.inverted () * db::DPoint (widget_width (), widget_height ()); return db::DBox (p1, p2); } @@ -1180,5 +1288,18 @@ BitmapViewObjectCanvas::set_size (double resolution) m_resolution = resolution; } +lay::PixelBuffer * +BitmapViewObjectCanvas::bg_image () +{ + return 0; +} + +lay::BitmapBuffer * +BitmapViewObjectCanvas::bg_bitmap () +{ + return 0; +} + + } diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index 3e10c0b0d..1df6d04b0 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -32,10 +32,12 @@ #include #include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif #include "tlObjectCollection.h" #include "tlVariant.h" @@ -45,6 +47,7 @@ #include "layCursor.h" #include "layBitmapRenderer.h" +#if defined(HAVE_QT) class QMouseEvent; class QImage; class QDragEnterEvent; @@ -52,6 +55,7 @@ class QDragMoveEvent; class QDragLeaveEvent; class QDropEvent; class QMimeData; +#endif namespace db { @@ -66,135 +70,12 @@ class ViewObjectWidget; class ViewObjectCanvas; class CanvasPlane; class Bitmap; +class PixelBuffer; +class BitmapBuffer; -LAYBASIC_PUBLIC const char *drag_drop_mime_type (); - -/** - * @brief A helper class required to store the drag/drop data - * - * Drag/drop data is basically a collection of key/value pairs. - * A category string is provided to identify the kind of data. - */ - -class LAYBASIC_PUBLIC DragDropDataBase -{ -public: - /** - * @brief Default constructor - */ - DragDropDataBase () { } - - /** - * @brief Dtor - */ - virtual ~DragDropDataBase () { } - - /** - * @brief Serializes itself to an QByteArray - */ - virtual QByteArray serialized () const = 0; - - /** - * @brief Try deserialization from an QByteArray - * - * Returns false, if deserialization failed. - */ - virtual bool deserialize (const QByteArray &ba) = 0; - - /** - * @brief Create a QMimeData object from the object - */ - QMimeData *to_mime_data () const; -}; - -/** - * @brief Drag/drop data for a cell - */ - -class LAYBASIC_PUBLIC CellDragDropData - : public DragDropDataBase -{ -public: - /** - * @brief Default ctor - */ - CellDragDropData () - : mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false) - { - // .. nothing yet .. - } - - /** - * @brief Specifies drag & drop of a cell - * - * @param layout the layout where the cell lives in - * @param cell_index The index of the cell - */ - CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector &pcell_params = std::vector ()) - : mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params) - { - // .. nothing yet .. - } - - /** - * @brief Gets the layout object where the cell lives in - */ - const db::Layout *layout () const - { - return mp_layout; - } - - /** - * @brief Gets the layout object where the cell lives in - */ - const db::Library *library () const - { - return mp_library; - } - - /** - * @brief PCell parameters - */ - const std::vector &pcell_params () const - { - return m_pcell_params; - } - - /** - * @brief Gets the index of the cell - */ - db::cell_index_type cell_index () const - { - return m_cell_index; - } - - /** - * @brief Gets a value indicating whether the cell is a pcell - */ - bool is_pcell () const - { - return m_is_pcell; - } - - /** - * @brief Serializes itself to an QByteArray - */ - virtual QByteArray serialized () const; - - /** - * @brief Try deserialization from an QByteArray - * - * Returns false, if deserialization failed. - */ - bool deserialize (const QByteArray &ba); - -private: - const db::Layout *mp_layout; - const db::Library *mp_library; - db::cell_index_type m_cell_index; - bool m_is_pcell; - std::vector m_pcell_params; -}; +#if defined(HAVE_QT) +class DragDropDataBase; +#endif /** * @brief A view service @@ -233,6 +114,7 @@ public: */ virtual bool key_event (unsigned int /*key*/, unsigned int /*buttons*/) { return false; } +#if defined(HAVE_QT) /** * @brief The drag enter event * @@ -257,6 +139,7 @@ public: * @brief The drop event */ virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; } +#endif /** * @brief Mouse press event handler @@ -373,7 +256,7 @@ public: /** * @brief This method is called to set the background and text (foreground) color */ - virtual void set_colors (QColor /*background*/, QColor /*text*/) { } + virtual void set_colors (lay::Color /*background*/, lay::Color /*text*/) { } /** * @brief This method is called when a drag operation should be cancelled @@ -628,12 +511,53 @@ private: * @brief Describes the button state (supposed to be ored) */ enum ButtonState { - ShiftButton = 1, + ShiftButton = 1, ControlButton = 2, - AltButton = 4, - LeftButton = 8, - MidButton = 16, - RightButton = 32 + AltButton = 4, + LeftButton = 8, + MidButton = 16, + RightButton = 32 +}; + +/** + * @brief Key codes for keys understood by the standard components + */ +enum KeyCodes { +#if defined(HAVE_QT) + KeyEscape = int(Qt::Key_Escape), + KeyTab = int(Qt::Key_Tab), + KeyBacktab = int(Qt::Key_Backtab), + KeyBackspace = int(Qt::Key_Backspace), + KeyReturn = int(Qt::Key_Return), + KeyEnter = int(Qt::Key_Enter), + KeyInsert = int(Qt::Key_Insert), + KeyDelete = int(Qt::Key_Delete), + KeyHome = int(Qt::Key_Home), + KeyEnd = int(Qt::Key_End), + KeyDown = int(Qt::Key_Down), + KeyUp = int(Qt::Key_Up), + KeyLeft = int(Qt::Key_Left), + KeyRight = int(Qt::Key_Right), + KeyPageUp = int(Qt::Key_PageUp), + KeyPageDown = int(Qt::Key_PageDown) +#else + KeyEscape = 0x01000000, + KeyTab = 0x01000001, + KeyBacktab = 0x01000002, + KeyBackspace = 0x01000003, + KeyReturn = 0x01000004, + KeyEnter = 0x01000005, + KeyInsert = 0x01000006, + KeyDelete = 0x01000007, + KeyHome = 0x01000010, + KeyEnd = 0x01000011, + KeyLeft = 0x01000012, + KeyUp = 0x01000013, + KeyRight = 0x01000014, + KeyDown = 0x01000015, + KeyPageUp = 0x01000016, + KeyPageDown = 0x01000017 +#endif }; /** @@ -644,8 +568,10 @@ enum ButtonState { * painting. */ -class LAYBASIC_PUBLIC ViewObjectWidget - : public QWidget, +class LAYBASIC_PUBLIC ViewObjectWidget : +#if defined(HAVE_QT) + public QWidget, +#endif public tl::Object { public: @@ -657,7 +583,11 @@ public: /** * @brief ctor */ +#if defined(HAVE_QT) ViewObjectWidget (QWidget *view, const char *name); +#else + ViewObjectWidget (); +#endif /** * @brief dtor @@ -857,6 +787,7 @@ public: */ virtual void key_event (unsigned int /*key*/, unsigned int /*buttons*/) { } +#if defined(HAVE_QT) /** * @brief The drag enter event * @@ -881,6 +812,7 @@ public: * @brief The drop event */ virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; } +#endif /** * @brief Remaining mouse double click event handler @@ -984,7 +916,7 @@ public: /** * @brief Gets the current mouse position */ - QPoint mouse_position () const + db::DPoint mouse_position () const { return m_mouse_pos; } @@ -1000,12 +932,12 @@ public: /** * @brief Translates a screen coordinate in micrometer coordinates */ - db::DPoint pixel_to_um (const QPoint &pt) const; + db::DPoint pixel_to_um (const db::Point &pt) const; /** * @brief Translates a screen coordinate in micrometer coordinates */ - db::DPoint pixel_to_um (const QPointF &pt) const; + db::DPoint pixel_to_um (const db::DPoint &pt) const; /** * @brief Gets a flag indicating whether the mouse is inside the window @@ -1015,7 +947,57 @@ public: return m_mouse_inside; } +#if !defined(HAVE_QT) + /** + * @brief Gets a value indicating that the image data has been updated + * + * This method will return true once after "update" was called. + */ + bool image_updated (); +#endif + + /** + * @brief External entry point for key press event generation + */ + void send_key_press_event (unsigned int key, unsigned int buttons); + + /** + * @brief External entry point for mouse move event generation + */ + void send_mouse_move_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for leave event generation + */ + void send_leave_event (); + + /** + * @brief External entry point for enter event generation + */ + void send_enter_event (); + + /** + * @brief External entry point for mouse button press event generation + */ + void send_mouse_press_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse button double-click event generation + */ + void send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse button release event generation + */ + void send_mouse_release_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse wheel event generation + */ + void send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons); + protected: +#if defined(HAVE_QT) /** * @brief Qt focus event handler */ @@ -1084,12 +1066,28 @@ protected: * @brief Qt mouse wheel event handler */ void wheelEvent (QWheelEvent *e); +#endif + +#if !defined(HAVE_QT) + /** + * @brief Emulates the update() method in the non-Qt case + * + * After calling this method, the next image_updated() call will return true while also resetting the + * update needed flag. + */ + void update (); +#endif /** * @brief Set the transformation for mouse events */ void mouse_event_trans (const db::DCplxTrans &trans); + /** + * @brief Resizes the widget + */ + void resize (unsigned int w, unsigned int h); + private: friend class lay::ViewObject; friend class lay::ViewService; @@ -1104,19 +1102,23 @@ private: bool m_needs_update_bg; lay::ViewService *mp_active_service; db::DCplxTrans m_trans; - QPoint m_mouse_pos; - QPoint m_mouse_pressed; + db::DPoint m_mouse_pos; + db::DPoint m_mouse_pressed; bool m_mouse_pressed_state; unsigned int m_mouse_buttons; bool m_in_mouse_move; bool m_mouse_inside; lay::Cursor::cursor_shape m_cursor, m_default_cursor; + unsigned int m_widget_width, m_widget_height; + bool m_image_updated; void ensure_entered (); void do_mouse_move (); void begin_mouse_event (lay::Cursor::cursor_shape cursor = lay::Cursor::keep); void end_mouse_event (); void objects_changed (); + int widget_height () const; + int widget_width () const; /** * @brief Register a service @@ -1152,17 +1154,17 @@ public: /** * @brief Background color property: background color of the canvas */ - virtual QColor background_color () const = 0; + virtual lay::Color background_color () const = 0; /** * @brief Foreground color property: foreground color of the canvas (some "contrast" color to background) */ - virtual QColor foreground_color () const = 0; + virtual lay::Color foreground_color () const = 0; /** * @brief Active color property: color of active elements on the canvas (some "contrast" color to background and different from foreground) */ - virtual QColor active_color () const = 0; + virtual lay::Color active_color () const = 0; /** * @brief Get the resolution @@ -1328,11 +1330,6 @@ public: */ void clear_fg_bitmaps (); - /** - * @brief Return the background image - */ - virtual QImage &bg_image () = 0; - /** * @brief Set the width and height and resolution */ @@ -1364,6 +1361,16 @@ public: return m_height; } + /** + * @brief Gets the pixel buffer that background objects render to + */ + virtual lay::PixelBuffer *bg_image (); + + /** + * @brief Gets the monochrome pixel buffer that background objects render to + */ + virtual lay::BitmapBuffer *bg_bitmap (); + private: std::map m_fg_bitmap_table; std::map , unsigned int> m_fgv_bitmap_table; diff --git a/src/laybasic/laybasic/layViewOp.h b/src/laybasic/laybasic/layViewOp.h index f9cf704c6..5527288c5 100644 --- a/src/laybasic/laybasic/layViewOp.h +++ b/src/laybasic/laybasic/layViewOp.h @@ -26,14 +26,13 @@ #define HDR_layViewOp #include "laybasicCommon.h" +#include "layColor.h" #include namespace lay { -typedef unsigned int color_t; - const unsigned int wordlen = 32; const unsigned int wordbits = 5; const unsigned int wordones = 0xffffffff; diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index 50af13b8a..26538d076 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -23,7 +23,7 @@ #include "layZoomBox.h" #include "layRubberBox.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { @@ -31,7 +31,7 @@ namespace lay // ------------------------------------------------------------- // ZoomService implementation -ZoomService::ZoomService (lay::LayoutView *view) +ZoomService::ZoomService (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), @@ -54,7 +54,7 @@ ZoomService::drag_cancel () } void -ZoomService::set_colors (QColor /*background*/, QColor color) +ZoomService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { diff --git a/src/laybasic/laybasic/layZoomBox.h b/src/laybasic/laybasic/layZoomBox.h index 27fb82ff8..7794c6473 100644 --- a/src/laybasic/laybasic/layZoomBox.h +++ b/src/laybasic/laybasic/layZoomBox.h @@ -30,7 +30,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class RubberBox; @@ -38,10 +38,10 @@ class LAYBASIC_PUBLIC ZoomService : public lay::ViewService { public: - ZoomService (lay::LayoutView *view); + ZoomService (lay::LayoutViewBase *view); ~ZoomService (); - void set_colors (QColor background, QColor text); + void set_colors (lay::Color background, lay::Color text); void begin (const db::DPoint &pos); void begin_pan (const db::DPoint &pos); @@ -55,7 +55,7 @@ private: db::DPoint m_p1, m_p2; db::DBox m_vp; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; }; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index ed2625d9d..33b10cf08 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -6,303 +6,142 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_LAYBASIC_LIBRARY -FORMS = \ - AlignCellOptionsDialog.ui \ - BookmarkManagementForm.ui \ - BrowseInstancesConfigPage.ui \ - BrowseInstancesForm.ui \ - BrowserDialog.ui \ - BrowserPanel.ui \ - BrowseShapesConfigPage.ui \ - BrowseShapesForm.ui \ - CellSelectionForm.ui \ - ClearLayerModeDialog.ui \ - ConfigurationDialog.ui \ - CopyCellModeDialog.ui \ - DeleteCellModeDialog.ui \ - DuplicateLayerDialog.ui \ - EditStipplesForm.ui \ - FlattenInstOptionsDialog.ui \ - GridNetConfigPage.ui \ - LayerMappingWidget.ui \ - LayerSourceDialog.ui \ - LayoutProperties.ui \ - LayoutViewConfigPage1.ui \ - LayoutViewConfigPage2a.ui \ - LayoutViewConfigPage2b.ui \ - LayoutViewConfigPage2c.ui \ - LayoutViewConfigPage2d.ui \ - LayoutViewConfigPage3a.ui \ - LayoutViewConfigPage3b.ui \ - LayoutViewConfigPage3c.ui \ - LayoutViewConfigPage3f.ui \ - LayoutViewConfigPage4.ui \ - LayoutViewConfigPage5.ui \ - LayoutViewConfigPage6.ui \ - LayoutViewConfigPage7.ui \ - LayoutViewConfigPage.ui \ - LibraryCellSelectionForm.ui \ - LoadLayoutOptionsDialog.ui \ - MarkerBrowserConfigPage2.ui \ - MarkerBrowserConfigPage.ui \ - MarkerBrowserDialog.ui \ - MarkerBrowserPage.ui \ - MarkerBrowserSnapshotView.ui \ - MoveOptionsDialog.ui \ - MoveToOptionsDialog.ui \ - NewCellPropertiesDialog.ui \ - NewLayerPropertiesDialog.ui \ - NewLayoutPropertiesDialog.ui \ - OpenLayoutModeDialog.ui \ - PropertiesDialog.ui \ - RenameCellDialog.ui \ - ReplaceCellOptionsDialog.ui \ - SaveLayoutOptionsDialog.ui \ - SaveLayoutAsOptionsDialog.ui \ - SelectStippleForm.ui \ - TipDialog.ui \ - UserPropertiesForm.ui \ - UserPropertiesEditForm.ui \ - SpecificLoadLayoutOptionsDialog.ui \ - SelectLineStyleForm.ui \ - LayoutViewConfigPage6a.ui \ - EditLineStylesForm.ui \ - NetlistBrowserPage.ui \ - NetlistBrowserConfigPage.ui \ - NetlistBrowserConfigPage2.ui \ - NetlistBrowserDialog.ui \ - NetInfoDialog.ui \ - NetExportDialog.ui \ - SelectCellViewForm.ui \ - LayoutStatistics.ui +!equals(HAVE_QT, 0) { -RESOURCES = \ - laybasicResources.qrc \ - layLayoutStatistics.qrc + FORMS = \ + PropertiesDialog.ui \ -SOURCES = \ - gtf.cc \ - gsiDeclLayDialogs.cc \ + SOURCES = \ + gtf.cc \ + layPluginConfigPage.cc \ + layPropertiesDialog.cc \ + layProperties.cc \ + layAbstractMenu.cc \ + layDragDropData.cc \ + layCursor.cc \ + + HEADERS = \ + gtf.h \ + layPluginConfigPage.h \ + layPropertiesDialog.h \ + layProperties.h \ + layAbstractMenu.h \ + layDragDropData.h \ + layCursor.h \ + +} + +SOURCES += \ gsiDeclLayLayers.cc \ - gsiDeclLayLayoutView.cc \ + gsiDeclLayLayoutViewBase.cc \ gsiDeclLayMarker.cc \ - gsiDeclLayMenu.cc \ gsiDeclLayPlugin.cc \ - gsiDeclLayStream.cc \ - layAbstractMenu.cc \ + gsiDeclLayPixelBuffer.cc \ + laybasicForceLink.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ layBitmapsToImage.cc \ layBookmarkList.cc \ - layBookmarkManagementForm.cc \ - layBrowseInstancesForm.cc \ - layBrowser.cc \ - layBrowserDialog.cc \ - layBrowserPanel.cc \ - layBrowseShapesForm.cc \ - layBusy.cc \ - layCanvasPlane.cc \ - layCellSelectionForm.cc \ - layCellTreeModel.cc \ layCellView.cc \ + layColor.cc \ layColorPalette.cc \ - layConfigurationDialog.cc \ layConverters.cc \ - layCursor.cc \ - layDialogs.cc \ + layDispatcher.cc \ layDisplayState.cc \ layDitherPattern.cc \ layDrawing.cc \ layEditable.cc \ - layEditStipplesForm.cc \ - layEditStippleWidget.cc \ - layEditorOptionsFrame.cc \ - layEditorOptionsPage.cc \ - layEditorOptionsPages.cc \ layEditorServiceBase.cc \ - layFileDialog.cc \ layFinder.cc \ layFixedFont.cc \ - layGridNet.cc \ - layHierarchyControlPanel.cc \ - layLayerControlPanel.cc \ - layLayerMappingWidget.cc \ - layLayerProperties.cc \ - layLayerToolbox.cc \ - layLayerTreeModel.cc \ layLayoutCanvas.cc \ - layLayoutPropertiesForm.cc \ - layLayoutView.cc \ - layLayoutViewConfigPages.cc \ - layLoadLayoutOptionsDialog.cc \ + layLineStylePalette.cc \ + layLineStyles.cc \ layMarker.cc \ layMouseTracker.cc \ layMove.cc \ + layNativePlugin.cc \ + layNetColorizer.cc \ layObjectInstPath.cc \ layParsedLayerSource.cc \ + layPixelBuffer.cc \ + layPixelBufferPainter.cc \ layPlugin.cc \ - layProperties.cc \ - layPropertiesDialog.cc \ - layQtTools.cc \ layRedrawLayerInfo.cc \ - layRedrawThreadCanvas.cc \ layRedrawThread.cc \ + layRedrawThreadCanvas.cc \ layRedrawThreadWorker.cc \ layRenderer.cc \ layRubberBox.cc \ - laySaveLayoutOptionsDialog.cc \ laySelector.cc \ - laySelectStippleForm.cc \ laySnap.cc \ - layStipplePalette.cc \ layStream.cc \ - layTechnology.cc \ - layTipDialog.cc \ + layStipplePalette.cc \ + layCanvasPlane.cc \ + layLayoutViewBase.cc \ + layLayerProperties.cc \ layViewObject.cc \ layViewOp.cc \ layViewport.cc \ - layWidgets.cc \ layZoomBox.cc \ - rdbInfoWidget.cc \ - rdbMarkerBrowser.cc \ - rdbMarkerBrowserDialog.cc \ - rdbMarkerBrowserPage.cc \ - layLineStyles.cc \ - laySelectLineStyleForm.cc \ - layLineStylePalette.cc \ - layEditLineStylesForm.cc \ - layEditLineStyleWidget.cc \ - layBackgroundAwareTreeStyle.cc \ - layNetlistBrowser.cc \ - layNetlistBrowserDialog.cc \ - layNetlistBrowserPage.cc \ - layItemDelegates.cc \ - layNetInfoDialog.cc \ - layNetExportDialog.cc \ - layNetlistBrowserModel.cc \ - layIndexedNetlistModel.cc \ - layNetlistCrossReferenceModel.cc \ - layNetlistBrowserTreeModel.cc \ - layLibrariesView.cc \ - layBookmarksView.cc \ - layGenericSyntaxHighlighter.cc \ - layDispatcher.cc \ - laySelectCellViewForm.cc \ - layLayoutStatisticsForm.cc \ - gsiDeclLayNetlistBrowserDialog.cc \ - layLayoutViewFunctions.cc -HEADERS = \ - gtf.h \ - layAbstractMenu.h \ +HEADERS += \ + laybasicConfig.h \ + laybasicForceLink.h \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ layBitmapsToImage.h \ layBookmarkList.h \ - layBookmarkManagementForm.h \ - layBrowseInstancesForm.h \ - layBrowserDialog.h \ - layBrowser.h \ - layBrowserPanel.h \ - layBrowseShapesForm.h \ - layBusy.h \ - layCanvasPlane.h \ - layCellSelectionForm.h \ - layCellTreeModel.h \ layCellView.h \ layColorPalette.h \ - layConfigurationDialog.h \ + layColor.h \ layConverters.h \ - layCursor.h \ - layDialogs.h \ + layDispatcher.h \ layDisplayState.h \ layDitherPattern.h \ layDrawing.h \ layEditable.h \ - layEditStipplesForm.h \ - layEditStippleWidget.h \ - layEditorOptionsFrame.h \ - layEditorOptionsPage.h \ - layEditorOptionsPages.h \ layEditorServiceBase.h \ - layFileDialog.h \ + layLayoutCanvas.h \ layFinder.h \ layFixedFont.h \ - layGridNet.h \ - layHierarchyControlPanel.h \ - layLayerControlPanel.h \ - layLayerMappingWidget.h \ - layLayerProperties.h \ - layLayerToolbox.h \ - layLayerTreeModel.h \ - layLayoutCanvas.h \ - layLayoutPropertiesForm.h \ - layLayoutViewConfigPages.h \ - layLayoutView.h \ - layLoadLayoutOptionsDialog.h \ + layLayoutViewBase.h \ + layLineStylePalette.h \ + layLineStyles.h \ layMarker.h \ layMouseTracker.h \ layMove.h \ + layNativePlugin.h \ + layNetColorizer.h \ layObjectInstPath.h \ layParsedLayerSource.h \ + layPixelBuffer.h \ + layPixelBufferPainter.h \ layPlugin.h \ - layPropertiesDialog.h \ - layProperties.h \ - layQtTools.h \ layRedrawLayerInfo.h \ - layRedrawThreadCanvas.h \ layRedrawThread.h \ + layRedrawThreadCanvas.h \ layRedrawThreadWorker.h \ layRenderer.h \ layRubberBox.h \ - laySaveLayoutOptionsDialog.h \ laySelector.h \ - laySelectStippleForm.h \ laySnap.h \ - layStipplePalette.h \ layStream.h \ - layTechnology.h \ - layTipDialog.h \ + layStipplePalette.h \ + layLayerProperties.h \ + layCanvasPlane.h \ layViewObject.h \ layViewOp.h \ layViewport.h \ - layWidgets.h \ layZoomBox.h \ - rdbInfoWidget.h \ - rdbMarkerBrowserDialog.h \ - rdbMarkerBrowser.h \ - rdbMarkerBrowserPage.h \ - layLineStyles.h \ - laySelectLineStyleForm.h \ - layLineStylePalette.h \ - layEditLineStylesForm.h \ - layEditLineStyleWidget.h \ laybasicCommon.h \ - laybasicConfig.h \ - layBackgroundAwareTreeStyle.h \ - layNetlistBrowser.h \ - layNetlistBrowserDialog.h \ - layNetlistBrowserPage.h \ - layItemDelegates.h \ - layNetInfoDialog.h \ - layNetExportDialog.h \ - layNetlistBrowserModel.h \ - layIndexedNetlistModel.h \ - layNetlistCrossReferenceModel.h \ - layNetlistBrowserTreeModel.h \ - layLibrariesView.h \ - layBookmarksView.h \ - layGenericSyntaxHighlighter.h \ - layDispatcher.h \ - laySelectCellViewForm.h \ - layLayoutStatisticsForm.h \ - layLayoutViewFunctions.h -INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym + +INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb INCLUDEPATH += $$QTBASIC_INC DEPENDPATH += $$QTBASIC_INC diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index d9e7bd5ad..0b84bf38f 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -20,7 +20,6 @@ */ - #ifndef HDR_laybasicConfig #define HDR_laybasicConfig @@ -147,4 +146,3 @@ static const std::string cfg_guiding_shape_vertex_size ("guiding-shape-vertex-si } #endif - diff --git a/src/laybasic/laybasic/laybasicForceLink.cc b/src/laybasic/laybasic/laybasicForceLink.cc new file mode 100644 index 000000000..9db8fe64f --- /dev/null +++ b/src/laybasic/laybasic/laybasicForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "laybasicForceLink.h" + +namespace laybasic +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/laybasic/laybasic/laybasicForceLink.h b/src/laybasic/laybasic/laybasicForceLink.h new file mode 100644 index 000000000..af2188be3 --- /dev/null +++ b/src/laybasic/laybasic/laybasicForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_laybasicForceLink +#define HDR_laybasicForceLink + +#include "laybasicCommon.h" + +/** + * @file Include this function to force linking of the laybasic module + */ + +namespace laybasic +{ + LAYBASIC_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/laybasic/unit_tests/layAbstractMenuTests.cc b/src/laybasic/unit_tests/layAbstractMenuTests.cc index 16b1ab1ff..3f6c67ada 100644 --- a/src/laybasic/unit_tests/layAbstractMenuTests.cc +++ b/src/laybasic/unit_tests/layAbstractMenuTests.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layAbstractMenu.h" #include "tlUnitTest.h" @@ -184,3 +186,4 @@ TEST(3_ActionReferences) EXPECT_EQ (action.get () == 0, true); } +#endif diff --git a/src/laybasic/unit_tests/layBitmapsToImage.cc b/src/laybasic/unit_tests/layBitmapsToImage.cc index e38c1c0d0..47d61206f 100644 --- a/src/laybasic/unit_tests/layBitmapsToImage.cc +++ b/src/laybasic/unit_tests/layBitmapsToImage.cc @@ -20,23 +20,19 @@ */ - #include "layBitmapsToImage.h" #include "layBitmap.h" #include "layDitherPattern.h" #include "layLineStyles.h" +#include "layPixelBuffer.h" #include "tlUnitTest.h" -#include -#include -#include - std::string -to_string (const QImage &img, unsigned int mask) +to_string (const lay::PixelBuffer &img, unsigned int mask) { std::string s; for (unsigned int i = 0; i < 32; ++i) { - const unsigned int *data = (const unsigned int *)img.scanLine (i); + const unsigned int *data = (const unsigned int *)img.scan_line (i); for (unsigned int j = 0; j < 32; ++j) { s += (data[j] & mask) ? "x" : "."; } @@ -89,13 +85,13 @@ TEST(1) view_ops.push_back (lay::ViewOp (0x000080, lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 1)); view_ops.push_back (lay::ViewOp (0x0000c0, lay::ViewOp::Or, 0, 0, 0, lay::ViewOp::Rect, 3)); - QImage img (QSize (32, 32), QImage::Format_RGB32); + lay::PixelBuffer img (32, 32); img.fill (0); lay::DitherPattern dp; lay::LineStyles ls; - QMutex m; + tl::Mutex m; lay::bitmaps_to_image (view_ops, pbitmaps, dp, ls, &img, 32, 32, 0, &m); EXPECT_EQ (to_string (img, 0x800000), @@ -939,4 +935,3 @@ TEST(1) ); } - diff --git a/src/laybasic/unit_tests/layColorTests.cc b/src/laybasic/unit_tests/layColorTests.cc new file mode 100644 index 000000000..3a8b308c6 --- /dev/null +++ b/src/laybasic/unit_tests/layColorTests.cc @@ -0,0 +1,219 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layColor.h" + +#include "tlUnitTest.h" + +#if defined(HAVE_QT) +#include +#endif + +TEST(1) +{ + EXPECT_EQ (lay::Color ().is_valid (), false); + EXPECT_EQ (lay::Color ().to_string (), ""); + EXPECT_EQ (lay::Color ().rgb (), 0x00000000); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor ().isValid (), false); + EXPECT_EQ (tl::to_string (QColor ().name ()), "#000000"); // why? + EXPECT_EQ (QColor ().rgb (), 0xff000000); +#endif +} + +TEST(2) +{ + EXPECT_EQ (lay::Color (0x102030).is_valid (), true); + EXPECT_EQ (lay::Color (0x102030).to_string (), "#102030"); + EXPECT_EQ (lay::Color (0x102030).rgb (), 0xff102030); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor (0x102030).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (0x102030).name ()), "#102030"); + EXPECT_EQ (QColor (0x102030).rgb (), 0xff102030); +#endif +} + +TEST(3) +{ + EXPECT_EQ (lay::Color (std::string ()).is_valid (), false); + EXPECT_EQ (lay::Color ("#102030").is_valid (), true); + EXPECT_EQ (lay::Color ("#102030").to_string (), "#102030"); + EXPECT_EQ (lay::Color ("#102030").rgb (), 0xff102030); + EXPECT_EQ (lay::Color ("102030").is_valid (), true); + EXPECT_EQ (lay::Color ("102030").to_string (), "#102030"); + EXPECT_EQ (lay::Color ("102030").rgb (), 0xff102030); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor (tl::to_qstring ("#102030")).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#102030")).name ()), "#102030"); + EXPECT_EQ (QColor (tl::to_qstring ("#102030")).rgb (), 0xff102030); +#endif +} + +TEST(4) +{ + EXPECT_EQ (lay::Color ("#123").is_valid (), true); + EXPECT_EQ (lay::Color ("#123").to_string (), "#112233"); + EXPECT_EQ (lay::Color ("#123").rgb (), 0xff112233); +} + +TEST(5) +{ + EXPECT_EQ (lay::Color ("#80102030").is_valid (), true); + EXPECT_EQ (lay::Color ("#80102030").alpha (), 128); + EXPECT_EQ (lay::Color ("#80102030").red (), 16); + EXPECT_EQ (lay::Color ("#80102030").green (), 32); + EXPECT_EQ (lay::Color ("#80102030").blue (), 48); + EXPECT_EQ (lay::Color ("#80102030").to_string (), "#80102030"); + EXPECT_EQ (lay::Color ("#80102030").rgb (), 0x80102030); + +#if defined(HAVE_QT) && QT_VERSION >= 0x50000 + // no alpha support in Qt + EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#80102030")).name ()), "#102030"); + EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).rgb (), 0xff102030); +#endif +} + +TEST(6) +{ + EXPECT_EQ (lay::Color ("#8123").is_valid (), true); + EXPECT_EQ (lay::Color ("#8123").to_string (), "#88112233"); + EXPECT_EQ (lay::Color ("#8123").rgb (), 0x88112233); +} + +TEST(7) +{ + EXPECT_EQ (lay::Color (16, 32, 48, 128).is_valid (), true); + EXPECT_EQ (lay::Color (16, 32, 48, 128).to_string (), "#80102030"); + EXPECT_EQ (lay::Color (16, 32, 48, 128).rgb (), 0x80102030); + +#if defined(HAVE_QT) + // no alpha support in Qt + EXPECT_EQ (QColor (16, 32, 48, 128).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (16, 32, 48, 128).name ()), "#102030"); + EXPECT_EQ (QColor (16, 32, 48, 128).rgb (), 0xff102030); +#endif +} + +TEST(8) +{ + unsigned int h, s, v; + int ih, is, iv; + lay::Color c = lay::Color (16, 32, 48); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 210); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#102030"); + +#if defined(HAVE_QT) + QColor qc = QColor (16, 32, 48); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 210); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (32, 16, 48); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 270); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#201030"); + +#if defined(HAVE_QT) + qc = QColor (32, 16, 48); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 270); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (32, 48, 16); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 90); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#203010"); + +#if defined(HAVE_QT) + qc = QColor (32, 48, 16); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 90); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (48, 32, 16); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 30); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#302010"); + +#if defined(HAVE_QT) + qc = QColor (48, 32, 16); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 30); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (48, 16, 32); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 330); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#301020"); + +#if defined(HAVE_QT) + qc = QColor (48, 16, 32); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 330); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (16, 48, 32); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 150); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#103020"); + +#if defined(HAVE_QT) + qc = QColor (16, 48, 32); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 150); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif +} diff --git a/src/laybasic/unit_tests/layLayerProperties.cc b/src/laybasic/unit_tests/layLayerProperties.cc index 3ef24eeea..577fe062c 100644 --- a/src/laybasic/unit_tests/layLayerProperties.cc +++ b/src/laybasic/unit_tests/layLayerProperties.cc @@ -23,7 +23,7 @@ #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlXMLParser.h" #include "tlUnitTest.h" #include "dbLayout.h" @@ -1304,7 +1304,7 @@ TEST (16) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1356,7 +1356,7 @@ TEST (17) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1423,7 +1423,7 @@ TEST (18) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1491,7 +1491,7 @@ TEST (19) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1560,7 +1560,7 @@ TEST (20) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1632,7 +1632,7 @@ TEST (21) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc new file mode 100644 index 000000000..fe57b7545 --- /dev/null +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -0,0 +1,656 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layPixelBuffer.h" + +#include "tlUnitTest.h" +#include "tlTimer.h" + +#if defined(HAVE_QT) + +# include +# include + +static bool compare_images (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images_mono (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + qimg2 = qimg2.convertToFormat (QImage::Format_MonoLSB); // that's the format of BitmapBuffer .. + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + // NOTE: slooooow ... + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if ((qimg.scanLine (j)[i / 8] & (0x01 << (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x01 << (i % 8)))) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +#endif + +static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) +{ + return img == img2; +} + +static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) +{ + return img == img2; +} + +TEST(1) +{ + lay::PixelBuffer img (15, 25); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img.stride (), 15 * sizeof (lay::color_t)); + + EXPECT_EQ (img.transparent (), false); + img.set_transparent (true); + EXPECT_EQ (img.transparent (), true); + + img.fill (0x112233); + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + + lay::PixelBuffer img2; + EXPECT_EQ (img2.transparent (), false); + img2 = img; + EXPECT_EQ (img2.transparent (), true); + EXPECT_EQ (img2.width (), 15); + EXPECT_EQ (img2.height (), 25); + + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + EXPECT_EQ (img2.scan_line (5)[10], 0x112233); + + img2.fill (0x332211); + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + EXPECT_EQ (img2.scan_line (5)[10], 0x332211); + + img.set_transparent (false); + img2.swap (img); + EXPECT_EQ (img2.transparent (), false); + EXPECT_EQ (img2.scan_line (5)[10], 0x112233); + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + + img2 = img; + EXPECT_EQ (compare_images (img, img2), true); + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + EXPECT_EQ (img2.scan_line (5)[10], 0x332211); + + img2 = lay::PixelBuffer (10, 16); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img2.width (), 10); + EXPECT_EQ (img2.height (), 16); + img2.fill (0x010203); + EXPECT_EQ (compare_images (img, img2), false); + + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + EXPECT_EQ (img2.scan_line (5)[8], 0xff010203); + + img = std::move (img2); + EXPECT_EQ (compare_images (img, img2), false); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[8], 0xff010203); + + lay::PixelBuffer img3 (img); + EXPECT_EQ (compare_images (img, img3), true); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[8], 0xff010203); + + img.fill (0x102030); + EXPECT_EQ (compare_images (img, img3), false); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[8], 0xff010203); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[8], 0xff102030); + + lay::PixelBuffer img4 (std::move (img)); + EXPECT_EQ (img4.width (), 10); + EXPECT_EQ (img4.height (), 16); + EXPECT_EQ (img4.scan_line (5)[8], 0xff102030); + + // other constructors + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true); + + lay::color_t *dnew = new lay::color_t [ img4.width () * img4.height () * sizeof (lay::color_t) ]; + memcpy (dnew, (const lay::color_t *) img4.data (), img4.width () * img4.height () * sizeof (lay::color_t)); + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), dnew), img4), true); +} + +#if defined(HAVE_QT) + +TEST(2) +{ + lay::PixelBuffer img (227, 231); + + for (unsigned int i = 0; i < img.width (); ++i) { + for (unsigned int j = 0; j < img.height (); ++j) { + img.scan_line (j) [i] = 0xff000000 | (i << 16) | j; + } + } + + EXPECT_EQ (img.transparent (), false); + EXPECT_EQ (img.to_image ().format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + QImage qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); + + lay::PixelBuffer img_returned = lay::PixelBuffer::from_image (qimg); + EXPECT_EQ (compare_images (img, img_returned), true); + + lay::PixelBuffer img_saved (img); + img.scan_line (52) [42] = 0xff000000; + + lay::PixelBuffer diff = img.diff (img_saved); + EXPECT_EQ (diff.transparent (), true); + EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true); + EXPECT_EQ (compare_images (img.to_image (), au), false); + EXPECT_EQ (compare_images (img_saved.to_image (), au), true); + + img.patch (diff); + EXPECT_EQ (compare_images (img.to_image (), au), true); + + img.fill (0xff000000); + img.patch (diff); + + tmp = tmp_file ("diff.png"); + qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + au = tl::testsrc () + "/testdata/lay/au_diff.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); + + qimg = img.to_image_copy (); + img.fill (false); + + tmp = tmp_file ("test2.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +#endif + +#if defined(HAVE_PNG) + +// libpng support +TEST(3) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png1.png"; // ARGB32 + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +TEST(4) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png2.png"; // RGB32 + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +TEST(5) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png3.png"; // GA + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_gs.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +TEST(6) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png4.png"; // G + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_gs.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +#endif + +TEST(7) +{ + { + tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + + for (unsigned int i = 0; i < 5000; ++i) { + lay::PixelBuffer img2 (img); + } + } + +#if defined(HAVE_QT) + { + tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + + for (unsigned int i = 0; i < 5000; ++i) { + QImage qimg2 (qimg); + } + } +#endif + + { + tl::SelfTimer timer ("Run time - lay::Image copy on write"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + + for (unsigned int i = 0; i < 5000; ++i) { + lay::PixelBuffer img2 (img); + img2.scan_line (100) [7] = 0; + } + } + +#if defined(HAVE_QT) + { + tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than lay::Image copy on write)"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + + for (unsigned int i = 0; i < 5000; ++i) { + QImage qimg2 (qimg); + qimg2.scanLine (100) [7] = 0; + } + } + + { + tl::SelfTimer timer ("Run time - direct QImage paint"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + QImage qrec (img.to_image ()); + qrec.fill (0); + + QPainter painter (&qrec); + for (unsigned int i = 0; i < 1000; ++i) { + painter.drawImage (QPoint (0, 0), qimg); + } + } + + { + tl::SelfTimer timer ("Run time - lay::Image paint (should not be much more than direct QImage paint)"); + + lay::PixelBuffer img (1000, 1000); + img.fill (0x112233); + QImage qrec (img.to_image ()); + qrec.fill (0); + + QPainter painter (&qrec); + for (unsigned int i = 0; i < 1000; ++i) { + painter.drawImage (QPoint (0, 0), img.to_image ()); + } + } + +#endif +} + +// Monochrome version + +TEST(11) +{ + lay::BitmapBuffer img (15, 25); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img.stride (), 4); + + img.fill (true); + EXPECT_EQ (img.scan_line (5)[1], 0xff); + + lay::BitmapBuffer img2; + img2 = img; + EXPECT_EQ (img2.width (), 15); + EXPECT_EQ (img2.height (), 25); + + EXPECT_EQ (img.scan_line (5)[1], 0xff); + EXPECT_EQ (img2.scan_line (5)[1], 0xff); + + img2.fill (false); + EXPECT_EQ (img.scan_line (5)[1], 0xff); + EXPECT_EQ (img2.scan_line (5)[1], 0); + + img2.swap (img); + EXPECT_EQ (img2.scan_line (5)[1], 0xff); + EXPECT_EQ (img.scan_line (5)[1], 0); + + img2 = img; + EXPECT_EQ (compare_images (img, img2), true); + EXPECT_EQ (img.scan_line (5)[1], 0); + EXPECT_EQ (img2.scan_line (5)[1], 0); + + img2 = lay::BitmapBuffer (10, 16); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img2.width (), 10); + EXPECT_EQ (img2.height (), 16); + img2.fill (true); + EXPECT_EQ (compare_images (img, img2), false); + + EXPECT_EQ (img.scan_line (5)[1], 0); + EXPECT_EQ (img2.scan_line (5)[0], 0xff); + + img = std::move (img2); + EXPECT_EQ (compare_images (img, img2), false); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[0], 0xff); + + lay::BitmapBuffer img3 (img); + EXPECT_EQ (compare_images (img, img3), true); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[1], 0xff); + + img.fill (false); + EXPECT_EQ (compare_images (img, img3), false); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[1], 0xff); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[1], 0); + + lay::BitmapBuffer img4 (std::move (img)); + EXPECT_EQ (img4.width (), 10); + EXPECT_EQ (img4.height (), 16); + EXPECT_EQ (img4.scan_line (5)[1], 0); + + // other constructors + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true); + + uint8_t *dnew = new uint8_t [ img4.width () * img4.height () * sizeof (uint8_t) ]; + memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ()); + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), dnew), img4), true); +} + +#if defined(HAVE_QT) + +TEST(12) +{ + lay::BitmapBuffer img (227, 231); + + for (unsigned int i = 0; i < img.stride (); ++i) { + for (unsigned int j = 0; j < img.height (); ++j) { + img.scan_line (j) [i] = uint8_t (i * j); + } + } + + EXPECT_EQ (img.to_image ().format () == QImage::Format_MonoLSB, true); + + std::string tmp = tmp_file ("test.png"); + QImage qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images_mono (qimg, au), true); + + lay::BitmapBuffer img_returned = lay::BitmapBuffer::from_image (qimg); + EXPECT_EQ (compare_images (img, img_returned), true); + + qimg = img.to_image_copy (); + img.fill (false); + + tmp = tmp_file ("test2.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + EXPECT_EQ (compare_images_mono (qimg, au), true); +} + +#endif + +#if defined(HAVE_PNG) + +// libpng support +TEST(13) +{ + lay::BitmapBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/au_mono.png"; + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::BitmapBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::BitmapBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::BitmapBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; + EXPECT_EQ (compare_images_mono (img2.to_image (), au), true); +#endif +} + +#endif diff --git a/src/laybasic/unit_tests/laySnapTests.cc b/src/laybasic/unit_tests/laySnapTests.cc index f51e28c11..f975386c8 100644 --- a/src/laybasic/unit_tests/laySnapTests.cc +++ b/src/laybasic/unit_tests/laySnapTests.cc @@ -21,14 +21,14 @@ */ #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlUnitTest.h" TEST(1) { db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); int cv1 = view.create_layout ("", true, false); db::Layout &ly1 = view.cellview (cv1)->layout (); diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index d948a1d87..e906d3a46 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -10,12 +10,12 @@ SOURCES = \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapsToImage.cc \ + layColorTests.cc \ layLayerProperties.cc \ layParsedLayerSource.cc \ + layPixelBufferTests.cc \ layRenderer.cc \ - layNetlistBrowserModelTests.cc \ - layNetlistBrowserTreeModelTests.cc \ - layAbstractMenuTests.cc \ + layAbstractMenuTests.cc \ laySnapTests.cc INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic diff --git a/src/layui/layui.pro b/src/layui/layui.pro new file mode 100644 index 000000000..19b992d3c --- /dev/null +++ b/src/layui/layui.pro @@ -0,0 +1,6 @@ + +TEMPLATE = subdirs +SUBDIRS = layui unit_tests + +unit_tests.depends += layui + diff --git a/src/laybasic/laybasic/AlignCellOptionsDialog.ui b/src/layui/layui/AlignCellOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/AlignCellOptionsDialog.ui rename to src/layui/layui/AlignCellOptionsDialog.ui diff --git a/src/laybasic/laybasic/BookmarkManagementForm.ui b/src/layui/layui/BookmarkManagementForm.ui similarity index 100% rename from src/laybasic/laybasic/BookmarkManagementForm.ui rename to src/layui/layui/BookmarkManagementForm.ui diff --git a/src/laybasic/laybasic/BrowseInstancesConfigPage.ui b/src/layui/layui/BrowseInstancesConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/BrowseInstancesConfigPage.ui rename to src/layui/layui/BrowseInstancesConfigPage.ui diff --git a/src/laybasic/laybasic/BrowseInstancesForm.ui b/src/layui/layui/BrowseInstancesForm.ui similarity index 100% rename from src/laybasic/laybasic/BrowseInstancesForm.ui rename to src/layui/layui/BrowseInstancesForm.ui diff --git a/src/laybasic/laybasic/BrowseShapesConfigPage.ui b/src/layui/layui/BrowseShapesConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/BrowseShapesConfigPage.ui rename to src/layui/layui/BrowseShapesConfigPage.ui diff --git a/src/laybasic/laybasic/BrowseShapesForm.ui b/src/layui/layui/BrowseShapesForm.ui similarity index 100% rename from src/laybasic/laybasic/BrowseShapesForm.ui rename to src/layui/layui/BrowseShapesForm.ui diff --git a/src/laybasic/laybasic/BrowserDialog.ui b/src/layui/layui/BrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/BrowserDialog.ui rename to src/layui/layui/BrowserDialog.ui diff --git a/src/laybasic/laybasic/BrowserPanel.ui b/src/layui/layui/BrowserPanel.ui similarity index 100% rename from src/laybasic/laybasic/BrowserPanel.ui rename to src/layui/layui/BrowserPanel.ui diff --git a/src/laybasic/laybasic/CellSelectionForm.ui b/src/layui/layui/CellSelectionForm.ui similarity index 100% rename from src/laybasic/laybasic/CellSelectionForm.ui rename to src/layui/layui/CellSelectionForm.ui diff --git a/src/laybasic/laybasic/ClearLayerModeDialog.ui b/src/layui/layui/ClearLayerModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/ClearLayerModeDialog.ui rename to src/layui/layui/ClearLayerModeDialog.ui diff --git a/src/laybasic/laybasic/ConfigurationDialog.ui b/src/layui/layui/ConfigurationDialog.ui similarity index 100% rename from src/laybasic/laybasic/ConfigurationDialog.ui rename to src/layui/layui/ConfigurationDialog.ui diff --git a/src/laybasic/laybasic/CopyCellModeDialog.ui b/src/layui/layui/CopyCellModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/CopyCellModeDialog.ui rename to src/layui/layui/CopyCellModeDialog.ui diff --git a/src/laybasic/laybasic/DeleteCellModeDialog.ui b/src/layui/layui/DeleteCellModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/DeleteCellModeDialog.ui rename to src/layui/layui/DeleteCellModeDialog.ui diff --git a/src/laybasic/laybasic/DuplicateLayerDialog.ui b/src/layui/layui/DuplicateLayerDialog.ui similarity index 100% rename from src/laybasic/laybasic/DuplicateLayerDialog.ui rename to src/layui/layui/DuplicateLayerDialog.ui diff --git a/src/laybasic/laybasic/EditLineStylesForm.ui b/src/layui/layui/EditLineStylesForm.ui similarity index 100% rename from src/laybasic/laybasic/EditLineStylesForm.ui rename to src/layui/layui/EditLineStylesForm.ui diff --git a/src/laybasic/laybasic/EditStipplesForm.ui b/src/layui/layui/EditStipplesForm.ui similarity index 100% rename from src/laybasic/laybasic/EditStipplesForm.ui rename to src/layui/layui/EditStipplesForm.ui diff --git a/src/laybasic/laybasic/FlattenInstOptionsDialog.ui b/src/layui/layui/FlattenInstOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/FlattenInstOptionsDialog.ui rename to src/layui/layui/FlattenInstOptionsDialog.ui diff --git a/src/laybasic/laybasic/LayerMappingWidget.ui b/src/layui/layui/LayerMappingWidget.ui similarity index 100% rename from src/laybasic/laybasic/LayerMappingWidget.ui rename to src/layui/layui/LayerMappingWidget.ui diff --git a/src/laybasic/laybasic/LayerSourceDialog.ui b/src/layui/layui/LayerSourceDialog.ui similarity index 100% rename from src/laybasic/laybasic/LayerSourceDialog.ui rename to src/layui/layui/LayerSourceDialog.ui diff --git a/src/laybasic/laybasic/LayoutProperties.ui b/src/layui/layui/LayoutProperties.ui similarity index 100% rename from src/laybasic/laybasic/LayoutProperties.ui rename to src/layui/layui/LayoutProperties.ui diff --git a/src/laybasic/laybasic/LayoutStatistics.ui b/src/layui/layui/LayoutStatistics.ui similarity index 100% rename from src/laybasic/laybasic/LayoutStatistics.ui rename to src/layui/layui/LayoutStatistics.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage.ui b/src/layui/layui/LayoutViewConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage.ui rename to src/layui/layui/LayoutViewConfigPage.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage1.ui b/src/layui/layui/LayoutViewConfigPage1.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage1.ui rename to src/layui/layui/LayoutViewConfigPage1.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2a.ui b/src/layui/layui/LayoutViewConfigPage2a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2a.ui rename to src/layui/layui/LayoutViewConfigPage2a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2b.ui b/src/layui/layui/LayoutViewConfigPage2b.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2b.ui rename to src/layui/layui/LayoutViewConfigPage2b.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2c.ui b/src/layui/layui/LayoutViewConfigPage2c.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2c.ui rename to src/layui/layui/LayoutViewConfigPage2c.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2d.ui b/src/layui/layui/LayoutViewConfigPage2d.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2d.ui rename to src/layui/layui/LayoutViewConfigPage2d.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3a.ui b/src/layui/layui/LayoutViewConfigPage3a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3a.ui rename to src/layui/layui/LayoutViewConfigPage3a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3b.ui b/src/layui/layui/LayoutViewConfigPage3b.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3b.ui rename to src/layui/layui/LayoutViewConfigPage3b.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3c.ui b/src/layui/layui/LayoutViewConfigPage3c.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3c.ui rename to src/layui/layui/LayoutViewConfigPage3c.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3f.ui b/src/layui/layui/LayoutViewConfigPage3f.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3f.ui rename to src/layui/layui/LayoutViewConfigPage3f.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage4.ui b/src/layui/layui/LayoutViewConfigPage4.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage4.ui rename to src/layui/layui/LayoutViewConfigPage4.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage5.ui b/src/layui/layui/LayoutViewConfigPage5.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage5.ui rename to src/layui/layui/LayoutViewConfigPage5.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage6.ui b/src/layui/layui/LayoutViewConfigPage6.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage6.ui rename to src/layui/layui/LayoutViewConfigPage6.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage6a.ui b/src/layui/layui/LayoutViewConfigPage6a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage6a.ui rename to src/layui/layui/LayoutViewConfigPage6a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage7.ui b/src/layui/layui/LayoutViewConfigPage7.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage7.ui rename to src/layui/layui/LayoutViewConfigPage7.ui diff --git a/src/laybasic/laybasic/LibraryCellSelectionForm.ui b/src/layui/layui/LibraryCellSelectionForm.ui similarity index 100% rename from src/laybasic/laybasic/LibraryCellSelectionForm.ui rename to src/layui/layui/LibraryCellSelectionForm.ui diff --git a/src/laybasic/laybasic/LoadLayoutOptionsDialog.ui b/src/layui/layui/LoadLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/LoadLayoutOptionsDialog.ui rename to src/layui/layui/LoadLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/MarkerBrowserConfigPage.ui b/src/layui/layui/MarkerBrowserConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserConfigPage.ui rename to src/layui/layui/MarkerBrowserConfigPage.ui diff --git a/src/laybasic/laybasic/MarkerBrowserConfigPage2.ui b/src/layui/layui/MarkerBrowserConfigPage2.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserConfigPage2.ui rename to src/layui/layui/MarkerBrowserConfigPage2.ui diff --git a/src/laybasic/laybasic/MarkerBrowserDialog.ui b/src/layui/layui/MarkerBrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserDialog.ui rename to src/layui/layui/MarkerBrowserDialog.ui diff --git a/src/laybasic/laybasic/MarkerBrowserPage.ui b/src/layui/layui/MarkerBrowserPage.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserPage.ui rename to src/layui/layui/MarkerBrowserPage.ui diff --git a/src/laybasic/laybasic/MarkerBrowserSnapshotView.ui b/src/layui/layui/MarkerBrowserSnapshotView.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserSnapshotView.ui rename to src/layui/layui/MarkerBrowserSnapshotView.ui diff --git a/src/laybasic/laybasic/MoveOptionsDialog.ui b/src/layui/layui/MoveOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/MoveOptionsDialog.ui rename to src/layui/layui/MoveOptionsDialog.ui diff --git a/src/laybasic/laybasic/MoveToOptionsDialog.ui b/src/layui/layui/MoveToOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/MoveToOptionsDialog.ui rename to src/layui/layui/MoveToOptionsDialog.ui diff --git a/src/laybasic/laybasic/NetExportDialog.ui b/src/layui/layui/NetExportDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetExportDialog.ui rename to src/layui/layui/NetExportDialog.ui diff --git a/src/laybasic/laybasic/NetInfoDialog.ui b/src/layui/layui/NetInfoDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetInfoDialog.ui rename to src/layui/layui/NetInfoDialog.ui diff --git a/src/laybasic/laybasic/NetlistBrowserConfigPage.ui b/src/layui/layui/NetlistBrowserConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserConfigPage.ui rename to src/layui/layui/NetlistBrowserConfigPage.ui diff --git a/src/laybasic/laybasic/NetlistBrowserConfigPage2.ui b/src/layui/layui/NetlistBrowserConfigPage2.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserConfigPage2.ui rename to src/layui/layui/NetlistBrowserConfigPage2.ui diff --git a/src/laybasic/laybasic/NetlistBrowserDialog.ui b/src/layui/layui/NetlistBrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserDialog.ui rename to src/layui/layui/NetlistBrowserDialog.ui diff --git a/src/laybasic/laybasic/NetlistBrowserPage.ui b/src/layui/layui/NetlistBrowserPage.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserPage.ui rename to src/layui/layui/NetlistBrowserPage.ui diff --git a/src/laybasic/laybasic/NewCellPropertiesDialog.ui b/src/layui/layui/NewCellPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewCellPropertiesDialog.ui rename to src/layui/layui/NewCellPropertiesDialog.ui diff --git a/src/laybasic/laybasic/NewLayerPropertiesDialog.ui b/src/layui/layui/NewLayerPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewLayerPropertiesDialog.ui rename to src/layui/layui/NewLayerPropertiesDialog.ui diff --git a/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui b/src/layui/layui/NewLayoutPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewLayoutPropertiesDialog.ui rename to src/layui/layui/NewLayoutPropertiesDialog.ui diff --git a/src/laybasic/laybasic/OpenLayoutModeDialog.ui b/src/layui/layui/OpenLayoutModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/OpenLayoutModeDialog.ui rename to src/layui/layui/OpenLayoutModeDialog.ui diff --git a/src/laybasic/laybasic/RenameCellDialog.ui b/src/layui/layui/RenameCellDialog.ui similarity index 100% rename from src/laybasic/laybasic/RenameCellDialog.ui rename to src/layui/layui/RenameCellDialog.ui diff --git a/src/laybasic/laybasic/ReplaceCellOptionsDialog.ui b/src/layui/layui/ReplaceCellOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/ReplaceCellOptionsDialog.ui rename to src/layui/layui/ReplaceCellOptionsDialog.ui diff --git a/src/laybasic/laybasic/SaveLayoutAsOptionsDialog.ui b/src/layui/layui/SaveLayoutAsOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SaveLayoutAsOptionsDialog.ui rename to src/layui/layui/SaveLayoutAsOptionsDialog.ui diff --git a/src/laybasic/laybasic/SaveLayoutOptionsDialog.ui b/src/layui/layui/SaveLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SaveLayoutOptionsDialog.ui rename to src/layui/layui/SaveLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/SelectCellViewForm.ui b/src/layui/layui/SelectCellViewForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectCellViewForm.ui rename to src/layui/layui/SelectCellViewForm.ui diff --git a/src/laybasic/laybasic/SelectLineStyleForm.ui b/src/layui/layui/SelectLineStyleForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectLineStyleForm.ui rename to src/layui/layui/SelectLineStyleForm.ui diff --git a/src/laybasic/laybasic/SelectStippleForm.ui b/src/layui/layui/SelectStippleForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectStippleForm.ui rename to src/layui/layui/SelectStippleForm.ui diff --git a/src/laybasic/laybasic/SpecificLoadLayoutOptionsDialog.ui b/src/layui/layui/SpecificLoadLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SpecificLoadLayoutOptionsDialog.ui rename to src/layui/layui/SpecificLoadLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/TipDialog.ui b/src/layui/layui/TipDialog.ui similarity index 100% rename from src/laybasic/laybasic/TipDialog.ui rename to src/layui/layui/TipDialog.ui diff --git a/src/laybasic/laybasic/UserPropertiesEditForm.ui b/src/layui/layui/UserPropertiesEditForm.ui similarity index 100% rename from src/laybasic/laybasic/UserPropertiesEditForm.ui rename to src/layui/layui/UserPropertiesEditForm.ui diff --git a/src/laybasic/laybasic/UserPropertiesForm.ui b/src/layui/layui/UserPropertiesForm.ui similarity index 100% rename from src/laybasic/laybasic/UserPropertiesForm.ui rename to src/layui/layui/UserPropertiesForm.ui diff --git a/src/laybasic/laybasic/gsiDeclLayDialogs.cc b/src/layui/layui/gsiDeclLayDialogs.cc similarity index 99% rename from src/laybasic/laybasic/gsiDeclLayDialogs.cc rename to src/layui/layui/gsiDeclLayDialogs.cc index 9cf0bc960..db506bb9e 100644 --- a/src/laybasic/laybasic/gsiDeclLayDialogs.cc +++ b/src/layui/layui/gsiDeclLayDialogs.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "gsiDecl.h" #include "gsiDeclBasic.h" #include "layBrowserDialog.h" @@ -388,7 +390,7 @@ Class decl_BrowserSource ("lay", "BrowserSource_Native", "@hide\n@alias BrowserSource" ); -LAYBASIC_PUBLIC +LAYUI_PUBLIC Class &laybasicdecl_BrowserSource () { return decl_BrowserSource; @@ -1186,3 +1188,5 @@ Class decl_MessageBox (QT_EXTERNAL_BASE (QMainWindow) "lay", "Messag ); } + +#endif diff --git a/src/laybasic/laybasic/gsiDeclLayMenu.cc b/src/layui/layui/gsiDeclLayMenu.cc similarity index 99% rename from src/laybasic/laybasic/gsiDeclLayMenu.cc rename to src/layui/layui/gsiDeclLayMenu.cc index 80f7c58b9..9bf185495 100644 --- a/src/laybasic/laybasic/gsiDeclLayMenu.cc +++ b/src/layui/layui/gsiDeclLayMenu.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gsiDecl.h" #include "gsiSignals.h" @@ -410,3 +411,5 @@ Class decl_Action (decl_ActionBase, "lay", "Action", ); } + +#endif diff --git a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc b/src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc similarity index 97% rename from src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc rename to src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc index b19e2ddf9..7f8d3c971 100644 --- a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc +++ b/src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc @@ -20,12 +20,15 @@ */ +#if defined(HAVE_QT) #include "gsiDecl.h" #include "gsiDeclBasic.h" #include "gsiSignals.h" +#include "dbNetlist.h" #include "layNetlistBrowserDialog.h" -#include "layLayoutView.h" +#include "layNetlistBrowserModel.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -204,14 +207,14 @@ Class decl_NetlistBrowserDialog ("lay", "NetlistBrows "This class has been introduced in version 0.27.\n" ); -static lay::NetlistBrowserDialog *netlist_browser (lay::LayoutView *lv) +static lay::NetlistBrowserDialog *netlist_browser (lay::LayoutViewBase *lv) { return lv->get_plugin (); } -// extend lay::LayoutView with the getter for the netlist browser +// extend lay::LayoutViewBase with the getter for the netlist browser static -gsi::ClassExt decl_ext_layout_view ( +gsi::ClassExt decl_ext_layout_view ( gsi::method_ext ("netlist_browser", &netlist_browser, "@brief Gets the netlist browser object for the given layout view\n" "\n" @@ -219,7 +222,7 @@ gsi::ClassExt decl_ext_layout_view ( ) ); - - } +#endif + diff --git a/src/laybasic/laybasic/gsiDeclLayStream.cc b/src/layui/layui/gsiDeclLayStream.cc similarity index 98% rename from src/laybasic/laybasic/gsiDeclLayStream.cc rename to src/layui/layui/gsiDeclLayStream.cc index 403cef728..b0ce8c418 100644 --- a/src/laybasic/laybasic/gsiDeclLayStream.cc +++ b/src/layui/layui/gsiDeclLayStream.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "gsiDecl.h" #include "dbReader.h" #include "layTechnology.h" @@ -46,4 +48,5 @@ gsi::ClassExt layout_reader_decl ( } +#endif diff --git a/src/laybasic/laybasic/images/icon_circuit_16.png b/src/layui/layui/images/icon_circuit_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_16.png rename to src/layui/layui/images/icon_circuit_16.png diff --git a/src/laybasic/laybasic/images/icon_circuit_24.png b/src/layui/layui/images/icon_circuit_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_24.png rename to src/layui/layui/images/icon_circuit_24.png diff --git a/src/laybasic/laybasic/images/icon_circuit_32.png b/src/layui/layui/images/icon_circuit_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_32.png rename to src/layui/layui/images/icon_circuit_32.png diff --git a/src/laybasic/laybasic/images/icon_circuit_48.png b/src/layui/layui/images/icon_circuit_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_48.png rename to src/layui/layui/images/icon_circuit_48.png diff --git a/src/laybasic/laybasic/images/icon_conn_16.png b/src/layui/layui/images/icon_conn_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_16.png rename to src/layui/layui/images/icon_conn_16.png diff --git a/src/laybasic/laybasic/images/icon_conn_24.png b/src/layui/layui/images/icon_conn_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_24.png rename to src/layui/layui/images/icon_conn_24.png diff --git a/src/laybasic/laybasic/images/icon_conn_32.png b/src/layui/layui/images/icon_conn_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_32.png rename to src/layui/layui/images/icon_conn_32.png diff --git a/src/laybasic/laybasic/images/icon_conn_48.png b/src/layui/layui/images/icon_conn_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_48.png rename to src/layui/layui/images/icon_conn_48.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_16.png b/src/layui/layui/images/icon_conn_light_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_16.png rename to src/layui/layui/images/icon_conn_light_16.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_24.png b/src/layui/layui/images/icon_conn_light_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_24.png rename to src/layui/layui/images/icon_conn_light_24.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_32.png b/src/layui/layui/images/icon_conn_light_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_32.png rename to src/layui/layui/images/icon_conn_light_32.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_48.png b/src/layui/layui/images/icon_conn_light_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_48.png rename to src/layui/layui/images/icon_conn_light_48.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_16.png b/src/layui/layui/images/icon_device_bjt_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_16.png rename to src/layui/layui/images/icon_device_bjt_16.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_24.png b/src/layui/layui/images/icon_device_bjt_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_24.png rename to src/layui/layui/images/icon_device_bjt_24.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_32.png b/src/layui/layui/images/icon_device_bjt_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_32.png rename to src/layui/layui/images/icon_device_bjt_32.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_48.png b/src/layui/layui/images/icon_device_bjt_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_48.png rename to src/layui/layui/images/icon_device_bjt_48.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_16.png b/src/layui/layui/images/icon_device_cap_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_16.png rename to src/layui/layui/images/icon_device_cap_16.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_24.png b/src/layui/layui/images/icon_device_cap_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_24.png rename to src/layui/layui/images/icon_device_cap_24.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_32.png b/src/layui/layui/images/icon_device_cap_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_32.png rename to src/layui/layui/images/icon_device_cap_32.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_48.png b/src/layui/layui/images/icon_device_cap_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_48.png rename to src/layui/layui/images/icon_device_cap_48.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_16.png b/src/layui/layui/images/icon_device_diode_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_16.png rename to src/layui/layui/images/icon_device_diode_16.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_24.png b/src/layui/layui/images/icon_device_diode_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_24.png rename to src/layui/layui/images/icon_device_diode_24.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_32.png b/src/layui/layui/images/icon_device_diode_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_32.png rename to src/layui/layui/images/icon_device_diode_32.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_48.png b/src/layui/layui/images/icon_device_diode_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_48.png rename to src/layui/layui/images/icon_device_diode_48.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_16.png b/src/layui/layui/images/icon_device_mos_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_16.png rename to src/layui/layui/images/icon_device_mos_16.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_24.png b/src/layui/layui/images/icon_device_mos_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_24.png rename to src/layui/layui/images/icon_device_mos_24.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_32.png b/src/layui/layui/images/icon_device_mos_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_32.png rename to src/layui/layui/images/icon_device_mos_32.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_48.png b/src/layui/layui/images/icon_device_mos_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_48.png rename to src/layui/layui/images/icon_device_mos_48.png diff --git a/src/laybasic/laybasic/images/icon_device_res_16.png b/src/layui/layui/images/icon_device_res_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_16.png rename to src/layui/layui/images/icon_device_res_16.png diff --git a/src/laybasic/laybasic/images/icon_device_res_24.png b/src/layui/layui/images/icon_device_res_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_24.png rename to src/layui/layui/images/icon_device_res_24.png diff --git a/src/laybasic/laybasic/images/icon_device_res_32.png b/src/layui/layui/images/icon_device_res_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_32.png rename to src/layui/layui/images/icon_device_res_32.png diff --git a/src/laybasic/laybasic/images/icon_device_res_48.png b/src/layui/layui/images/icon_device_res_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_48.png rename to src/layui/layui/images/icon_device_res_48.png diff --git a/src/laybasic/laybasic/images/icon_net_16.png b/src/layui/layui/images/icon_net_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_16.png rename to src/layui/layui/images/icon_net_16.png diff --git a/src/laybasic/laybasic/images/icon_net_24.png b/src/layui/layui/images/icon_net_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_24.png rename to src/layui/layui/images/icon_net_24.png diff --git a/src/laybasic/laybasic/images/icon_net_32.png b/src/layui/layui/images/icon_net_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_32.png rename to src/layui/layui/images/icon_net_32.png diff --git a/src/laybasic/laybasic/images/icon_net_48.png b/src/layui/layui/images/icon_net_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_48.png rename to src/layui/layui/images/icon_net_48.png diff --git a/src/laybasic/laybasic/images/icon_net_light_16.png b/src/layui/layui/images/icon_net_light_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_16.png rename to src/layui/layui/images/icon_net_light_16.png diff --git a/src/laybasic/laybasic/images/icon_net_light_24.png b/src/layui/layui/images/icon_net_light_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_24.png rename to src/layui/layui/images/icon_net_light_24.png diff --git a/src/laybasic/laybasic/images/icon_net_light_32.png b/src/layui/layui/images/icon_net_light_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_32.png rename to src/layui/layui/images/icon_net_light_32.png diff --git a/src/laybasic/laybasic/images/icon_net_light_48.png b/src/layui/layui/images/icon_net_light_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_48.png rename to src/layui/layui/images/icon_net_light_48.png diff --git a/src/laybasic/laybasic/images/icon_pin_16.png b/src/layui/layui/images/icon_pin_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_16.png rename to src/layui/layui/images/icon_pin_16.png diff --git a/src/laybasic/laybasic/images/icon_pin_24.png b/src/layui/layui/images/icon_pin_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_24.png rename to src/layui/layui/images/icon_pin_24.png diff --git a/src/laybasic/laybasic/images/icon_pin_32.png b/src/layui/layui/images/icon_pin_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_32.png rename to src/layui/layui/images/icon_pin_32.png diff --git a/src/laybasic/laybasic/images/icon_pin_48.png b/src/layui/layui/images/icon_pin_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_48.png rename to src/layui/layui/images/icon_pin_48.png diff --git a/src/laybasic/laybasic/images/icons.svg b/src/layui/layui/images/icons.svg similarity index 100% rename from src/laybasic/laybasic/images/icons.svg rename to src/layui/layui/images/icons.svg diff --git a/src/laybasic/laybasic/images/st_plus_node.png b/src/layui/layui/images/st_plus_node.png similarity index 100% rename from src/laybasic/laybasic/images/st_plus_node.png rename to src/layui/layui/images/st_plus_node.png diff --git a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.cc b/src/layui/layui/layBackgroundAwareTreeStyle.cc similarity index 99% rename from src/laybasic/laybasic/layBackgroundAwareTreeStyle.cc rename to src/layui/layui/layBackgroundAwareTreeStyle.cc index ccb8fbac1..1aaa81262 100644 --- a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.cc +++ b/src/layui/layui/layBackgroundAwareTreeStyle.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layBackgroundAwareTreeStyle.h" #include @@ -108,3 +110,6 @@ BackgroundAwareTreeStyle::drawPrimitive (QStyle::PrimitiveElement pe, const QSty } } + +#endif + diff --git a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h b/src/layui/layui/layBackgroundAwareTreeStyle.h similarity index 92% rename from src/laybasic/laybasic/layBackgroundAwareTreeStyle.h rename to src/layui/layui/layBackgroundAwareTreeStyle.h index 18b8bd642..d0ad1b81a 100644 --- a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h +++ b/src/layui/layui/layBackgroundAwareTreeStyle.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBackgroundAwareTreeStyle #define HDR_layBackgroundAwareTreeStyle -#include "laybasicCommon.h" +#include "layuiCommon.h" #include @@ -38,7 +39,7 @@ namespace lay * The default Gtk style is not, hence making the background dark means the * triangles become invisible. */ -class LAYBASIC_PUBLIC BackgroundAwareTreeStyle +class LAYUI_PUBLIC BackgroundAwareTreeStyle : public QProxyStyle { public: @@ -50,3 +51,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.cc b/src/layui/layui/layBookmarkManagementForm.cc similarity index 79% rename from src/laybasic/laybasic/layBookmarkManagementForm.cc rename to src/layui/layui/layBookmarkManagementForm.cc index e582bbc4d..a2f2172f4 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.cc +++ b/src/layui/layui/layBookmarkManagementForm.cc @@ -20,10 +20,12 @@ */ +#if defined(HAVE_QT) #include "layBookmarkManagementForm.h" #include "dbCellInst.h" -#include "layLayoutView.h" + +#include "ui_BookmarkManagementForm.h" #include @@ -54,17 +56,18 @@ private: // ------------------------------------------------------------ BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks, const std::set &selected) - : QDialog (parent), Ui::BookmarkManagementForm (), + : QDialog (parent), m_bookmarks (bookmarks) { + mp_ui = new Ui::BookmarkManagementForm (); setObjectName (QString::fromUtf8 (name)); - Ui::BookmarkManagementForm::setupUi (this); + mp_ui->setupUi (this); QListWidgetItem *first_item = 0; for (size_t i = 0; i < m_bookmarks.size (); ++i) { - QListWidgetItem *item = new BookmarkListLVI (bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i)); + QListWidgetItem *item = new BookmarkListLVI (mp_ui->bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i)); item->setSelected (selected.find (i) != selected.end ()); if (! first_item && item->isSelected ()) { first_item = item; @@ -72,16 +75,16 @@ BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *nam } if (first_item) { - bookmark_list->scrollToItem (first_item); + mp_ui->bookmark_list->scrollToItem (first_item); } - connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_pressed ())); + connect (mp_ui->delete_button, SIGNAL (clicked ()), this, SLOT (delete_pressed ())); } void BookmarkManagementForm::delete_pressed () { - QList sel = bookmark_list->selectedItems (); + QList sel = mp_ui->bookmark_list->selectedItems (); for (QList::const_iterator i = sel.begin (); i != sel.end (); ++i) { delete *i; } @@ -91,12 +94,12 @@ void BookmarkManagementForm::accept () { m_bookmarks.clear (); - m_bookmarks.reserve (bookmark_list->count ()); + m_bookmarks.reserve (mp_ui->bookmark_list->count ()); // TODO: is there an iterator? Here we use the trick to select all and then get the // list of items - bookmark_list->selectAll (); - QList sel = bookmark_list->selectedItems (); + mp_ui->bookmark_list->selectAll (); + QList sel = mp_ui->bookmark_list->selectedItems (); for (QList::const_iterator i = sel.begin (); i != sel.end (); ++i) { BookmarkListLVI *bm = dynamic_cast (*i); if (bm) { @@ -109,5 +112,5 @@ BookmarkManagementForm::accept () } - +#endif diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.h b/src/layui/layui/layBookmarkManagementForm.h similarity index 82% rename from src/laybasic/laybasic/layBookmarkManagementForm.h rename to src/layui/layui/layBookmarkManagementForm.h index 0d80e0941..ba437c862 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.h +++ b/src/layui/layui/layBookmarkManagementForm.h @@ -20,22 +20,28 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBookmarkManagementForm #define HDR_layBookmarkManagementForm -#include // required during the dependency pass -#include "ui_BookmarkManagementForm.h" +#include -#include "layLayoutView.h" +#include "layuiCommon.h" +#include "layLayoutViewBase.h" #include +namespace Ui +{ + class BookmarkManagementForm; +} + namespace lay { -class BookmarkManagementForm - : public QDialog, private Ui::BookmarkManagementForm +class LAYUI_PUBLIC BookmarkManagementForm + : public QDialog { Q_OBJECT @@ -56,6 +62,7 @@ public slots: void delete_pressed (); private: + Ui::BookmarkManagementForm *mp_ui; lay::BookmarkList m_bookmarks; }; @@ -63,3 +70,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/layui/layui/layBookmarksView.cc similarity index 94% rename from src/laybasic/laybasic/layBookmarksView.cc rename to src/layui/layui/layBookmarksView.cc index 39df8be5e..3bdbe7cee 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/layui/layui/layBookmarksView.cc @@ -20,9 +20,10 @@ */ +#if defined(HAVE_QT) #include "layBookmarksView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "laybasicConfig.h" @@ -88,7 +89,7 @@ private: // -------------------------------------------------------------------------------------------- -BookmarksView::BookmarksView (LayoutView *view, QWidget *parent, const char *name) +BookmarksView::BookmarksView (LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_follow_selection (false) { setObjectName (QString::fromUtf8 (name)); @@ -134,18 +135,18 @@ BookmarksView::follow_selection (bool f) } void -BookmarksView::set_background_color (QColor c) +BookmarksView::set_background_color (lay::Color c) { QPalette pl (mp_bookmarks->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); mp_bookmarks->setPalette (pl); } void -BookmarksView::set_text_color (QColor c) +BookmarksView::set_text_color (lay::Color c) { QPalette pl (mp_bookmarks->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); mp_bookmarks->setPalette (pl); } @@ -211,3 +212,5 @@ static tl::RegisteredClass config_decl (new BookmarksVie } +#endif + diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/layui/layui/layBookmarksView.h similarity index 82% rename from src/laybasic/laybasic/layBookmarksView.h rename to src/layui/layui/layBookmarksView.h index 54bc6214d..8393f9fea 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/layui/layui/layBookmarksView.h @@ -20,13 +20,15 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBookmarksView #define HDR_layBookmarksView -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layBookmarkList.h" +#include "layColor.h" #include #include @@ -42,17 +44,17 @@ class AbstractMenu; /** * @brief A widget to display a bookmark list */ -class LAYBASIC_PUBLIC BookmarksView +class LAYUI_PUBLIC BookmarksView : public QFrame { Q_OBJECT public: - BookmarksView (LayoutView *view, QWidget *parent, const char *name); + BookmarksView (lay::LayoutViewBase *view, QWidget *parent, const char *name); ~BookmarksView (); - void set_background_color (QColor c); - void set_text_color (QColor c); + void set_background_color (lay::Color c); + void set_text_color (lay::Color c); void follow_selection (bool f); std::set selected_bookmarks (); @@ -65,7 +67,7 @@ public slots: void context_menu (const QPoint &p); private: - LayoutView *mp_view; + LayoutViewBase *mp_view; QListView *mp_bookmarks; bool m_follow_selection; }; @@ -74,3 +76,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/layui/layui/layBrowseInstancesForm.cc similarity index 99% rename from src/laybasic/laybasic/layBrowseInstancesForm.cc rename to src/layui/layui/layBrowseInstancesForm.cc index fb28e6b65..b1946ebb9 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/layui/layui/layBrowseInstancesForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -79,7 +80,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseInstancesForm (root, view); } @@ -289,7 +290,7 @@ private: // ------------------------------------------------------------ -BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *vw) +BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseInstancesForm (), m_cv_index (0), @@ -530,9 +531,9 @@ BrowseInstancesForm::activated () } // obtain active cellview index and cell index - int cv_index = view ()->active_cellview_index (); + int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; + lay::LayoutViewBase::cell_path_type path; view ()->current_cell_path (path); // no cell to index @@ -912,3 +913,5 @@ BrowseInstancesForm::prev_inst () } +#endif + diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/layui/layui/layBrowseInstancesForm.h similarity index 94% rename from src/laybasic/laybasic/layBrowseInstancesForm.h rename to src/layui/layui/layBrowseInstancesForm.h index 7e7937dfc..20a5b2479 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/layui/layui/layBrowseInstancesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowseInstancesForm #define HDR_layBrowseInstancesForm @@ -27,7 +28,8 @@ #include "ui_BrowseInstancesForm.h" #include "ui_BrowseInstancesConfigPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" +#include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" @@ -64,7 +66,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Parent }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view); + BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutViewBase *view); ~BrowseInstancesForm (); bool eventFilter (QObject *watched, QEvent *event); @@ -131,3 +133,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/layui/layui/layBrowseShapesForm.cc similarity index 99% rename from src/laybasic/laybasic/layBrowseShapesForm.cc rename to src/layui/layui/layBrowseShapesForm.cc index 08304872a..e75fd9bbb 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/layui/layui/layBrowseShapesForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -80,7 +81,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseShapesForm (root, view); } @@ -392,7 +393,7 @@ private: // ------------------------------------------------------------ -BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *vw) +BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseShapesForm (), m_cv_index (-1), @@ -662,7 +663,7 @@ BrowseShapesForm::activated () { view ()->save_view (m_display_state); - std::vector sel_layers = view ()->selected_layers (); + std::vector sel_layers = view ()->selected_layers (); if (sel_layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected"))); @@ -1179,3 +1180,5 @@ BrowseShapesForm::prev_inst () } +#endif + diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/layui/layui/layBrowseShapesForm.h similarity index 94% rename from src/laybasic/laybasic/layBrowseShapesForm.h rename to src/layui/layui/layBrowseShapesForm.h index d933f0520..e12a193b5 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/layui/layui/layBrowseShapesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowseShapesForm #define HDR_layBrowseShapesForm @@ -27,7 +28,8 @@ #include "ui_BrowseShapesForm.h" #include "ui_BrowseShapesConfigPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" +#include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" @@ -63,7 +65,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Local }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *view); + BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *view); ~BrowseShapesForm (); bool eventFilter (QObject *watched, QEvent *event); @@ -133,3 +135,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/layui/layui/layBrowser.cc similarity index 86% rename from src/laybasic/laybasic/layBrowser.cc rename to src/layui/layui/layBrowser.cc index 8a9fcc241..27a32a324 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/layui/layui/layBrowser.cc @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #include #include "layBrowser.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include @@ -32,9 +33,9 @@ namespace lay { #if QT_VERSION >= 0x050000 -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WindowFlags fl) #else -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WFlags fl) #endif // TODO: clarify whether to keep the browsers as separate (potentially hidden) windows : QDialog (0 /*view*/, fl), @@ -95,3 +96,5 @@ Browser::accept () } +#endif + diff --git a/src/laybasic/laybasic/layBrowser.h b/src/layui/layui/layBrowser.h similarity index 85% rename from src/laybasic/laybasic/layBrowser.h rename to src/layui/layui/layBrowser.h index 31510fd5f..f10434e75 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/layui/layui/layBrowser.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowser #define HDR_layBrowser -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layPlugin.h" @@ -35,10 +36,10 @@ class QCloseEvent; namespace lay { -class LayoutView; +class LayoutViewBase; class Dispatcher; -class LAYBASIC_PUBLIC Browser +class LAYUI_PUBLIC Browser : public QDialog, public lay::Plugin { @@ -47,9 +48,9 @@ public: * @brief Constructor */ #if QT_VERSION >= 0x050000 - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); #else - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); #endif /** @@ -93,7 +94,7 @@ public: /** * @brief Return the pointer to the layout view */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -132,7 +133,7 @@ public: private: bool m_active; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; void closeEvent (QCloseEvent *); @@ -143,3 +144,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowserDialog.cc b/src/layui/layui/layBrowserDialog.cc similarity index 98% rename from src/laybasic/laybasic/layBrowserDialog.cc rename to src/layui/layui/layBrowserDialog.cc index 2e4862562..9fcdccdc1 100644 --- a/src/laybasic/laybasic/layBrowserDialog.cc +++ b/src/layui/layui/layBrowserDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBrowserPanel.h" #include "layBrowserDialog.h" @@ -128,3 +129,5 @@ BrowserDialog::accept () } +#endif + diff --git a/src/laybasic/laybasic/layBrowserDialog.h b/src/layui/layui/layBrowserDialog.h similarity index 97% rename from src/laybasic/laybasic/layBrowserDialog.h rename to src/layui/layui/layBrowserDialog.h index 6329d2c95..959277f99 100644 --- a/src/laybasic/laybasic/layBrowserDialog.h +++ b/src/layui/layui/layBrowserDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowserDialog #define HDR_layBrowserDialog @@ -41,7 +42,7 @@ namespace lay * URL's with the special scheme "int" are retrieved from a BrowserSource object. * This will act as a kind of "server" for these URL's. */ -class LAYBASIC_PUBLIC BrowserDialog +class LAYUI_PUBLIC BrowserDialog : public QDialog, private Ui::BrowserDialog { @@ -132,3 +133,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowserPanel.cc b/src/layui/layui/layBrowserPanel.cc similarity index 99% rename from src/laybasic/laybasic/layBrowserPanel.cc rename to src/layui/layui/layBrowserPanel.cc index 7a05aba0d..75d0a0a08 100644 --- a/src/laybasic/laybasic/layBrowserPanel.cc +++ b/src/layui/layui/layBrowserPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBrowserPanel.h" #include "layDispatcher.h" @@ -831,4 +832,5 @@ BrowserSource::attach (lay::BrowserPanel *d) } +#endif diff --git a/src/laybasic/laybasic/layBrowserPanel.h b/src/layui/layui/layBrowserPanel.h similarity index 97% rename from src/laybasic/laybasic/layBrowserPanel.h rename to src/layui/layui/layBrowserPanel.h index 3dd593327..70627b0e2 100644 --- a/src/laybasic/laybasic/layBrowserPanel.h +++ b/src/layui/layui/layBrowserPanel.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowserPanel #define HDR_layBrowserPanel -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlDeferredExecution.h" #include "tlObject.h" #include "gsiObject.h" @@ -57,7 +58,7 @@ class Dispatcher; * The outline is a hierarchical tree of items. Each node has a title, a URL to navigate to and * optional child items. */ -class LAYBASIC_PUBLIC BrowserOutline +class LAYUI_PUBLIC BrowserOutline { public: typedef std::list::const_iterator const_child_iterator; @@ -169,7 +170,7 @@ private: /** * @brief The source for BrowserDialog's "int" URL's */ -class LAYBASIC_PUBLIC BrowserSource +class LAYUI_PUBLIC BrowserSource : public gsi::ObjectBase, public tl::Object { public: @@ -261,7 +262,7 @@ private: /** * @brief A specialization of QTextBrowser that allows loading a specific resource through BrowserPanel */ -class LAYBASIC_PUBLIC BrowserTextWidget +class LAYUI_PUBLIC BrowserTextWidget : public QTextBrowser { public: @@ -285,7 +286,7 @@ private: /** * @brief A structure describing a bookmark item */ -struct LAYBASIC_PUBLIC BookmarkItem +struct LAYUI_PUBLIC BookmarkItem { BookmarkItem () : position (0) { } @@ -305,7 +306,7 @@ struct LAYBASIC_PUBLIC BookmarkItem /** * @brief A specialization of QWidget around a TextBrowser that allows loading a specific resource */ -class LAYBASIC_PUBLIC BrowserPanel +class LAYUI_PUBLIC BrowserPanel : public QWidget { friend class BrowserTextWidget; @@ -487,3 +488,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBusy.cc b/src/layui/layui/layBusy.cc similarity index 98% rename from src/laybasic/laybasic/layBusy.cc rename to src/layui/layui/layBusy.cc index bfd7cda31..ea03d3f44 100644 --- a/src/laybasic/laybasic/layBusy.cc +++ b/src/layui/layui/layBusy.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layBusy.h" #include "tlThreads.h" @@ -80,3 +82,5 @@ BusySection::is_busy () // ---------------------------------------------------------------------------------------------------------- } + +#endif diff --git a/src/laybasic/laybasic/layBusy.h b/src/layui/layui/layBusy.h similarity index 90% rename from src/laybasic/laybasic/layBusy.h rename to src/layui/layui/layBusy.h index ed9597c33..cda8c2e32 100644 --- a/src/laybasic/laybasic/layBusy.h +++ b/src/layui/layui/layBusy.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBusy #define HDR_layBusy -#include "laybasicCommon.h" +#include "layuiCommon.h" namespace lay { @@ -34,7 +35,7 @@ namespace lay * * There must be one provider implementing this interface. */ -class LAYBASIC_PUBLIC BusyMode +class LAYUI_PUBLIC BusyMode { public: BusyMode (); @@ -47,7 +48,7 @@ public: /** * @brief A RAII implementation of the busy mode setter */ -class LAYBASIC_PUBLIC BusySection +class LAYUI_PUBLIC BusySection { public: BusySection (); @@ -63,3 +64,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/layui/layui/layCellSelectionForm.cc similarity index 65% rename from src/laybasic/laybasic/layCellSelectionForm.cc rename to src/layui/layui/layCellSelectionForm.cc index fd84934c0..17c9ede28 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/layui/layui/layCellSelectionForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -36,9 +37,12 @@ #include "tlAssert.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" +#include "ui_CellSelectionForm.h" +#include "ui_LibraryCellSelectionForm.h" + #include namespace lay @@ -49,8 +53,8 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ -CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, const char *name, bool simple_mode) - : QDialog (parent), Ui::CellSelectionForm (), +CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode) + : QDialog (parent), mp_view (view), m_current_cv (-1), m_name_cb_enabled (true), @@ -60,11 +64,12 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co m_update_all_dm (this, &CellSelectionForm::update_all), m_simple_mode (simple_mode) { + mp_ui = new Ui::CellSelectionForm (); setObjectName (QString::fromUtf8 (name)); - Ui::CellSelectionForm::setupUi (this); + mp_ui->setupUi (this); - le_cell_name->set_tab_signal_enabled (true); + mp_ui->le_cell_name->set_tab_signal_enabled (true); mp_use_regular_expressions = new QAction (this); mp_use_regular_expressions->setCheckable (true); @@ -85,33 +90,33 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co mp_use_regular_expressions->setChecked (ue); } - QMenu *m = new QMenu (le_cell_name); + QMenu *m = new QMenu (mp_ui->le_cell_name); m->addAction (mp_use_regular_expressions); m->addAction (mp_case_sensitive); connect (mp_use_regular_expressions, SIGNAL (triggered ()), this, SLOT (name_changed ())); connect (mp_case_sensitive, SIGNAL (triggered ()), this, SLOT (name_changed ())); - le_cell_name->set_clear_button_enabled (true); - le_cell_name->set_options_button_enabled (true); - le_cell_name->set_options_menu (m); + mp_ui->le_cell_name->set_clear_button_enabled (true); + mp_ui->le_cell_name->set_options_button_enabled (true); + mp_ui->le_cell_name->set_options_menu (m); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (cb_views, SIGNAL(activated(int)), this, SLOT(view_changed(int))); - connect (tb_set_parent, SIGNAL(clicked()), this, SLOT(set_parent())); - connect (tb_set_child, SIGNAL(clicked()), this, SLOT(set_child())); - connect (pb_hide, SIGNAL(clicked()), this, SLOT(hide_cell())); - connect (pb_show, SIGNAL(clicked()), this, SLOT(show_cell())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (apply_button, SIGNAL(clicked()), this, SLOT(apply_clicked())); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (le_cell_name, SIGNAL(tab_pressed()), this, SLOT(find_next_clicked())); - connect (le_cell_name, SIGNAL(backtab_pressed()), this, SLOT(find_prev_clicked())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->cb_views, SIGNAL(activated(int)), this, SLOT(view_changed(int))); + connect (mp_ui->tb_set_parent, SIGNAL(clicked()), this, SLOT(set_parent())); + connect (mp_ui->tb_set_child, SIGNAL(clicked()), this, SLOT(set_child())); + connect (mp_ui->pb_hide, SIGNAL(clicked()), this, SLOT(hide_cell())); + connect (mp_ui->pb_show, SIGNAL(clicked()), this, SLOT(show_cell())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->apply_button, SIGNAL(clicked()), this, SLOT(apply_clicked())); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->le_cell_name, SIGNAL(tab_pressed()), this, SLOT(find_next_clicked())); + connect (mp_ui->le_cell_name, SIGNAL(backtab_pressed()), this, SLOT(find_prev_clicked())); - connect (lv_parents, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(parent_changed(const QModelIndex &))); - connect (lv_children, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(child_changed(const QModelIndex &))); + connect (mp_ui->lv_parents, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(parent_changed(const QModelIndex &))); + connect (mp_ui->lv_children, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(child_changed(const QModelIndex &))); m_cellviews.reserve (mp_view->cellviews ()); @@ -120,11 +125,11 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co } if (simple_mode) { - apply_button->hide (); - tools_frame->hide (); + mp_ui->apply_button->hide (); + mp_ui->tools_frame->hide (); } else { - apply_button->show (); - tools_frame->show (); + mp_ui->apply_button->show (); + mp_ui->tools_frame->show (); } if (! m_cellviews.empty ()) { @@ -133,26 +138,26 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co int cvi = 0; for (std::vector::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv, ++cvi) { - cb_views->addItem (tl::to_qstring ((*cv)->name () + " (@" + tl::to_string (cvi + 1) + ")")); + mp_ui->cb_views->addItem (tl::to_qstring ((*cv)->name () + " (@" + tl::to_string (cvi + 1) + ")")); } - cb_views->setCurrentIndex (m_current_cv); + mp_ui->cb_views->setCurrentIndex (m_current_cv); if (m_cellviews.size () == 1) { - cb_views->hide (); - layout_lbl->hide (); + mp_ui->cb_views->hide (); + mp_ui->layout_lbl->hide (); } else { - cb_views->show (); - layout_lbl->show (); + mp_ui->cb_views->show (); + mp_ui->layout_lbl->show (); } - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - lv_children->header ()->hide (); - lv_children->setRootIsDecorated (false); + mp_ui->lv_children->header ()->hide (); + mp_ui->lv_children->setRootIsDecorated (false); - lv_parents->header ()->hide (); - lv_parents->setRootIsDecorated (false); + mp_ui->lv_parents->header ()->hide (); + mp_ui->lv_parents->setRootIsDecorated (false); update_cell_list (); @@ -167,15 +172,15 @@ CellSelectionForm::update_cell_list () return; } - if (lv_cells->model ()) { - delete lv_cells->model (); + if (mp_ui->lv_cells->model ()) { + delete mp_ui->lv_cells->model (); } - lay::CellTreeModel *model = new lay::CellTreeModel (lv_cells, mp_view, m_current_cv, lay::CellTreeModel::Flat); + lay::CellTreeModel *model = new lay::CellTreeModel (mp_ui->lv_cells, mp_view, m_current_cv, lay::CellTreeModel::Flat); - lv_cells->setModel (model); + mp_ui->lv_cells->setModel (model); // connect can only happen after setModel() - connect (lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); + connect (mp_ui->lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); lay::CellView::unspecific_cell_path_type path (m_cellviews [m_current_cv].combined_unspecific_path ()); if (! path.empty ()) { @@ -190,13 +195,13 @@ CellSelectionForm::update_parents_list () if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - if (lv_parents->model ()) { - delete lv_parents->model (); + if (mp_ui->lv_parents->model ()) { + delete mp_ui->lv_parents->model (); } - lv_parents->setModel (new lay::CellTreeModel (lv_parents, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Parents, model->cell (lv_cells->selectionModel ()->currentIndex ()))); + mp_ui->lv_parents->setModel (new lay::CellTreeModel (mp_ui->lv_parents, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Parents, model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()))); } @@ -212,13 +217,13 @@ CellSelectionForm::update_children_list () if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - if (lv_children->model ()) { - delete lv_children->model (); + if (mp_ui->lv_children->model ()) { + delete mp_ui->lv_children->model (); } - lv_children->setModel (new lay::CellTreeModel (lv_children, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Children, model->cell (lv_cells->selectionModel ()->currentIndex ()))); + mp_ui->lv_children->setModel (new lay::CellTreeModel (mp_ui->lv_children, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Children, model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()))); } @@ -246,12 +251,12 @@ CellSelectionForm::commit_cv () // update the cell view if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } - const db::Cell *cell = model->cell (lv_cells->selectionModel ()->currentIndex ()); + const db::Cell *cell = model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()); if (cell) { m_cellviews [m_current_cv].set_cell (cell->cell_index ()); } @@ -297,12 +302,12 @@ CellSelectionForm::apply_clicked() // select the current cell but don't make it the new top. if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } - const db::Cell *cell = model->cell (lv_cells->selectionModel ()->currentIndex ()); + const db::Cell *cell = model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()); lay::CellView cv (m_cellviews [m_current_cv]); cv.set_cell (cell->cell_index ()); @@ -318,9 +323,9 @@ CellSelectionForm::cell_changed (const QModelIndex ¤t, const QModelIndex & m_name_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - le_cell_name->setText (tl::to_qstring (model->cell_name (current))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (current))); model->clear_locate (); } @@ -335,7 +340,7 @@ CellSelectionForm::cell_changed (const QModelIndex ¤t, const QModelIndex & void CellSelectionForm::set_child () { - child_changed (lv_children->selectionModel ()->currentIndex ()); + child_changed (mp_ui->lv_children->selectionModel ()->currentIndex ()); } void @@ -343,9 +348,9 @@ CellSelectionForm::child_changed(const QModelIndex ¤t) { if (m_children_cb_enabled && current.isValid ()) { if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_children->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_children->model ()); if (model) { - select_entry (model->cell_index (lv_children->selectionModel ()->currentIndex ())); + select_entry (model->cell_index (mp_ui->lv_children->selectionModel ()->currentIndex ())); } } } @@ -354,7 +359,7 @@ CellSelectionForm::child_changed(const QModelIndex ¤t) void CellSelectionForm::set_parent () { - parent_changed (lv_parents->selectionModel ()->currentIndex ()); + parent_changed (mp_ui->lv_parents->selectionModel ()->currentIndex ()); } void @@ -362,9 +367,9 @@ CellSelectionForm::parent_changed(const QModelIndex ¤t) { if (m_parents_cb_enabled && current.isValid ()) { if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_parents->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_parents->model ()); if (model) { - select_entry (model->cell_index (lv_parents->selectionModel ()->currentIndex ())); + select_entry (model->cell_index (mp_ui->lv_parents->selectionModel ()->currentIndex ())); } } } @@ -375,7 +380,7 @@ CellSelectionForm::select_entry (lay::CellView::cell_index_type ci) { m_cells_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -393,12 +398,12 @@ CellSelectionForm::select_entry (lay::CellView::cell_index_type ci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -421,7 +426,7 @@ CellSelectionForm::update_all () void CellSelectionForm::find_next_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -430,8 +435,8 @@ CellSelectionForm::find_next_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); update_children_list (); update_parents_list (); m_cells_cb_enabled = true; @@ -442,7 +447,7 @@ CellSelectionForm::find_next_clicked () void CellSelectionForm::find_prev_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -451,8 +456,8 @@ CellSelectionForm::find_prev_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); update_children_list (); update_parents_list (); m_cells_cb_enabled = true; @@ -465,9 +470,9 @@ CellSelectionForm::name_changed () { if (m_name_cb_enabled) { - QString s = le_cell_name->text (); + QString s = mp_ui->le_cell_name->text (); - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -480,9 +485,9 @@ CellSelectionForm::name_changed () } m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); if (mi.isValid ()) { - lv_cells->scrollTo (mi); + mp_ui->lv_cells->scrollTo (mi); } update_children_list (); update_parents_list (); @@ -494,7 +499,7 @@ CellSelectionForm::name_changed () void CellSelectionForm::show_cell () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -502,7 +507,7 @@ CellSelectionForm::show_cell () return; } - QModelIndexList sel = lv_cells->selectionModel ()->selectedIndexes (); + QModelIndexList sel = mp_ui->lv_cells->selectionModel ()->selectedIndexes (); for (QModelIndexList::const_iterator s = sel.begin (); s != sel.end (); ++s) { db::cell_index_type ci = model->cell (*s)->cell_index (); mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Show cells"))); @@ -516,7 +521,7 @@ CellSelectionForm::show_cell () void CellSelectionForm::hide_cell () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -524,7 +529,7 @@ CellSelectionForm::hide_cell () return; } - QModelIndexList sel = lv_cells->selectionModel ()->selectedIndexes (); + QModelIndexList sel = mp_ui->lv_cells->selectionModel ()->selectedIndexes (); for (QModelIndexList::const_iterator s = sel.begin (); s != sel.end (); ++s) { db::cell_index_type ci = model->cell (*s)->cell_index (); mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Hide cells"))); @@ -538,7 +543,7 @@ CellSelectionForm::hide_cell () // ------------------------------------------------------------ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells, bool top_cells_only) - : QDialog (parent), Ui::LibraryCellSelectionForm (), + : QDialog (parent), mp_lib (0), mp_layout (layout), m_name_cb_enabled (true), m_cells_cb_enabled (true), @@ -548,32 +553,33 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout m_all_cells (all_cells), m_top_cells_only (top_cells_only) { + mp_ui = new Ui::LibraryCellSelectionForm (); setObjectName (QString::fromUtf8 (name)); - Ui::LibraryCellSelectionForm::setupUi (this); + mp_ui->setupUi (this); // no library selection - lib_label->hide (); - lib_cb->hide (); + mp_ui->lib_label->hide (); + mp_ui->lib_cb->hide (); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - ok_button->setText (QObject::tr ("Ok")); - cancel_button->setText (QObject::tr ("Cancel")); + mp_ui->ok_button->setText (QObject::tr ("Ok")); + mp_ui->cancel_button->setText (QObject::tr ("Cancel")); update_cell_list (); } LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells, bool top_cells_only) - : QDialog (parent), Ui::LibraryCellSelectionForm (), + : QDialog (parent), mp_lib (0), mp_layout (0), m_name_cb_enabled (true), m_cells_cb_enabled (true), @@ -583,28 +589,30 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char m_all_cells (all_cells), m_top_cells_only (top_cells_only) { + mp_ui = new Ui::LibraryCellSelectionForm (); + mp_lib = db::LibraryManager::instance ().lib_ptr_by_name ("Basic"); mp_layout = &mp_lib->layout (); setObjectName (QString::fromUtf8 (name)); - Ui::LibraryCellSelectionForm::setupUi (this); + mp_ui->setupUi (this); - lib_cb->set_current_library (mp_lib); + mp_ui->lib_cb->set_current_library (mp_lib); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (lib_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(lib_changed())); - connect (cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->lib_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(lib_changed())); + connect (mp_ui->cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - ok_button->setText (QObject::tr ("Ok")); - cancel_button->setText (QObject::tr ("Cancel")); + mp_ui->ok_button->setText (QObject::tr ("Ok")); + mp_ui->cancel_button->setText (QObject::tr ("Cancel")); update_cell_list (); } @@ -612,14 +620,14 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char void LibraryCellSelectionForm::show_all_changed () { - m_all_cells = cb_show_all_cells->isChecked (); + m_all_cells = mp_ui->cb_show_all_cells->isChecked (); update_cell_list (); } void LibraryCellSelectionForm::lib_changed () { - mp_lib = lib_cb->current_library (); + mp_lib = mp_ui->lib_cb->current_library (); mp_layout = mp_lib ? &mp_lib->layout () : 0; update_cell_list (); } @@ -674,11 +682,11 @@ END_PROTECTED void LibraryCellSelectionForm::update_cell_list () { - if (lv_cells->model ()) { - delete lv_cells->model (); + if (mp_ui->lv_cells->model ()) { + delete mp_ui->lv_cells->model (); } - cb_show_all_cells->setChecked (m_all_cells); + mp_ui->cb_show_all_cells->setChecked (m_all_cells); if (mp_layout) { @@ -691,11 +699,11 @@ LibraryCellSelectionForm::update_cell_list () } // TODO: get rid of that const_cast - lay::CellTreeModel *model = new lay::CellTreeModel (lv_cells, const_cast (mp_layout), flags); + lay::CellTreeModel *model = new lay::CellTreeModel (mp_ui->lv_cells, const_cast (mp_layout), flags); - lv_cells->setModel (model); + mp_ui->lv_cells->setModel (model); // connect can only happen after setModel() - connect (lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); + connect (mp_ui->lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); select_entry (std::numeric_limits::max ()); @@ -709,7 +717,7 @@ LibraryCellSelectionForm::cell_changed (const QModelIndex ¤t, const QModel m_name_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { m_is_pcell = model->is_pcell (current); if (m_is_pcell) { @@ -717,7 +725,7 @@ LibraryCellSelectionForm::cell_changed (const QModelIndex ¤t, const QModel } else { m_cell_index = model->cell_index (current); } - le_cell_name->setText (tl::to_qstring (model->cell_name (current))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (current))); model->clear_locate (); } else { m_cell_index = -1; @@ -737,7 +745,7 @@ LibraryCellSelectionForm::select_pcell_entry (db::pcell_id_type pci) m_pcell_id = pci; m_is_pcell = true; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -755,12 +763,12 @@ LibraryCellSelectionForm::select_pcell_entry (db::pcell_id_type pci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -776,7 +784,7 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) m_cell_index = ci; m_is_pcell = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -794,12 +802,12 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -811,7 +819,7 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) void LibraryCellSelectionForm::find_next_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -820,8 +828,8 @@ LibraryCellSelectionForm::find_next_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_is_pcell = model->is_pcell (mi); if (m_is_pcell) { @@ -844,7 +852,7 @@ LibraryCellSelectionForm::name_changed (const QString &s) { if (m_name_cb_enabled) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -853,8 +861,8 @@ LibraryCellSelectionForm::name_changed (const QString &s) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_is_pcell = model->is_pcell (mi); if (m_is_pcell) { @@ -876,4 +884,4 @@ LibraryCellSelectionForm::name_changed (const QString &s) } - +#endif diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/layui/layui/layCellSelectionForm.h similarity index 90% rename from src/laybasic/laybasic/layCellSelectionForm.h rename to src/layui/layui/layCellSelectionForm.h index 3d6f8c42b..15c00dc2d 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/layui/layui/layCellSelectionForm.h @@ -20,20 +20,28 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layCellSelectionForm #define HDR_layCellSelectionForm -#include - -#include "ui_CellSelectionForm.h" -#include "ui_LibraryCellSelectionForm.h" +#include "layuiCommon.h" #include "layCellView.h" #include "tlDeferredExecution.h" #include #include +#include +#include +#include + +namespace Ui +{ + class CellSelectionForm; + class LibraryCellSelectionForm; +} + namespace lay { @@ -43,13 +51,13 @@ class LayoutView; /** * @brief A form to select a cell and a cell view index */ -class LAYBASIC_PUBLIC CellSelectionForm - : public QDialog, private Ui::CellSelectionForm +class LAYUI_PUBLIC CellSelectionForm + : public QDialog { Q_OBJECT public: - CellSelectionForm (QWidget *parent, lay::LayoutView *view, const char *name, bool simple_mode = false); + CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode = false); /** * @brief Obtain the selected cellview's index (with changes) @@ -76,7 +84,8 @@ public slots: void find_prev_clicked(); private: - lay::LayoutView *mp_view; + Ui::CellSelectionForm *mp_ui; + lay::LayoutViewBase *mp_view; std::vector m_cellviews; int m_current_cv; bool m_name_cb_enabled; @@ -102,8 +111,8 @@ private: /** * @brief A form to select a cell from a library */ -class LAYBASIC_PUBLIC LibraryCellSelectionForm - : public QDialog, private Ui::LibraryCellSelectionForm +class LAYUI_PUBLIC LibraryCellSelectionForm + : public QDialog { Q_OBJECT @@ -181,6 +190,7 @@ public slots: void show_all_changed (); private: + Ui::LibraryCellSelectionForm *mp_ui; db::Library *mp_lib; const db::Layout *mp_layout; bool m_name_cb_enabled; @@ -201,3 +211,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/layui/layui/layCellTreeModel.cc similarity index 98% rename from src/laybasic/laybasic/layCellTreeModel.cc rename to src/layui/layui/layCellTreeModel.cc index d8e4ca573..6568a2c3c 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/layui/layui/layCellTreeModel.cc @@ -20,9 +20,11 @@ */ +#if defined(HAVE_QT) #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" +#include "layDragDropData.h" #include "tlGlobPattern.h" #include "dbPCellHeader.h" #include "dbPCellVariant.h" @@ -303,7 +305,7 @@ CellTreeItem::by_area_equal_than (const CellTreeItem *b) const // valid ("under construction"). In this case, the model will return defaults or void // objects. -CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) : QAbstractItemModel (parent), m_flags (flags), m_sorting (sorting), @@ -379,7 +381,7 @@ CellTreeModel::~CellTreeModel () } void -CellTreeModel::configure (lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::configure (lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { db::Layout *layout = & view->cellview (cv_index)->layout (); do_configure (layout, 0, view, cv_index, flags, base, sorting); @@ -398,7 +400,7 @@ CellTreeModel::configure (db::Library *library, unsigned int flags, const db::Ce } void -CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { bool flat = ((flags & Flat) != 0) && ((flags & TopCells) == 0); @@ -1295,3 +1297,6 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive, } } // namespace lay + +#endif + diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/layui/layui/layCellTreeModel.h similarity index 94% rename from src/laybasic/laybasic/layCellTreeModel.h rename to src/layui/layui/layCellTreeModel.h index 2e8569e55..0ddf88dce 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/layui/layui/layCellTreeModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layCellTreeModel #define HDR_layCellTreeModel @@ -45,7 +46,7 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; class CellTreeItem; /** @@ -85,7 +86,7 @@ public: * If flags "Children" or "Parents" are given, "base" must be set to the cell of which * the children or parents should be derived. */ - CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Constructor @@ -120,7 +121,7 @@ public: /** * @brief Reconfigures the model with a LayoutView */ - void configure (lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + void configure (LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Reconfigures the model with a pure Layout @@ -257,7 +258,7 @@ private: unsigned int m_flags; Sorting m_sorting; QWidget *mp_parent; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::Layout *mp_layout; db::Library *mp_library; int m_cv_index; @@ -271,7 +272,7 @@ private: void build_top_level (); void clear_top_level (); bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item); - void do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); + void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); }; /** @@ -349,3 +350,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layConfigurationDialog.cc b/src/layui/layui/layConfigurationDialog.cc similarity index 98% rename from src/laybasic/laybasic/layConfigurationDialog.cc rename to src/layui/layui/layConfigurationDialog.cc index 63d9edeb5..46de6b29f 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.cc +++ b/src/layui/layui/layConfigurationDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -28,6 +29,7 @@ #include "ui_ConfigurationDialog.h" #include "layConfigurationDialog.h" #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layDispatcher.h" #include "tlLog.h" @@ -143,3 +145,4 @@ ConfigurationDialog::ok_clicked () } +#endif diff --git a/src/laybasic/laybasic/layConfigurationDialog.h b/src/layui/layui/layConfigurationDialog.h similarity index 94% rename from src/laybasic/laybasic/layConfigurationDialog.h rename to src/layui/layui/layConfigurationDialog.h index 2e800ca47..13e0a86c5 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.h +++ b/src/layui/layui/layConfigurationDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layConfigurationDialog #define HDR_layConfigurationDialog @@ -42,7 +43,7 @@ class Dispatcher; class ConfigPage; class PluginDeclaration; -class LAYBASIC_PUBLIC ConfigurationDialog +class LAYUI_PUBLIC ConfigurationDialog : public QDialog { Q_OBJECT @@ -69,3 +70,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layDialogs.cc b/src/layui/layui/layDialogs.cc similarity index 99% rename from src/laybasic/laybasic/layDialogs.cc rename to src/layui/layui/layDialogs.cc index 0c89906fc..5128640d3 100644 --- a/src/laybasic/laybasic/layDialogs.cc +++ b/src/layui/layui/layDialogs.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layDialogs.h" @@ -32,8 +33,7 @@ #include "layLayerProperties.h" #include "layFileDialog.h" -#include "layLayoutView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellTreeModel.h" #include "layQtTools.h" #include "layGenericSyntaxHighlighter.h" @@ -823,7 +823,7 @@ DuplicateLayerDialog::cv_changed (int) } bool -DuplicateLayerDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, int &hier_mode, bool &clear_before) +DuplicateLayerDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, int &hier_mode, bool &clear_before) { mp_view = view; @@ -1179,7 +1179,7 @@ UserPropertiesForm::set_properties (const db::PropertiesRepository::properties_s } bool -UserPropertiesForm::show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id) +UserPropertiesForm::show (LayoutViewBase *view, unsigned int cv_index, db::properties_id_type &prop_id) { bool ret = false; @@ -1411,3 +1411,4 @@ END_PROTECTED } +#endif diff --git a/src/laybasic/laybasic/layDialogs.h b/src/layui/layui/layDialogs.h similarity index 88% rename from src/laybasic/laybasic/layDialogs.h rename to src/layui/layui/layDialogs.h index c338e6a48..b78de3731 100644 --- a/src/laybasic/laybasic/layDialogs.h +++ b/src/layui/layui/layDialogs.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layDialogs #define HDR_layDialogs @@ -28,7 +29,7 @@ #include "dbVector.h" #include "dbTypes.h" #include "dbPropertiesRepository.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -71,12 +72,12 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; /** * @brief The layer source dialog */ -class LAYBASIC_PUBLIC LayerSourceDialog +class LAYUI_PUBLIC LayerSourceDialog : public QDialog { Q_OBJECT @@ -94,7 +95,7 @@ private: /** * @brief The new cell properties dialog */ -class LAYBASIC_PUBLIC NewCellPropertiesDialog +class LAYUI_PUBLIC NewCellPropertiesDialog : public QDialog { Q_OBJECT @@ -115,7 +116,7 @@ private: /** * @brief The new layer properties dialog */ -class LAYBASIC_PUBLIC NewLayerPropertiesDialog +class LAYUI_PUBLIC NewLayerPropertiesDialog : public QDialog { Q_OBJECT @@ -137,7 +138,7 @@ private: /** * @brief The move options dialog */ -class LAYBASIC_PUBLIC MoveOptionsDialog +class LAYUI_PUBLIC MoveOptionsDialog : public QDialog { Q_OBJECT @@ -157,7 +158,7 @@ private: /** * @brief The move "to" options dialog */ -class LAYBASIC_PUBLIC MoveToOptionsDialog +class LAYUI_PUBLIC MoveToOptionsDialog : public QDialog { Q_OBJECT @@ -180,7 +181,7 @@ private: /** * @brief The rename cell options dialog */ -class LAYBASIC_PUBLIC RenameCellDialog +class LAYUI_PUBLIC RenameCellDialog : public QDialog { Q_OBJECT @@ -201,7 +202,7 @@ private: /** * @brief The replace cell options dialog */ -class LAYBASIC_PUBLIC ReplaceCellOptionsDialog +class LAYUI_PUBLIC ReplaceCellOptionsDialog : public QDialog { Q_OBJECT @@ -227,7 +228,7 @@ private: /** * @brief The copy cell options dialog */ -class LAYBASIC_PUBLIC CopyCellModeDialog +class LAYUI_PUBLIC CopyCellModeDialog : public QDialog { Q_OBJECT @@ -250,7 +251,7 @@ private: /** * @brief The delete cell options dialog */ -class LAYBASIC_PUBLIC DeleteCellModeDialog +class LAYUI_PUBLIC DeleteCellModeDialog : public QDialog { Q_OBJECT @@ -273,7 +274,7 @@ private: /** * @brief The delete cell options dialog */ -class LAYBASIC_PUBLIC ClearLayerModeDialog +class LAYUI_PUBLIC ClearLayerModeDialog : public QDialog { Q_OBJECT @@ -296,7 +297,7 @@ private: /** * @brief The open layout mode dialog */ -class LAYBASIC_PUBLIC OpenLayoutModeDialog +class LAYUI_PUBLIC OpenLayoutModeDialog : public QDialog { Q_OBJECT @@ -319,7 +320,7 @@ private: /** * @brief The new layout properties dialog */ -class LAYBASIC_PUBLIC NewLayoutPropertiesDialog +class LAYUI_PUBLIC NewLayoutPropertiesDialog : public QDialog { Q_OBJECT @@ -342,7 +343,7 @@ private: /** * @brief The duplicate layer operation options */ -class LAYBASIC_PUBLIC DuplicateLayerDialog +class LAYUI_PUBLIC DuplicateLayerDialog : public QDialog { Q_OBJECT @@ -351,7 +352,7 @@ public: DuplicateLayerDialog (QWidget *parent); virtual ~DuplicateLayerDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, int &hier_mode, bool &clear_before); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, int &hier_mode, bool &clear_before); public slots: void cv_changed (int); @@ -360,13 +361,13 @@ private: virtual void accept (); Ui::DuplicateLayerDialog *mp_ui; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** * @brief A data structure holding the options for the "align cell" dialog */ -struct LAYBASIC_PUBLIC AlignCellOptions +struct LAYUI_PUBLIC AlignCellOptions { AlignCellOptions () : mode_x (-1), mode_y (-1), xpos (0.0), ypos (0.0), visible_only (false), adjust_parents (true) @@ -381,7 +382,7 @@ struct LAYBASIC_PUBLIC AlignCellOptions /** * @brief The merge operation options */ -class LAYBASIC_PUBLIC AlignCellOptionsDialog +class LAYUI_PUBLIC AlignCellOptionsDialog : public QDialog { Q_OBJECT @@ -403,7 +404,7 @@ private: /** * @brief Options dialog for the "flatten instances" function */ -class LAYBASIC_PUBLIC FlattenInstOptionsDialog +class LAYUI_PUBLIC FlattenInstOptionsDialog : public QDialog { public: @@ -419,7 +420,7 @@ private: /** * @brief The user properties report form */ -class LAYBASIC_PUBLIC UserPropertiesForm +class LAYUI_PUBLIC UserPropertiesForm : public QDialog { Q_OBJECT @@ -428,7 +429,7 @@ public: UserPropertiesForm (QWidget *parent); virtual ~UserPropertiesForm (); - bool show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id); + bool show (lay::LayoutViewBase *view, unsigned int cv_index, db::properties_id_type &prop_id); public slots: void add (); @@ -451,7 +452,7 @@ private: /** * @brief The user properties report form */ -class LAYBASIC_PUBLIC UserPropertiesEditForm +class LAYUI_PUBLIC UserPropertiesEditForm : public QDialog { public: @@ -468,4 +469,4 @@ public: #endif - +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.cc b/src/layui/layui/layEditLineStyleWidget.cc similarity index 99% rename from src/laybasic/laybasic/layEditLineStyleWidget.cc rename to src/layui/layui/layEditLineStyleWidget.cc index ea6fdf748..0f119b33a 100644 --- a/src/laybasic/laybasic/layEditLineStyleWidget.cc +++ b/src/layui/layui/layEditLineStyleWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layEditLineStyleWidget.h" @@ -422,3 +423,4 @@ EditLineStyleWidget::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.h b/src/layui/layui/layEditLineStyleWidget.h similarity index 97% rename from src/laybasic/laybasic/layEditLineStyleWidget.h rename to src/layui/layui/layEditLineStyleWidget.h index 1deaef97f..14f369c62 100644 --- a/src/laybasic/laybasic/layEditLineStyleWidget.h +++ b/src/layui/layui/layEditLineStyleWidget.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditLineStyleWidget #define HDR_layEditLineStyleWidget @@ -100,3 +101,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditLineStylesForm.cc b/src/layui/layui/layEditLineStylesForm.cc similarity index 98% rename from src/laybasic/laybasic/layEditLineStylesForm.cc rename to src/layui/layui/layEditLineStylesForm.cc index f8e804b83..ece6f7bca 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.cc +++ b/src/layui/layui/layEditLineStylesForm.cc @@ -20,12 +20,12 @@ */ - +#if defined(HAVE_QT) #include "layEditLineStylesForm.h" #include "ui_EditLineStylesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "tlString.h" @@ -50,8 +50,8 @@ struct CurrentStyleOp int prev_index, new_index; }; -EditLineStylesForm::EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles) - : QDialog (view), db::Object (0), +EditLineStylesForm::EditLineStylesForm (lay::LayoutViewBase *view, const lay::LineStyles &styles) + : QDialog (view->widget ()), db::Object (0), m_selected (-1), m_styles (styles), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; @@ -556,3 +556,4 @@ EditLineStylesForm::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditLineStylesForm.h b/src/layui/layui/layEditLineStylesForm.h similarity index 92% rename from src/laybasic/laybasic/layEditLineStylesForm.h rename to src/layui/layui/layEditLineStylesForm.h index 25cc35d9c..1eab57563 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.h +++ b/src/layui/layui/layEditLineStylesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditLineStylesForm #define HDR_layEditLineStylesForm @@ -39,7 +40,7 @@ namespace Ui namespace lay { -class LayoutView; +class LayoutViewBase; class EditLineStylesForm : public QDialog, public db::Object @@ -47,7 +48,7 @@ class EditLineStylesForm Q_OBJECT public: - EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles); + EditLineStylesForm (lay::LayoutViewBase *view, const lay::LineStyles &styles); ~EditLineStylesForm (); // ... @@ -99,7 +100,7 @@ private: int m_selected; lay::LineStyles m_styles; db::Manager m_manager; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_selection_changed_enabled; }; @@ -107,3 +108,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditStippleWidget.cc b/src/layui/layui/layEditStippleWidget.cc similarity index 99% rename from src/laybasic/laybasic/layEditStippleWidget.cc rename to src/layui/layui/layEditStippleWidget.cc index 1bb613e2e..a87b9870a 100644 --- a/src/laybasic/laybasic/layEditStippleWidget.cc +++ b/src/layui/layui/layEditStippleWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layEditStippleWidget.h" @@ -529,3 +530,4 @@ EditStippleWidget::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditStippleWidget.h b/src/layui/layui/layEditStippleWidget.h similarity index 98% rename from src/laybasic/laybasic/layEditStippleWidget.h rename to src/layui/layui/layEditStippleWidget.h index e94d4228a..b3944f3d4 100644 --- a/src/laybasic/laybasic/layEditStippleWidget.h +++ b/src/layui/layui/layEditStippleWidget.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditStippleWidget #define HDR_layEditStippleWidget @@ -109,3 +110,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditStipplesForm.cc b/src/layui/layui/layEditStipplesForm.cc similarity index 98% rename from src/laybasic/laybasic/layEditStipplesForm.cc rename to src/layui/layui/layEditStipplesForm.cc index 19cc4616d..eef978271 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.cc +++ b/src/layui/layui/layEditStipplesForm.cc @@ -20,12 +20,12 @@ */ - +#if defined(HAVE_QT) #include "layEditStipplesForm.h" #include "ui_EditStipplesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "tlString.h" @@ -50,8 +50,8 @@ struct CurrentPatternOp int prev_index, new_index; }; -EditStipplesForm::EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern) - : QDialog (view), db::Object (0), +EditStipplesForm::EditStipplesForm (lay::LayoutViewBase *view, const lay::DitherPattern &pattern) + : QDialog (view->widget ()), db::Object (0), m_selected (-1), m_pattern (pattern), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; @@ -623,3 +623,4 @@ EditStipplesForm::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditStipplesForm.h b/src/layui/layui/layEditStipplesForm.h similarity index 92% rename from src/laybasic/laybasic/layEditStipplesForm.h rename to src/layui/layui/layEditStipplesForm.h index 5fe4fc0f0..9d3e55cd0 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.h +++ b/src/layui/layui/layEditStipplesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditStipplesForm #define HDR_layEditStipplesForm @@ -39,7 +40,7 @@ namespace Ui namespace lay { -class LayoutView; +class LayoutViewBase; class EditStipplesForm : public QDialog, public db::Object @@ -47,7 +48,7 @@ class EditStipplesForm Q_OBJECT public: - EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern); + EditStipplesForm (lay::LayoutViewBase *view, const lay::DitherPattern &pattern); ~EditStipplesForm (); // ... @@ -103,7 +104,7 @@ private: int m_selected; lay::DitherPattern m_pattern; db::Manager m_manager; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_selection_changed_enabled; }; @@ -111,3 +112,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.cc b/src/layui/layui/layEditorOptionsFrame.cc similarity index 94% rename from src/laybasic/laybasic/layEditorOptionsFrame.cc rename to src/layui/layui/layEditorOptionsFrame.cc index dd593f9e4..9061e74cc 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.cc +++ b/src/layui/layui/layEditorOptionsFrame.cc @@ -20,11 +20,13 @@ */ +#if defined(HAVE_QT) + #include "layEditorOptionsFrame.h" #include "layEditorOptionsPage.h" #include "layEditorOptionsPages.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include @@ -47,7 +49,7 @@ EditorOptionsFrame::~EditorOptionsFrame () } void -EditorOptionsFrame::populate (LayoutView *view) +EditorOptionsFrame::populate (LayoutViewBase *view) { std::vector prop_dialog_pages; for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { @@ -68,3 +70,5 @@ EditorOptionsFrame::populate (LayoutView *view) } } + +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.h b/src/layui/layui/layEditorOptionsFrame.h similarity index 86% rename from src/laybasic/laybasic/layEditorOptionsFrame.h rename to src/layui/layui/layEditorOptionsFrame.h index 6ccadf986..e9ccb73c9 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.h +++ b/src/layui/layui/layEditorOptionsFrame.h @@ -20,26 +20,28 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layEditorOptionsFrame #define HDR_layEditorOptionsFrame -#include "laybasicCommon.h" +#include "layuiCommon.h" #include namespace lay { class EditorOptionsPages; -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC EditorOptionsFrame +class LAYUI_PUBLIC EditorOptionsFrame : public QFrame { public: EditorOptionsFrame (QWidget *parent); virtual ~EditorOptionsFrame (); - void populate (LayoutView *view); + void populate (lay::LayoutViewBase *view); EditorOptionsPages *pages_widget () const { @@ -53,3 +55,5 @@ public: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsPage.cc b/src/layui/layui/layEditorOptionsPage.cc similarity index 93% rename from src/laybasic/laybasic/layEditorOptionsPage.cc rename to src/layui/layui/layEditorOptionsPage.cc index f2f893da0..0b093e259 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.cc +++ b/src/layui/layui/layEditorOptionsPage.cc @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "layEditorOptionsPage.h" #include "layEditorOptionsPages.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { @@ -32,7 +33,7 @@ namespace lay // ------------------------------------------------------------------ // EditorOptionsPage implementation -EditorOptionsPage::EditorOptionsPage (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsPage::EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : QWidget (0), mp_owner (0), m_active (true), mp_plugin_declaration (0), mp_dispatcher (dispatcher), mp_view (view) { attach_events (); @@ -88,3 +89,5 @@ EditorOptionsPage::activate (bool active) } } + +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsPage.h b/src/layui/layui/layEditorOptionsPage.h similarity index 88% rename from src/laybasic/laybasic/layEditorOptionsPage.h rename to src/layui/layui/layEditorOptionsPage.h index fb752ffaa..51486fae9 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.h +++ b/src/layui/layui/layEditorOptionsPage.h @@ -20,10 +20,12 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layEditorOptionsPage #define HDR_layEditorOptionsPage -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlObject.h" @@ -34,7 +36,7 @@ namespace lay class PluginDeclaration; class Dispatcher; -class LayoutView; +class LayoutViewBase; class Plugin; class CellView; class EditorOptionsPages; @@ -42,13 +44,13 @@ class EditorOptionsPages; /** * @brief The base class for a object properties page */ -class LAYBASIC_PUBLIC EditorOptionsPage +class LAYUI_PUBLIC EditorOptionsPage : public QWidget, public tl::Object { Q_OBJECT public: - EditorOptionsPage (lay::LayoutView *view, lay::Dispatcher *dispatcher); + EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher); virtual ~EditorOptionsPage (); virtual std::string title () const = 0; @@ -76,7 +78,7 @@ protected: return mp_dispatcher; } - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -89,7 +91,7 @@ private: bool m_active; const lay::PluginDeclaration *mp_plugin_declaration; lay::Dispatcher *mp_dispatcher; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; void on_active_cellview_changed (); void on_technology_changed (); @@ -99,3 +101,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsPages.cc b/src/layui/layui/layEditorOptionsPages.cc similarity index 98% rename from src/laybasic/laybasic/layEditorOptionsPages.cc rename to src/layui/layui/layEditorOptionsPages.cc index a17d518b8..6dc7cc653 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.cc +++ b/src/layui/layui/layEditorOptionsPages.cc @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "layEditorOptionsPages.h" #include "tlExceptions.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" #include @@ -214,3 +215,4 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le } +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsPages.h b/src/layui/layui/layEditorOptionsPages.h similarity index 94% rename from src/laybasic/laybasic/layEditorOptionsPages.h rename to src/layui/layui/layEditorOptionsPages.h index a65e3c100..8e40676d6 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.h +++ b/src/layui/layui/layEditorOptionsPages.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditorOptionsPages #define HDR_layEditorOptionsPages -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layEditorOptionsPage.h" #include @@ -46,7 +47,7 @@ class Plugin; /** * @brief The object properties dialog */ -class LAYBASIC_PUBLIC EditorOptionsPages +class LAYUI_PUBLIC EditorOptionsPages : public QFrame { Q_OBJECT @@ -83,3 +84,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layFileDialog.cc b/src/layui/layui/layFileDialog.cc similarity index 99% rename from src/laybasic/laybasic/layFileDialog.cc rename to src/layui/layui/layFileDialog.cc index 79c04addd..9630fd471 100644 --- a/src/laybasic/laybasic/layFileDialog.cc +++ b/src/layui/layui/layFileDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -303,3 +304,4 @@ FileDialog::get_save (std::string &fp, const std::string &title) } // namespace lay +#endif diff --git a/src/laybasic/laybasic/layFileDialog.h b/src/layui/layui/layFileDialog.h similarity index 96% rename from src/laybasic/laybasic/layFileDialog.h rename to src/layui/layui/layFileDialog.h index 54f320265..cb1bdb635 100644 --- a/src/laybasic/laybasic/layFileDialog.h +++ b/src/layui/layui/layFileDialog.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layFileDialog #define HDR_layFileDialog -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -44,7 +45,7 @@ namespace lay * we need to use the static functions since these use the * system dialogs. */ -class LAYBASIC_PUBLIC FileDialog +class LAYUI_PUBLIC FileDialog : public QObject { public: @@ -98,3 +99,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc b/src/layui/layui/layGenericSyntaxHighlighter.cc similarity index 99% rename from src/laybasic/laybasic/layGenericSyntaxHighlighter.cc rename to src/layui/layui/layGenericSyntaxHighlighter.cc index 4aaa01596..1705d86bf 100644 --- a/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc +++ b/src/layui/layui/layGenericSyntaxHighlighter.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layGenericSyntaxHighlighter.h" @@ -1726,4 +1727,4 @@ GenericSyntaxHighlighter::highlightBlock(const QString &text) } - +#endif diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h b/src/layui/layui/layGenericSyntaxHighlighter.h similarity index 96% rename from src/laybasic/laybasic/layGenericSyntaxHighlighter.h rename to src/layui/layui/layGenericSyntaxHighlighter.h index c73d0c22d..dea49a5a2 100644 --- a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h +++ b/src/layui/layui/layGenericSyntaxHighlighter.h @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layGenericSyntaxHighlighter #define HDR_layGenericSyntaxHighlighter #include "tlString.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -41,7 +42,7 @@ namespace lay /** * @brief Specifies one element in the text block's user data */ -struct LAYBASIC_PUBLIC SyntaxHighlighterElement +struct LAYUI_PUBLIC SyntaxHighlighterElement { public: /** @@ -62,7 +63,7 @@ public: * * The user data will contain useful data for bracket detection and other things */ -class LAYBASIC_PUBLIC SyntaxHighlighterUserData +class LAYUI_PUBLIC SyntaxHighlighterUserData : public QTextBlockUserData { public: @@ -93,7 +94,7 @@ public: * Rule implementations must implement this base class in order to plug into the * generic syntax highlighter framework. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleBase +class LAYUI_PUBLIC GenericSyntaxHighlighterRuleBase { public: /** @@ -132,7 +133,7 @@ public: /** * @brief A specialization of GenericSyntaxHighlighterRuleBase which looks for a choice of strings */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleStringList +class LAYUI_PUBLIC GenericSyntaxHighlighterRuleStringList : public GenericSyntaxHighlighterRuleBase { public: @@ -153,7 +154,7 @@ private: * * This object will forward the match request to the actual implementation. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRule +class LAYUI_PUBLIC GenericSyntaxHighlighterRule { public: /** @@ -320,7 +321,7 @@ private: * Special context ID's are 0 (#stay), -n (#pop n times). * A context is associated with an attribute, which is given by an integer ID. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterContext +class LAYUI_PUBLIC GenericSyntaxHighlighterContext { public: enum { @@ -479,7 +480,7 @@ private: /** * @brief A collection of (named) contexts */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterContexts +class LAYUI_PUBLIC GenericSyntaxHighlighterContexts { public: GenericSyntaxHighlighterContexts (); @@ -580,7 +581,7 @@ enum def_style { /** * @brief A collection of attributes */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterAttributes +class LAYUI_PUBLIC GenericSyntaxHighlighterAttributes { public: typedef std::map::const_iterator const_iterator; @@ -673,7 +674,7 @@ private: /** * @brief The parser's state */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterState +class LAYUI_PUBLIC GenericSyntaxHighlighterState { public: GenericSyntaxHighlighterState (const GenericSyntaxHighlighterContexts *contexts); @@ -711,7 +712,7 @@ private: /** * @brief A generic syntax highlighter using "Kate"'s syntax highlight scripts */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighter +class LAYUI_PUBLIC GenericSyntaxHighlighter : public QSyntaxHighlighter { public: @@ -735,3 +736,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/layui/layui/layHierarchyControlPanel.cc similarity index 98% rename from src/laybasic/laybasic/layHierarchyControlPanel.cc rename to src/layui/layui/layHierarchyControlPanel.cc index 1f21ae24c..304126ba0 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/layui/layui/layHierarchyControlPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -45,7 +46,7 @@ #include "layBusy.h" #include "layHierarchyControlPanel.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "layQtTools.h" #include "layDialogs.h" @@ -208,7 +209,7 @@ HCPCellTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -HierarchyControlPanel::HierarchyControlPanel (lay::LayoutView *view, QWidget *parent, const char *name) +HierarchyControlPanel::HierarchyControlPanel (lay::LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), mp_view (view), @@ -655,23 +656,23 @@ HierarchyControlPanel::current_cell (int cv_index, HierarchyControlPanel::cell_p } void -HierarchyControlPanel::set_background_color (QColor c) +HierarchyControlPanel::set_background_color (lay::Color c) { m_background_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); (*f)->setPalette (pl); } } void -HierarchyControlPanel::set_text_color (QColor c) +HierarchyControlPanel::set_text_color (lay::Color c) { m_text_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); (*f)->setPalette (pl); } } @@ -895,11 +896,11 @@ HierarchyControlPanel::do_update_content (int cv_index) cell_list->setUniformRowHeights (true); pl = cell_list->palette (); - if (m_text_color.isValid ()) { - pl.setColor (QPalette::Text, m_text_color); + if (m_text_color.is_valid ()) { + pl.setColor (QPalette::Text, QColor (m_text_color.rgb ())); } - if (m_background_color.isValid ()) { - pl.setColor (QPalette::Base, m_background_color); + if (m_background_color.is_valid ()) { + pl.setColor (QPalette::Base, QColor (m_background_color.rgb ())); } cell_list->setPalette (pl); @@ -1243,3 +1244,5 @@ public: static tl::RegisteredClass config_decl (new HierarchyControlPanelPluginDeclaration (), -8, "HierarchyControlPanelPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/layui/layui/layHierarchyControlPanel.h similarity index 94% rename from src/laybasic/laybasic/layHierarchyControlPanel.h rename to src/layui/layui/layHierarchyControlPanel.h index 516ec1d46..1387d9c9a 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/layui/layui/layHierarchyControlPanel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layHierarchyControlPanel #define HDR_layHierarchyControlPanel @@ -31,10 +32,11 @@ #include #include +#include "layuiCommon.h" #include "dbLayout.h" #include "layCanvasPlane.h" #include "layViewOp.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellTreeModel.h" #include "layWidgets.h" #include "tlDeferredExecution.h" @@ -95,7 +97,7 @@ protected: * The class communicates with a Layout interface for * retrieval of the cell hierarchy */ -class HierarchyControlPanel +class LAYUI_PUBLIC HierarchyControlPanel : public QFrame, public tl::Object { @@ -110,7 +112,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - HierarchyControlPanel (lay::LayoutView *view, QWidget *parent = 0, const char *name = "control_panel"); + HierarchyControlPanel (lay::LayoutViewBase *view, QWidget *parent = 0, const char *name = "control_panel"); /** * @brief Destructor @@ -125,12 +127,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Select the active cellview @@ -257,7 +259,7 @@ public: /** * @brief Gets the layout view this panel is attached to */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -283,7 +285,7 @@ public slots: private: db::Layout *mp_layout; bool m_enable_cb; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_cellviews; std::vector mp_cell_lists; std::vector mp_cell_list_headers; @@ -304,8 +306,8 @@ private: QFrame *mp_search_frame; QCheckBox *mp_search_close_cb; QSplitter *mp_splitter; - QColor m_background_color; - QColor m_text_color; + lay::Color m_background_color; + lay::Color m_text_color; tl::DeferredMethod m_do_update_content_dm; tl::DeferredMethod m_do_full_update_content_dm; std::unique_ptr mp_tree_style; @@ -340,3 +342,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.cc b/src/layui/layui/layIndexedNetlistModel.cc similarity index 99% rename from src/laybasic/laybasic/layIndexedNetlistModel.cc rename to src/layui/layui/layIndexedNetlistModel.cc index 8c9fd6788..35c1f67a4 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.cc +++ b/src/layui/layui/layIndexedNetlistModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layIndexedNetlistModel.h" #include "dbNetlist.h" @@ -463,3 +464,5 @@ SingleIndexedNetlistModel::subcircuit_index (const subcircuit_pair &subcircuits) } } + +#endif diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.h b/src/layui/layui/layIndexedNetlistModel.h similarity index 98% rename from src/laybasic/laybasic/layIndexedNetlistModel.h rename to src/layui/layui/layIndexedNetlistModel.h index 6e6c35610..4f6bc4c6a 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.h +++ b/src/layui/layui/layIndexedNetlistModel.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layIndexedNetlistModel #define HDR_layIndexedNetlistModel -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbNetlistCrossReference.h" // for Status enum #include @@ -54,7 +55,7 @@ const size_t no_netlist_index = std::numeric_limits::max (); /** * @brief An interface to supply the netlist browser model with indexed items */ -class LAYBASIC_PUBLIC IndexedNetlistModel +class LAYUI_PUBLIC IndexedNetlistModel { public: typedef db::NetlistCrossReference::Status Status; @@ -126,7 +127,7 @@ private: /** * @brief An incarnation of the indexed netlist model for a single netlist */ -class LAYBASIC_PUBLIC SingleIndexedNetlistModel +class LAYUI_PUBLIC SingleIndexedNetlistModel : public IndexedNetlistModel { public: @@ -205,3 +206,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layItemDelegates.cc b/src/layui/layui/layItemDelegates.cc similarity index 99% rename from src/laybasic/laybasic/layItemDelegates.cc rename to src/layui/layui/layItemDelegates.cc index 6d3e230c6..dd5e8f112 100644 --- a/src/laybasic/laybasic/layItemDelegates.cc +++ b/src/layui/layui/layItemDelegates.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layItemDelegates.h" #include @@ -206,3 +208,5 @@ HTMLItemDelegate::editorEvent (QEvent *event, QAbstractItemModel * /*model*/, co } } + +#endif diff --git a/src/laybasic/laybasic/layItemDelegates.h b/src/layui/layui/layItemDelegates.h similarity index 95% rename from src/laybasic/laybasic/layItemDelegates.h rename to src/layui/layui/layItemDelegates.h index 6c860b2c2..f3e5f7e49 100644 --- a/src/laybasic/laybasic/layItemDelegates.h +++ b/src/layui/layui/layItemDelegates.h @@ -20,10 +20,12 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layItemDelegates #define HDR_layItemDelegates -#include "laybasicCommon.h" +#include "layuiCommon.h" #include @@ -35,7 +37,7 @@ namespace lay /** * @brief A delegate displaying the display text as HTML formatted text */ -class LAYBASIC_PUBLIC HTMLItemDelegate +class LAYUI_PUBLIC HTMLItemDelegate : public QStyledItemDelegate { Q_OBJECT @@ -103,3 +105,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/layui/layui/layLayerControlPanel.cc similarity index 98% rename from src/laybasic/laybasic/layLayerControlPanel.cc rename to src/layui/layui/layLayerControlPanel.cc index bdb0a3004..372064b74 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/layui/layui/layLayerControlPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -198,7 +199,7 @@ LCPTreeWidget::expand_all () // -------------------------------------------------------------------- // LayerControlPanel implementation -LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent, const char *name) +LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *manager, QWidget *parent, const char *name) : QFrame (parent), db::Object (manager), mp_view (view), @@ -301,8 +302,8 @@ LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manage mp_model = new lay::LayerTreeModel (this, view); mp_layer_list = new LCPTreeWidget (this, mp_model, "layer_tree"); mp_layer_list->setUniformRowHeights (true); - mp_model->set_font (mp_layer_list->font ()); mp_layer_list->setIconSize (mp_model->icon_size ()); + mp_model->set_font_no_signal (mp_layer_list->font ()); l->addWidget (mp_layer_list); connect (mp_layer_list, SIGNAL (double_clicked (const QModelIndex &, Qt::KeyboardModifiers)), this, SLOT (double_clicked (const QModelIndex &, Qt::KeyboardModifiers))); @@ -444,39 +445,12 @@ void LayerControlPanel::cm_remove_unused () { BEGIN_PROTECTED_CLEANUP - begin_updates (); - transaction (tl::to_string (QObject::tr ("Clean up views"))); - - bool any_deleted; - do { - - std::vector sel; - - lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); - while (! l.at_end ()) { - if (! l->has_children () && l->bbox ().empty ()) { - sel.push_back (l); - } - ++l; - } - - std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); - any_deleted = false; - for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { - mp_view->delete_layer (*s); - any_deleted = true; - } - - } while (any_deleted); - + mp_view->remove_unused_layers (); commit (); - end_updates (); - emit order_changed (); - END_PROTECTED_CLEANUP { recover (); } } @@ -1333,7 +1307,7 @@ struct LDSortingProps struct LayerSorter { - LayerSorter (const lay::LayoutView *view, lay::LayerControlPanel::SortOrder order) + LayerSorter (const lay::LayoutViewBase *view, lay::LayerControlPanel::SortOrder order) : m_order (order), mp_view (view) { // .. nothing yet .. @@ -1416,7 +1390,7 @@ struct LayerSorter private: lay::LayerControlPanel::SortOrder m_order; - const lay::LayoutView *mp_view; + const lay::LayoutViewBase *mp_view; }; void @@ -1640,21 +1614,21 @@ LayerControlPanel::set_no_stipples (bool ns) } void -LayerControlPanel::set_background_color (QColor c) +LayerControlPanel::set_background_color (lay::Color c) { QPalette pl (mp_layer_list->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); mp_layer_list->setPalette (pl); - mp_model->set_background_color (c); + mp_model->set_background_color (QColor (c.rgb ())); } void -LayerControlPanel::set_text_color (QColor c) +LayerControlPanel::set_text_color (lay::Color c) { QPalette pl (mp_layer_list->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); mp_layer_list->setPalette (pl); - mp_model->set_text_color (c); + mp_model->set_text_color (QColor (c.rgb ())); } void @@ -2367,3 +2341,5 @@ public: static tl::RegisteredClass config_decl (new LayerControlPanelPluginDeclaration (), -9, "LayerControlPanelPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h similarity index 95% rename from src/laybasic/laybasic/layLayerControlPanel.h rename to src/layui/layui/layLayerControlPanel.h index 1db2ee13c..f82371b27 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -20,11 +20,25 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerControlPanel #define HDR_layLayerControlPanel +#include "layuiCommon.h" +#include "layCanvasPlane.h" +#include "layViewOp.h" +#include "layLayoutViewBase.h" +#include "layColorPalette.h" +#include "layStipplePalette.h" +#include "layDitherPattern.h" +#include "layLayerProperties.h" +#include "layLayerTreeModel.h" +#include "layWidgets.h" +#include "dbObject.h" +#include "tlDeferredExecution.h" + #include #include #include @@ -36,18 +50,6 @@ #include #include -#include "layCanvasPlane.h" -#include "layViewOp.h" -#include "layLayoutView.h" -#include "layColorPalette.h" -#include "layStipplePalette.h" -#include "layDitherPattern.h" -#include "layLayerProperties.h" -#include "layLayerTreeModel.h" -#include "layWidgets.h" -#include "dbObject.h" -#include "tlDeferredExecution.h" - class QTreeView; class QModelIndex; class QMenu; @@ -107,7 +109,7 @@ private: * The class communicates with a Layout interface for * retrieval and changing of layer properties. */ -class LayerControlPanel +class LAYUI_PUBLIC LayerControlPanel : public QFrame, public db::Object, public tl::Object @@ -126,7 +128,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent = 0, const char *name = "control_panel"); + LayerControlPanel (LayoutViewBase *view, db::Manager *manager, QWidget *parent = 0, const char *name = "control_panel"); /** * @brief Destructor @@ -166,12 +168,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Set the "hide empty layers" flag @@ -338,7 +340,7 @@ private: LCPTreeWidget *mp_layer_list; std::unique_ptr mp_ll_style; LayerTreeModel *mp_model; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_needs_update; bool m_tabs_need_update; bool m_hidden_flags_need_update; @@ -379,3 +381,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerMappingWidget.cc b/src/layui/layui/layLayerMappingWidget.cc similarity index 99% rename from src/laybasic/laybasic/layLayerMappingWidget.cc rename to src/layui/layui/layLayerMappingWidget.cc index e1f75ef47..1ec214ba4 100644 --- a/src/laybasic/laybasic/layLayerMappingWidget.cc +++ b/src/layui/layui/layLayerMappingWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayerMappingWidget.h" #include "tlExceptions.h" @@ -259,3 +260,4 @@ LayerMappingWidget::current_tab_changed (int index) } +#endif diff --git a/src/laybasic/laybasic/layLayerMappingWidget.h b/src/layui/layui/layLayerMappingWidget.h similarity index 94% rename from src/laybasic/laybasic/layLayerMappingWidget.h rename to src/layui/layui/layLayerMappingWidget.h index 2690b7a8a..706c2c355 100644 --- a/src/laybasic/laybasic/layLayerMappingWidget.h +++ b/src/layui/layui/layLayerMappingWidget.h @@ -20,13 +20,14 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerMappingWidget #define HDR_layLayerMappingWidget #include -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbStreamLayers.h" namespace Ui @@ -42,7 +43,7 @@ class FileDialog; /** * @brief A widget for editing the layer mapping for the reader options */ -class LAYBASIC_PUBLIC LayerMappingWidget +class LAYUI_PUBLIC LayerMappingWidget : public QFrame { Q_OBJECT @@ -98,3 +99,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerToolbox.cc b/src/layui/layui/layLayerToolbox.cc similarity index 99% rename from src/laybasic/laybasic/layLayerToolbox.cc rename to src/layui/layui/layLayerToolbox.cc index 4ceb5cf89..416858fdd 100644 --- a/src/laybasic/laybasic/layLayerToolbox.cc +++ b/src/layui/layui/layLayerToolbox.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayerToolbox.h" @@ -33,7 +34,7 @@ #include #include "tlExceptions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layEditStipplesForm.h" #include "layEditLineStylesForm.h" #include "laySelectStippleForm.h" @@ -927,7 +928,7 @@ LayerToolbox::~LayerToolbox () } void -LayerToolbox::set_view (LayoutView *view) +LayerToolbox::set_view (LayoutViewBase *view) { mp_dither_palette->set_view (view); mp_style_palette->set_view (view); @@ -1467,3 +1468,4 @@ LayerToolbox::set_palette (const lay::LineStylePalette &p) } +#endif diff --git a/src/laybasic/laybasic/layLayerToolbox.h b/src/layui/layui/layLayerToolbox.h similarity index 95% rename from src/laybasic/laybasic/layLayerToolbox.h rename to src/layui/layui/layLayerToolbox.h index fa65510a5..a635254b7 100644 --- a/src/laybasic/laybasic/layLayerToolbox.h +++ b/src/layui/layui/layLayerToolbox.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerToolbox #define HDR_layLayerToolbox @@ -32,6 +33,7 @@ #include #include +#include "layuiCommon.h" #include "layColorPalette.h" #include "layStipplePalette.h" #include "layLineStylePalette.h" @@ -39,7 +41,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class LCPDitherPalette; class LCPColorPalette; class LCPActiveLabel; @@ -142,7 +144,7 @@ Q_OBJECT public: LCPStylePalette (QWidget *parent, const char *name = 0); - void set_view (LayoutView *view) + void set_view (LayoutViewBase *view) { mp_view = view; } @@ -163,7 +165,7 @@ private: void create_pixmap_for_line_style (LCPActiveLabel *b, int n); lay::LineStylePalette m_palette; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_style_buttons; }; @@ -184,7 +186,7 @@ public: void set_palette (const lay::StipplePalette &p); - void set_view (LayoutView *view) + void set_view (LayoutViewBase *view) { mp_view = view; } @@ -198,7 +200,7 @@ signals: private: lay::StipplePalette m_palette; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_stipple_buttons; void create_pixmap_for (LCPActiveLabel *b, int n); @@ -258,7 +260,7 @@ private: /** * @brief A widget implementing the layer toolbox */ -class LAYBASIC_PUBLIC LayerToolbox +class LAYUI_PUBLIC LayerToolbox : public QWidget { Q_OBJECT @@ -279,7 +281,7 @@ public: * * This will make the toolbox control the given layout view */ - void set_view (LayoutView *view); + void set_view (LayoutViewBase *view); /** * @brief Changing of the color palette @@ -334,7 +336,7 @@ protected slots: void animation_changed (int mode); private: - LayoutView *mp_view; + LayoutViewBase *mp_view; std::vector > m_tool_panels; LCPDitherPalette *mp_dither_palette; LCPStylePalette *mp_style_palette; @@ -351,3 +353,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/layui/layui/layLayerTreeModel.cc similarity index 97% rename from src/laybasic/laybasic/layLayerTreeModel.cc rename to src/layui/layui/layLayerTreeModel.cc index 5a3c09eea..e53bd19fc 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/layui/layui/layLayerTreeModel.cc @@ -20,9 +20,10 @@ */ +#if defined(HAVE_QT) #include "layLayerTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layBitmapsToImage.h" #include "dbLayoutUtils.h" #include "tlLog.h" @@ -178,7 +179,7 @@ EmptyWithinViewCache::determine_empty_layers (const db::Layout *layout, unsigned // -------------------------------------------------------------------- // LayerTreeModel implementation -LayerTreeModel::LayerTreeModel (QWidget *parent, lay::LayoutView *view) +LayerTreeModel::LayerTreeModel (QWidget *parent, lay::LayoutViewBase *view) : QAbstractItemModel (parent), mp_view (view), m_filter_mode (false), m_id_start (0), m_id_end (0), m_phase ((unsigned int) -1), m_test_shapes_in_view (false), m_hide_empty_layers (false) { @@ -203,7 +204,13 @@ LayerTreeModel::set_font (const QFont &font) signal_data_changed (); } -void +void +LayerTreeModel::set_font_no_signal (const QFont &font) +{ + m_font = font; +} + +void LayerTreeModel::set_text_color (QColor color) { m_text_color = color; @@ -523,7 +530,7 @@ LayerTreeModel::parent (const QModelIndex &index) const */ static void single_bitmap_to_image (const lay::ViewOp &view_op, lay::Bitmap &bitmap, - QImage *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles, + lay::PixelBuffer *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles, unsigned int width, unsigned int height) { std::vector view_ops; @@ -629,9 +636,9 @@ LayerTreeModel::empty_within_view_predicate (const QModelIndex &index) const } } -LAYBASIC_PUBLIC +LAYUI_PUBLIC QIcon -LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) +LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) { h = std::max ((unsigned int) 16, h); w = std::max ((unsigned int) 16, w); @@ -640,11 +647,12 @@ LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, l lay::color_t fill_color = iter->has_fill_color (true) ? iter->eff_fill_color (true) : def_color; lay::color_t frame_color = iter->has_frame_color (true) ? iter->eff_frame_color (true) : def_color; - QImage image (w, h, QImage::Format_ARGB32); + lay::PixelBuffer image (w, h); + image.set_transparent (true); image.fill (view->background_color ().rgb ()); // upper scanline is a dummy one - uint32_t *sl0 = (uint32_t *) image.scanLine (0); + uint32_t *sl0 = (uint32_t *) image.scan_line (0); uint32_t transparent = QColor (Qt::transparent).rgba (); for (size_t i = 0; i < w; ++i) { *sl0++ = transparent; @@ -773,7 +781,7 @@ LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, l // create vertex single_bitmap_to_image (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Cross, iter->marked (true) ? 9/*mark size*/ : 0), vertex, &image, view->dither_pattern (), view->line_styles (), w, h); - QPixmap pixmap = QPixmap::fromImage (image); // Qt 4.6.0 workaround + QPixmap pixmap = QPixmap::fromImage (image.to_image ()); // Qt 4.6.0 workaround return QIcon (pixmap); } @@ -843,7 +851,7 @@ LayerTreeModel::data (const QModelIndex &index, int role) const if (m_selected_ids.find (size_t (index.internalPointer ())) != m_selected_ids.end ()) { // for selected items pick a color between Highlight and Base - QPalette pl (mp_view->palette ()); + QPalette pl (mp_view->widget ()->palette ()); QColor c1 = pl.color (QPalette::Highlight); QColor cb = pl.color (QPalette::Base); return QVariant (QColor ((c1.red () + cb.red ()) / 2, (c1.green () + cb.green ()) / 2, (c1.blue () + cb.blue ()) / 2)); @@ -924,3 +932,5 @@ LayerTreeModel::index (lay::LayerPropertiesConstIterator iter, int column) const } } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/layui/layui/layLayerTreeModel.h similarity index 93% rename from src/laybasic/laybasic/layLayerTreeModel.h rename to src/layui/layui/layLayerTreeModel.h index 8273526f7..b5a0b49d5 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/layui/layui/layLayerTreeModel.h @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerTreeModel #define HDR_layLayerTreeModel #include "dbBox.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -47,7 +48,7 @@ namespace tl namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesConstIterator; /** @@ -78,7 +79,7 @@ private: * representation or a hierarchical one. */ -class LAYBASIC_PUBLIC LayerTreeModel +class LAYUI_PUBLIC LayerTreeModel : public QAbstractItemModel { Q_OBJECT @@ -89,7 +90,7 @@ public: * * The LayoutView reference is required to obtain hidden cell state and current state flags. */ - LayerTreeModel (QWidget *parent, lay::LayoutView *view); + LayerTreeModel (QWidget *parent, lay::LayoutViewBase *view); /** * @brief Dtor @@ -108,7 +109,7 @@ public: /** * @brief Provides an icon for a given layer style */ - static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); + static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); /** * @brief Gets the preferred icon size @@ -150,6 +151,11 @@ public: */ void set_font (const QFont &font); + /** + * @brief Set the font to use for text display (without emitting a signal) + */ + void set_font_no_signal (const QFont &font); + /** * @brief Set the text color to use for text display */ @@ -245,7 +251,7 @@ signals: void hidden_flags_need_update (); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_filter_mode; size_t m_id_start, m_id_end; unsigned int m_phase; @@ -276,3 +282,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.cc b/src/layui/layui/layLayoutPropertiesForm.cc similarity index 98% rename from src/laybasic/laybasic/layLayoutPropertiesForm.cc rename to src/layui/layui/layLayoutPropertiesForm.cc index ad5eaf135..283a2a08f 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.cc +++ b/src/layui/layui/layLayoutPropertiesForm.cc @@ -20,9 +20,10 @@ */ +#if defined(HAVE_QT) #include "layLayoutPropertiesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "layDialogs.h" #include "tlInternational.h" @@ -39,7 +40,7 @@ namespace lay // ------------------------------------------------------------ -LayoutPropertiesForm::LayoutPropertiesForm (QWidget *parent, lay::LayoutView *view, const char *name) +LayoutPropertiesForm::LayoutPropertiesForm (QWidget *parent, lay::LayoutViewBase *view, const char *name) : QDialog (parent), Ui::LayoutPropertiesForm () { m_editable = view->is_editable (); @@ -206,5 +207,4 @@ END_PROTECTED } - - +#endif diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.h b/src/layui/layui/layLayoutPropertiesForm.h similarity index 83% rename from src/laybasic/laybasic/layLayoutPropertiesForm.h rename to src/layui/layui/layLayoutPropertiesForm.h index 992ac207c..5a5e8d664 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.h +++ b/src/layui/layui/layLayoutPropertiesForm.h @@ -20,27 +20,31 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutPropertiesForm #define HDR_layLayoutPropertiesForm -#include -#include "ui_LayoutProperties.h" +#include "layuiCommon.h" #include "layCellView.h" +#include "ui_LayoutProperties.h" + +#include + #include namespace lay { -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC LayoutPropertiesForm +class LAYUI_PUBLIC LayoutPropertiesForm : public QDialog, private Ui::LayoutPropertiesForm { Q_OBJECT public: - LayoutPropertiesForm (QWidget *parent, lay::LayoutView *view, const char *name); + LayoutPropertiesForm (QWidget *parent, lay::LayoutViewBase *view, const char *name); void accept (); void commit (); @@ -53,7 +57,7 @@ private slots: private: std::vector m_handles; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_index; bool m_editable; }; @@ -62,3 +66,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutStatistics.qrc b/src/layui/layui/layLayoutStatistics.qrc similarity index 100% rename from src/laybasic/laybasic/layLayoutStatistics.qrc rename to src/layui/layui/layLayoutStatistics.qrc diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.cc b/src/layui/layui/layLayoutStatisticsForm.cc similarity index 99% rename from src/laybasic/laybasic/layLayoutStatisticsForm.cc rename to src/layui/layui/layLayoutStatisticsForm.cc index a2e9db0b9..a5dd164ee 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.cc +++ b/src/layui/layui/layLayoutStatisticsForm.cc @@ -20,9 +20,10 @@ */ +#if defined(HAVE_QT) #include "layLayoutStatisticsForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlInternational.h" #include "tlString.h" #include "tlExpression.h" @@ -794,7 +795,7 @@ StatisticsSource::get (const std::string &url) // ------------------------------------------------------------ -LayoutStatisticsForm::LayoutStatisticsForm (QWidget *parent, lay::LayoutView *view, const char *name) +LayoutStatisticsForm::LayoutStatisticsForm (QWidget *parent, lay::LayoutViewBase *view, const char *name) : QDialog (parent), Ui::LayoutStatisticsForm (), mp_source (0) { setObjectName (QString::fromUtf8 (name)); @@ -853,5 +854,4 @@ LayoutStatisticsForm::layout_selected (int index) } - - +#endif diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.h b/src/layui/layui/layLayoutStatisticsForm.h similarity index 88% rename from src/laybasic/laybasic/layLayoutStatisticsForm.h rename to src/layui/layui/layLayoutStatisticsForm.h index f85afb598..e2abaef50 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.h +++ b/src/layui/layui/layLayoutStatisticsForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutStatisticsForm #define HDR_layLayoutStatisticsForm @@ -32,7 +33,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class StatisticsSource; class LayoutStatisticsForm @@ -41,7 +42,7 @@ class LayoutStatisticsForm Q_OBJECT public: - LayoutStatisticsForm (QWidget *parent, lay::LayoutView *view, const char *name); + LayoutStatisticsForm (QWidget *parent, lay::LayoutViewBase *view, const char *name); ~LayoutStatisticsForm (); public slots: @@ -56,3 +57,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/layui/layui/layLayoutViewConfigPages.cc similarity index 99% rename from src/laybasic/laybasic/layLayoutViewConfigPages.cc rename to src/layui/layui/layLayoutViewConfigPages.cc index 8463a6a5e..314abe80f 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/layui/layui/layLayoutViewConfigPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutViewConfigPages.h" #include "laybasicConfig.h" @@ -1631,3 +1632,4 @@ static tl::RegisteredClass config_decl (new LayoutViewCo } +#endif diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/layui/layui/layLayoutViewConfigPages.h similarity index 98% rename from src/laybasic/laybasic/layLayoutViewConfigPages.h rename to src/layui/layui/layLayoutViewConfigPages.h index 176e0e633..b2bae947e 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.h +++ b/src/layui/layui/layLayoutViewConfigPages.h @@ -20,11 +20,13 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutViewConfigPages #define HDR_layLayoutViewConfigPages #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" #include "layStipplePalette.h" #include "layLineStylePalette.h" @@ -357,3 +359,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/layui/layui/layLayoutViewFunctions.cc similarity index 80% rename from src/laybasic/laybasic/layLayoutViewFunctions.cc rename to src/layui/layui/layLayoutViewFunctions.cc index ba769f0d6..b25017d5b 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/layui/layui/layLayoutViewFunctions.cc @@ -20,8 +20,10 @@ */ +#if defined(HAVE_QT) + #include "layLayoutViewFunctions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellSelectionForm.h" #include "layLayoutStatisticsForm.h" #include "layLayoutPropertiesForm.h" @@ -55,7 +57,7 @@ collect_cells_to_delete (const db::Layout &layout, const db::Cell &cell, std::se } static bool -validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &path) +validate_cell_path (const db::Layout &layout, lay::LayoutViewBase::cell_path_type &path) { for (size_t i = 0; i < path.size (); ++i) { @@ -77,7 +79,7 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p return false; } -LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutView *view) +LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) : lay::Plugin (view), mp_view (view), mp_manager (manager) { m_del_cell_mode = 0; @@ -104,9 +106,13 @@ LayoutViewFunctions::~LayoutViewFunctions () void LayoutViewFunctions::menu_activated (const std::string &symbol) { + if (! view ()) { + return; + } + if (symbol == "cm_show_properties") { - view ()->show_properties (view ()); + view ()->show_properties (view ()->widget ()); } else if (symbol == "cm_delete") { @@ -173,7 +179,7 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) } else if (symbol == "cm_select_current_cell") { if (view ()->active_cellview_index () >= 0) { - lay::LayoutView::cell_path_type path; + lay::LayoutViewBase::cell_path_type path; int cvi = view ()->active_cellview_index (); view ()->current_cell_path (path); view ()->select_cell_fit (path, cvi); @@ -299,10 +305,10 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) cm_new_layer (); } } else if (symbol == "cm_layout_props") { - lay::LayoutPropertiesForm lp_form (view (), view (), "layout_props_form"); + lay::LayoutPropertiesForm lp_form (view ()->widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_layout_stats") { - lay::LayoutStatisticsForm lp_form (view (), view (), "layout_props_form"); + lay::LayoutStatisticsForm lp_form (view ()->widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_reload") { cm_reload (); @@ -412,13 +418,9 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) void LayoutViewFunctions::cm_cell_user_properties () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; - view ()->hierarchy_panel ()->current_cell (cv_index, path); + lay::LayoutViewBase::cell_path_type path; + view ()->current_cell_path (cv_index, path); if (cv_index >= 0 && path.size () > 0) { @@ -426,10 +428,10 @@ LayoutViewFunctions::cm_cell_user_properties () db::Cell &cell = layout.cell (path.back ()); db::properties_id_type prop_id = cell.prop_id (); - lay::UserPropertiesForm props_form (view ()); + lay::UserPropertiesForm props_form (view ()->widget ()); if (props_form.show (view (), cv_index, prop_id)) { - view ()->transaction (tl::to_string (QObject::tr ("Edit cell's user properties"))); + view ()->transaction (tl::to_string (tr ("Edit cell's user properties"))); cell.prop_id (prop_id); view ()->commit (); @@ -441,31 +443,27 @@ LayoutViewFunctions::cm_cell_user_properties () void LayoutViewFunctions::cm_cell_replace () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { if (paths.size () > 1) { - throw tl::Exception (tl::to_string (QObject::tr ("Replace cell cannot be used when multiple cells are selected"))); + throw tl::Exception (tl::to_string (tr ("Replace cell cannot be used when multiple cells are selected"))); } db::Layout &layout = view ()->cellview (cv_index)->layout (); bool needs_to_ask = false; - for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { if (layout.is_valid_cell_index (p->back ()) && ! layout.cell (p->back ()).is_leaf ()) { needs_to_ask = true; } } - lay::ReplaceCellOptionsDialog mode_dialog (view ()); + lay::ReplaceCellOptionsDialog mode_dialog (view ()->widget ()); db::cell_index_type with_cell = paths.front ().back (); int mode = needs_to_ask ? m_del_cell_mode : 0; @@ -479,11 +477,11 @@ LayoutViewFunctions::cm_cell_replace () if (with_cell != paths.front ().back ()) { // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Replace cells"))); + view ()->transaction (tl::to_string (tr ("Replace cells"))); // replace instances of the target cell with the new cell @@ -501,7 +499,7 @@ LayoutViewFunctions::cm_cell_replace () } std::set cells_to_delete; - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { cells_to_delete.insert (p->back ()); if (mode == 2) { @@ -551,7 +549,7 @@ LayoutViewFunctions::cm_lay_convert_to_static () db::Layout &layout = view ()->cellview (cv_index)->layout (); - view ()->transaction (tl::to_string (QObject::tr ("Convert all cells to static"))); + view ()->transaction (tl::to_string (tr ("Convert all cells to static"))); std::vector cells; for (db::Layout::const_iterator c = layout.begin (); c != layout.end (); ++c) { @@ -590,28 +588,24 @@ LayoutViewFunctions::cm_lay_convert_to_static () void LayoutViewFunctions::cm_cell_convert_to_static () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { db::Layout &layout = view ()->cellview (cv_index)->layout (); // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Convert cells to static"))); + view ()->transaction (tl::to_string (tr ("Convert cells to static"))); std::map cell_map; - for (std::vector::iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { db::cell_index_type new_cell = layout.convert_cell_to_static (p->back ()); if (new_cell != p->back ()) { @@ -647,20 +641,16 @@ LayoutViewFunctions::cm_cell_convert_to_static () void LayoutViewFunctions::cm_cell_delete () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { db::Layout &layout = view ()->cellview (cv_index)->layout (); bool needs_to_ask = false; - for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { if (layout.is_valid_cell_index (p->back ()) && ! layout.cell (p->back ()).is_leaf ()) { needs_to_ask = true; } @@ -671,7 +661,7 @@ LayoutViewFunctions::cm_cell_delete () mode = 0; } - lay::DeleteCellModeDialog mode_dialog (view ()); + lay::DeleteCellModeDialog mode_dialog (view ()->widget ()); if (! needs_to_ask || mode_dialog.exec_dialog (mode)) { if (needs_to_ask) { @@ -679,12 +669,12 @@ LayoutViewFunctions::cm_cell_delete () } // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); std::set cells_to_delete; - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { cells_to_delete.insert (p->back ()); if (mode == 2) { @@ -693,7 +683,7 @@ LayoutViewFunctions::cm_cell_delete () } } - view ()->transaction (tl::to_string (QObject::tr ("Delete cells"))); + view ()->transaction (tl::to_string (tr ("Delete cells"))); if (mode == 0 || mode == 2) { layout.delete_cells (cells_to_delete); @@ -726,7 +716,7 @@ void LayoutViewFunctions::cm_layer_cut () { if (view ()->control_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); + db::Transaction trans (manager (), tl::to_string (tr ("Cut Layers"))); view ()->control_panel ()->cut (); } } @@ -735,7 +725,7 @@ void LayoutViewFunctions::cm_layer_paste () { if (view ()->control_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Layers"))); + db::Transaction trans (manager (), tl::to_string (tr ("Paste Layers"))); view ()->control_panel ()->paste (); } } @@ -754,7 +744,7 @@ void LayoutViewFunctions::cm_cell_paste () { if (view ()->hierarchy_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Cells"))); + db::Transaction trans (manager (), tl::to_string (tr ("Paste Cells"))); view ()->hierarchy_panel ()->paste (); } } @@ -783,18 +773,18 @@ LayoutViewFunctions::cm_cell_flatten () if (cv.is_valid ()) { std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + view ()->selected_cells_paths (cv_index, paths); if (paths.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No cells selected for flattening"))); + throw tl::Exception (tl::to_string (tr ("No cells selected for flattening"))); } for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (p->size () > 0 && cv->layout ().cell (p->back ()).is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } } - FlattenInstOptionsDialog options_dialog (view ()); + FlattenInstOptionsDialog options_dialog (view ()->widget ()); int flatten_insts_levels = -1; bool prune = true; @@ -805,7 +795,7 @@ LayoutViewFunctions::cm_cell_flatten () if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), + tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), "flatten-undo-buffering", lay::TipDialog::yesnocancel_buttons); @@ -828,7 +818,7 @@ LayoutViewFunctions::cm_cell_flatten () if (! supports_undo) { manager ()->clear (); } else { - manager ()->transaction (tl::to_string (QObject::tr ("Flatten cell"))); + manager ()->transaction (tl::to_string (tr ("Flatten cell"))); } } @@ -870,23 +860,19 @@ LayoutViewFunctions::cm_cell_flatten () void LayoutViewFunctions::cm_cell_rename () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; - view ()->hierarchy_panel ()->current_cell (cv_index, path); + lay::LayoutViewBase::cell_path_type path; + view ()->current_cell_path (cv_index, path); if (cv_index >= 0 && path.size () > 0) { - lay::RenameCellDialog name_dialog (view ()); + lay::RenameCellDialog name_dialog (view ()->widget ()); db::Layout &layout = view ()->cellview (cv_index)->layout (); std::string name (layout.cell_name (path.back ())); if (name_dialog.exec_dialog (layout, name)) { - view ()->transaction (tl::to_string (QObject::tr ("Rename cell"))); + view ()->transaction (tl::to_string (tr ("Rename cell"))); layout.rename_cell (path.back (), name.c_str ()); view ()->commit (); @@ -912,53 +898,43 @@ LayoutViewFunctions::cm_open_current_cell () void LayoutViewFunctions::cm_cell_hide () { - if (view ()->hierarchy_panel ()) { + std::vector paths; + view ()->selected_cells_paths (view ()->active_cellview_index (), paths); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); + view ()->transaction (tl::to_string (tr ("Hide cell"))); - view ()->transaction (tl::to_string (QObject::tr ("Hide cell"))); - - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { - if (! p->empty ()) { - view ()->hide_cell (p->back (), view ()->active_cellview_index ()); - } + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + if (! p->empty ()) { + view ()->hide_cell (p->back (), view ()->active_cellview_index ()); } - - view ()->commit (); - } + + view ()->commit (); } void LayoutViewFunctions::cm_cell_show () { - if (view ()->hierarchy_panel ()) { + std::vector paths; + view ()->selected_cells_paths (view ()->active_cellview_index (), paths); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); + view ()->transaction (tl::to_string (tr ("Show cell"))); - view ()->transaction (tl::to_string (QObject::tr ("Show cell"))); - - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { - if (! p->empty ()) { - view ()->show_cell (p->back (), view ()->active_cellview_index ()); - } + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + if (! p->empty ()) { + view ()->show_cell (p->back (), view ()->active_cellview_index ()); } - - view ()->commit (); - } + + view ()->commit (); } void LayoutViewFunctions::cm_cell_show_all () { - if (view ()->hierarchy_panel ()) { - view ()->transaction (tl::to_string (QObject::tr ("Show all cells"))); - view ()->show_all_cells (); - view ()->commit (); - } + view ()->transaction (tl::to_string (tr ("Show all cells"))); + view ()->show_all_cells (); + view ()->commit (); } void @@ -1240,7 +1216,7 @@ LayoutViewFunctions::cm_new_cell () static double s_new_cell_window_size = 2.0; static std::string s_new_cell_cell_name; - NewCellPropertiesDialog cell_prop_dia (view ()); + NewCellPropertiesDialog cell_prop_dia (view ()->widget ()); if (cell_prop_dia.exec_dialog (& cv->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { db::cell_index_type new_ci = view ()->new_cell (view ()->active_cellview_index (), s_new_cell_cell_name.c_str ()); @@ -1266,7 +1242,7 @@ LayoutViewFunctions::cm_reload () if (view ()->cellviews () > 1) { - lay::SelectCellViewForm form (0, view (), tl::to_string (QObject::tr ("Select Layouts To Reload"))); + lay::SelectCellViewForm form (0, view (), tl::to_string (tr ("Select Layouts To Reload"))); form.select_all (); if (form.exec () == QDialog::Accepted) { @@ -1303,11 +1279,11 @@ LayoutViewFunctions::cm_reload () bool can_reload = true; if (dirty_layouts != 0) { - QMessageBox mbox (view ()); - mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); - mbox.setWindowTitle (QObject::tr ("Save Needed")); + QMessageBox mbox (view ()->widget ()); + mbox.setText (tl::to_qstring (tl::to_string (tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); + mbox.setWindowTitle (tr ("Save Needed")); mbox.setIcon (QMessageBox::Warning); - QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); + QAbstractButton *yes_button = mbox.addButton (tr ("Reload Without Saving"), QMessageBox::YesRole); mbox.addButton (QMessageBox::Cancel); mbox.exec (); @@ -1348,7 +1324,7 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) db::Layout &layout = view ()->cellview (cv_index)->layout (); - db::ICplxTrans tr (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ())); + db::ICplxTrans trans (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ())); bool has_proxy = false; for (db::Layout::const_iterator c = layout.begin (); ! has_proxy && c != layout.end (); ++c) { @@ -1356,20 +1332,20 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) } if (has_proxy && - QMessageBox::question (view (), - QObject::tr ("Transforming PCells Or Library Cells"), - QObject::tr ("The layout contains PCells or library cells or both.\n" - "Any changes to such cells may be lost when their layout is refreshed later.\n" - "Consider using 'Convert all cells to static' before transforming the layout.\n" - "\n" - "Would you like to continue?\n" - "Choose 'Yes' to continue anyway. Choose 'No' to cancel."), + QMessageBox::question (view ()->widget (), + tr ("Transforming PCells Or Library Cells"), + tr ("The layout contains PCells or library cells or both.\n" + "Any changes to such cells may be lost when their layout is refreshed later.\n" + "Consider using 'Convert all cells to static' before transforming the layout.\n" + "\n" + "Would you like to continue?\n" + "Choose 'Yes' to continue anyway. Choose 'No' to cancel."), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { return; } - view ()->transaction (tl::to_string (QObject::tr ("Transform layout"))); - layout.transform (tr); + view ()->transaction (tl::to_string (tr ("Transform layout"))); + layout.transform (trans); view ()->commit (); } @@ -1405,8 +1381,8 @@ LayoutViewFunctions::cm_lay_free_rot () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Free rotation"), - QObject::tr ("Rotation angle in degree (counterclockwise)"), + tr ("Free rotation"), + tr ("Rotation angle in degree (counterclockwise)"), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1425,8 +1401,8 @@ LayoutViewFunctions::cm_lay_scale () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Scaling"), - QObject::tr ("Scaling factor"), + tr ("Scaling"), + tr ("Scaling factor"), QLineEdit::Normal, QString::fromUtf8 ("1.0"), &ok); @@ -1443,7 +1419,7 @@ LayoutViewFunctions::cm_lay_scale () void LayoutViewFunctions::cm_lay_move () { - lay::MoveOptionsDialog options (view ()); + lay::MoveOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_dist)) { transform_layout (db::DCplxTrans (m_move_dist)); } @@ -1498,8 +1474,8 @@ LayoutViewFunctions::cm_sel_free_rot () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Free rotation"), - QObject::tr ("Rotation angle in degree (counterclockwise)"), + tr ("Free rotation"), + tr ("Rotation angle in degree (counterclockwise)"), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1523,8 +1499,8 @@ LayoutViewFunctions::cm_sel_scale () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Scaling"), - QObject::tr ("Scaling factor"), + tr ("Scaling"), + tr ("Scaling factor"), QLineEdit::Normal, QString::fromUtf8 ("1.0"), &ok); @@ -1556,14 +1532,14 @@ LayoutViewFunctions::cm_sel_move_to () { db::DBox sel_bbox (view ()->lay::Editables::selection_bbox ()); if (sel_bbox.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to move"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to move"))); } double x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5); double y = sel_bbox.bottom () + (sel_bbox.height () * (1 + m_move_to_origin_mode_y) * 0.5); db::DPoint move_target (x, y); - lay::MoveToOptionsDialog options (view ()); + lay::MoveToOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_to_origin_mode_x, m_move_to_origin_mode_y, move_target)) { x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5); @@ -1577,7 +1553,7 @@ LayoutViewFunctions::cm_sel_move_to () void LayoutViewFunctions::cm_sel_move () { - lay::MoveOptionsDialog options (view ()); + lay::MoveOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_dist)) { do_transform (db::DCplxTrans (m_move_dist)); } @@ -1611,7 +1587,7 @@ LayoutViewFunctions::cm_copy_layer () } - lay::DuplicateLayerDialog dialog (view ()); + lay::DuplicateLayerDialog dialog (view ()->widget ()); if (dialog.exec_dialog (view (), m_copy_cva, m_copy_layera, m_copy_cvr, m_copy_layerr, m_duplicate_hier_mode, m_clear_before)) { bool supports_undo = true; @@ -1619,7 +1595,7 @@ LayoutViewFunctions::cm_copy_layer () if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), + tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), "copy-layer-undo-buffering", lay::TipDialog::yesnocancel_buttons); @@ -1641,7 +1617,7 @@ LayoutViewFunctions::cm_copy_layer () if (! supports_undo) { manager ()->clear (); } else { - manager ()->transaction (tl::to_string (QObject::tr ("Duplicate layer"))); + manager ()->transaction (tl::to_string (tr ("Duplicate layer"))); } } @@ -1649,7 +1625,7 @@ LayoutViewFunctions::cm_copy_layer () bool same_layout = (&view ()->cellview (m_copy_cvr)->layout () == &view ()->cellview (m_copy_cva)->layout ()); if (same_layout && m_copy_layera == m_copy_layerr) { - throw tl::Exception (tl::to_string (QObject::tr ("Source and target layer must not be identical for duplicate operation"))); + throw tl::Exception (tl::to_string (tr ("Source and target layer must not be identical for duplicate operation"))); } if (m_duplicate_hier_mode == 0) { @@ -1771,16 +1747,16 @@ LayoutViewFunctions::cm_new_layer () const lay::CellView &cv = view ()->cellview (index); - lay::NewLayerPropertiesDialog prop_dia (view ()); + lay::NewLayerPropertiesDialog prop_dia (view ()->widget ()); if (prop_dia.exec_dialog (cv, m_new_layer_props)) { for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { if (cv->layout ().is_valid_layer (l) && cv->layout ().get_properties (l).log_equal (m_new_layer_props)) { - throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ()); + throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ()); } } - view ()->transaction (tl::to_string (QObject::tr ("New layer"))); + view ()->transaction (tl::to_string (tr ("New layer"))); unsigned int l = cv->layout ().insert_layer (m_new_layer_props); std::vector nl; @@ -1806,15 +1782,15 @@ LayoutViewFunctions::cm_align_cell_origin () return; } if (cell->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } - lay::AlignCellOptionsDialog dialog (view ()); + lay::AlignCellOptionsDialog dialog (view ()->widget ()); if (dialog.exec_dialog (m_align_cell_options)) { view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Align cell origin"))); + view ()->transaction (tl::to_string (tr ("Align cell origin"))); db::Box bbox; @@ -1896,28 +1872,28 @@ LayoutViewFunctions::cm_edit_layer () { lay::LayerPropertiesConstIterator sel = view ()->current_layer (); if (sel.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for editing it's properties"))); + throw tl::Exception (tl::to_string (tr ("No layer selected for editing it's properties"))); } int index = sel->cellview_index (); if (sel->has_children () || index < 0 || int (view ()->cellviews ()) <= index || sel->layer_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No valid layer selected for editing it's properties"))); + throw tl::Exception (tl::to_string (tr ("No valid layer selected for editing it's properties"))); } const lay::CellView &cv = view ()->cellview (index); db::LayerProperties layer_props = cv->layout ().get_properties ((unsigned int) sel->layer_index ()); - lay::NewLayerPropertiesDialog prop_dia (view ()); + lay::NewLayerPropertiesDialog prop_dia (view ()->widget ()); if (prop_dia.exec_dialog (cv, layer_props)) { for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { if (cv->layout ().is_valid_layer (l) && int (l) != sel->layer_index () && cv->layout ().get_properties (l).log_equal (layer_props)) { - throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + layer_props.to_string ()); + throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + layer_props.to_string ()); } } - view ()->transaction (tl::to_string (QObject::tr ("Edit layer"))); + view ()->transaction (tl::to_string (tr ("Edit layer"))); cv->layout ().set_properties (sel->layer_index (), layer_props); @@ -1959,13 +1935,13 @@ LayoutViewFunctions::cm_delete_layer () } if (valid_sel.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No or no valid layer selected for deleting them"))); + throw tl::Exception (tl::to_string (tr ("No or no valid layer selected for deleting them"))); } view ()->cancel_edits (); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Delete layers"))); + view ()->transaction (tl::to_string (tr ("Delete layers"))); // Hint: delete_layer must come before the layers are actually deleted in because // for undo this must be the last thing to do (otherwise the layout is not propertly set up) @@ -1998,16 +1974,16 @@ LayoutViewFunctions::cm_clear_layer () { std::vector sel = view ()->selected_layers (); if (sel.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for clearing"))); + throw tl::Exception (tl::to_string (tr ("No layer selected for clearing"))); } - lay::ClearLayerModeDialog mode_dialog (view ()); + lay::ClearLayerModeDialog mode_dialog (view ()->widget ()); if (mode_dialog.exec_dialog (m_layer_hier_mode)) { view ()->cancel_edits (); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Clear layer"))); + view ()->transaction (tl::to_string (tr ("Clear layer"))); for (std::vector::const_iterator si = sel.begin (); si != sel.end (); ++si) { @@ -2054,153 +2030,153 @@ public: // secret menu entries at = "@secrets.end"; - menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (QObject::tr ("Paste Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (QObject::tr ("Duplicate Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (QObject::tr ("Move Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (QObject::tr ("Select Next Item(Space)")))); - menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (QObject::tr ("Select Next Item too(Shift+Space)")))); + menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (tr ("Paste Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (tr ("Duplicate Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (tr ("Move Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (tr ("Select Next Item(Space)")))); + menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (tr ("Select Next Item too(Shift+Space)")))); at = "edit_menu.edit_options_group"; - menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)")))); - menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)")))); + menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (tr ("Undo(Ctrl+Z)")))); + menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (tr ("Redo(Ctrl+Y)")))); menu_entries.push_back (lay::separator ("basic_group", at)); - menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layout")))); + menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (tr ("Layout")))); { std::string at = "edit_menu.layout_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (QObject::tr ("Flip Horizontally")))); - menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (QObject::tr ("Flip Vertically")))); - menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); - menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); - menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (QObject::tr ("Rotation By Angle")))); - menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (QObject::tr ("Scale")))); - menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (tr ("Move By")))); menu_entries.push_back (lay::separator ("cellop_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert All Cells To Static")))); + menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (tr ("Convert All Cells To Static")))); } - menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Cell")))); + menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (tr ("Cell")))); { std::string at = "edit_menu.cell_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell")))); + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (tr ("New Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (tr ("Delete Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (tr ("Rename Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (tr ("Replace Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (tr ("Flatten Cell")))); menu_entries.push_back (lay::separator ("ops_group", at)); - menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (QObject::tr ("Adjust Origin")))); - menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert Cell To Static")))); + menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (tr ("Adjust Origin")))); + menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (tr ("Convert Cell To Static")))); menu_entries.push_back (lay::separator ("props_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (QObject::tr ("User Properties")))); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (tr ("User Properties")))); } - menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layer")))); + menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (tr ("Layer")))); { std::string at = "edit_menu.layer_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layer")))); - menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Clear Layer")))); - menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Layer")))); - menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Copy Layer")))); - menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Edit Layer Specification")))); + menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (tr ("New Layer")))); + menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (tr ("Clear Layer")))); + menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (tr ("Delete Layer")))); + menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (tr ("Copy Layer")))); + menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (tr ("Edit Layer Specification")))); } - menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (QObject::tr ("Selection")))); + menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (tr ("Selection")))); { std::string at = "edit_menu.selection_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (QObject::tr ("Flip Horizontally")))); - menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (QObject::tr ("Flip Vertically")))); - menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); - menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); - menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (QObject::tr ("Rotation By Angle")))); - menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (QObject::tr ("Scale")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (QObject::tr ("Move By")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (QObject::tr ("Move To")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (tr ("Move To")))); } menu_entries.push_back (lay::separator ("utils_group", at)); - menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Utilities")))); + menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (tr ("Utilities")))); menu_entries.push_back (lay::separator ("misc_group", at)); - menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (QObject::tr ("Delete(Del)")))); - menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (QObject::tr ("Properties(Q)")))); + menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (tr ("Delete(Del)")))); + menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (tr ("Properties(Q)")))); menu_entries.push_back (lay::separator ("cpc_group", at)); - menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (QObject::tr ("Copy(Ctrl+C)")))); - menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (QObject::tr ("Cut(Ctrl+X)")))); - menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (QObject::tr ("Paste(Ctrl+V)")))); - menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")))); + menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (tr ("Copy(Ctrl+C)")))); + menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (tr ("Cut(Ctrl+X)")))); + menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (tr ("Paste(Ctrl+V)")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (tr ("Duplicate(Ctrl+B)")))); menu_entries.push_back (lay::separator ("modes_group", at)); - menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (QObject::tr ("Mode")))); + menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (tr ("Mode")))); - menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (QObject::tr ("Select")))); + menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (tr ("Select")))); { std::string at = "edit_menu.select_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All")))); - menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (QObject::tr ("Unselect All")))); + menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (tr ("Select All")))); + menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (tr ("Unselect All")))); menu_entries.push_back (lay::separator ("edit_select_basic_group", at)); - menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All")))); - menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All")))); + menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (tr ("Enable All")))); + menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (tr ("Disable All")))); menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); }; menu_entries.push_back (lay::separator ("cancel_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (QObject::tr ("Cancel(Esc)")))); + menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (tr ("Cancel(Esc)")))); at = "bookmark_menu.end"; - menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (QObject::tr ("Goto Bookmark")))); - menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (QObject::tr ("Bookmark This View")))); + menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (tr ("Goto Bookmark")))); + menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (tr ("Bookmark This View")))); menu_entries.push_back (lay::separator ("bookmark_mgm_group", at)); - menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks")))); - menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks")))); - menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks")))); - menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (QObject::tr ("Recent Bookmark Files")))); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (tr ("Manage Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (tr ("Load Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (tr ("Save Bookmarks")))); + menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (tr ("Recent Bookmark Files")))); at = "zoom_menu.end"; - menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (QObject::tr ("Global Transformation")))); + menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (tr ("Global Transformation")))); { std::string at = "zoom_menu.global_trans.end"; - menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); } menu_entries.push_back (lay::separator ("hier_group", at)); - menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (QObject::tr ("Full Hierarchy(*)")))); - menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (QObject::tr ("Box Only(0)")))); - menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (QObject::tr ("Top Level Only(1)")))); - menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (QObject::tr ("Increment Hierarchy(+)")))); - menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (QObject::tr ("Decrement Hierarchy(-)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (tr ("Full Hierarchy(*)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (tr ("Box Only(0)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (tr ("Top Level Only(1)")))); + menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (tr ("Increment Hierarchy(+)")))); + menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (tr ("Decrement Hierarchy(-)")))); menu_entries.push_back (lay::separator ("zoom_group", at)); - menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (QObject::tr ("Zoom Fit(F2)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Ctrl++)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Ctrl+-)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (tr ("Zoom Fit(F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (tr ("Zoom Fit Selection(Shift+F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (tr ("Zoom In(Ctrl++)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (tr ("Zoom Out(Ctrl+-)")))); /* disabled because that interferes with the use of the arrow keys for moving the selection MenuLayoutEntry::separator ("pan_group"); - menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (QObject::tr ("Pan Up(Up)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (QObject::tr ("Pan Down(Down)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (QObject::tr ("Pan Left(Left)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (QObject::tr ("Pan Right(Right)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (tr ("Pan Up(Up)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (tr ("Pan Down(Down)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (tr ("Pan Left(Left)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (tr ("Pan Right(Right)")))); */ menu_entries.push_back (lay::separator ("redraw_group", at)); - menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (QObject::tr ("Redraw")))); + menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (tr ("Redraw")))); menu_entries.push_back (lay::separator ("state_group", at)); menu_entries.push_back (lay::menu_item_copy ("cm_prev_display_state", "prev_display_state", at, "@toolbar.prev_display_state")); menu_entries.push_back (lay::menu_item_copy ("cm_next_display_state", "next_display_state", at, "@toolbar.next_display_state")); menu_entries.push_back (lay::separator ("select_group", at)); - menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (QObject::tr ("Select Cell")))); - menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")))); - menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")))); + menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (tr ("Select Cell")))); + menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (tr ("Show As New Top(Ctrl+S)")))); + menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (tr ("Goto Position(Ctrl+G)")))); // Add a hook for inserting new items after the modes menu_entries.push_back (lay::separator ("end_modes", "@toolbar.end")); @@ -2231,7 +2207,7 @@ public: void implements_primary_mouse_modes (std::vector > > &modes) { std::vector mode_titles; - lay::LayoutView::intrinsic_mouse_modes (&mode_titles); + lay::LayoutViewBase::intrinsic_mouse_modes (&mode_titles); int mode_id = 0; for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { @@ -2240,7 +2216,7 @@ public: } } - lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutViewBase *view) const { return new LayoutViewFunctions (manager, view); } @@ -2249,3 +2225,5 @@ public: static tl::RegisteredClass config_decl (new LayoutViewPluginDeclaration (), -10, "LayoutViewPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.h b/src/layui/layui/layLayoutViewFunctions.h similarity index 93% rename from src/laybasic/laybasic/layLayoutViewFunctions.h rename to src/layui/layui/layLayoutViewFunctions.h index 37fdeb676..9950ebcf2 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.h +++ b/src/layui/layui/layLayoutViewFunctions.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutViewFunctions #define HDR_layLayoutViewFunctions -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layPlugin.h" #include "layDialogs.h" // For AlignCellOptions @@ -34,19 +35,19 @@ namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief The layout view's functions implementation */ -class LAYBASIC_PUBLIC LayoutViewFunctions +class LAYUI_PUBLIC LayoutViewFunctions : public lay::Plugin { public: /** * @brief Constructor */ - LayoutViewFunctions (db::Manager *manager, lay::LayoutView *view); + LayoutViewFunctions (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief Destructor @@ -132,7 +133,7 @@ public: void cm_cell_convert_to_static (); protected: - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -151,7 +152,7 @@ protected: void transform_layout (const db::DCplxTrans &tr); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::Manager *mp_manager; db::LayerProperties m_new_layer_props; db::DVector m_move_dist; @@ -169,3 +170,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/layui/layui/layLibrariesView.cc similarity index 97% rename from src/laybasic/laybasic/layLibrariesView.cc rename to src/layui/layui/layLibrariesView.cc index 4b1246666..203213bf9 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/layui/layui/layLibrariesView.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -47,7 +48,7 @@ #include "layBusy.h" #include "layLibrariesView.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "layDialogs.h" #include "tlExceptions.h" @@ -198,7 +199,7 @@ LibraryTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -LibrariesView::LibrariesView (lay::LayoutView *view, QWidget *parent, const char *name) +LibrariesView::LibrariesView (lay::LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), mp_view (view), @@ -489,23 +490,23 @@ LibrariesView::double_clicked (const QModelIndex & /*index*/) } void -LibrariesView::set_background_color (QColor c) +LibrariesView::set_background_color (lay::Color c) { m_background_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); (*f)->setPalette (pl); } } void -LibrariesView::set_text_color (QColor c) +LibrariesView::set_text_color (lay::Color c) { m_text_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); (*f)->setPalette (pl); } } @@ -637,11 +638,11 @@ LibrariesView::do_update_content (int lib_index) cell_list->setUniformRowHeights (true); pl = cell_list->palette (); - if (m_text_color.isValid ()) { - pl.setColor (QPalette::Text, m_text_color); + if (m_text_color.is_valid ()) { + pl.setColor (QPalette::Text, QColor (m_text_color.rgb ())); } - if (m_background_color.isValid ()) { - pl.setColor (QPalette::Base, m_background_color); + if (m_background_color.is_valid ()) { + pl.setColor (QPalette::Base, QColor (m_background_color.rgb ())); } cell_list->setPalette (pl); @@ -847,3 +848,5 @@ public: static tl::RegisteredClass config_decl (new LibraryViewPluginDeclaration (), -7, "LibraryViewPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/layui/layui/layLibrariesView.h similarity index 93% rename from src/laybasic/laybasic/layLibrariesView.h rename to src/layui/layui/layLibrariesView.h index 3b12f3a20..5eb2dbdad 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/layui/layui/layLibrariesView.h @@ -20,10 +20,20 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLibrariesView #define HDR_layLibrariesView +#include "layuiCommon.h" +#include "dbLayout.h" +#include "layCanvasPlane.h" +#include "layViewOp.h" +#include "layLayoutViewBase.h" +#include "layCellTreeModel.h" +#include "layWidgets.h" +#include "tlDeferredExecution.h" + #include #include #include @@ -31,14 +41,6 @@ #include #include -#include "dbLayout.h" -#include "layCanvasPlane.h" -#include "layViewOp.h" -#include "layLayoutView.h" -#include "layCellTreeModel.h" -#include "layWidgets.h" -#include "tlDeferredExecution.h" - class QModelIndex; class QComboBox; class QMenu; @@ -94,7 +96,7 @@ protected: * The class communicates with a Layout interface for * retrieval of the cell hierarchy */ -class LibrariesView +class LAYUI_PUBLIC LibrariesView : public QFrame, public tl::Object { @@ -107,7 +109,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - LibrariesView (lay::LayoutView *view, QWidget *parent = 0, const char *name = "libraries_view"); + LibrariesView (LayoutViewBase *view, QWidget *parent = 0, const char *name = "libraries_view"); /** * @brief Destructor @@ -122,12 +124,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Sets the active library by name @@ -206,7 +208,7 @@ public: /** * @brief Gets the layout view this panel is attached to */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -230,7 +232,7 @@ public slots: private: db::Layout *mp_layout; bool m_enable_cb; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector mp_cell_lists; std::vector mp_cell_list_headers; std::vector mp_cell_list_frames; @@ -247,8 +249,8 @@ private: QFrame *mp_search_frame; QCheckBox *mp_search_close_cb; QSplitter *mp_splitter; - QColor m_background_color; - QColor m_text_color; + lay::Color m_background_color; + lay::Color m_text_color; tl::DeferredMethod m_do_update_content_dm; tl::DeferredMethod m_do_full_update_content_dm; std::unique_ptr mp_tree_style; @@ -274,3 +276,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc b/src/layui/layui/layLoadLayoutOptionsDialog.cc similarity index 99% rename from src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc rename to src/layui/layui/layLoadLayoutOptionsDialog.cc index 6d3835299..b36ba0ac1 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc +++ b/src/layui/layui/layLoadLayoutOptionsDialog.cc @@ -20,8 +20,9 @@ */ +#if defined(HAVE_QT) -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layLoadLayoutOptionsDialog.h" #include "layStream.h" #include "layFileDialog.h" @@ -361,4 +362,4 @@ END_PROTECTED } - +#endif diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h b/src/layui/layui/layLoadLayoutOptionsDialog.h similarity index 93% rename from src/laybasic/laybasic/layLoadLayoutOptionsDialog.h rename to src/layui/layui/layLoadLayoutOptionsDialog.h index 2ea91d1a5..f276b783b 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h +++ b/src/layui/layui/layLoadLayoutOptionsDialog.h @@ -20,11 +20,12 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_layLoadLayoutOptionsDialog #define HDR_layLoadLayoutOptionsDialog +#include "layuiCommon.h" #include "dbStream.h" #include "dbLayout.h" #include "layStream.h" @@ -51,11 +52,10 @@ namespace Ui namespace lay { -class LayoutView; class Dispatcher; class FileDialog; -class LAYBASIC_PUBLIC LoadLayoutOptionsDialog +class LAYUI_PUBLIC LoadLayoutOptionsDialog : public QDialog { Q_OBJECT @@ -96,7 +96,7 @@ private: bool get_options_internal (); }; -class LAYBASIC_PUBLIC SpecificLoadLayoutOptionsDialog +class LAYUI_PUBLIC SpecificLoadLayoutOptionsDialog : public QDialog { public: @@ -118,3 +118,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetExportDialog.cc b/src/layui/layui/layNetExportDialog.cc similarity index 99% rename from src/laybasic/laybasic/layNetExportDialog.cc rename to src/layui/layui/layNetExportDialog.cc index 6838810c5..dc38fd9c8 100644 --- a/src/laybasic/laybasic/layNetExportDialog.cc +++ b/src/layui/layui/layNetExportDialog.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layNetExportDialog.h" #include "layPlugin.h" #include "layDispatcher.h" @@ -213,3 +215,5 @@ NetExportDialog::exec_dialog (lay::Dispatcher *plugin_root) } } + +#endif diff --git a/src/laybasic/laybasic/layNetExportDialog.h b/src/layui/layui/layNetExportDialog.h similarity index 97% rename from src/laybasic/laybasic/layNetExportDialog.h rename to src/layui/layui/layNetExportDialog.h index ee46befd4..d0ced5975 100644 --- a/src/laybasic/laybasic/layNetExportDialog.h +++ b/src/layui/layui/layNetExportDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetExportDialog #define HDR_layNetExportDialog @@ -87,3 +88,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetInfoDialog.cc b/src/layui/layui/layNetInfoDialog.cc similarity index 99% rename from src/laybasic/laybasic/layNetInfoDialog.cc rename to src/layui/layui/layNetInfoDialog.cc index bd326b193..056bc2214 100644 --- a/src/laybasic/laybasic/layNetInfoDialog.cc +++ b/src/layui/layui/layNetInfoDialog.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layNetInfoDialog.h" #include "tlXMLWriter.h" @@ -486,3 +488,5 @@ void NetInfoDialog::update_info_text () } } + +#endif diff --git a/src/laybasic/laybasic/layNetInfoDialog.h b/src/layui/layui/layNetInfoDialog.h similarity index 96% rename from src/laybasic/laybasic/layNetInfoDialog.h rename to src/layui/layui/layNetInfoDialog.h index 3c3353125..dee3a88e7 100644 --- a/src/laybasic/laybasic/layNetInfoDialog.h +++ b/src/layui/layui/layNetInfoDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetInfoDialog #define HDR_layNetInfoDialog @@ -73,3 +74,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/layui/layui/layNetlistBrowser.cc similarity index 81% rename from src/laybasic/laybasic/layNetlistBrowser.cc rename to src/layui/layui/layNetlistBrowser.cc index d43501a38..4069e9166 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/layui/layui/layNetlistBrowser.cc @@ -20,12 +20,16 @@ */ +#if defined(HAVE_QT) -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layNetlistBrowserDialog.h" #include "layConverters.h" #include "layDispatcher.h" +#include "ui_NetlistBrowserConfigPage.h" +#include "ui_NetlistBrowserConfigPage2.h" + #include #include @@ -99,9 +103,10 @@ NetlistBrowserWindowModeConverter::to_string (lay::NetlistBrowserConfig::net_win NetlistBrowserConfigPage::NetlistBrowserConfigPage (QWidget *parent) : lay::ConfigPage (parent) { - Ui::NetlistBrowserConfigPage::setupUi (this); + mp_ui = new Ui::NetlistBrowserConfigPage (); + mp_ui->setupUi (this); - connect (cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); + connect (mp_ui->cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); } void @@ -110,17 +115,17 @@ NetlistBrowserConfigPage::setup (lay::Dispatcher *root) // window mode lay::NetlistBrowserConfig::net_window_type wmode = lay::NetlistBrowserConfig::FitNet; root->config_get (cfg_l2ndb_window_mode, wmode, NetlistBrowserWindowModeConverter ()); - cbx_window->setCurrentIndex (int (wmode)); + mp_ui->cbx_window->setCurrentIndex (int (wmode)); // window dimension double wdim = 1.0; root->config_get (cfg_l2ndb_window_dim, wdim); - le_window->setText (tl::to_qstring (tl::to_string (wdim))); + mp_ui->le_window->setText (tl::to_qstring (tl::to_string (wdim))); // max. shapes highlighted unsigned int max_marker_count = 10000; root->config_get (cfg_l2ndb_max_shapes_highlighted, max_marker_count); - le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); + mp_ui->le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); // enable controls window_changed (int (wmode)); @@ -129,19 +134,19 @@ NetlistBrowserConfigPage::setup (lay::Dispatcher *root) void NetlistBrowserConfigPage::window_changed (int m) { - le_window->setEnabled (m == int (lay::NetlistBrowserConfig::FitNet) || m == int (lay::NetlistBrowserConfig::CenterSize)); + mp_ui->le_window->setEnabled (m == int (lay::NetlistBrowserConfig::FitNet) || m == int (lay::NetlistBrowserConfig::CenterSize)); } void NetlistBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string_ext (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (mp_ui->le_window->text ()), dim); unsigned int max_shapes_highlighted = 10000; - tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); + tl::from_string_ext (tl::to_string (mp_ui->le_max_markers->text ()), max_shapes_highlighted); - root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ()); + root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (mp_ui->cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ()); root->config_set (cfg_l2ndb_window_dim, dim); root->config_set (cfg_l2ndb_max_shapes_highlighted, max_shapes_highlighted); } @@ -162,10 +167,11 @@ static QToolButton * (Ui::NetlistBrowserConfigPage2::*cc_buttons []) = { NetlistBrowserConfigPage2::NetlistBrowserConfigPage2 (QWidget *parent) : lay::ConfigPage (parent) { - Ui::NetlistBrowserConfigPage2::setupUi (this); + mp_ui = new Ui::NetlistBrowserConfigPage2 (); + mp_ui->setupUi (this); for (unsigned int i = 0; i < sizeof (cc_buttons) / sizeof (cc_buttons [0]); ++i) { - connect (this->*(cc_buttons [i]), SIGNAL (clicked ()), this, SLOT (color_button_clicked ())); + connect (mp_ui->*(cc_buttons [i]), SIGNAL (clicked ()), this, SLOT (color_button_clicked ())); } } @@ -174,7 +180,7 @@ NetlistBrowserConfigPage2::color_button_clicked () { for (unsigned int i = 0; i < sizeof (cc_buttons) / sizeof (cc_buttons [0]); ++i) { - if (sender () == this->*(cc_buttons [i])) { + if (sender () == mp_ui->*(cc_buttons [i])) { QColor c; if (m_palette.colors () > i) { @@ -199,7 +205,7 @@ NetlistBrowserConfigPage2::setup (lay::Dispatcher *root) { bool cycle_enabled = false; root->config_get (cfg_l2ndb_marker_cycle_colors_enabled, cycle_enabled); - cycle_colors_cb->setChecked (cycle_enabled); + mp_ui->cycle_colors_cb->setChecked (cycle_enabled); std::string cc; root->config_get (cfg_l2ndb_marker_cycle_colors, cc); @@ -217,47 +223,47 @@ NetlistBrowserConfigPage2::setup (lay::Dispatcher *root) // marker color QColor color; root->config_get (cfg_l2ndb_marker_color, color, lay::ColorConverter ()); - color_pb->set_color (color); + mp_ui->color_pb->set_color (color); // use original color bool original_colors = false; root->config_get (cfg_l2ndb_marker_use_original_colors, original_colors); - brightness_cb->setChecked (original_colors); - brightness_sb->setEnabled (original_colors); - brightness_label->setEnabled (original_colors); + mp_ui->brightness_cb->setChecked (original_colors); + mp_ui->brightness_sb->setEnabled (original_colors); + mp_ui->brightness_label->setEnabled (original_colors); // brightness offset int brightness = 0; root->config_get (cfg_l2ndb_marker_intensity, brightness); - brightness_sb->setValue (brightness); + mp_ui->brightness_sb->setValue (brightness); // marker line width int lw = 0; root->config_get (cfg_l2ndb_marker_line_width, lw); if (lw < 0) { - lw_le->setText (QString ()); + mp_ui->lw_le->setText (QString ()); } else { - lw_le->setText (tl::to_qstring (tl::to_string (lw))); + mp_ui->lw_le->setText (tl::to_qstring (tl::to_string (lw))); } // marker vertex size int vs = 0; root->config_get (cfg_l2ndb_marker_vertex_size, vs); if (vs < 0) { - vs_le->setText (QString ()); + mp_ui->vs_le->setText (QString ()); } else { - vs_le->setText (tl::to_qstring (tl::to_string (vs))); + mp_ui->vs_le->setText (tl::to_qstring (tl::to_string (vs))); } // stipple pattern int dp = 0; root->config_get (cfg_l2ndb_marker_dither_pattern, dp); - stipple_pb->set_dither_pattern (dp); + mp_ui->stipple_pb->set_dither_pattern (dp); // halo int halo = 0; root->config_get (cfg_l2ndb_marker_halo, halo); - halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); + mp_ui->halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); } void @@ -280,8 +286,8 @@ NetlistBrowserConfigPage2::update_colors () QRect r (0, 0, pxmp.width () - 1, pxmp.height () - 1); pxpainter.drawRect (r); - (this->*(cc_buttons [i]))->setIconSize (pxmp.size ()); - (this->*(cc_buttons [i]))->setIcon (QIcon (pxmp)); + (mp_ui->*(cc_buttons [i]))->setIconSize (pxmp.size ()); + (mp_ui->*(cc_buttons [i]))->setIcon (QIcon (pxmp)); } } @@ -289,45 +295,45 @@ NetlistBrowserConfigPage2::update_colors () void NetlistBrowserConfigPage2::commit (lay::Dispatcher *root) { - root->config_set (cfg_l2ndb_marker_cycle_colors_enabled, cycle_colors_cb->isChecked ()); + root->config_set (cfg_l2ndb_marker_cycle_colors_enabled, mp_ui->cycle_colors_cb->isChecked ()); root->config_set (cfg_l2ndb_marker_cycle_colors, m_palette.to_string ()); - QColor color = color_pb->get_color (); + QColor color = mp_ui->color_pb->get_color (); root->config_set (cfg_l2ndb_marker_color, color, lay::ColorConverter ()); - if (lw_le->text ().isEmpty ()) { + if (mp_ui->lw_le->text ().isEmpty ()) { root->config_set (cfg_l2ndb_marker_line_width, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->lw_le->text ()), s); root->config_set (cfg_l2ndb_marker_line_width, s); } catch (...) { } } - if (vs_le->text ().isEmpty ()) { + if (mp_ui->vs_le->text ().isEmpty ()) { root->config_set (cfg_l2ndb_marker_vertex_size, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->vs_le->text ()), s); root->config_set (cfg_l2ndb_marker_vertex_size, s); } catch (...) { } } - root->config_set (cfg_l2ndb_marker_dither_pattern, stipple_pb->dither_pattern ()); + root->config_set (cfg_l2ndb_marker_dither_pattern, mp_ui->stipple_pb->dither_pattern ()); - if (halo_cb->checkState () == Qt::PartiallyChecked) { + if (mp_ui->halo_cb->checkState () == Qt::PartiallyChecked) { root->config_set (cfg_l2ndb_marker_halo, -1); - } else if (halo_cb->checkState () == Qt::Unchecked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Unchecked) { root->config_set (cfg_l2ndb_marker_halo, 0); - } else if (halo_cb->checkState () == Qt::Checked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Checked) { root->config_set (cfg_l2ndb_marker_halo, 1); } - root->config_set (cfg_l2ndb_marker_intensity, brightness_sb->value ()); + root->config_set (cfg_l2ndb_marker_intensity, mp_ui->brightness_sb->value ()); - root->config_set (cfg_l2ndb_marker_use_original_colors, brightness_cb->isChecked ()); + root->config_set (cfg_l2ndb_marker_use_original_colors, mp_ui->brightness_cb->isChecked ()); } // ------------------------------------------------------------ @@ -376,7 +382,7 @@ public: menu_entries.push_back (lay::menu_item ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new lay::NetlistBrowserDialog (root, view); } @@ -386,3 +392,4 @@ static tl::RegisteredClass config_decl (new NetlistBrows } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/layui/layui/layNetlistBrowser.h similarity index 85% rename from src/laybasic/laybasic/layNetlistBrowser.h rename to src/layui/layui/layNetlistBrowser.h index 96b55874d..1bea24283 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/layui/layui/layNetlistBrowser.h @@ -20,19 +20,25 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowser #define HDR_layNetlistBrowser #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" -#include "ui_NetlistBrowserConfigPage.h" -#include "ui_NetlistBrowserConfigPage2.h" #include "dbTrans.h" #include +namespace Ui +{ + class NetlistBrowserConfigPage; + class NetlistBrowserConfigPage2; +} + namespace lay { @@ -42,8 +48,7 @@ struct NetlistBrowserConfig }; class NetlistBrowserConfigPage - : public lay::ConfigPage, - private Ui::NetlistBrowserConfigPage + : public lay::ConfigPage { Q_OBJECT @@ -55,11 +60,13 @@ public: public slots: void window_changed (int); + +private: + Ui::NetlistBrowserConfigPage *mp_ui; }; class NetlistBrowserConfigPage2 - : public lay::ConfigPage, - private Ui::NetlistBrowserConfigPage2 + : public lay::ConfigPage { Q_OBJECT @@ -75,6 +82,7 @@ public slots: private: void update_colors (); + Ui::NetlistBrowserConfigPage2 *mp_ui; lay::ColorPalette m_palette; }; @@ -89,3 +97,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/layui/layui/layNetlistBrowserDialog.cc similarity index 81% rename from src/laybasic/laybasic/layNetlistBrowserDialog.cc rename to src/layui/layui/layNetlistBrowserDialog.cc index 4ecf301b4..8c54ccb54 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/layui/layui/layNetlistBrowserDialog.cc @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserDialog.h" #include "tlProgress.h" #include "tlExceptions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layFinder.h" #include "layFileDialog.h" #include "layConverters.h" @@ -33,6 +34,8 @@ #include "dbLayoutToNetlist.h" #include "dbRecursiveShapeIterator.h" +#include "ui_NetlistBrowserDialog.h" + #include #include @@ -56,10 +59,9 @@ extern const std::string cfg_l2ndb_max_shapes_highlighted; extern const std::string cfg_l2ndb_show_all; extern const std::string cfg_l2ndb_window_state; -NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), lay::ViewService (vw->view_object_widget ()), - Ui::NetlistBrowserDialog (), m_window (lay::NetlistBrowserConfig::FitNet), m_window_dim (0.0), m_max_shape_count (0), @@ -74,9 +76,10 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi m_l2n_index (-1), m_mouse_state (0) { - Ui::NetlistBrowserDialog::setupUi (this); + mp_ui = new Ui::NetlistBrowserDialog (); + mp_ui->setupUi (this); - browser_page->set_dispatcher (root); + mp_ui->browser_page->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &NetlistBrowserDialog::cellviews_changed); @@ -84,12 +87,12 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi view ()->l2ndb_list_changed_event.add (this, &NetlistBrowserDialog::l2ndbs_changed); } - m_open_action = new QAction (QObject::tr ("Open"), file_menu); - m_saveas_action = new QAction (QObject::tr ("Save As"), file_menu); - m_export_action = new QAction (QObject::tr ("Export To Layout"), file_menu); - m_reload_action = new QAction (QObject::tr ("Reload"), file_menu); - m_unload_action = new QAction (QObject::tr ("Unload"), file_menu); - m_unload_all_action = new QAction (QObject::tr ("Unload All"), file_menu); + m_open_action = new QAction (QObject::tr ("Open"), mp_ui->file_menu); + m_saveas_action = new QAction (QObject::tr ("Save As"), mp_ui->file_menu); + m_export_action = new QAction (QObject::tr ("Export To Layout"), mp_ui->file_menu); + m_reload_action = new QAction (QObject::tr ("Reload"), mp_ui->file_menu); + m_unload_action = new QAction (QObject::tr ("Unload"), mp_ui->file_menu); + m_unload_all_action = new QAction (QObject::tr ("Unload All"), mp_ui->file_menu); connect (m_open_action, SIGNAL (triggered ()), this, SLOT (open_clicked ())); connect (m_saveas_action, SIGNAL (triggered ()), this, SLOT (saveas_clicked ())); @@ -98,30 +101,30 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi connect (m_unload_action, SIGNAL (triggered ()), this, SLOT (unload_clicked ())); connect (m_unload_all_action, SIGNAL (triggered ()), this, SLOT (unload_all_clicked ())); - file_menu->addAction (m_open_action); - file_menu->addAction (m_saveas_action); - QAction *sep0 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_open_action); + mp_ui->file_menu->addAction (m_saveas_action); + QAction *sep0 = new QAction (mp_ui->file_menu); sep0->setSeparator (true); - file_menu->addAction (m_export_action); - QAction *sep1 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_export_action); + QAction *sep1 = new QAction (mp_ui->file_menu); sep1->setSeparator (true); - file_menu->addAction (sep1); - file_menu->addAction (m_reload_action); - QAction *sep2 = new QAction (file_menu); + mp_ui->file_menu->addAction (sep1); + mp_ui->file_menu->addAction (m_reload_action); + QAction *sep2 = new QAction (mp_ui->file_menu); sep2->setSeparator (true); - file_menu->addAction (sep2); - file_menu->addAction (m_unload_action); - file_menu->addAction (m_unload_all_action); + mp_ui->file_menu->addAction (sep2); + mp_ui->file_menu->addAction (m_unload_action); + mp_ui->file_menu->addAction (m_unload_all_action); - connect (layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); - connect (l2ndb_cb, SIGNAL (activated (int)), this, SLOT (l2ndb_index_changed (int))); - connect (configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); - connect (probe_pb, SIGNAL (clicked ()), this, SLOT (probe_button_pressed ())); - connect (sticky_cbx, SIGNAL (clicked ()), this, SLOT (sticky_mode_clicked ())); + connect (mp_ui->layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); + connect (mp_ui->l2ndb_cb, SIGNAL (activated (int)), this, SLOT (l2ndb_index_changed (int))); + connect (mp_ui->configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); + connect (mp_ui->probe_pb, SIGNAL (clicked ()), this, SLOT (probe_button_pressed ())); + connect (mp_ui->sticky_cbx, SIGNAL (clicked ()), this, SLOT (sticky_mode_clicked ())); cellviews_changed (); - browser_page->selection_changed_event.add (this, &NetlistBrowserDialog::selection_changed); + mp_ui->browser_page->selection_changed_event.add (this, &NetlistBrowserDialog::selection_changed); } NetlistBrowserDialog::~NetlistBrowserDialog () @@ -132,14 +135,14 @@ NetlistBrowserDialog::~NetlistBrowserDialog () db::LayoutToNetlist * NetlistBrowserDialog::db () { - return browser_page->db (); + return mp_ui->browser_page->db (); } const lay::NetlistObjectsPath & NetlistBrowserDialog::current_path () const { - if (browser_page) { - return browser_page->current_path (); + if (mp_ui->browser_page) { + return mp_ui->browser_page->current_path (); } else { static lay::NetlistObjectsPath empty; return empty; @@ -149,8 +152,8 @@ NetlistBrowserDialog::current_path () const const std::vector & NetlistBrowserDialog::selected_paths () const { - if (browser_page) { - return browser_page->selected_paths (); + if (mp_ui->browser_page) { + return mp_ui->browser_page->selected_paths (); } else { static std::vector empty; return empty; @@ -180,7 +183,7 @@ void NetlistBrowserDialog::sticky_mode_clicked () { BEGIN_PROTECTED - if (! sticky_cbx->isChecked ()) { + if (! mp_ui->sticky_cbx->isChecked ()) { release_mouse (); } else { probe_button_pressed (); @@ -205,7 +208,7 @@ NetlistBrowserDialog::mouse_click_event (const db::DPoint &p, unsigned int butto bool trace_path = (m_mouse_state == 3); - if (trace_path || ! sticky_cbx->isChecked ()) { + if (trace_path || ! mp_ui->sticky_cbx->isChecked ()) { release_mouse (); } @@ -332,12 +335,12 @@ NetlistBrowserDialog::probe_net (const db::DPoint &p, bool trace_path) path.path = lay::NetlistObjectPath::path_type (sc_path.begin (), sc_path.end ()); } - browser_page->select_path (path); + mp_ui->browser_page->select_path (path); // emits the probe event // NOTE: browser_page->current_path () will hold the paired path with the schematic side being // expanded. - probe_event (browser_page->current_path ().first (), browser_page->current_path ().second ()); + probe_event (mp_ui->browser_page->current_path ().first (), mp_ui->browser_page->current_path ().second ()); } void @@ -409,7 +412,7 @@ void NetlistBrowserDialog::export_clicked () { if (m_l2n_index < int (view ()->num_l2ndbs ()) && m_l2n_index >= 0) { - browser_page->export_all (); + mp_ui->browser_page->export_all (); } } @@ -423,7 +426,7 @@ BEGIN_PROTECTED db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index); db::LayoutVsSchematic *lvsdb = dynamic_cast (l2ndb); - if (lvsdb && ! browser_page->is_netlist_mode ()) { + if (lvsdb && ! mp_ui->browser_page->is_netlist_mode ()) { // prepare and open the file dialog lay::FileDialog save_dialog (this, tl::to_string (QObject::tr ("Save LVS Database")), "KLayout LVS DB files (*.lvsdb)"); @@ -471,10 +474,10 @@ BEGIN_PROTECTED tl::log << tl::to_string (QObject::tr ("Loading file: ")) << l2ndb->filename (); tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - browser_page->set_db (0); + mp_ui->browser_page->set_db (0); try { l2ndb->load (l2ndb->filename ()); - browser_page->set_db (l2ndb); + mp_ui->browser_page->set_db (l2ndb); current_db_changed_event (); } catch (...) { current_db_changed_event (); @@ -512,7 +515,7 @@ BEGIN_PROTECTED tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); int l2n_index = view ()->add_l2ndb (db::LayoutToNetlist::create_from_file (m_open_filename)); - l2ndb_cb->setCurrentIndex (l2n_index); + mp_ui->l2ndb_cb->setCurrentIndex (l2n_index); // it looks like the setCurrentIndex does not issue this signal: l2ndb_index_changed (l2n_index); @@ -526,7 +529,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val { bool need_update = false; bool taken = true; - bool show_all = browser_page->show_all (); + bool show_all = mp_ui->browser_page->show_all (); if (name == cfg_l2ndb_show_all) { @@ -555,7 +558,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val } else if (name == cfg_l2ndb_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } @@ -623,12 +626,12 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val } if (active () && need_update) { - browser_page->set_max_shape_count (m_max_shape_count); - browser_page->set_window (m_window, m_window_dim); - browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); + mp_ui->browser_page->set_max_shape_count (m_max_shape_count); + mp_ui->browser_page->set_window (m_window, m_window_dim); + mp_ui->browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); } - browser_page->show_all (show_all); + mp_ui->browser_page->show_all (show_all); return taken; } @@ -661,11 +664,11 @@ NetlistBrowserDialog::l2ndbs_changed () { int l2n_index = -1; - l2ndb_cb->clear (); + mp_ui->l2ndb_cb->clear (); for (unsigned int i = 0; i < view ()->num_l2ndbs (); ++i) { const db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (i); - l2ndb_cb->addItem (tl::to_qstring (l2ndb->name ())); + mp_ui->l2ndb_cb->addItem (tl::to_qstring (l2ndb->name ())); if (l2ndb->name () == m_l2ndb_name) { l2n_index = i; } @@ -673,7 +676,7 @@ NetlistBrowserDialog::l2ndbs_changed () // force an update m_l2n_index = l2n_index; - l2ndb_cb->setCurrentIndex (l2n_index); + mp_ui->l2ndb_cb->setCurrentIndex (l2n_index); if (active ()) { update_content (); } @@ -682,7 +685,7 @@ NetlistBrowserDialog::l2ndbs_changed () void NetlistBrowserDialog::cellview_changed (int) { - browser_page->update_highlights (); + mp_ui->browser_page->update_highlights (); } void @@ -690,17 +693,17 @@ NetlistBrowserDialog::cellviews_changed () { int cv_index = -1; - layout_cb->clear (); + mp_ui->layout_cb->clear (); for (unsigned int i = 0; i < view ()->cellviews (); ++i) { const lay::CellView &cv = view ()->cellview (i); - layout_cb->addItem (tl::to_qstring (cv->name ())); + mp_ui->layout_cb->addItem (tl::to_qstring (cv->name ())); if (cv.is_valid () && cv->name () == m_layout_name) { cv_index = i; } } - layout_cb->setCurrentIndex (cv_index); + mp_ui->layout_cb->setCurrentIndex (cv_index); cv_index_changed (cv_index); } @@ -756,11 +759,11 @@ NetlistBrowserDialog::update_content () db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index); - probe_pb->setEnabled (l2ndb != 0); + mp_ui->probe_pb->setEnabled (l2ndb != 0); release_mouse (); if (! l2ndb) { - central_stack->setCurrentIndex (1); + mp_ui->central_stack->setCurrentIndex (1); } bool db_changed = false; @@ -771,18 +774,18 @@ NetlistBrowserDialog::update_content () m_unload_all_action->setEnabled (l2ndb != 0); m_reload_action->setEnabled (l2ndb != 0); - browser_page->enable_updates (false); // Avoid building the internal lists several times ... - db_changed = browser_page->set_db (l2ndb); - browser_page->set_max_shape_count (m_max_shape_count); - browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); - browser_page->set_window (m_window, m_window_dim); - browser_page->set_view (view (), m_cv_index); - browser_page->enable_updates (true); + mp_ui->browser_page->enable_updates (false); // Avoid building the internal lists several times ... + db_changed = mp_ui->browser_page->set_db (l2ndb); + mp_ui->browser_page->set_max_shape_count (m_max_shape_count); + mp_ui->browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); + mp_ui->browser_page->set_window (m_window, m_window_dim); + mp_ui->browser_page->set_view (view (), m_cv_index); + mp_ui->browser_page->enable_updates (true); if (l2ndb) { // Note: it appears to be required to show the browser page after it has been configured. // Otherwise the header gets messed up and the configuration is reset. - central_stack->setCurrentIndex (0); + mp_ui->central_stack->setCurrentIndex (0); } lay::CellView cv = view ()->cellview (m_cv_index); @@ -791,12 +794,12 @@ NetlistBrowserDialog::update_content () m_layout_name = cv->name (); } - if (layout_cb->currentIndex () != m_cv_index) { - layout_cb->setCurrentIndex (m_cv_index); + if (mp_ui->layout_cb->currentIndex () != m_cv_index) { + mp_ui->layout_cb->setCurrentIndex (m_cv_index); } - if (l2ndb_cb->currentIndex () != m_l2n_index) { - l2ndb_cb->setCurrentIndex (m_l2n_index); + if (mp_ui->l2ndb_cb->currentIndex () != m_l2n_index) { + mp_ui->l2ndb_cb->setCurrentIndex (m_l2n_index); } if (db_changed) { @@ -814,11 +817,11 @@ NetlistBrowserDialog::deactivated () } bool db_changed = false; - if (browser_page->db () != 0) { + if (mp_ui->browser_page->db () != 0) { db_changed = true; - browser_page->set_db (0); + mp_ui->browser_page->set_db (0); } - browser_page->set_view (0, 0); + mp_ui->browser_page->set_view (0, 0); if (db_changed) { current_db_changed_event (); @@ -838,3 +841,4 @@ NetlistBrowserDialog::menu_activated (const std::string &symbol) } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/layui/layui/layNetlistBrowserDialog.h similarity index 89% rename from src/laybasic/laybasic/layNetlistBrowserDialog.h rename to src/layui/layui/layNetlistBrowserDialog.h index b8e929cfa..6c7021fb5 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/layui/layui/layNetlistBrowserDialog.h @@ -20,29 +20,42 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserDialog #define HDR_layNetlistBrowserDialog -#include "ui_NetlistBrowserDialog.h" +#include "layuiCommon.h" #include "layBrowser.h" #include "layNetlistBrowser.h" #include "layViewObject.h" #include "layColorPalette.h" #include "tlEvents.h" +namespace Ui +{ + class NetlistBrowserDialog; +} + +namespace db +{ + class LayoutToNetlist; +} + namespace lay { -class NetlistBrowserDialog +class NetlistObjectPath; +class NetlistObjectsPath; + +class LAYUI_PUBLIC NetlistBrowserDialog : public lay::Browser, - public lay::ViewService, - private Ui::NetlistBrowserDialog + public lay::ViewService { Q_OBJECT public: - NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~NetlistBrowserDialog (); void load (int lay_index, int cv_index); @@ -116,10 +129,11 @@ public slots: void sticky_mode_clicked (); private: + Ui::NetlistBrowserDialog *mp_ui; lay::NetlistBrowserConfig::net_window_type m_window; double m_window_dim; unsigned int m_max_shape_count; - QColor m_marker_color; + lay::Color m_marker_color; lay::ColorPalette m_auto_colors; bool m_auto_color_enabled; int m_marker_line_width; @@ -151,3 +165,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/layui/layui/layNetlistBrowserModel.cc similarity index 96% rename from src/laybasic/laybasic/layNetlistBrowserModel.cc rename to src/layui/layui/layNetlistBrowserModel.cc index 61126be03..cd1696a7b 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/layui/layui/layNetlistBrowserModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserModel.h" #include "layIndexedNetlistModel.h" @@ -100,129 +101,6 @@ NetlistObjectsPath::second () const return p; } -// ---------------------------------------------------------------------------------- -// NetColorizer implementation - -NetColorizer::NetColorizer () -{ - m_auto_colors_enabled = false; - m_update_needed = false; - m_signals_enabled = true; -} - -void -NetColorizer::configure (const QColor &marker_color, const lay::ColorPalette *auto_colors) -{ - m_marker_color = marker_color; - if (auto_colors) { - m_auto_colors = *auto_colors; - m_auto_colors_enabled = true; - } else { - m_auto_colors_enabled = false; - } - - emit_colors_changed (); -} - -bool -NetColorizer::has_color_for_net (const db::Net *net) -{ - return net != 0 && (m_auto_colors_enabled || m_custom_color.find (net) != m_custom_color.end ()); -} - -void -NetColorizer::set_color_of_net (const db::Net *net, const QColor &color) -{ - m_custom_color[net] = color; - emit_colors_changed (); -} - -void -NetColorizer::reset_color_of_net (const db::Net *net) -{ - m_custom_color.erase (net); - emit_colors_changed (); -} - -void -NetColorizer::clear () -{ - m_net_index_by_object.clear (); - m_custom_color.clear (); - emit_colors_changed (); -} - -void -NetColorizer::begin_changes () -{ - if (m_signals_enabled) { - m_update_needed = false; - m_signals_enabled = false; - } -} - -void -NetColorizer::end_changes () -{ - if (! m_signals_enabled) { - m_signals_enabled = true; - if (m_update_needed) { - emit colors_changed (); - } - m_update_needed = false; - } -} - -void -NetColorizer::emit_colors_changed () -{ - if (! m_signals_enabled) { - m_update_needed = true; - } else { - emit colors_changed (); - } -} - -QColor -NetColorizer::color_of_net (const db::Net *net) const -{ - if (! net) { - return QColor (); - } - - std::map::const_iterator c = m_custom_color.find (net); - if (c != m_custom_color.end ()) { - return c->second; - } - - if (m_auto_colors_enabled) { - - const db::Circuit *circuit = net->circuit (); - - size_t index = 0; - - std::map::iterator cc = m_net_index_by_object.find (net); - if (cc == m_net_index_by_object.end ()) { - - size_t i = 0; - for (db::Circuit::const_net_iterator n = circuit->begin_nets (); n != circuit->end_nets (); ++n, ++i) { - m_net_index_by_object.insert (std::make_pair (n.operator-> (), i)); - if (n.operator-> () == net) { - index = i; - } - } - - } else { - index = cc->second; - } - - return m_auto_colors.color_by_index ((unsigned int) index); - - } else { - return QColor (); - } -} - // ---------------------------------------------------------------------------------- // Implementation of the item classes @@ -823,9 +701,9 @@ static QIcon icon_for_subcircuit () return icon; } -static QIcon colored_icon (const QColor &color, const QIcon &original_icon) +static QIcon colored_icon (const lay::Color &color, const QIcon &original_icon) { - if (! color.isValid ()) { + if (! color.is_valid ()) { return icon_for_net (); } @@ -857,12 +735,12 @@ static QIcon colored_icon (const QColor &color, const QIcon &original_icon) return colored_icon; } -static QIcon net_icon_with_color (const QColor &color) +static QIcon net_icon_with_color (const lay::Color &color) { return colored_icon (color, light_icon_for_net ()); } -static QIcon connection_icon_with_color (const QColor &color) +static QIcon connection_icon_with_color (const lay::Color &color) { return colored_icon (color, light_icon_for_connection ()); } @@ -2503,7 +2381,7 @@ NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutToNetlist * { mp_root.reset (new RootItemData ()); mp_indexer.reset (new SingleIndexedNetlistModel (l2ndb->netlist ())); - connect (mp_colorizer, SIGNAL (colors_changed ()), this, SLOT (colors_changed ())); + mp_colorizer->colors_changed.add (this, &NetlistBrowserModel::colors_changed); m_object_column = 0; m_status_column = -1; @@ -2516,7 +2394,7 @@ NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutVsSchematic { mp_root.reset (new RootItemData ()); mp_indexer.reset (new NetlistCrossReferenceModel (lvsdb->cross_ref ())); - connect (mp_colorizer, SIGNAL (colors_changed ()), this, SLOT (colors_changed ())); + mp_colorizer->colors_changed.add (this, &NetlistBrowserModel::colors_changed); m_object_column = 0; m_status_column = 1; @@ -2869,7 +2747,7 @@ NetlistBrowserModel::icon_for_nets (const std::pairhas_color_for_net (net)) { - QColor color = mp_colorizer->color_of_net (net); + lay::Color color = mp_colorizer->color_of_net (net); lay::color_t rgb = lay::color_t (color.rgb ()); std::map::const_iterator c = m_net_icon_per_color.find (rgb); @@ -2891,7 +2769,7 @@ NetlistBrowserModel::icon_for_connection (const std::pairhas_color_for_net (net)) { - QColor color = mp_colorizer->color_of_net (net); + lay::Color color = mp_colorizer->color_of_net (net); lay::color_t rgb = lay::color_t (color.rgb ()); std::map::const_iterator c = m_connection_icon_per_color.find (rgb); @@ -3143,3 +3021,4 @@ NetlistBrowserModel::set_item_visibility (QTreeView *view, bool show_all, bool w } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/layui/layui/layNetlistBrowserModel.h similarity index 90% rename from src/laybasic/laybasic/layNetlistBrowserModel.h rename to src/layui/layui/layNetlistBrowserModel.h index 005664a6f..0a634aebd 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/layui/layui/layNetlistBrowserModel.h @@ -20,21 +20,23 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserModel #define HDR_layNetlistBrowserModel #include "layColorPalette.h" -#include "laybasicCommon.h" +#include "layColor.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" +#include "layNetColorizer.h" #include "tlList.h" #include "tlTypeTraits.h" #include -#include #include #include @@ -46,48 +48,6 @@ namespace lay class IndexedNetlistModel; -// ---------------------------------------------------------------------------------- -// NetColorizer definition - -class LAYBASIC_PUBLIC NetColorizer - : public QObject -{ -Q_OBJECT - -public: - NetColorizer (); - - void configure (const QColor &marker_color, const lay::ColorPalette *auto_colors); - bool has_color_for_net (const db::Net *net); - void set_color_of_net (const db::Net *net, const QColor &color); - void reset_color_of_net (const db::Net *net); - void clear (); - - QColor color_of_net (const db::Net *net) const; - - const QColor &marker_color () const - { - return m_marker_color; - } - - void begin_changes (); - void end_changes (); - -signals: - void colors_changed (); - -private: - QColor m_marker_color; - lay::ColorPalette m_auto_colors; - bool m_auto_colors_enabled; - std::map m_custom_color; - bool m_update_needed; - bool m_signals_enabled; - mutable std::map m_net_index_by_object; - - void emit_colors_changed (); -}; - // ---------------------------------------------------------------------------------- // NetlistBrowserModel definition @@ -175,8 +135,9 @@ private: * This object applies to pairs of these objects. A class providing a path for a single * object is NetlistObjectPath */ -struct LAYBASIC_PUBLIC NetlistObjectPath +class LAYUI_PUBLIC NetlistObjectPath { +public: typedef std::list path_type; typedef path_type::const_iterator path_iterator; @@ -209,8 +170,9 @@ struct LAYBASIC_PUBLIC NetlistObjectPath * This object applies to pairs of these objects. A class providing a path for a single * object is NetlistObjectPath */ -struct LAYBASIC_PUBLIC NetlistObjectsPath +class LAYUI_PUBLIC NetlistObjectsPath { +public: typedef std::list > path_type; typedef path_type::const_iterator path_iterator; @@ -261,8 +223,8 @@ struct LAYBASIC_PUBLIC NetlistObjectsPath * - #pins+#nets+#subcircuits..: devices * - terminals and nets */ -class LAYBASIC_PUBLIC NetlistBrowserModel - : public QAbstractItemModel +class LAYUI_PUBLIC NetlistBrowserModel + : public QAbstractItemModel, public tl::Object { Q_OBJECT @@ -384,3 +346,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/layui/layui/layNetlistBrowserPage.cc similarity index 97% rename from src/laybasic/laybasic/layNetlistBrowserPage.cc rename to src/layui/layui/layNetlistBrowserPage.cc index f69b537d7..ebe686886 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/layui/layui/layNetlistBrowserPage.cc @@ -20,13 +20,14 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserPage.h" #include "layNetlistBrowserModel.h" #include "layNetlistBrowserTreeModel.h" #include "layItemDelegates.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "layNetInfoDialog.h" #include "layNetExportDialog.h" @@ -229,7 +230,7 @@ NetlistBrowserPage::set_dispatcher (lay::Dispatcher *pr) } void -NetlistBrowserPage::set_highlight_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors) +NetlistBrowserPage::set_highlight_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors) { m_colorizer.configure (color, auto_colors); m_marker_line_width = line_width; @@ -242,7 +243,7 @@ NetlistBrowserPage::set_highlight_style (QColor color, int line_width, int verte } void -NetlistBrowserPage::set_view (lay::LayoutView *view, int cv_index) +NetlistBrowserPage::set_view (lay::LayoutViewBase *view, int cv_index) { if (mp_view) { mp_view->layer_list_changed_event.remove (this, &NetlistBrowserPage::layer_list_changed); @@ -492,13 +493,13 @@ NetlistBrowserPage::selection_changed () } void -NetlistBrowserPage::set_color_for_selected_nets (const QColor &color) +NetlistBrowserPage::set_color_for_selected_nets (const lay::Color &color) { std::vector nets = selected_nets (); m_colorizer.begin_changes (); for (std::vector::const_iterator n = nets.begin (); n != nets.end (); ++n) { - if (color.isValid ()) { + if (color.is_valid ()) { m_colorizer.set_color_of_net (*n, color); } else { m_colorizer.reset_color_of_net (*n); @@ -514,7 +515,7 @@ NetlistBrowserPage::browse_color_for_net () { QColor c = QColorDialog::getColor (QColor (), this); if (c.isValid ()) { - set_color_for_selected_nets (c); + set_color_for_selected_nets (lay::Color (c.rgb ())); } } @@ -523,7 +524,7 @@ NetlistBrowserPage::select_color_for_net () { QAction *action = dynamic_cast (sender ()); if (action) { - set_color_for_selected_nets (action->data ().value ()); + set_color_for_selected_nets (lay::Color (action->data ().value ().rgb ())); } } @@ -1095,11 +1096,11 @@ NetlistBrowserPage::adjust_view () } } -QColor -NetlistBrowserPage::make_valid_color (const QColor &color) +lay::Color +NetlistBrowserPage::make_valid_color (const lay::Color &color) { - if (! color.isValid () && mp_view) { - return mp_view->background_color ().green () < 128 ? QColor (Qt::white) : QColor (Qt::black); + if (! color.is_valid () && mp_view) { + return mp_view->background_color ().to_mono () ? lay::Color (0, 0, 0) : lay::Color (255, 255, 255); } else { return color; } @@ -1110,7 +1111,7 @@ NetlistBrowserPage::produce_highlights_for_device (const db::Device *device, siz { const db::Layout *layout = mp_database->internal_layout (); - QColor color = make_valid_color (m_colorizer.marker_color ()); + lay::Color color = make_valid_color (m_colorizer.marker_color ()); db::Box device_bbox = bbox_for_device_abstract (layout, device->device_abstract (), device->trans ()); if (! device_bbox.empty ()) { @@ -1159,7 +1160,7 @@ NetlistBrowserPage::produce_highlights_for_circuit (const db::Circuit *circuit, { const db::Layout *layout = mp_database->internal_layout (); - QColor color = make_valid_color (m_colorizer.marker_color ()); + lay::Color color = make_valid_color (m_colorizer.marker_color ()); db::Box circuit_bbox = bbox_for_circuit (layout, circuit); if (circuit_bbox.empty ()) { return false; @@ -1188,8 +1189,8 @@ NetlistBrowserPage::produce_highlights_for_net (const db::Net *net, size_t &n_ma db::cell_index_type cell_index = net->circuit ()->cell_index (); size_t cluster_id = net->cluster_id (); - QColor net_color = m_colorizer.color_of_net (net); - QColor fallback_color = make_valid_color (m_colorizer.marker_color ()); + lay::Color net_color = m_colorizer.color_of_net (net); + lay::Color fallback_color = make_valid_color (m_colorizer.marker_color ()); const db::Connectivity &conn = mp_database->connectivity (); for (db::Connectivity::layer_iterator layer = conn.begin_layers (); layer != conn.end_layers (); ++layer) { @@ -1212,7 +1213,7 @@ NetlistBrowserPage::produce_highlights_for_net (const db::Net *net, size_t &n_ma mp_markers.push_back (new lay::Marker (mp_view, m_cv_index)); mp_markers.back ()->set (shapes->polygon_ref (), shapes.trans (), tv); - if (net_color.isValid ()) { + if (net_color.is_valid ()) { mp_markers.back ()->set_color (net_color); mp_markers.back ()->set_frame_color (net_color); @@ -1424,7 +1425,7 @@ NetlistBrowserPage::export_nets (const std::vector *nets) if (dialog->exec_dialog (mp_plugin_root)) { // NOTE: mp_view and database might get reset to 0 in create_layout - lay::LayoutView *view = mp_view; + lay::LayoutViewBase *view = mp_view; db::LayoutToNetlist *database = mp_database.get (); unsigned int cv_index = view->create_layout (true); @@ -1458,3 +1459,4 @@ NetlistBrowserPage::export_nets (const std::vector *nets) } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/layui/layui/layNetlistBrowserPage.h similarity index 93% rename from src/laybasic/laybasic/layNetlistBrowserPage.h rename to src/layui/layui/layNetlistBrowserPage.h index 77cf489e7..4fb4281ac 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/layui/layui/layNetlistBrowserPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserPage #define HDR_layNetlistBrowserPage @@ -27,7 +28,7 @@ #include "ui_NetlistBrowserPage.h" #include "layNetlistBrowserModel.h" #include "layNetlistBrowser.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" #include "dbLayoutUtils.h" @@ -42,7 +43,7 @@ class QAction; namespace lay { -class LayoutView; +class LayoutViewBase; class Dispatcher; class Marker; class NetInfoDialog; @@ -86,7 +87,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutView *view, int cv_index); + void set_view (LayoutViewBase *view, int cv_index); /** * @brief Attaches the page to a L2N DB @@ -141,7 +142,7 @@ public: * @param halo The halo flag or -1 for default * @param dither_pattern The dither pattern index of -1 to take the default */ - void set_highlight_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors); + void set_highlight_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors); /** * @brief Gets a value indicating whether all items in the netlist tree are shown (specifically for cross-reference DBs) @@ -224,7 +225,7 @@ private: int m_marker_dither_pattern; int m_marker_intensity; bool m_use_original_colors; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; lay::Dispatcher *mp_plugin_root; tl::weak_ptr mp_database; @@ -253,9 +254,9 @@ private: std::vector selected_devices (); std::vector selected_subcircuits (); std::vector selected_circuits (); - void set_color_for_selected_nets (const QColor &color); + void set_color_for_selected_nets (const lay::Color &color); void layer_list_changed (int); - QColor make_valid_color (const QColor &color); + lay::Color make_valid_color (const lay::Color &color); bool produce_highlights_for_net(const db::Net *net, size_t &n_markers, const std::map &display_by_lp, const std::vector &tv); bool produce_highlights_for_device (const db::Device *device, size_t &n_markers, const std::vector &tv); bool produce_highlights_for_circuit (const db::Circuit *circuit, size_t &n_markers, const std::vector &tv); @@ -269,3 +270,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc b/src/layui/layui/layNetlistBrowserTreeModel.cc similarity index 99% rename from src/laybasic/laybasic/layNetlistBrowserTreeModel.cc rename to src/layui/layui/layNetlistBrowserTreeModel.cc index c88954df6..cc13503c0 100644 --- a/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc +++ b/src/layui/layui/layNetlistBrowserTreeModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserTreeModel.h" #include "layIndexedNetlistModel.h" @@ -447,3 +448,5 @@ NetlistBrowserTreeModel::rowCount (const QModelIndex &parent) const } } + +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h b/src/layui/layui/layNetlistBrowserTreeModel.h similarity index 96% rename from src/laybasic/laybasic/layNetlistBrowserTreeModel.h rename to src/layui/layui/layNetlistBrowserTreeModel.h index d17c0bff2..021694e8a 100644 --- a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h +++ b/src/layui/layui/layNetlistBrowserTreeModel.h @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserTreeModel #define HDR_layNetlistBrowserTreeModel #include "layColorPalette.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" @@ -42,7 +43,7 @@ namespace lay { class IndexedNetlistModel; -struct NetlistObjectsPath; +class NetlistObjectsPath; // ---------------------------------------------------------------------------------- // NetlistBrowserTreeModel definition @@ -50,7 +51,7 @@ struct NetlistObjectsPath; /** * @brief The model for the circuit hierarchy tree */ -class LAYBASIC_PUBLIC NetlistBrowserTreeModel +class LAYUI_PUBLIC NetlistBrowserTreeModel : public QAbstractItemModel { Q_OBJECT @@ -103,3 +104,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc b/src/layui/layui/layNetlistCrossReferenceModel.cc similarity index 99% rename from src/laybasic/laybasic/layNetlistCrossReferenceModel.cc rename to src/layui/layui/layNetlistCrossReferenceModel.cc index 17ced1c64..ca0a4682b 100644 --- a/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc +++ b/src/layui/layui/layNetlistCrossReferenceModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistCrossReferenceModel.h" @@ -800,3 +801,5 @@ std::string NetlistCrossReferenceModel::subcircuit_status_hint (const circuit_pa } } + +#endif diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h b/src/layui/layui/layNetlistCrossReferenceModel.h similarity index 98% rename from src/laybasic/laybasic/layNetlistCrossReferenceModel.h rename to src/layui/layui/layNetlistCrossReferenceModel.h index 8ad542411..9a721c56a 100644 --- a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h +++ b/src/layui/layui/layNetlistCrossReferenceModel.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistCrossReference #define HDR_layNetlistCrossReference -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layIndexedNetlistModel.h" #include "dbNetlistCrossReference.h" @@ -35,7 +36,7 @@ namespace lay /** * @brief An indexed netlist model for the netlist cross-reference */ -class LAYBASIC_PUBLIC NetlistCrossReferenceModel +class LAYUI_PUBLIC NetlistCrossReferenceModel : public lay::IndexedNetlistModel { public: @@ -119,3 +120,5 @@ public: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layQtTools.cc b/src/layui/layui/layQtTools.cc similarity index 99% rename from src/laybasic/laybasic/layQtTools.cc rename to src/layui/layui/layQtTools.cc index 70a0f6b22..66ac0ee61 100644 --- a/src/laybasic/laybasic/layQtTools.cc +++ b/src/layui/layui/layQtTools.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layQtTools.h" #include "tlString.h" @@ -219,3 +220,4 @@ SignalBlocker::~SignalBlocker () } +#endif diff --git a/src/laybasic/laybasic/layQtTools.h b/src/layui/layui/layQtTools.h similarity index 75% rename from src/laybasic/laybasic/layQtTools.h rename to src/layui/layui/layQtTools.h index fe0a65557..f5c4ae97f 100644 --- a/src/laybasic/laybasic/layQtTools.h +++ b/src/layui/layui/layQtTools.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layQtTools #define HDR_layQtTools -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -47,27 +48,27 @@ namespace lay * * The state can be recovered from the string using restore_dialog_state; */ -LAYBASIC_PUBLIC std::string save_dialog_state (QWidget *dialog, bool with_section_sizes = true); +LAYUI_PUBLIC std::string save_dialog_state (QWidget *dialog, bool with_section_sizes = true); /** * @brief Restore the dialog's state from the given string */ -LAYBASIC_PUBLIC void restore_dialog_state (QWidget *dialog, const std::string &s, bool with_section_sizes = true); +LAYUI_PUBLIC void restore_dialog_state (QWidget *dialog, const std::string &s, bool with_section_sizes = true); /** * @brief A utility function connecting a label's linkActivated event with the help browser */ -LAYBASIC_PUBLIC void activate_help_links (QLabel *label); +LAYUI_PUBLIC void activate_help_links (QLabel *label); /** * @brief A utility function connecting a label's linkActivated event with the help browser (modal help dialogs) */ -LAYBASIC_PUBLIC void activate_modal_help_links (QLabel *label); +LAYUI_PUBLIC void activate_modal_help_links (QLabel *label); /** * @brief Register the help handler (object and slots for non-modal and modal help dialogs) */ -LAYBASIC_PUBLIC void register_help_handler (QObject *object, const char *slot, const char *modal_slot); +LAYUI_PUBLIC void register_help_handler (QObject *object, const char *slot, const char *modal_slot); /** * @brief Configures a QLineEdit or other widget to indicate an error @@ -76,24 +77,24 @@ LAYBASIC_PUBLIC void register_help_handler (QObject *object, const char *slot, c * and the exception's text will be used as tooltip. Use this function with * a null ex pointer to clear the error condition. */ -LAYBASIC_PUBLIC void indicate_error (QWidget *le, const tl::Exception *ex); +LAYUI_PUBLIC void indicate_error (QWidget *le, const tl::Exception *ex); /** * @brief Configures a QLineEdit or other widget to indicate an error */ -LAYBASIC_PUBLIC void indicate_error (QWidget *le, bool error); +LAYUI_PUBLIC void indicate_error (QWidget *le, bool error); /** * @brief Gets the system monospace font */ -LAYBASIC_PUBLIC QFont monospace_font (); +LAYUI_PUBLIC QFont monospace_font (); #if QT_VERSION < 0x050000 // Provide missing QSignalBlocker for Qt4 -class LAYBASIC_PUBLIC SignalBlocker +class LAYUI_PUBLIC SignalBlocker { public: SignalBlocker (QWidget *w); @@ -114,3 +115,4 @@ typedef QSignalBlocker SignalBlocker; #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc b/src/layui/layui/laySaveLayoutOptionsDialog.cc similarity index 98% rename from src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc rename to src/layui/layui/laySaveLayoutOptionsDialog.cc index 675373333..dc741a3c5 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc +++ b/src/layui/layui/laySaveLayoutOptionsDialog.cc @@ -20,8 +20,9 @@ */ +#if defined(HAVE_QT) -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySaveLayoutOptionsDialog.h" #include "layStream.h" #include "laybasicConfig.h" @@ -436,7 +437,7 @@ SaveLayoutAsOptionsDialog::ok_button_pressed () } bool -SaveLayoutAsOptionsDialog::get_options (lay::LayoutView *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &om, db::SaveLayoutOptions &options) +SaveLayoutAsOptionsDialog::get_options (lay::LayoutViewBase *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &om, db::SaveLayoutOptions &options) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { @@ -584,3 +585,4 @@ SaveLayoutAsOptionsDialog::fmt_cbx_changed (int index) } +#endif diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/layui/layui/laySaveLayoutOptionsDialog.h similarity index 87% rename from src/laybasic/laybasic/laySaveLayoutOptionsDialog.h rename to src/layui/layui/laySaveLayoutOptionsDialog.h index a482e90f5..db37f3c4d 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/layui/layui/laySaveLayoutOptionsDialog.h @@ -20,10 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySaveLayoutOptionsDialog #define HDR_laySaveLayoutOptionsDialog +#include "layuiCommon.h" #include "ui_SaveLayoutOptionsDialog.h" #include "ui_SaveLayoutAsOptionsDialog.h" #include "dbStream.h" @@ -45,9 +47,9 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC SaveLayoutAsOptionsDialog +class LAYUI_PUBLIC SaveLayoutAsOptionsDialog : public QDialog, private Ui::SaveLayoutAsOptionsDialog { Q_OBJECT @@ -56,7 +58,7 @@ public: SaveLayoutAsOptionsDialog (QWidget *parent, const std::string &title); ~SaveLayoutAsOptionsDialog (); - bool get_options (lay::LayoutView *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &compression, db::SaveLayoutOptions &options); + bool get_options (lay::LayoutViewBase *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &compression, db::SaveLayoutOptions &options); public slots: void ok_button_pressed (); @@ -70,7 +72,7 @@ private: const db::Technology *mp_tech; }; -class LAYBASIC_PUBLIC SaveLayoutOptionsDialog +class LAYUI_PUBLIC SaveLayoutOptionsDialog : public QDialog, private Ui::SaveLayoutOptionsDialog { Q_OBJECT @@ -103,3 +105,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectCellViewForm.cc b/src/layui/layui/laySelectCellViewForm.cc similarity index 96% rename from src/laybasic/laybasic/laySelectCellViewForm.cc rename to src/layui/layui/laySelectCellViewForm.cc index 7ef98e984..ccdb27d1d 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.cc +++ b/src/layui/layui/laySelectCellViewForm.cc @@ -20,17 +20,18 @@ */ +#if defined(HAVE_QT) #include "laySelectCellViewForm.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { // ------------------------------------------------------------ -SelectCellViewForm::SelectCellViewForm (QWidget *parent, lay::LayoutView *view, const std::string &title, bool single) +SelectCellViewForm::SelectCellViewForm (QWidget *parent, lay::LayoutViewBase *view, const std::string &title, bool single) : QDialog (parent), Ui::SelectCellViewForm () { setObjectName (QString::fromUtf8 ("select_cv")); @@ -134,3 +135,4 @@ SelectCellViewForm::select_all () } +#endif diff --git a/src/laybasic/laybasic/laySelectCellViewForm.h b/src/layui/layui/laySelectCellViewForm.h similarity index 88% rename from src/laybasic/laybasic/laySelectCellViewForm.h rename to src/layui/layui/laySelectCellViewForm.h index 9dd053bc4..9d3a1d63c 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.h +++ b/src/layui/layui/laySelectCellViewForm.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_SelectCellViewForm #define HDR_SelectCellViewForm -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -37,15 +38,15 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC SelectCellViewForm +class LAYUI_PUBLIC SelectCellViewForm : public QDialog, private Ui::SelectCellViewForm { Q_OBJECT public: - SelectCellViewForm (QWidget *parent, lay::LayoutView *view, const std::string &title, bool single = false); + SelectCellViewForm (QWidget *parent, lay::LayoutViewBase *view, const std::string &title, bool single = false); /** * @brief Set the selection to a single selection @@ -90,3 +91,4 @@ public slots: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.cc b/src/layui/layui/laySelectLineStyleForm.cc similarity index 99% rename from src/laybasic/laybasic/laySelectLineStyleForm.cc rename to src/layui/layui/laySelectLineStyleForm.cc index df64c51b9..cb32fd06b 100644 --- a/src/laybasic/laybasic/laySelectLineStyleForm.cc +++ b/src/layui/layui/laySelectLineStyleForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "laySelectLineStyleForm.h" #include "ui_SelectLineStyleForm.h" @@ -133,3 +133,4 @@ SelectLineStyleForm::sel_changed (QListWidgetItem *citem, QListWidgetItem *) } +#endif diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.h b/src/layui/layui/laySelectLineStyleForm.h similarity index 96% rename from src/laybasic/laybasic/laySelectLineStyleForm.h rename to src/layui/layui/laySelectLineStyleForm.h index 971e244aa..9cb159e2a 100644 --- a/src/laybasic/laybasic/laySelectLineStyleForm.h +++ b/src/layui/layui/laySelectLineStyleForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySelectLineStyleForm #define HDR_laySelectLineStyleForm @@ -72,3 +73,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectStippleForm.cc b/src/layui/layui/laySelectStippleForm.cc similarity index 99% rename from src/laybasic/laybasic/laySelectStippleForm.cc rename to src/layui/layui/laySelectStippleForm.cc index 97e954faf..76f9354a4 100644 --- a/src/laybasic/laybasic/laySelectStippleForm.cc +++ b/src/layui/layui/laySelectStippleForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "laySelectStippleForm.h" #include "ui_SelectStippleForm.h" @@ -133,3 +133,4 @@ SelectStippleForm::sel_changed (QListWidgetItem *citem, QListWidgetItem *) } +#endif diff --git a/src/laybasic/laybasic/laySelectStippleForm.h b/src/layui/layui/laySelectStippleForm.h similarity index 96% rename from src/laybasic/laybasic/laySelectStippleForm.h rename to src/layui/layui/laySelectStippleForm.h index a6432e460..4769914fc 100644 --- a/src/laybasic/laybasic/laySelectStippleForm.h +++ b/src/layui/layui/laySelectStippleForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySelectStippleForm #define HDR_laySelectStippleForm @@ -72,3 +73,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layTechnology.cc b/src/layui/layui/layTechnology.cc similarity index 96% rename from src/laybasic/laybasic/layTechnology.cc rename to src/layui/layui/layTechnology.cc index 5f03acdce..a7f8de11b 100644 --- a/src/laybasic/laybasic/layTechnology.cc +++ b/src/layui/layui/layTechnology.cc @@ -20,7 +20,10 @@ */ +#if defined(HAVE_QT) #include "layTechnology.h" // .. nothing yet .. + +#endif diff --git a/src/laybasic/laybasic/layTechnology.h b/src/layui/layui/layTechnology.h similarity index 94% rename from src/laybasic/laybasic/layTechnology.h rename to src/layui/layui/layTechnology.h index a4d25fccc..1dcf693a1 100644 --- a/src/laybasic/laybasic/layTechnology.h +++ b/src/layui/layui/layTechnology.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layTechnology #define HDR_layTechnology -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbTechnology.h" @@ -40,7 +41,7 @@ namespace lay * To do so, it must implement a TechnologyComponentEditor that provides an * editor for it's component. */ -class LAYBASIC_PUBLIC TechnologyComponentEditor +class LAYUI_PUBLIC TechnologyComponentEditor : public QFrame { public: @@ -105,7 +106,7 @@ private: /** * @brief A base class for a technology component provider */ -class LAYBASIC_PUBLIC TechnologyEditorProvider +class LAYUI_PUBLIC TechnologyEditorProvider { public: /** @@ -137,3 +138,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layTipDialog.cc b/src/layui/layui/layTipDialog.cc similarity index 99% rename from src/laybasic/laybasic/layTipDialog.cc rename to src/layui/layui/layTipDialog.cc index fd9c27493..c7c86a923 100644 --- a/src/laybasic/laybasic/layTipDialog.cc +++ b/src/layui/layui/layTipDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layTipDialog.h" #include "laybasicConfig.h" @@ -217,3 +218,4 @@ TipDialog::~TipDialog () } +#endif diff --git a/src/laybasic/laybasic/layTipDialog.h b/src/layui/layui/layTipDialog.h similarity index 96% rename from src/laybasic/laybasic/layTipDialog.h rename to src/layui/layui/layTipDialog.h index dabc68318..80748bef9 100644 --- a/src/laybasic/laybasic/layTipDialog.h +++ b/src/layui/layui/layTipDialog.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layTipDialog #define HDR_layTipDialog -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -41,7 +42,7 @@ namespace lay { * A tip window is basically a message box with the ability to hide the box forever (or at least until the * configuration is reset). */ -class LAYBASIC_PUBLIC TipDialog +class LAYUI_PUBLIC TipDialog : public QDialog { Q_OBJECT @@ -110,3 +111,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layWidgets.cc b/src/layui/layui/layWidgets.cc similarity index 99% rename from src/laybasic/laybasic/layWidgets.cc rename to src/layui/layui/layWidgets.cc index 3335861a2..7f8207279 100644 --- a/src/laybasic/laybasic/layWidgets.cc +++ b/src/layui/layui/layWidgets.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -30,7 +31,7 @@ #include "layWidgets.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layDialogs.h" #include "tlExceptions.h" #include "layStipplePalette.h" @@ -68,7 +69,7 @@ DitherPatternSelectionButton::~DitherPatternSelectionButton () } void -DitherPatternSelectionButton::set_view (lay::LayoutView *view) +DitherPatternSelectionButton::set_view (lay::LayoutViewBase *view) { if (view != mp_view) { mp_view = view; @@ -227,7 +228,7 @@ DitherPatternSelectionButton::update_menu () struct CellViewSelectionComboBoxPrivateData { - const lay::LayoutView *layout_view; + const lay::LayoutViewBase *layout_view; }; CellViewSelectionComboBox::CellViewSelectionComboBox (QWidget *parent) @@ -243,14 +244,14 @@ CellViewSelectionComboBox::~CellViewSelectionComboBox () mp_private = 0; } -const lay::LayoutView * +const lay::LayoutViewBase * CellViewSelectionComboBox::layout_view () const { return mp_private->layout_view; } void -CellViewSelectionComboBox::set_layout_view (const lay::LayoutView *layout_view) +CellViewSelectionComboBox::set_layout_view (const lay::LayoutViewBase *layout_view) { // TODO: should register a listener, so it does the update automatically. mp_private->layout_view = layout_view; @@ -296,7 +297,7 @@ struct LayerSelectionComboBoxPrivateData bool new_layer_enabled; bool all_layers; const db::Layout *layout; - lay::LayoutView *view; + lay::LayoutViewBase *view; int cv_index; db::LayerProperties last_props; }; @@ -413,7 +414,7 @@ struct LPIPairCompareOp }; void -LayerSelectionComboBox::set_view (lay::LayoutView *view, int cv_index, bool all_layers) +LayerSelectionComboBox::set_view (lay::LayoutViewBase *view, int cv_index, bool all_layers) { if (view == 0 || cv_index < 0) { set_layout (0); @@ -1314,3 +1315,5 @@ InteractiveListWidget::refresh_flags () } } + +#endif diff --git a/src/laybasic/laybasic/layWidgets.h b/src/layui/layui/layWidgets.h similarity index 94% rename from src/laybasic/laybasic/layWidgets.h rename to src/layui/layui/layWidgets.h index 6020c78a9..02d9666f4 100644 --- a/src/laybasic/laybasic/layWidgets.h +++ b/src/layui/layui/layWidgets.h @@ -20,11 +20,12 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layWidgets #define HDR_layWidgets -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlObject.h" @@ -46,14 +47,14 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; struct LayerSelectionComboBoxPrivateData; struct CellViewSelectionComboBoxPrivateData; /** * @brief A selection button for dither pattern */ -class LAYBASIC_PUBLIC DitherPatternSelectionButton +class LAYUI_PUBLIC DitherPatternSelectionButton : public QPushButton { Q_OBJECT @@ -74,7 +75,7 @@ public: * * This method is required to select the proper dither pattern */ - void set_view (lay::LayoutView *view); + void set_view (lay::LayoutViewBase *view); /** * @brief Set the dither pattern index @@ -105,7 +106,7 @@ private slots: void menu_about_to_show (); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_dither_pattern; void update_pattern (); @@ -117,7 +118,7 @@ private: * * This combo box allows selecting a library */ -class LAYBASIC_PUBLIC LibrarySelectionComboBox +class LAYUI_PUBLIC LibrarySelectionComboBox : public QComboBox { Q_OBJECT @@ -171,7 +172,7 @@ private: * * This combo box allows selecting a (physical) layer from a layout */ -class LAYBASIC_PUBLIC LayerSelectionComboBox +class LAYUI_PUBLIC LayerSelectionComboBox : public QComboBox, public tl::Object { Q_OBJECT @@ -203,7 +204,7 @@ public: * If all_layers is set to true, layers are shown which are in the layer list, but * not created as layers yet. */ - void set_view (lay::LayoutView *view, int cv_index, bool all_layers = false); + void set_view (lay::LayoutViewBase *view, int cv_index, bool all_layers = false); /** * @brief Sets a flag indicating whether the "new layer" option is available @@ -260,7 +261,7 @@ private: * * This combo box allows selecting a cellview from a lay::LayoutView */ -class LAYBASIC_PUBLIC CellViewSelectionComboBox +class LAYUI_PUBLIC CellViewSelectionComboBox : public QComboBox { Q_OBJECT @@ -269,8 +270,8 @@ public: CellViewSelectionComboBox (QWidget *parent); ~CellViewSelectionComboBox (); - void set_layout_view (const lay::LayoutView *view); - const lay::LayoutView *layout_view () const; + void set_layout_view (const lay::LayoutViewBase *view); + const lay::LayoutViewBase *layout_view () const; void set_current_cv_index (int l); int current_cv_index () const; @@ -286,7 +287,7 @@ private: * usual push button and supplies a color chooser without the * capability to switch to "auto" color mode. */ -class LAYBASIC_PUBLIC SimpleColorButton +class LAYUI_PUBLIC SimpleColorButton : public QPushButton { Q_OBJECT @@ -319,7 +320,7 @@ private slots: * usual push button and supplies a color chooser with the * capability to switch to "auto" color mode. */ -class LAYBASIC_PUBLIC ColorButton +class LAYUI_PUBLIC ColorButton : public QPushButton { Q_OBJECT @@ -354,7 +355,7 @@ private slots: /** * @brief An edit box with a clear button and options menu */ -class LAYBASIC_PUBLIC DecoratedLineEdit +class LAYUI_PUBLIC DecoratedLineEdit : public QLineEdit { Q_OBJECT @@ -467,7 +468,7 @@ private: /** * @brief An interactive list widget which offers slots to delete and move items and interfaces to std::vector */ -class LAYBASIC_PUBLIC InteractiveListWidget +class LAYUI_PUBLIC InteractiveListWidget : public QListWidget { Q_OBJECT @@ -524,3 +525,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laybasicResources.qrc b/src/layui/layui/laybasicResources.qrc similarity index 100% rename from src/laybasic/laybasic/laybasicResources.qrc rename to src/layui/layui/laybasicResources.qrc diff --git a/src/layui/layui/layui.pro b/src/layui/layui/layui.pro new file mode 100644 index 000000000..086291e28 --- /dev/null +++ b/src/layui/layui/layui.pro @@ -0,0 +1,214 @@ + +DESTDIR = $$OUT_PWD/../.. +TARGET = klayout_layui + +include($$PWD/../../lib.pri) + +DEFINES += MAKE_LAYUI_LIBRARY + +FORMS = \ + AlignCellOptionsDialog.ui \ + BookmarkManagementForm.ui \ + BrowseInstancesConfigPage.ui \ + BrowseInstancesForm.ui \ + BrowserDialog.ui \ + BrowserPanel.ui \ + BrowseShapesConfigPage.ui \ + BrowseShapesForm.ui \ + CellSelectionForm.ui \ + ClearLayerModeDialog.ui \ + ConfigurationDialog.ui \ + CopyCellModeDialog.ui \ + DeleteCellModeDialog.ui \ + DuplicateLayerDialog.ui \ + EditStipplesForm.ui \ + FlattenInstOptionsDialog.ui \ + LayerMappingWidget.ui \ + LayerSourceDialog.ui \ + LayoutProperties.ui \ + LayoutViewConfigPage1.ui \ + LayoutViewConfigPage2a.ui \ + LayoutViewConfigPage2b.ui \ + LayoutViewConfigPage2c.ui \ + LayoutViewConfigPage2d.ui \ + LayoutViewConfigPage3a.ui \ + LayoutViewConfigPage3b.ui \ + LayoutViewConfigPage3c.ui \ + LayoutViewConfigPage3f.ui \ + LayoutViewConfigPage4.ui \ + LayoutViewConfigPage5.ui \ + LayoutViewConfigPage6.ui \ + LayoutViewConfigPage7.ui \ + LayoutViewConfigPage.ui \ + LibraryCellSelectionForm.ui \ + LoadLayoutOptionsDialog.ui \ + MarkerBrowserConfigPage2.ui \ + MarkerBrowserConfigPage.ui \ + MarkerBrowserDialog.ui \ + MarkerBrowserPage.ui \ + MarkerBrowserSnapshotView.ui \ + MoveOptionsDialog.ui \ + MoveToOptionsDialog.ui \ + NewCellPropertiesDialog.ui \ + NewLayerPropertiesDialog.ui \ + NewLayoutPropertiesDialog.ui \ + OpenLayoutModeDialog.ui \ + RenameCellDialog.ui \ + ReplaceCellOptionsDialog.ui \ + SaveLayoutOptionsDialog.ui \ + SaveLayoutAsOptionsDialog.ui \ + SelectStippleForm.ui \ + TipDialog.ui \ + UserPropertiesForm.ui \ + UserPropertiesEditForm.ui \ + SpecificLoadLayoutOptionsDialog.ui \ + SelectLineStyleForm.ui \ + LayoutViewConfigPage6a.ui \ + EditLineStylesForm.ui \ + NetlistBrowserPage.ui \ + NetlistBrowserConfigPage.ui \ + NetlistBrowserConfigPage2.ui \ + NetlistBrowserDialog.ui \ + NetInfoDialog.ui \ + NetExportDialog.ui \ + SelectCellViewForm.ui \ + LayoutStatistics.ui \ + +RESOURCES = \ + laybasicResources.qrc \ + layLayoutStatistics.qrc \ + +SOURCES = \ + gsiDeclLayDialogs.cc \ + gsiDeclLayMenu.cc \ + gsiDeclLayNetlistBrowserDialog.cc \ + gsiDeclLayStream.cc \ + layuiForceLink.cc \ + layBackgroundAwareTreeStyle.cc \ + layBookmarkManagementForm.cc \ + layBookmarksView.cc \ + layBrowseInstancesForm.cc \ + layBrowseShapesForm.cc \ + layBrowser.cc \ + layBrowserDialog.cc \ + layBrowserPanel.cc \ + layBusy.cc \ + layCellSelectionForm.cc \ + layCellTreeModel.cc \ + layConfigurationDialog.cc \ + layDialogs.cc \ + layEditLineStyleWidget.cc \ + layEditLineStylesForm.cc \ + layEditStippleWidget.cc \ + layEditStipplesForm.cc \ + layEditorOptionsFrame.cc \ + layEditorOptionsPage.cc \ + layEditorOptionsPages.cc \ + layFileDialog.cc \ + layGenericSyntaxHighlighter.cc \ + layHierarchyControlPanel.cc \ + layIndexedNetlistModel.cc \ + layItemDelegates.cc \ + layLayerControlPanel.cc \ + layLayerMappingWidget.cc \ + layLayerToolbox.cc \ + layLayerTreeModel.cc \ + layLayoutPropertiesForm.cc \ + layLayoutStatisticsForm.cc \ + layLayoutViewConfigPages.cc \ + layLayoutViewFunctions.cc \ + layLibrariesView.cc \ + layLoadLayoutOptionsDialog.cc \ + layNetExportDialog.cc \ + layNetInfoDialog.cc \ + layNetlistBrowser.cc \ + layNetlistBrowserDialog.cc \ + layNetlistBrowserModel.cc \ + layNetlistBrowserPage.cc \ + layNetlistBrowserTreeModel.cc \ + layNetlistCrossReferenceModel.cc \ + layQtTools.cc \ + laySaveLayoutOptionsDialog.cc \ + laySelectCellViewForm.cc \ + laySelectLineStyleForm.cc \ + laySelectStippleForm.cc \ + layTechnology.cc \ + layTipDialog.cc \ + layWidgets.cc \ + rdbInfoWidget.cc \ + rdbMarkerBrowser.cc \ + rdbMarkerBrowserDialog.cc \ + rdbMarkerBrowserPage.cc \ + +HEADERS = \ + layuiForceLink.h \ + layBackgroundAwareTreeStyle.h \ + layBookmarkManagementForm.h \ + layBookmarksView.h \ + layBrowseInstancesForm.h \ + layBrowseShapesForm.h \ + layBrowser.h \ + layBrowserDialog.h \ + layBrowserPanel.h \ + layBusy.h \ + layCellSelectionForm.h \ + layCellTreeModel.h \ + layConfigurationDialog.h \ + layDialogs.h \ + layEditLineStyleWidget.h \ + layEditLineStylesForm.h \ + layEditStippleWidget.h \ + layEditStipplesForm.h \ + layEditorOptionsFrame.h \ + layEditorOptionsPage.h \ + layEditorOptionsPages.h \ + layFileDialog.h \ + layGenericSyntaxHighlighter.h \ + layHierarchyControlPanel.h \ + layIndexedNetlistModel.h \ + layItemDelegates.h \ + layLayerControlPanel.h \ + layLayerMappingWidget.h \ + layLayerToolbox.h \ + layLayerTreeModel.h \ + layLayoutPropertiesForm.h \ + layLayoutStatisticsForm.h \ + layLayoutViewConfigPages.h \ + layLayoutViewFunctions.h \ + layLibrariesView.h \ + layLoadLayoutOptionsDialog.h \ + layNetExportDialog.h \ + layNetInfoDialog.h \ + layNetlistBrowser.h \ + layNetlistBrowserDialog.h \ + layNetlistBrowserModel.h \ + layNetlistBrowserPage.h \ + layNetlistBrowserTreeModel.h \ + layNetlistCrossReferenceModel.h \ + layQtTools.h \ + laySaveLayoutOptionsDialog.h \ + laySelectCellViewForm.h \ + laySelectLineStyleForm.h \ + laySelectStippleForm.h \ + layTechnology.h \ + layTipDialog.h \ + layWidgets.h \ + rdbInfoWidget.h \ + rdbMarkerBrowser.h \ + rdbMarkerBrowserDialog.h \ + rdbMarkerBrowserPage.h \ + +INCLUDEPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_laybasic -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb + +INCLUDEPATH += $$QTBASIC_INC +DEPENDPATH += $$QTBASIC_INC + +equals(HAVE_QTBINDINGS, "1") { + LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore + greaterThan(QT_MAJOR_VERSION, 4) { + LIBS += -lklayout_QtWidgets + } +} + diff --git a/src/layui/layui/layuiCommon.h b/src/layui/layui/layuiCommon.h new file mode 100644 index 000000000..b6c807d2f --- /dev/null +++ b/src/layui/layui/layuiCommon.h @@ -0,0 +1,51 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#if !defined(HDR_layuiCommon_h) +# define HDR_layuiCommon_h + +# if defined _WIN32 || defined __CYGWIN__ + +# ifdef MAKE_LAYUI_LIBRARY +# define LAYUI_PUBLIC __declspec(dllexport) +# else +# define LAYUI_PUBLIC __declspec(dllimport) +# endif +# define LAYUI_LOCAL +# define LAYUI_PUBLIC_TEMPLATE + +# else + +# if __GNUC__ >= 4 || defined(__clang__) +# define LAYUI_PUBLIC __attribute__ ((visibility ("default"))) +# define LAYUI_PUBLIC_TEMPLATE __attribute__ ((visibility ("default"))) +# define LAYUI_LOCAL __attribute__ ((visibility ("hidden"))) +# else +# define LAYUI_PUBLIC +# define LAYUI_PUBLIC_TEMPLATE +# define LAYUI_LOCAL +# endif + +# endif + +#endif diff --git a/src/layui/layui/layuiForceLink.cc b/src/layui/layui/layuiForceLink.cc new file mode 100644 index 000000000..488f478f9 --- /dev/null +++ b/src/layui/layui/layuiForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layuiForceLink.h" + +namespace layui +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/layui/layui/layuiForceLink.h b/src/layui/layui/layuiForceLink.h new file mode 100644 index 000000000..86ed0eb11 --- /dev/null +++ b/src/layui/layui/layuiForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layuiForceLink +#define HDR_layuiForceLink + +#include "layuiCommon.h" + +/** + * @file Include this function to force linking of the layui module + */ + +namespace layui +{ + LAYUI_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/laybasic/laybasic/rdbInfoWidget.cc b/src/layui/layui/rdbInfoWidget.cc similarity index 98% rename from src/laybasic/laybasic/rdbInfoWidget.cc rename to src/layui/layui/rdbInfoWidget.cc index f692ab093..f702c0ed8 100644 --- a/src/laybasic/laybasic/rdbInfoWidget.cc +++ b/src/layui/layui/rdbInfoWidget.cc @@ -21,6 +21,8 @@ */ +#if defined(HAVE_QT) + #include "rdbInfoWidget.h" #include @@ -63,3 +65,4 @@ InfoWidget::loadResource (int type, const QUrl &name) } +#endif diff --git a/src/laybasic/laybasic/rdbInfoWidget.h b/src/layui/layui/rdbInfoWidget.h similarity index 95% rename from src/laybasic/laybasic/rdbInfoWidget.h rename to src/layui/layui/rdbInfoWidget.h index b9198970b..447978656 100644 --- a/src/laybasic/laybasic/rdbInfoWidget.h +++ b/src/layui/layui/rdbInfoWidget.h @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_rdbInfoWidget #define HDR_rdbInfoWidget @@ -52,3 +52,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/layui/layui/rdbMarkerBrowser.cc similarity index 81% rename from src/laybasic/laybasic/rdbMarkerBrowser.cc rename to src/layui/layui/rdbMarkerBrowser.cc index 2a7e9928a..4b7e3ec2f 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/layui/layui/rdbMarkerBrowser.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "rdbMarkerBrowserDialog.h" @@ -28,6 +28,9 @@ #include "layConverters.h" #include "layDispatcher.h" +#include "ui_MarkerBrowserConfigPage.h" +#include "ui_MarkerBrowserConfigPage2.h" + #include namespace rdb @@ -128,9 +131,10 @@ MarkerBrowserWindowModeConverter::to_string (rdb::window_type mode) MarkerBrowserConfigPage::MarkerBrowserConfigPage (QWidget *parent) : lay::ConfigPage (parent) { - Ui::MarkerBrowserConfigPage::setupUi (this); + mp_ui = new Ui::MarkerBrowserConfigPage (); + mp_ui->setupUi (this); - connect (cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); + connect (mp_ui->cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); } void @@ -139,22 +143,22 @@ MarkerBrowserConfigPage::setup (lay::Dispatcher *root) // context mode rdb::context_mode_type cmode = rdb::DatabaseTop; root->config_get (cfg_rdb_context_mode, cmode, MarkerBrowserContextModeConverter ()); - cbx_context->setCurrentIndex (int (cmode)); + mp_ui->cbx_context->setCurrentIndex (int (cmode)); // window mode rdb::window_type wmode = rdb::FitMarker; root->config_get (cfg_rdb_window_mode, wmode, MarkerBrowserWindowModeConverter ()); - cbx_window->setCurrentIndex (int (wmode)); + mp_ui->cbx_window->setCurrentIndex (int (wmode)); // window dimension double wdim = 1.0; root->config_get (cfg_rdb_window_dim, wdim); - le_window->setText (tl::to_qstring (tl::to_string (wdim))); + mp_ui->le_window->setText (tl::to_qstring (tl::to_string (wdim))); // max. marker count unsigned int max_marker_count = 1000; root->config_get (cfg_rdb_max_marker_count, max_marker_count); - le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); + mp_ui->le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); // enable controls window_changed (int (wmode)); @@ -163,20 +167,20 @@ MarkerBrowserConfigPage::setup (lay::Dispatcher *root) void MarkerBrowserConfigPage::window_changed (int m) { - le_window->setEnabled (m == int (rdb::FitMarker) || m == int (rdb::CenterSize)); + mp_ui->le_window->setEnabled (m == int (rdb::FitMarker) || m == int (rdb::CenterSize)); } void MarkerBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string_ext (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (mp_ui->le_window->text ()), dim); unsigned int max_markers_count = 1000; - tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_markers_count); + tl::from_string_ext (tl::to_string (mp_ui->le_max_markers->text ()), max_markers_count); - root->config_set (cfg_rdb_context_mode, rdb::context_mode_type (cbx_context->currentIndex ()), MarkerBrowserContextModeConverter ()); - root->config_set (cfg_rdb_window_mode, rdb::window_type (cbx_window->currentIndex ()), MarkerBrowserWindowModeConverter ()); + root->config_set (cfg_rdb_context_mode, rdb::context_mode_type (mp_ui->cbx_context->currentIndex ()), MarkerBrowserContextModeConverter ()); + root->config_set (cfg_rdb_window_mode, rdb::window_type (mp_ui->cbx_window->currentIndex ()), MarkerBrowserWindowModeConverter ()); root->config_set (cfg_rdb_window_dim, dim); root->config_set (cfg_rdb_max_marker_count, max_markers_count); } @@ -187,7 +191,8 @@ MarkerBrowserConfigPage::commit (lay::Dispatcher *root) MarkerBrowserConfigPage2::MarkerBrowserConfigPage2 (QWidget *parent) : lay::ConfigPage (parent) { - Ui::MarkerBrowserConfigPage2::setupUi (this); + mp_ui = new Ui::MarkerBrowserConfigPage2 (); + mp_ui->setupUi (this); } void @@ -196,70 +201,70 @@ MarkerBrowserConfigPage2::setup (lay::Dispatcher *root) // marker color QColor color; root->config_get (cfg_rdb_marker_color, color, lay::ColorConverter ()); - color_pb->set_color (color); + mp_ui->color_pb->set_color (color); // marker line width int lw = 0; root->config_get (cfg_rdb_marker_line_width, lw); if (lw < 0) { - lw_le->setText (QString ()); + mp_ui->lw_le->setText (QString ()); } else { - lw_le->setText (tl::to_qstring (tl::to_string (lw))); + mp_ui->lw_le->setText (tl::to_qstring (tl::to_string (lw))); } // marker vertex size int vs = 0; root->config_get (cfg_rdb_marker_vertex_size, vs); if (vs < 0) { - vs_le->setText (QString ()); + mp_ui->vs_le->setText (QString ()); } else { - vs_le->setText (tl::to_qstring (tl::to_string (vs))); + mp_ui->vs_le->setText (tl::to_qstring (tl::to_string (vs))); } // stipple pattern int dp = 0; root->config_get (cfg_rdb_marker_dither_pattern, dp); - stipple_pb->set_dither_pattern (dp); + mp_ui->stipple_pb->set_dither_pattern (dp); // halo int halo = 0; root->config_get (cfg_rdb_marker_halo, halo); - halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); + mp_ui->halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); } void MarkerBrowserConfigPage2::commit (lay::Dispatcher *root) { - QColor color (color_pb->get_color ()); + QColor color (mp_ui->color_pb->get_color ()); root->config_set (cfg_rdb_marker_color, color, lay::ColorConverter ()); - if (lw_le->text ().isEmpty ()) { + if (mp_ui->lw_le->text ().isEmpty ()) { root->config_set (cfg_rdb_marker_line_width, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->lw_le->text ()), s); root->config_set (cfg_rdb_marker_line_width, s); } catch (...) { } } - if (vs_le->text ().isEmpty ()) { + if (mp_ui->vs_le->text ().isEmpty ()) { root->config_set (cfg_rdb_marker_vertex_size, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->vs_le->text ()), s); root->config_set (cfg_rdb_marker_vertex_size, s); } catch (...) { } } - root->config_set (cfg_rdb_marker_dither_pattern, stipple_pb->dither_pattern ()); + root->config_set (cfg_rdb_marker_dither_pattern, mp_ui->stipple_pb->dither_pattern ()); - if (halo_cb->checkState () == Qt::PartiallyChecked) { + if (mp_ui->halo_cb->checkState () == Qt::PartiallyChecked) { root->config_set (cfg_rdb_marker_halo, -1); - } else if (halo_cb->checkState () == Qt::Unchecked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Unchecked) { root->config_set (cfg_rdb_marker_halo, 0); - } else if (halo_cb->checkState () == Qt::Checked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Checked) { root->config_set (cfg_rdb_marker_halo, 1); } } @@ -302,7 +307,7 @@ public: menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new rdb::MarkerBrowserDialog (root, view); } @@ -312,3 +317,4 @@ static tl::RegisteredClass config_decl (new MarkerBrowse } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/layui/layui/rdbMarkerBrowser.h similarity index 85% rename from src/laybasic/laybasic/rdbMarkerBrowser.h rename to src/layui/layui/rdbMarkerBrowser.h index 8c9feb344..0c0a21f04 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.h +++ b/src/layui/layui/rdbMarkerBrowser.h @@ -20,18 +20,24 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowser #define HDR_rdbMarkerBrowser #include "layPlugin.h" -#include "ui_MarkerBrowserConfigPage.h" -#include "ui_MarkerBrowserConfigPage2.h" +#include "layPluginConfigPage.h" #include "dbTrans.h" #include +namespace Ui +{ + class MarkerBrowserConfigPage; + class MarkerBrowserConfigPage2; +} + namespace rdb { @@ -39,8 +45,7 @@ enum context_mode_type { AnyCell = 0 , DatabaseTop, Current, CurrentOrAny, Local enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; class MarkerBrowserConfigPage - : public lay::ConfigPage, - private Ui::MarkerBrowserConfigPage + : public lay::ConfigPage { Q_OBJECT @@ -52,11 +57,13 @@ public: public slots: void window_changed (int); + +private: + Ui::MarkerBrowserConfigPage *mp_ui; }; class MarkerBrowserConfigPage2 - : public lay::ConfigPage, - private Ui::MarkerBrowserConfigPage2 + : public lay::ConfigPage { Q_OBJECT @@ -65,6 +72,9 @@ public: virtual void setup (lay::Dispatcher *root); virtual void commit (lay::Dispatcher *root); + +private: + Ui::MarkerBrowserConfigPage2 *mp_ui; }; class MarkerBrowserContextModeConverter @@ -85,3 +95,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/layui/layui/rdbMarkerBrowserDialog.cc similarity index 88% rename from src/laybasic/laybasic/rdbMarkerBrowserDialog.cc rename to src/layui/layui/rdbMarkerBrowserDialog.cc index 76baf7e1d..b3c7de898 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/layui/layui/rdbMarkerBrowserDialog.cc @@ -20,12 +20,13 @@ */ +#if defined(HAVE_QT) #include "rdbMarkerBrowserDialog.h" #include "rdb.h" #include "rdbReader.h" #include "tlProgress.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "layFileDialog.h" #include "layConverters.h" @@ -34,6 +35,8 @@ #include "dbLayoutUtils.h" #include "dbRecursiveShapeIterator.h" +#include "ui_MarkerBrowserDialog.h" + #include #include @@ -54,9 +57,8 @@ extern std::string cfg_rdb_marker_vertex_size; extern std::string cfg_rdb_marker_halo; extern std::string cfg_rdb_marker_dither_pattern; -MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) : lay::Browser (root, vw), - Ui::MarkerBrowserDialog (), m_context (rdb::AnyCell), m_window (rdb::FitMarker), m_window_dim (0.0), @@ -68,9 +70,10 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView m_cv_index (-1), m_rdb_index (-1) { - Ui::MarkerBrowserDialog::setupUi (this); + mp_ui = new Ui::MarkerBrowserDialog (); + mp_ui->setupUi (this); - browser_frame->set_dispatcher (root); + mp_ui->browser_frame->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &MarkerBrowserDialog::cellviews_changed); @@ -78,12 +81,12 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView view ()->rdb_list_changed_event.add (this, &MarkerBrowserDialog::rdbs_changed); } - m_open_action = new QAction (QObject::tr ("Open"), file_menu); - m_saveas_action = new QAction (QObject::tr ("Save As"), file_menu); - m_export_action = new QAction (QObject::tr ("Export To Layout"), file_menu); - m_reload_action = new QAction (QObject::tr ("Reload"), file_menu); - m_unload_action = new QAction (QObject::tr ("Unload"), file_menu); - m_unload_all_action = new QAction (QObject::tr ("Unload All"), file_menu); + m_open_action = new QAction (QObject::tr ("Open"), mp_ui->file_menu); + m_saveas_action = new QAction (QObject::tr ("Save As"), mp_ui->file_menu); + m_export_action = new QAction (QObject::tr ("Export To Layout"), mp_ui->file_menu); + m_reload_action = new QAction (QObject::tr ("Reload"), mp_ui->file_menu); + m_unload_action = new QAction (QObject::tr ("Unload"), mp_ui->file_menu); + m_unload_all_action = new QAction (QObject::tr ("Unload All"), mp_ui->file_menu); connect (m_open_action, SIGNAL (triggered ()), this, SLOT (open_clicked ())); connect (m_saveas_action, SIGNAL (triggered ()), this, SLOT (saveas_clicked ())); @@ -92,24 +95,24 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView connect (m_unload_action, SIGNAL (triggered ()), this, SLOT (unload_clicked ())); connect (m_unload_all_action, SIGNAL (triggered ()), this, SLOT (unload_all_clicked ())); - file_menu->addAction (m_open_action); - file_menu->addAction (m_saveas_action); - QAction *sep0 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_open_action); + mp_ui->file_menu->addAction (m_saveas_action); + QAction *sep0 = new QAction (mp_ui->file_menu); sep0->setSeparator (true); - file_menu->addAction (m_export_action); - QAction *sep1 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_export_action); + QAction *sep1 = new QAction (mp_ui->file_menu); sep1->setSeparator (true); - file_menu->addAction (sep1); - file_menu->addAction (m_reload_action); - QAction *sep2 = new QAction (file_menu); + mp_ui->file_menu->addAction (sep1); + mp_ui->file_menu->addAction (m_reload_action); + QAction *sep2 = new QAction (mp_ui->file_menu); sep2->setSeparator (true); - file_menu->addAction (sep2); - file_menu->addAction (m_unload_action); - file_menu->addAction (m_unload_all_action); + mp_ui->file_menu->addAction (sep2); + mp_ui->file_menu->addAction (m_unload_action); + mp_ui->file_menu->addAction (m_unload_all_action); - connect (layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); - connect (rdb_cb, SIGNAL (activated (int)), this, SLOT (rdb_index_changed (int))); - connect (configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); + connect (mp_ui->layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); + connect (mp_ui->rdb_cb, SIGNAL (activated (int)), this, SLOT (rdb_index_changed (int))); + connect (mp_ui->configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); cellviews_changed (); } @@ -396,9 +399,9 @@ BEGIN_PROTECTED rdb::Database *rdb = view ()->get_rdb (m_rdb_index); if (rdb && ! rdb->filename ().empty ()) { - browser_frame->set_rdb (0); + mp_ui->browser_frame->set_rdb (0); rdb->load (rdb->filename ()); - browser_frame->set_rdb (rdb); + mp_ui->browser_frame->set_rdb (rdb); } @@ -425,7 +428,7 @@ BEGIN_PROTECTED db->load (m_open_filename); int rdb_index = view ()->add_rdb (db.release ()); - rdb_cb->setCurrentIndex (rdb_index); + mp_ui->rdb_cb->setCurrentIndex (rdb_index); // it looks like the setCurrentIndex does not issue this signal: rdb_index_changed (rdb_index); @@ -439,7 +442,7 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu { bool need_update = false; bool taken = true; - bool show_all = browser_frame->show_all (); + bool show_all = mp_ui->browser_frame->show_all (); if (name == cfg_rdb_context_mode) { @@ -474,7 +477,7 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu } else if (name == cfg_rdb_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } @@ -529,12 +532,12 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu } if (active () && need_update) { - browser_frame->set_max_marker_count (m_max_marker_count); - browser_frame->set_window (m_window, m_window_dim, m_context); - browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); + mp_ui->browser_frame->set_max_marker_count (m_max_marker_count); + mp_ui->browser_frame->set_window (m_window, m_window_dim, m_context); + mp_ui->browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); } - browser_frame->show_all (show_all); + mp_ui->browser_frame->show_all (show_all); return taken; } @@ -567,11 +570,11 @@ MarkerBrowserDialog::rdbs_changed () { int rdb_index = -1; - rdb_cb->clear (); + mp_ui->rdb_cb->clear (); for (unsigned int i = 0; i < view ()->num_rdbs (); ++i) { const rdb::Database *rdb = view ()->get_rdb (i); - rdb_cb->addItem (tl::to_qstring (rdb->name ())); + mp_ui->rdb_cb->addItem (tl::to_qstring (rdb->name ())); if (rdb->name () == m_rdb_name) { rdb_index = i; } @@ -579,7 +582,7 @@ MarkerBrowserDialog::rdbs_changed () // force an update m_rdb_index = rdb_index; - rdb_cb->setCurrentIndex (rdb_index); + mp_ui->rdb_cb->setCurrentIndex (rdb_index); if (active ()) { update_content (); } @@ -588,7 +591,7 @@ MarkerBrowserDialog::rdbs_changed () void MarkerBrowserDialog::cellview_changed (int) { - browser_frame->update_markers (); + mp_ui->browser_frame->update_markers (); } void @@ -596,17 +599,17 @@ MarkerBrowserDialog::cellviews_changed () { int cv_index = -1; - layout_cb->clear (); + mp_ui->layout_cb->clear (); for (unsigned int i = 0; i < view ()->cellviews (); ++i) { const lay::CellView &cv = view ()->cellview (i); - layout_cb->addItem (tl::to_qstring (cv->name ())); + mp_ui->layout_cb->addItem (tl::to_qstring (cv->name ())); if (cv.is_valid () && cv->name () == m_layout_name) { cv_index = i; } } - layout_cb->setCurrentIndex (cv_index); + mp_ui->layout_cb->setCurrentIndex (cv_index); cv_index_changed (cv_index); } @@ -661,7 +664,7 @@ MarkerBrowserDialog::update_content () rdb::Database *rdb = view ()->get_rdb (m_rdb_index); if (!rdb ) { - central_stack->setCurrentIndex (1); + mp_ui->central_stack->setCurrentIndex (1); } m_saveas_action->setEnabled (rdb != 0); @@ -670,19 +673,19 @@ MarkerBrowserDialog::update_content () m_unload_all_action->setEnabled (rdb != 0); m_reload_action->setEnabled (rdb != 0); - browser_frame->enable_updates (false); // Avoid building the internal lists several times ... - browser_frame->set_rdb (0); // force update - browser_frame->set_rdb (rdb); - browser_frame->set_max_marker_count (m_max_marker_count); - browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); - browser_frame->set_window (m_window, m_window_dim, m_context); - browser_frame->set_view (view (), m_cv_index); - browser_frame->enable_updates (true); + mp_ui->browser_frame->enable_updates (false); // Avoid building the internal lists several times ... + mp_ui->browser_frame->set_rdb (0); // force update + mp_ui->browser_frame->set_rdb (rdb); + mp_ui->browser_frame->set_max_marker_count (m_max_marker_count); + mp_ui->browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); + mp_ui->browser_frame->set_window (m_window, m_window_dim, m_context); + mp_ui->browser_frame->set_view (view (), m_cv_index); + mp_ui->browser_frame->enable_updates (true); if (rdb) { // Note: it appears to be required to show the browser page after it has been configured. // Otherwise the header gets messed up and the configuration is reset. - central_stack->setCurrentIndex (0); + mp_ui->central_stack->setCurrentIndex (0); } lay::CellView cv = view ()->cellview (m_cv_index); @@ -691,12 +694,12 @@ MarkerBrowserDialog::update_content () m_layout_name = cv->name (); } - if (layout_cb->currentIndex () != m_cv_index) { - layout_cb->setCurrentIndex (m_cv_index); + if (mp_ui->layout_cb->currentIndex () != m_cv_index) { + mp_ui->layout_cb->setCurrentIndex (m_cv_index); } - if (rdb_cb->currentIndex () != m_rdb_index) { - rdb_cb->setCurrentIndex (m_rdb_index); + if (mp_ui->rdb_cb->currentIndex () != m_rdb_index) { + mp_ui->rdb_cb->setCurrentIndex (m_rdb_index); } } @@ -707,8 +710,8 @@ MarkerBrowserDialog::deactivated () lay::Dispatcher::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this).c_str ()); } - browser_frame->set_rdb (0); - browser_frame->set_view (0, 0); + mp_ui->browser_frame->set_rdb (0); + mp_ui->browser_frame->set_view (0, 0); } void @@ -902,3 +905,4 @@ MarkerBrowserDialog::menu_activated (const std::string &symbol) } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/layui/layui/rdbMarkerBrowserDialog.h similarity index 86% rename from src/laybasic/laybasic/rdbMarkerBrowserDialog.h rename to src/layui/layui/rdbMarkerBrowserDialog.h index b15dd5369..6bfcf642c 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/layui/layui/rdbMarkerBrowserDialog.h @@ -20,25 +20,31 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowserDialog #define HDR_rdbMarkerBrowserDialog -#include "ui_MarkerBrowserDialog.h" +#include "layuiCommon.h" #include "layBrowser.h" +#include "layColor.h" #include "rdbMarkerBrowser.h" +namespace Ui +{ + class MarkerBrowserDialog; +} + namespace rdb { -class MarkerBrowserDialog - : public lay::Browser, - private Ui::MarkerBrowserDialog +class LAYUI_PUBLIC MarkerBrowserDialog + : public lay::Browser { Q_OBJECT public: - MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~MarkerBrowserDialog (); void load (int rdb_index, int cv_index); @@ -69,11 +75,12 @@ public slots: void configure_clicked (); private: + Ui::MarkerBrowserDialog *mp_ui; context_mode_type m_context; window_type m_window; double m_window_dim; unsigned int m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; @@ -99,3 +106,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/layui/layui/rdbMarkerBrowserPage.cc similarity index 99% rename from src/laybasic/laybasic/rdbMarkerBrowserPage.cc rename to src/layui/layui/rdbMarkerBrowserPage.cc index 1342fa14b..52bd2b58a 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/layui/layui/rdbMarkerBrowserPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "rdbMarkerBrowserPage.h" #include "rdb.h" @@ -27,7 +28,7 @@ #include "dbLayoutUtils.h" #include "tlRecipe.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "tlExceptions.h" @@ -1609,7 +1610,7 @@ MarkerBrowserPage::set_dispatcher (lay::Dispatcher *pr) } void -MarkerBrowserPage::set_marker_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern) +MarkerBrowserPage::set_marker_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern) { m_marker_color = color; m_marker_line_width = line_width; @@ -1620,7 +1621,7 @@ MarkerBrowserPage::set_marker_style (QColor color, int line_width, int vertex_si } void -MarkerBrowserPage::set_view (lay::LayoutView *view, unsigned int cv_index) +MarkerBrowserPage::set_view (lay::LayoutViewBase *view, unsigned int cv_index) { mp_view = view; m_cv_index = cv_index; @@ -3163,3 +3164,4 @@ MarkerBrowserPage::eventFilter (QObject *watched, QEvent *event) } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/layui/layui/rdbMarkerBrowserPage.h similarity index 94% rename from src/laybasic/laybasic/rdbMarkerBrowserPage.h rename to src/layui/layui/rdbMarkerBrowserPage.h index a4d82da0c..21448553d 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/layui/layui/rdbMarkerBrowserPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowserPage #define HDR_rdbMarkerBrowserPage @@ -27,6 +28,7 @@ #include "ui_MarkerBrowserPage.h" #include "rdbMarkerBrowser.h" #include "tlDeferredExecution.h" +#include "layColor.h" #include "dbBox.h" #include @@ -35,7 +37,7 @@ class QAction; namespace lay { - class LayoutView; + class LayoutViewBase; class DMarker; class Dispatcher; } @@ -77,7 +79,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutView *view, unsigned int cv_index); + void set_view (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief Attach the page to a RDB @@ -136,7 +138,7 @@ public: * @param halo The halo flag or -1 for default * @param dither_pattern The dither pattern index of -1 to take the default */ - void set_marker_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern); + void set_marker_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern); /** * @brief Enable or disable updates @@ -183,7 +185,7 @@ private: rdb::Database *mp_database; bool m_show_all; QAction *m_show_all_action; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; std::vector mp_markers; db::DBox m_markers_bbox; @@ -195,7 +197,7 @@ private: rdb::window_type m_window; double m_window_dim; size_t m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; @@ -224,3 +226,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/syntax/d25_text.xml b/src/layui/layui/syntax/d25_text.xml similarity index 100% rename from src/laybasic/laybasic/syntax/d25_text.xml rename to src/layui/layui/syntax/d25_text.xml diff --git a/src/laybasic/laybasic/syntax/ur_text.xml b/src/layui/layui/syntax/ur_text.xml similarity index 100% rename from src/laybasic/laybasic/syntax/ur_text.xml rename to src/layui/layui/syntax/ur_text.xml diff --git a/src/laybasic/laybasic/tree.stxml b/src/layui/layui/tree.stxml similarity index 100% rename from src/laybasic/laybasic/tree.stxml rename to src/layui/layui/tree.stxml diff --git a/src/laybasic/unit_tests/layNetlistBrowserModelTests.cc b/src/layui/unit_tests/layNetlistBrowserModelTests.cc similarity index 100% rename from src/laybasic/unit_tests/layNetlistBrowserModelTests.cc rename to src/layui/unit_tests/layNetlistBrowserModelTests.cc diff --git a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc b/src/layui/unit_tests/layNetlistBrowserTreeModelTests.cc similarity index 99% rename from src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc rename to src/layui/unit_tests/layNetlistBrowserTreeModelTests.cc index b6dff3fbd..0cedf039f 100644 --- a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc +++ b/src/layui/unit_tests/layNetlistBrowserTreeModelTests.cc @@ -103,3 +103,4 @@ TEST (2) EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).isValid (), true); EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).internalId () == inv2PairIndex.internalId (), true); } + diff --git a/src/layui/unit_tests/unit_tests.pro b/src/layui/unit_tests/unit_tests.pro new file mode 100644 index 000000000..d9772a389 --- /dev/null +++ b/src/layui/unit_tests/unit_tests.pro @@ -0,0 +1,26 @@ + +DESTDIR_UT = $$OUT_PWD/../.. +DESTDIR = $$OUT_PWD/.. + +TARGET = layui_tests + +include($$PWD/../../lib_ut.pri) + +SOURCES = \ + layAbstractMenuTests.cc \ + +SOURCES = \ + +!equals(HAVE_QT, "0") { + + SOURCES += \ + layNetlistBrowserModelTests.cc \ + layNetlistBrowserTreeModelTests.cc \ + +} + +INCLUDEPATH += $$LAYUI_INC $$LAYBASIC_INC $$TL_INC $$UI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../ui +DEPENDPATH += $$LAYUI_INC $$LAYBASIC_INC $$TL_INC $$UI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../ui + +LIBS += -L$$DESTDIR_UT -lklayout_laybasic -lklayout_layui -lklayout_db -lklayout_tl -lklayout_gsi + diff --git a/src/layview/layview.pro b/src/layview/layview.pro new file mode 100644 index 000000000..7a08952e9 --- /dev/null +++ b/src/layview/layview.pro @@ -0,0 +1,6 @@ + +TEMPLATE = subdirs +SUBDIRS = layview unit_tests + +unit_tests.depends += layview + diff --git a/src/laybasic/laybasic/GridNetConfigPage.ui b/src/layview/layview/GridNetConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/GridNetConfigPage.ui rename to src/layview/layview/GridNetConfigPage.ui diff --git a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc new file mode 100644 index 000000000..a0eaf8235 --- /dev/null +++ b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc @@ -0,0 +1,116 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if !defined(HAVE_QT) + +#include "gsiDecl.h" +#include "gsiSignals.h" +#include "layLayoutView.h" +#include "laybasicCommon.h" + +namespace gsi +{ + +static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) +{ + return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); +} + +extern LAYBASIC_PUBLIC Class decl_LayoutViewBase; + +Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", + gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ) + + gsi::event ("on_image_updated_event", static_cast (&lay::LayoutView::image_updated_event), + "@brief An event indicating that the image (\"screenshot\") was updated\n" + "\n" + "This event is triggered when calling \\timer." + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutView::drawing_finished_event), + "@brief An event indicating that the image is fully drawn\n" + "\n" + "This event is triggered when calling \\timer. " + "Before this event is issue, a final \\on_image_updated_event may be issued.\n" + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::method ("timer", static_cast (&lay::LayoutView::timer), + "@brief A callback required to be called regularily in the non-Qt case.\n" + "\n" + "This callback eventually implements the event loop in the non-Qt case. The main task " + "is to indicate new versions of the layout image while it is drawn. " + "When a new image has arrived, this method will issue an \\on_image_updated_event. " + "In the implementation of the latter, \"screenshot\" may be called to retrieve the current image.\n" + "When drawing has finished, the \\on_drawing_finished_event will be triggered.\n" + "\n" + "This method has been introduced in version 0.28." + ), + "@brief The view object presenting one or more layout objects\n" + "\n" + "The visual part of the view is the tab panel in the main window. The non-visual part " + "are the redraw thread, the layout handles, cell lists, layer view lists etc. " + "This object controls these aspects of the view and controls the appearance of the data. " +); + +static lay::LayoutView *get_view (lay::CellViewRef *cv) +{ + return cv->view ()->ui (); +} + +static ClassExt extdecl_CellView ( + method_ext ("view", &get_view, + "@brief Gets the view the cellview resides in\n" + "This reference will be nil if the cellview is not a valid one.\n" + "This method has been added in version 0.25.\n" + ) +); + +static lay::LayoutView *get_view_from_lp (lay::LayerPropertiesNode *node) +{ + return node->view ()->ui (); +} + +static ClassExt extdecl_LayerPropertiesNode ( + method_ext ("view", &get_view_from_lp, + "@brief Gets the view this node lives in\n" + "\n" + "This reference can be nil if the node is a orphan node that lives outside a view." + ) +); + +} + +#endif + diff --git a/src/layview/layview/gsiDeclLayLayoutView_qt.cc b/src/layview/layview/gsiDeclLayLayoutView_qt.cc new file mode 100644 index 000000000..aac221373 --- /dev/null +++ b/src/layview/layview/gsiDeclLayLayoutView_qt.cc @@ -0,0 +1,226 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#include "gsiDecl.h" +#include "gsiSignals.h" +#include "gsiEnums.h" +#include "rdb.h" +#include "layLayoutView.h" +#include "layLayerProperties.h" +#include "layDitherPattern.h" +#include "layLineStyles.h" +#include "dbSaveLayoutOptions.h" +#include "dbLayoutToNetlist.h" +#include "dbLayoutVsSchematic.h" +#include "tlStream.h" + +namespace gsi +{ + +#if defined(HAVE_QTBINDINGS) +static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) +{ + lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); + if (parent) { + // transfer ownership to the parent + lv->keep (); + } + return lv; +} +#endif + +static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) +{ + return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, 0 /*parent*/, "view", options); +} + +extern Class decl_LayoutViewBase; + +Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", +#if defined(HAVE_QTBINDINGS) + gsi::constructor ("new", &new_view, gsi::arg ("parent"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param parent The parent widget in which to embed the view\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ) + +#endif + gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ) + +#if defined(HAVE_QTBINDINGS) + gsi::method ("layer_control_frame", static_cast (&lay::LayoutView::layer_control_frame), + "@brief Gets the layer control side widget\n" + "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " + "embed it into a different context. Please note that with embedding through 'setParent' it will be " + "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" + "\n" + "The side widget can be configured through the views configuration interface.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("hierarchy_control_frame", static_cast (&lay::LayoutView::hierarchy_control_frame), + "@brief Gets the cell view (hierarchy view) side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("libraries_frame", static_cast (&lay::LayoutView::libraries_frame), + "@brief Gets the library view side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("bookmarks_frame", static_cast (&lay::LayoutView::bookmarks_frame), + "@brief Gets the bookmarks side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + +#endif + gsi::method ("current", &lay::LayoutView::current, + "@brief Returns the current view\n" + "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" + "\n" + "This method has been introduced in version 0.23.\n" + ) + + gsi::method ("bookmark_view", static_cast (&lay::LayoutView::bookmark_view), gsi::arg ("name"), + "@brief Bookmarks the current view under the given name\n" + "\n" + "@param name The name under which to bookmark the current state" + ) + + gsi::event ("on_close", static_cast (&lay::LayoutView::close_event), + "@brief A event indicating that the view is about to close\n" + "\n" + "This event is triggered when the view is going to be closed entirely.\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::event ("on_show", static_cast (&lay::LayoutView::show_event), + "@brief A event indicating that the view is going to become visible\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::event ("on_hide", static_cast (&lay::LayoutView::hide_event), + "@brief A event indicating that the view is going to become invisible\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::method ("show_rdb", static_cast (&lay::LayoutView::open_rdb_browser), gsi::arg ("rdb_index"), gsi::arg ("cv_index"), + "@brief Shows a report database in the marker browser on a certain layout\n" + "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + ) + + gsi::method ("show_l2ndb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), + "@brief Shows a netlist database in the marker browser on a certain layout\n" + "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + "\n" + "This method has been added in version 0.26." + ) + + gsi::method ("show_lvsdb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), + "@brief Shows a netlist database in the marker browser on a certain layout\n" + "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + "\n" + "This method has been added in version 0.26." + ), + "@brief The view object presenting one or more layout objects\n" + "\n" + "The visual part of the view is the tab panel in the main window. The non-visual part " + "are the redraw thread, the layout handles, cell lists, layer view lists etc. " + "This object controls these aspects of the view and controls the appearance of the data. " +); + +static lay::CellViewRef get_active_cellview_ref () +{ + lay::LayoutView *view = lay::LayoutView::current (); + if (! view) { + return lay::CellViewRef (); + } + if (view->active_cellview_index () >= 0) { + return view->active_cellview_ref (); + } else { + return lay::CellViewRef (); + } +} + +static lay::LayoutView *get_view (lay::CellViewRef *cv) +{ + return cv->view ()->ui (); +} + +static ClassExt extdecl_CellView ( + method ("active", &get_active_cellview_ref, + "@brief Gets the active CellView\n" + "The active CellView is the one that is selected in the current layout view. This method is " + "equivalent to\n" + "@code\n" + "RBA::LayoutView::current.active_cellview\n" + "@/code\n" + "If no CellView is active, this method returns nil.\n" + "\n" + "This method has been introduced in version 0.23." + ) + + method_ext ("view", &get_view, + "@brief Gets the view the cellview resides in\n" + "This reference will be nil if the cellview is not a valid one.\n" + "This method has been added in version 0.25.\n" + ) +); + +static lay::LayoutView *get_view_from_lp (lay::LayerPropertiesNode *node) +{ + return node->view ()->ui (); +} + +static ClassExt extdecl_LayerPropertiesNode ( + method_ext ("view", &get_view_from_lp, + "@brief Gets the view this node lives in\n" + "\n" + "This reference can be nil if the node is a orphan node that lives outside a view." + ) +); + +} + +#endif diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/layview/layview/layGridNet.cc similarity index 54% rename from src/laybasic/laybasic/layGridNet.cc rename to src/layview/layview/layGridNet.cc index 31f0dca4f..f17061177 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/layview/layview/layGridNet.cc @@ -23,13 +23,17 @@ #include "laybasicConfig.h" #include "layGridNet.h" -#include "layWidgets.h" -#include "layLayoutView.h" #include "layConverters.h" +#include "layLayoutViewBase.h" #include "layFixedFont.h" +#include "layPixelBufferPainter.h" #include "laySnap.h" +#include "layColor.h" #include "dbTrans.h" -#include "ui_GridNetConfigPage.h" + +#if defined(HAVE_QT) +# include "layGridNetConfigPage.h" +#endif namespace lay { @@ -52,32 +56,28 @@ static struct { { lay::GridNet::CheckerBoard, "checkerboard" } }; -class GridNetStyleConverter +void +GridNetStyleConverter::from_string (const std::string &value, lay::GridNet::GridStyle &style) { -public: - void - from_string (const std::string &value, lay::GridNet::GridStyle &style) - { - for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { - if (value == grid_styles [i].string) { - style = grid_styles [i].style; - return; - } + for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { + if (value == grid_styles [i].string) { + style = grid_styles [i].style; + return; } - throw tl::Exception (tl::to_string (QObject::tr ("Invalid grid net style: ")) + value); } + throw tl::Exception (tl::to_string (tr ("Invalid grid net style: ")) + value); +} - std::string - to_string (lay::GridNet::GridStyle style) - { - for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { - if (style == grid_styles [i].style) { - return grid_styles [i].string; - } +std::string +GridNetStyleConverter::to_string (lay::GridNet::GridStyle style) +{ + for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { + if (style == grid_styles [i].style) { + return grid_styles [i].string; } - return ""; } -}; + return ""; +} // ------------------------------------------------------------ // Implementation of the GridNetPluginDeclaration @@ -97,102 +97,27 @@ GridNetPluginDeclaration::get_options (std::vector < std::pair config_decl (new GridNetPluginDeclaration (), 2010, "GridNetPlugin"); -// ------------------------------------------------------------ -// Implementation of the configuration page - -GridNetConfigPage::GridNetConfigPage (QWidget *parent) - : lay::ConfigPage (parent) -{ - mp_ui = new Ui::GridNetConfigPage (); - mp_ui->setupUi (this); - - mp_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_net_color_pb); - mp_grid_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_grid_color_pb); - mp_grid_axis_color_cbtn = new lay::ColorButton (mp_ui->grid_axis_color_pb); - mp_grid_ruler_color_cbtn = new lay::ColorButton (mp_ui->grid_ruler_color_pb); -} - -GridNetConfigPage::~GridNetConfigPage () -{ - delete mp_ui; - mp_ui = 0; -} - -void -GridNetConfigPage::setup (lay::Dispatcher *root) -{ - std::string value; - - // Grid visibility - bool visible = false; - root->config_get (cfg_grid_visible, visible); - mp_ui->grid_group->setChecked (visible); - - bool show_ruler = false; - root->config_get (cfg_grid_show_ruler, show_ruler); - mp_ui->show_ruler->setChecked (show_ruler); - - QColor color; - root->config_get (cfg_grid_color, color, ColorConverter ()); - mp_grid_color_cbtn->set_color (color); - - root->config_get (cfg_grid_grid_color, color, ColorConverter ()); - mp_grid_grid_color_cbtn->set_color (color); - - root->config_get (cfg_grid_axis_color, color, ColorConverter ()); - mp_grid_axis_color_cbtn->set_color (color); - - root->config_get (cfg_grid_ruler_color, color, ColorConverter ()); - mp_grid_ruler_color_cbtn->set_color (color); - - lay::GridNet::GridStyle style; - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style0, style, GridNetStyleConverter ()); - mp_ui->style0_cbx->setCurrentIndex (int (style)); - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style1, style, GridNetStyleConverter ()); - mp_ui->style1_cbx->setCurrentIndex (int (style)); - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style2, style, GridNetStyleConverter ()); - mp_ui->style2_cbx->setCurrentIndex (int (style)); -} - -void -GridNetConfigPage::commit (lay::Dispatcher *root) -{ - root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ()); - root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ()); - root->config_set (cfg_grid_color, mp_grid_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_grid_color, mp_grid_grid_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_axis_color, mp_grid_axis_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_ruler_color, mp_grid_ruler_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_style0, lay::GridNet::GridStyle (mp_ui->style0_cbx->currentIndex ()), GridNetStyleConverter ()); - root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ()); - root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ()); -} - // ------------------------------------------------------------ // Implementation of the GridNet object -GridNet::GridNet (lay::LayoutView *view) +GridNet::GridNet (LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Plugin (view), mp_view (view), @@ -210,25 +135,25 @@ GridNet::configure (const std::string &name, const std::string &value) if (name == cfg_grid_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_color, color); } else if (name == cfg_grid_grid_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_grid_color, color); } else if (name == cfg_grid_axis_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_axis_color, color); } else if (name == cfg_grid_ruler_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_ruler_color, color); @@ -283,181 +208,36 @@ GridNet::configure (const std::string &name, const std::string &value) return taken; } - -class ImagePainter -{ -public: - ImagePainter (lay::BitmapViewObjectCanvas &canvas) - : mp_img (&canvas.bg_image ()), - m_resolution (canvas.resolution ()), m_width (canvas.canvas_width ()), m_height (canvas.canvas_height ()) - { - // .. nothing yet .. - } - - void set (const QPoint &p, QColor c) - { - if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { - ((unsigned int *) mp_img->scanLine (p.y ())) [p.x ()] = c.rgb (); - } - } - - void draw_line (const QPoint &p1, const QPoint &p2, QColor c) - { - if (p1.x () == p2.x ()) { - - int x = p1.x (); - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - if ((y2 >= 0 || y1 < m_height) && x >= 0 && x < m_width) { - y1 = std::max (y1, 0); - y2 = std::min (y2, m_height - 1); - for (int y = y1; y <= y2; ++y) { - ((unsigned int *) mp_img->scanLine (y)) [x] = c.rgb (); - } - } - - } else if (p1.y () == p2.y ()) { - - int y = p1.y (); - int x1 = std::min (p1.x (), p2.x ()); - int x2 = std::max (p1.x (), p2.x ()); - if ((x2 >= 0 || x1 < m_width) && y >= 0 && y < m_height) { - x1 = std::max (x1, 0); - x2 = std::min (x2, m_width - 1); - unsigned int *sl = (unsigned int *) mp_img->scanLine (y) + x1; - for (int x = x1; x <= x2; ++x) { - *sl++ = c.rgb (); - } - } - - } else { - // TODO: not implemented yet. - } - } - - void fill_rect (const QPoint &p1, const QPoint &p2, QColor c) - { - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - for (int y = y1; y <= y2; ++y) { - draw_line (QPoint (p1.x (), y), QPoint (p2.x (), y), c); - } - } - - void draw_rect (const QPoint &p1, const QPoint &p2, QColor c) - { - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - int x1 = std::min (p1.x (), p2.x ()); - int x2 = std::max (p1.x (), p2.x ()); - draw_line (QPoint (x1, y1), QPoint (x2, y1), c); - draw_line (QPoint (x1, y2), QPoint (x2, y2), c); - draw_line (QPoint (x1, y1), QPoint (x1, y2), c); - draw_line (QPoint (x2, y1), QPoint (x2, y2), c); - } - - void draw_text (const char *t, const QPoint &p, QColor c, int halign, int valign) - { - const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); - int x = p.x (), y = p.y (); - - if (halign < 0) { - x -= ff.width () * int (strlen (t)); - } else if (halign == 0) { - x -= ff.width () * int (strlen (t)) / 2; - } - - if (valign < 0) { - y += ff.height (); - } else if (valign == 0) { - y += ff.height () / 2; - } - - // TODO: simple implementation - for (; *t; ++t) { - - unsigned char ch = *t; - - if (x < -int (ff.width ()) || x >= int (mp_img->width ()) || y < 0 || y >= int (mp_img->height () + ff.height ())) { - continue; - } - - if (ch < ff.first_char () || (ch - ff.first_char ()) >= ff.n_chars ()) { - continue; - } - - const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height () * ff.stride (); - for (unsigned int i = 0; i < ff.height (); ++i, dc += ff.stride ()) { - - int iy = y - ff.height () + i + 1; - if (iy >= 0 || iy < mp_img->height ()) { - - uint32_t *d = (uint32_t *) mp_img->scanLine (y - ff.height () + i); - uint32_t m = 1; - int ix = x; - const uint32_t *ds = dc; - - for (unsigned int j = 0; j < ff.width (); ++j, ++ix) { - - if ((*ds & m) && ix >= 0 && ix < mp_img->width ()) { - d[ix] = c.rgb (); - } - - m <<= 1; - // word wrap - if (m == 0) { - ++ds; - m = 1; - } - - } - - } - - } - - x += ff.width (); - - } - - } - -private: - QImage *mp_img; - double m_resolution; - int m_width, m_height; -}; - -void +void GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) { if (m_visible) { - QColor color; - if (m_color.isValid ()) { + lay::Color color; + if (m_color.is_valid ()) { color = m_color; } else { - color = QColor (128, 128, 128); // TODO: this is not a "real" automatic color .. + color = lay::Color (128, 128, 128); // TODO: this is not a "real" automatic color .. } - QColor grid_color = color, axis_color = color, ruler_color = color; - if (m_grid_color.isValid ()) { + lay::Color grid_color = color, axis_color = color, ruler_color = color; + if (m_grid_color.is_valid ()) { grid_color = m_grid_color; } - if (m_axis_color.isValid ()) { + if (m_axis_color.is_valid ()) { axis_color = m_axis_color; } - if (m_ruler_color.isValid ()) { + if (m_ruler_color.is_valid ()) { ruler_color = m_ruler_color; } // TODO: currently, the grid net can only be rendered to a bitmap canvas .. BitmapViewObjectCanvas *bmp_canvas = dynamic_cast (&canvas); - if (! bmp_canvas) { + if (! bmp_canvas || ! bmp_canvas->bg_image ()) { return; } - ImagePainter painter (*bmp_canvas); + PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution ()); db::DCplxTrans trans = vp.trans (); db::DCplxTrans::inverse_trans trans_inv (trans.inverted ()); @@ -506,16 +286,16 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) int xoffset = int (floor (0.5 + fw * 2.5)); int yoffset = int (floor (0.5 + fw * 2.5)); - painter.fill_rect (QPoint (xoffset, vp.height () - yoffset - rh / 2), - QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2), + painter.fill_rect (db::Point (xoffset, vp.height () - yoffset - rh / 2), + db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2), ruler_color); - painter.draw_rect (QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset - rh / 2), - QPoint (xoffset + int (floor (0.5 + 2 * dgrid)), vp.height () - yoffset + rh / 2), + painter.draw_rect (db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset - rh / 2), + db::Point (xoffset + int (floor (0.5 + 2 * dgrid)), vp.height () - yoffset + rh / 2), ruler_color); painter.draw_text (tl::sprintf ("%g \265m", grid * 2).c_str (), - QPoint (xoffset + int (floor (0.5 + trans.ctrans (2 * grid))), vp.height () - yoffset - rh / 2 - 2), + db::Point (xoffset + int (floor (0.5 + trans.ctrans (2 * grid))), vp.height () - yoffset - rh / 2 - 2), ruler_color, -1, 1); if (mp_view->global_trans ().fp_trans () != db::DFTrans ()) { @@ -540,9 +320,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) poly.transform (db::FTrans (mp_view->global_trans ().fp_trans ())); for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); !e.at_end (); ++e) { - QPoint p0 (xoffset + 2 * rh, vp.height () - yoffset - rh * 5); - QPoint p1 = p0 + QPoint (int (floor (0.5 + (*e).p1 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p1 ().y () * 0.1 * rh * 4))); - QPoint p2 = p0 + QPoint (int (floor (0.5 + (*e).p2 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p2 ().y () * 0.1 * rh * 4))); + db::Point p0 (xoffset + 2 * rh, vp.height () - yoffset - rh * 5); + db::Point p1 = p0 + db::Vector (int (floor (0.5 + (*e).p1 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p1 ().y () * 0.1 * rh * 4))); + db::Point p2 = p0 + db::Vector (int (floor (0.5 + (*e).p2 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p2 ().y () * 0.1 * rh * 4))); painter.draw_line (p1, p2, ruler_color); } @@ -586,9 +366,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) for (db::DCoord x = x1; x < x2 + grid * eps; x += grid) { for (db::DCoord y = y1; y < y2 + grid * eps; y += grid) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), grid_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), grid_color); } } @@ -599,15 +379,15 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. n = nx; for (db::DCoord x = x1; n > 0; x += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); painter.draw_line (p1, p2, grid_color); } n = ny; for (db::DCoord y = y1; n > 0; y += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); painter.draw_line (p1, p2, grid_color); } @@ -627,23 +407,23 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. n = nx; for (db::DCoord x = x1; n > 0; x += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); painter.draw_line (p1, p2, grid_color); for (db::DCoord y = y1; y < y2 + g * eps; y += g) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), grid_color); } } n = ny; for (db::DCoord y = y1; n > 0; y += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); painter.draw_line (p1, p2, grid_color); for (db::DCoord x = x1; x < x2 + g * eps; x += g) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), grid_color); } } @@ -653,9 +433,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) for (db::DCoord y = y1; y < y2 + grid * eps; y += grid) { double idx = (x + y) / grid + eps; if (idx - 2.0 * floor (idx * 0.5) < 0.5) { - QPoint p1 (draw_round (trans * db::DPoint (x, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x + grid, y + grid), vp.height ())); - painter.fill_rect (p1, p2 + QPoint (-1, 1), grid_color); + db::Point p1 (draw_round (trans * db::DPoint (x, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x + grid, y + grid), vp.height ())); + painter.fill_rect (p1, p2 + db::Vector (-1, 1), grid_color); } } } @@ -708,28 +488,28 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) } else if (m_style0 == Crosses) { for (db::DCoord y = y1; y < y2 + grid * eps && draw_yaxis; y += grid) { - QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } for (db::DCoord x = x1; x < x2 + grid * eps && draw_xaxis; x += grid) { - QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } } else if (m_style0 == Lines) { // the way we iterate here is safe against integer overflow .. if (draw_yaxis) { - QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); painter.draw_line (p1, p2, axis_color); } if (draw_xaxis) { - QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); painter.draw_line (p1, p2, axis_color); } @@ -747,22 +527,22 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. if (draw_yaxis) { - QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); painter.draw_line (p1, p2, axis_color); for (db::DCoord y = y1; y < y2 + g * eps; y += g) { - QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); + db::Point p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); } } if (draw_xaxis) { - QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); painter.draw_line (p1, p2, axis_color); for (db::DCoord x = x1; x < x2 + g * eps; x += g) { - QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } } @@ -771,9 +551,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) } } - } - } // namespace lay diff --git a/src/laybasic/laybasic/layGridNet.h b/src/layview/layview/layGridNet.h similarity index 75% rename from src/laybasic/laybasic/layGridNet.h rename to src/layview/layview/layGridNet.h index 728eadf65..3991f948a 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/layview/layview/layGridNet.h @@ -26,6 +26,10 @@ #include "layViewObject.h" #include "layPlugin.h" +#if defined(HAVE_QT) +# include "layPluginConfigPage.h" +#endif +#include "layColor.h" #include "dbTypes.h" #include "dbBox.h" @@ -35,7 +39,7 @@ namespace Ui { namespace lay { -class LayoutView; +class LayoutViewBase; class ColorButton; class GridNetPluginDeclaration @@ -43,28 +47,10 @@ class GridNetPluginDeclaration { public: virtual void get_options (std::vector < std::pair > &options) const; +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; -}; - -class GridNetConfigPage - : public lay::ConfigPage -{ -Q_OBJECT - -public: - GridNetConfigPage (QWidget *parent); - ~GridNetConfigPage (); - - virtual void setup (lay::Dispatcher *root); - virtual void commit (lay::Dispatcher *root); - -private: - Ui::GridNetConfigPage *mp_ui; - lay::ColorButton *mp_grid_color_cbtn; - lay::ColorButton *mp_grid_grid_color_cbtn; - lay::ColorButton *mp_grid_axis_color_cbtn; - lay::ColorButton *mp_grid_ruler_color_cbtn; +#endif + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; }; class GridNet @@ -82,7 +68,7 @@ public: CheckerBoard }; - GridNet (lay::LayoutView *view); + GridNet (lay::LayoutViewBase *view); private: virtual void render_bg (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas); @@ -90,19 +76,26 @@ private: // implementation of the lay::Plugin interface virtual bool configure (const std::string &name, const std::string &value); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_visible; bool m_show_ruler; double m_grid; - QColor m_color; - QColor m_grid_color; - QColor m_axis_color; - QColor m_ruler_color; + lay::Color m_color; + lay::Color m_grid_color; + lay::Color m_axis_color; + lay::Color m_ruler_color; GridStyle m_style0; GridStyle m_style1; GridStyle m_style2; }; +class GridNetStyleConverter +{ +public: + void from_string (const std::string &value, lay::GridNet::GridStyle &style); + std::string to_string (lay::GridNet::GridStyle style); +}; + } #endif diff --git a/src/layview/layview/layGridNetConfigPage.cc b/src/layview/layview/layGridNetConfigPage.cc new file mode 100644 index 000000000..2538f6129 --- /dev/null +++ b/src/layview/layview/layGridNetConfigPage.cc @@ -0,0 +1,115 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#include "laybasicConfig.h" +#include "layGridNetConfigPage.h" +#include "layConverters.h" +#include "layDispatcher.h" +#include "layGridNet.h" +#include "layWidgets.h" +#include "ui_GridNetConfigPage.h" + +namespace lay +{ + +// ------------------------------------------------------------ +// Implementation of the configuration page + +GridNetConfigPage::GridNetConfigPage (QWidget *parent) + : lay::ConfigPage (parent) +{ + mp_ui = new Ui::GridNetConfigPage (); + mp_ui->setupUi (this); + + mp_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_net_color_pb); + mp_grid_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_grid_color_pb); + mp_grid_axis_color_cbtn = new lay::ColorButton (mp_ui->grid_axis_color_pb); + mp_grid_ruler_color_cbtn = new lay::ColorButton (mp_ui->grid_ruler_color_pb); +} + +GridNetConfigPage::~GridNetConfigPage () +{ + delete mp_ui; + mp_ui = 0; +} + +void +GridNetConfigPage::setup (lay::Dispatcher *root) +{ + std::string value; + + // Grid visibility + bool visible = false; + root->config_get (cfg_grid_visible, visible); + mp_ui->grid_group->setChecked (visible); + + bool show_ruler = false; + root->config_get (cfg_grid_show_ruler, show_ruler); + mp_ui->show_ruler->setChecked (show_ruler); + + QColor color; + root->config_get (cfg_grid_color, color, ColorConverter ()); + mp_grid_color_cbtn->set_color (color); + + root->config_get (cfg_grid_grid_color, color, ColorConverter ()); + mp_grid_grid_color_cbtn->set_color (color); + + root->config_get (cfg_grid_axis_color, color, ColorConverter ()); + mp_grid_axis_color_cbtn->set_color (color); + + root->config_get (cfg_grid_ruler_color, color, ColorConverter ()); + mp_grid_ruler_color_cbtn->set_color (color); + + lay::GridNet::GridStyle style; + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style0, style, GridNetStyleConverter ()); + mp_ui->style0_cbx->setCurrentIndex (int (style)); + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style1, style, GridNetStyleConverter ()); + mp_ui->style1_cbx->setCurrentIndex (int (style)); + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style2, style, GridNetStyleConverter ()); + mp_ui->style2_cbx->setCurrentIndex (int (style)); +} + +void +GridNetConfigPage::commit (lay::Dispatcher *root) +{ + root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ()); + root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ()); + root->config_set (cfg_grid_color, mp_grid_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_grid_color, mp_grid_grid_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_axis_color, mp_grid_axis_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_ruler_color, mp_grid_ruler_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_style0, lay::GridNet::GridStyle (mp_ui->style0_cbx->currentIndex ()), GridNetStyleConverter ()); + root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ()); + root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ()); +} + +} // namespace lay + +#endif diff --git a/src/layview/layview/layGridNetConfigPage.h b/src/layview/layview/layGridNetConfigPage.h new file mode 100644 index 000000000..585bd6a7e --- /dev/null +++ b/src/layview/layview/layGridNetConfigPage.h @@ -0,0 +1,62 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#ifndef HDR_layGridNetConfigPage +#define HDR_layGridNetConfigPage + +#include "layPluginConfigPage.h" + +namespace Ui { + class GridNetConfigPage; +} + +namespace lay { + +class ColorButton; + +class GridNetConfigPage + : public lay::ConfigPage +{ +Q_OBJECT + +public: + GridNetConfigPage (QWidget *parent); + ~GridNetConfigPage (); + + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); + +private: + Ui::GridNetConfigPage *mp_ui; + lay::ColorButton *mp_grid_color_cbtn; + lay::ColorButton *mp_grid_grid_color_cbtn; + lay::ColorButton *mp_grid_axis_color_cbtn; + lay::ColorButton *mp_grid_ruler_color_cbtn; +}; + +} + +#endif + +#endif // defined(HAVE_QT) diff --git a/src/layview/layview/layLayoutView.h b/src/layview/layview/layLayoutView.h new file mode 100644 index 000000000..16d5cc9cf --- /dev/null +++ b/src/layview/layview/layLayoutView.h @@ -0,0 +1,33 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layLayoutView +#define HDR_layLayoutView + +#if defined(HAVE_QT) +# include "layLayoutView_qt.h" +#else +# include "layLayoutView_noqt.h" +#endif + +#endif diff --git a/src/layview/layview/layLayoutView_noqt.cc b/src/layview/layview/layLayoutView_noqt.cc new file mode 100644 index 000000000..6b8743a40 --- /dev/null +++ b/src/layview/layview/layLayoutView_noqt.cc @@ -0,0 +1,64 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if !defined(HAVE_QT) + +#include "layLayoutView.h" + +namespace lay +{ + +LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (this, mgr, editable, plugin_parent, options) +{ + config_setup (); +} + +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (this, source, mgr, editable, plugin_parent, options) +{ + config_setup (); +} + +// NOTE: this methods needs to be called "frequently" +void +LayoutView::timer () +{ + LayoutViewBase::timer (); + + // Without Qt, this is also the opportunity to execute deferred methods + tl::DeferredMethodScheduler::execute (); + + // We also issue the "image_updated" event if the image ("screenshot") has been updated + if (canvas ()->image_updated ()) { + image_updated_event (); + } + + // And also the drawing_finished event + if (canvas ()->drawing_finished ()) { + drawing_finished_event (); + } +} + +} // namespace lay + +#endif diff --git a/src/layview/layview/layLayoutView_noqt.h b/src/layview/layview/layLayoutView_noqt.h new file mode 100644 index 000000000..0288d6081 --- /dev/null +++ b/src/layview/layview/layLayoutView_noqt.h @@ -0,0 +1,83 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if !defined(HAVE_QT) + +#ifndef HDR_layLayoutViewNoQt +#define HDR_layLayoutViewNoQt + +#include "layviewCommon.h" +#include "layLayoutViewBase.h" + +namespace lay +{ + +/** + * @brief The layout view object + * + * The layout view is responsible for displaying one or a set of layouts. + * It manages the layer display list and many other components. + */ +class LAYVIEW_PUBLIC LayoutView + : public LayoutViewBase +{ +public: + /** + * @brief Constructor + */ + LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Constructor (clone from another view) + */ + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief This event is triggered in the "timer" callback when the image ("screenshot") was updated. + */ + tl::Event image_updated_event; + + /** + * @brief This event is triggered in the "timer" callback when the drawing thread has finished. + */ + tl::Event drawing_finished_event; + + /** + * @brief A callback that needs to be called "frequently" + */ + void timer (); + +protected: + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *get_ui () { return this; } + +private: + using LayoutViewBase::ui; +}; + +} + +#endif + +#endif diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc new file mode 100644 index 000000000..e8805b1b3 --- /dev/null +++ b/src/layview/layview/layLayoutView_qt.cc @@ -0,0 +1,1090 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tlInternational.h" +#include "tlExpression.h" +#include "tlTimer.h" +#include "tlString.h" +#include "tlLog.h" +#include "tlAssert.h" +#include "tlExceptions.h" +#include "layLayoutView.h" +#include "layViewOp.h" +#include "layViewObject.h" +#include "laybasicConfig.h" +#include "layConverters.h" +#include "layGridNet.h" +#include "layMove.h" +#include "layZoomBox.h" +#include "layMouseTracker.h" +#include "layEditable.h" +#include "layFixedFont.h" +#include "laySelector.h" +#include "layLayoutCanvas.h" +#include "layLayerControlPanel.h" +#include "layHierarchyControlPanel.h" +#include "layLibrariesView.h" +#include "layBrowser.h" +#include "layRedrawThread.h" +#include "layRedrawThreadWorker.h" +#include "layParsedLayerSource.h" +#include "layBookmarkManagementForm.h" +#include "layNetlistBrowserDialog.h" +#include "layBookmarksView.h" +#include "layEditorOptionsFrame.h" +#include "layEditorOptionsPages.h" +#include "dbClipboard.h" +#include "dbLayout.h" +#include "dbLayoutUtils.h" +#include "dbManager.h" +#include "dbLibrary.h" +#include "rdb.h" +#include "rdbMarkerBrowserDialog.h" +#include "dbLayoutToNetlist.h" +#include "tlXMLParser.h" +#include "gsi.h" +#include "gtf.h" + +#include + +namespace lay +{ + +// ------------------------------------------------------------- + +const int timer_interval = 10; + +static LayoutView *ms_current = 0; + +LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) + : LayoutViewBase (parent, this, manager, editable, plugin_parent, options), + dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) +{ + // ensures the deferred method scheduler is present + tl::DeferredMethodScheduler::instance (); + + setObjectName (QString::fromUtf8(name)); + init_ui (); +} + +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) + : LayoutViewBase (parent, this, source, manager, editable, plugin_parent, options), + dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) +{ + // ensures the deferred method scheduler is present + tl::DeferredMethodScheduler::instance (); + + setObjectName (QString::fromUtf8 (name)); + init_ui (); + + bookmarks (source->bookmarks ()); + set_active_cellview_index (source->active_cellview_index ()); +} + +bool +LayoutView::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == mp_min_hier_spbx || obj == mp_max_hier_spbx) { + + // Makes the min/max spin boxes accept only numeric and some control keys .. + QKeyEvent *keyEvent = dynamic_cast(event); + if (keyEvent && + keyEvent->key () != Qt::Key_Home && + keyEvent->key () != Qt::Key_End && + keyEvent->key () != Qt::Key_Delete && + keyEvent->key () != Qt::Key_Backspace && + (keyEvent->key () < Qt::Key_0 || keyEvent->key () > Qt::Key_9)) { + return true; + } else { + return false; + } + + } else { + return QFrame::eventFilter (obj, event); + } +} + +void +LayoutView::init_menu () +{ + // make the plugins create their menu items + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + // TODO: get rid of the const_cast hack + const_cast (&*cls)->init_menu (dispatcher ()); + } + + // if not in editable mode, hide all entries from "edit_mode" group and show all from the "view_mode" group and vice versa + std::vector edit_mode_grp = menu ()->group ("edit_mode"); + for (std::vector::const_iterator g = edit_mode_grp.begin (); g != edit_mode_grp.end (); ++g) { + menu ()->action (*g)->set_visible (is_editable ()); + } + std::vector view_mode_grp = menu ()->group ("view_mode"); + for (std::vector::const_iterator g = view_mode_grp.begin (); g != view_mode_grp.end (); ++g) { + menu ()->action (*g)->set_visible (! is_editable ()); + } +} + +void +LayoutView::init_ui () +{ + m_activated = true; + m_always_show_source = false; + m_always_show_ld = true; + m_always_show_layout_index = false; + + mp_timer = 0; + mp_left_frame = 0; + mp_control_panel = 0; + mp_hierarchy_panel = 0; + mp_libraries_view = 0; + mp_bookmarks_view = 0; + mp_control_frame = 0; + mp_hierarchy_frame = 0; + mp_libraries_frame = 0; + mp_bookmarks_frame = 0; + mp_editor_options_frame = 0; + mp_min_hier_spbx = 0; + mp_max_hier_spbx = 0; + + QVBoxLayout *vbl = new QVBoxLayout (this); + vbl->setContentsMargins (0, 0, 0, 0); + vbl->setSpacing (0); + vbl->addWidget (view_object_widget ()); + + if ((options () & LV_NoHierarchyPanel) == 0 && (options () & LV_Naked) == 0) { + + QFrame *hierarchy_frame = new QFrame (0); + hierarchy_frame->setObjectName (QString::fromUtf8 ("left")); + mp_hierarchy_frame = hierarchy_frame; + QVBoxLayout *left_frame_ly = new QVBoxLayout (hierarchy_frame); + left_frame_ly->setContentsMargins (0, 0, 0, 0); + left_frame_ly->setSpacing (0); + + mp_hierarchy_panel = new lay::HierarchyControlPanel (this, hierarchy_frame, "hcp"); + left_frame_ly->addWidget (mp_hierarchy_panel, 1 /*stretch*/); + + connect (mp_hierarchy_panel, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int))); + connect (mp_hierarchy_panel, SIGNAL (active_cellview_changed (int)), this, SLOT (active_cellview_changed (int))); + connect (mp_hierarchy_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + + QFrame *levels_frame = new QFrame (hierarchy_frame); + levels_frame->setObjectName (QString::fromUtf8 ("lvl_frame")); + left_frame_ly->addWidget (levels_frame); + QHBoxLayout *levels_frame_ly = new QHBoxLayout (levels_frame); + levels_frame_ly->setContentsMargins (1, 1, 1, 1); + QLabel *level_l1 = new QLabel (tl::to_qstring (" " + tl::to_string (QObject::tr ("Levels"))), levels_frame); + levels_frame_ly->addWidget (level_l1); + mp_min_hier_spbx = new QSpinBox (levels_frame); + mp_min_hier_spbx->setObjectName (QString::fromUtf8 ("min_lvl")); + levels_frame_ly->addWidget (mp_min_hier_spbx); + QLabel *level_l2 = new QLabel (QString::fromUtf8 (".."), levels_frame); + levels_frame_ly->addWidget (level_l2); + mp_max_hier_spbx = new QSpinBox (levels_frame); + mp_max_hier_spbx->setObjectName (QString::fromUtf8 ("max_lvl")); + levels_frame_ly->addWidget (mp_max_hier_spbx); + + mp_min_hier_spbx->installEventFilter (this); + mp_max_hier_spbx->installEventFilter (this); + + mp_min_hier_spbx->setMaximum (0); + mp_min_hier_spbx->setMinimum (-1000); + mp_min_hier_spbx->setValue (0); + mp_max_hier_spbx->setMaximum (999); + mp_max_hier_spbx->setValue (0); + mp_max_hier_spbx->setMinimum (-1000); + + connect (mp_min_hier_spbx, SIGNAL (valueChanged (int)), this, SLOT (min_hier_changed (int))); + connect (mp_max_hier_spbx, SIGNAL (valueChanged (int)), this, SLOT (max_hier_changed (int))); + + } + + if ((options () & LV_NoBookmarksView) == 0 && (options () & LV_Naked) == 0) { + + QFrame *bookmarks_frame = new QFrame (0); + bookmarks_frame->setObjectName (QString::fromUtf8 ("bookmarks_frame")); + mp_bookmarks_frame = bookmarks_frame; + QVBoxLayout *left_frame_ly = new QVBoxLayout (bookmarks_frame); + left_frame_ly->setContentsMargins (0, 0, 0, 0); + left_frame_ly->setSpacing (0); + + mp_bookmarks_view = new lay::BookmarksView (this, bookmarks_frame, "bookmarks"); + left_frame_ly->addWidget (mp_bookmarks_view, 1 /*stretch*/); + + connect (mp_bookmarks_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + + } + + if ((options () & LV_NoLibrariesView) == 0 && (options () & LV_Naked) == 0) { + + mp_libraries_frame = new QFrame (0); + mp_libraries_frame->setObjectName (QString::fromUtf8 ("libs_frame")); + QVBoxLayout *left_frame_ly = new QVBoxLayout (mp_libraries_frame); + left_frame_ly->setContentsMargins (0, 0, 0, 0); + left_frame_ly->setSpacing (0); + + mp_libraries_view = new lay::LibrariesView (this, mp_libraries_frame, "libs"); + left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/); + + connect (mp_libraries_view, SIGNAL (active_library_changed (int)), this, SLOT (active_library_changed (int))); + connect (mp_libraries_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + + } + + if ((options () & LV_NoEditorOptionsPanel) == 0 && (options () & LV_Naked) == 0) { + + mp_editor_options_frame = new lay::EditorOptionsFrame (0); + mp_editor_options_frame->populate (this); + + connect (mp_editor_options_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + + } + + if ((options () & LV_NoLayers) == 0 && (options () & LV_Naked) == 0) { + + mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); + mp_control_frame = mp_control_panel; + + connect (mp_control_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + connect (mp_control_panel, SIGNAL (tab_changed ()), this, SLOT (layer_tab_changed ())); + connect (mp_control_panel, SIGNAL (order_changed ()), this, SLOT (layer_order_changed ())); + connect (mp_control_panel, SIGNAL (current_layer_changed (const lay::LayerPropertiesConstIterator &)), this, SLOT (current_layer_changed_slot (const lay::LayerPropertiesConstIterator &))); + /* + connect (mp_control_panel, SIGNAL (marked_changed ()), this, SLOT (prop_changed ())); + connect (mp_control_panel, SIGNAL (width_changed ()), this, SLOT (prop_changed ())); + connect (mp_control_panel, SIGNAL (animation_changed ()), this, SLOT (prop_changed ())); + connect (mp_control_panel, SIGNAL (visibility_changed ()), this, SLOT (visibility_changed ())); + connect (mp_control_panel, SIGNAL (transparency_changed ()), this, SLOT (prop_changed ())); + connect (mp_control_panel, SIGNAL (stipple_changed ()), this, SLOT (prop_changed ())); + connect (mp_control_panel, SIGNAL (color_changed ()), this, SLOT (prop_changed ())); + */ + + } + + config_setup (); + + mp_timer = new QTimer (this); + connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); + mp_timer->start (timer_interval); +} + +LayoutView::~LayoutView () +{ + close_event (); + + if (ms_current == this) { + ms_current = 0; + } + + if (mp_control_frame) { + delete mp_control_frame; + } + mp_control_panel = 0; + mp_control_frame = 0; + + if (mp_hierarchy_frame) { + delete mp_hierarchy_frame; + } + mp_hierarchy_frame = 0; + mp_hierarchy_panel = 0; + + if (mp_libraries_frame) { + delete mp_libraries_frame; + } + mp_libraries_frame = 0; + mp_libraries_view = 0; + + if (mp_editor_options_frame) { + delete mp_editor_options_frame; + } + mp_editor_options_frame = 0; + + if (mp_bookmarks_frame) { + delete mp_bookmarks_frame; + } + mp_bookmarks_frame = 0; + mp_bookmarks_view = 0; +} + +void +LayoutView::do_change_active_cellview () +{ + dm_setup_editor_option_pages (); +} + +lay::EditorOptionsPages *LayoutView::editor_options_pages () +{ + if (! mp_editor_options_frame) { + return 0; + } else { + return mp_editor_options_frame->pages_widget (); + } +} + +void LayoutView::do_setup_editor_options_pages () +{ + // initialize the editor option pages + lay::EditorOptionsPages *eo_pages = editor_options_pages (); + if (eo_pages) { + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + (*op)->setup (this); + } + } +} + +void LayoutView::side_panel_destroyed () +{ + if (sender () == mp_control_frame) { + mp_control_frame = 0; + mp_control_panel = 0; + } else if (sender () == mp_hierarchy_frame) { + mp_hierarchy_frame = 0; + mp_hierarchy_panel = 0; + } else if (sender () == mp_libraries_frame) { + mp_libraries_frame = 0; + mp_libraries_view = 0; + } else if (sender () == mp_editor_options_frame) { + mp_editor_options_frame = 0; + } else if (sender () == mp_bookmarks_frame) { + mp_bookmarks_frame = 0; + mp_bookmarks_view = 0; + } +} + +void LayoutView::hideEvent (QHideEvent *) +{ + hide_event (); +} + +void LayoutView::showEvent (QShowEvent *) +{ + show_event (); +} + +void LayoutView::set_current () +{ + set_current (this); +} + +void LayoutView::set_current (lay::LayoutView *view) +{ + if (ms_current != view) { + if (ms_current) { + ms_current->deactivate (); + } + ms_current = view; + if (ms_current) { + ms_current->activate (); + } + } +} + +LayoutView *LayoutView::current () +{ + return ms_current; +} + +void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) +{ + LayoutViewBase::create_plugins (except_this); + dm_setup_editor_option_pages (); +} + +namespace { + +class GotoBookmarkAction + : public lay::Action +{ +public: + GotoBookmarkAction (lay::LayoutView *view, size_t id, const std::string &title) + : Action (), mp_view (view), m_id (id) + { + set_title (title); + } + + void triggered () + { + if (mp_view) { + mp_view->goto_view (mp_view->bookmarks ().state (m_id)); + } + } + +private: + tl::weak_ptr mp_view; + size_t m_id; +}; + +} + +void +LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) +{ + std::string bm_menu = "bookmark_menu.goto_bookmark_menu"; + + if (menu.is_valid (bm_menu)) { + + menu.clear_menu (bm_menu); + + Action *goto_bookmark_action = menu.action (bm_menu); + + if (view && view->bookmarks ().size () > 0) { + + goto_bookmark_action->set_enabled (true); + + const lay::BookmarkList &bookmarks = view->bookmarks (); + for (size_t i = 0; i < bookmarks.size (); ++i) { + Action *action = new GotoBookmarkAction (view, i, bookmarks.name (i)); + menu.insert_item (bm_menu + ".end", tl::sprintf ("bookmark_%d", i + 1), action); + } + + } else { + goto_bookmark_action->set_enabled (false); + } + + } +} + +bool +LayoutView::configure (const std::string &name, const std::string &value) +{ + if (LayoutViewBase::configure (name, value)) { + return true; + } + + if (name == cfg_flat_cell_list) { + + bool f; + tl::from_string (value, f); + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_flat (f); + } + return true; + + } else if (name == cfg_split_cell_list) { + + bool f; + tl::from_string (value, f); + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_split_mode (f); + } + return true; + + } else if (name == cfg_split_lib_views) { + + bool f; + tl::from_string (value, f); + if (mp_libraries_view) { + mp_libraries_view->set_split_mode (f); + } + return true; + + } else if (name == cfg_bookmarks_follow_selection) { + + bool f; + tl::from_string (value, f); + if (mp_bookmarks_view) { + mp_bookmarks_view->follow_selection (f); + } + return true; + + } else if (name == cfg_current_lib_view) { + + if (mp_libraries_view) { + mp_libraries_view->select_active_lib_by_name (value); + } + return true; + + } else if (name == cfg_cell_list_sorting) { + + if (mp_hierarchy_panel) { + if (value == "by-name") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByName); + } else if (value == "by-area") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByArea); + } else if (value == "by-area-reverse") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByAreaReverse); + } + } + return true; + + } else if (name == cfg_hide_empty_layers) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_hide_empty_layers (f); + } + return true; + + } else if (name == cfg_test_shapes_in_view) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_test_shapes_in_view (f); + } + return true; + + } else if (name == cfg_layers_always_show_source) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_source) { + m_always_show_source = a; + layer_list_changed_event (4); + } + + return true; + + } else if (name == cfg_layers_always_show_ld) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_ld) { + m_always_show_ld = a; + layer_list_changed_event (4); + } + + return true; + + } else if (name == cfg_layers_always_show_layout_index) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_layout_index) { + m_always_show_layout_index = a; + layer_list_changed_event (4); + } + + return true; + + } else { + return false; + } +} + +void +LayoutView::config_finalize () +{ + // It's important that the editor option pages are updated last - because the + // configuration change may trigger other configuration changes + dm_setup_editor_option_pages (); +} + +void +LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) +{ + if (mp_control_panel) { + mp_control_panel->set_current_layer (l); + } +} + +lay::LayerPropertiesConstIterator +LayoutView::current_layer () const +{ + if (mp_control_panel) { + return mp_control_panel->current_layer (); + } else { + return lay::LayerPropertiesConstIterator (); + } +} + +std::vector +LayoutView::selected_layers () const +{ + if (mp_control_panel) { + return mp_control_panel->selected_layers (); + } else { + return std::vector (); + } +} + +void +LayoutView::set_selected_layers (const std::vector &sel) +{ + if (mp_control_panel) { + mp_control_panel->set_selection (sel); + } +} + +void +LayoutView::begin_layer_updates () +{ + if (mp_control_panel) { + mp_control_panel->begin_updates (); + } +} + +void +LayoutView::end_layer_updates () +{ + if (mp_control_panel) { + mp_control_panel->end_updates (); + } +} + +bool +LayoutView::layer_model_updated () +{ + // because check_updated is called in the initialization phase, we check if the pointers + // to the widgets are non-null: + if (mp_control_panel) { + return mp_control_panel->model_updated (); + } else { + return false; + } +} + +void +LayoutView::bookmark_current_view () +{ + QString proposed_name = tl::to_qstring (bookmarks ().propose_new_bookmark_name ()); + + while (true) { + bool ok = false; + QString text = QInputDialog::getText (this, QObject::tr ("Enter Bookmark Name"), QObject::tr ("Bookmark name"), + QLineEdit::Normal, proposed_name, &ok); + if (! ok) { + break; + } else if (text.isEmpty ()) { + QMessageBox::critical (this, QObject::tr ("Error"), QObject::tr ("Enter a name for the bookmark")); + } else { + bookmark_view (tl::to_string (text)); + break; + } + } +} + +void +LayoutView::manage_bookmarks () +{ + std::set selected_bm; + if (mp_bookmarks_frame->isVisible ()) { + selected_bm = mp_bookmarks_view->selected_bookmarks (); + } + + BookmarkManagementForm dialog (this, "bookmark_form", bookmarks (), selected_bm); + if (dialog.exec ()) { + bookmarks (dialog.bookmarks ()); + } +} + +void +LayoutView::bookmarks_changed () +{ + mp_bookmarks_view->refresh (); + emit menu_needs_update (); +} + +void +LayoutView::layer_tab_changed () +{ + update_content (); +} + +void +LayoutView::layer_order_changed () +{ + update_content (); +} + +void +LayoutView::min_hier_changed (int i) +{ + mp_max_hier_spbx->setMinimum (i); + set_hier_levels (std::make_pair (i, get_hier_levels ().second)); +} + +void +LayoutView::max_hier_changed (int i) +{ + mp_min_hier_spbx->setMaximum (i); + set_hier_levels (std::make_pair (get_hier_levels ().first, i)); +} + +lay::Color +LayoutView::default_background_color () +{ + return lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); +} + +void +LayoutView::do_set_background_color (lay::Color c, lay::Color contrast) +{ + if (mp_control_panel) { + mp_control_panel->set_background_color (c); + mp_control_panel->set_text_color (contrast); + } + + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_background_color (c); + mp_hierarchy_panel->set_text_color (contrast); + } + + if (mp_libraries_view) { + mp_libraries_view->set_background_color (c); + mp_libraries_view->set_text_color (contrast); + } + + if (mp_bookmarks_view) { + mp_bookmarks_view->set_background_color (c); + mp_bookmarks_view->set_text_color (contrast); + } +} + +void +LayoutView::do_set_no_stipples (bool no_stipples) +{ + if (mp_control_panel) { + mp_control_panel->set_no_stipples (no_stipples); + } +} + +void +LayoutView::do_set_phase (int phase) +{ + if (mp_control_panel) { + mp_control_panel->set_phase (phase); + } +} + +void +LayoutView::active_library_changed (int /*index*/) +{ + std::string lib_name; + if (mp_libraries_view->active_lib ()) { + lib_name = mp_libraries_view->active_lib ()->get_name (); + } + + // commit the new active library to the other views and persist this state + // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) + dispatcher ()->config_set (cfg_current_lib_view, lib_name); +} + +bool +LayoutView::set_hier_levels_basic (std::pair l) +{ + if (l != get_hier_levels ()) { + + if (mp_min_hier_spbx) { + mp_min_hier_spbx->blockSignals (true); + mp_min_hier_spbx->setValue (l.first); + mp_min_hier_spbx->setMaximum (l.second); + mp_min_hier_spbx->blockSignals (false); + } + + if (mp_max_hier_spbx) { + mp_max_hier_spbx->blockSignals (true); + mp_max_hier_spbx->setValue (l.second); + mp_max_hier_spbx->setMinimum (l.first); + mp_max_hier_spbx->blockSignals (false); + } + + return LayoutViewBase::set_hier_levels_basic (l); + + } else { + return false; + } +} + +bool +LayoutView::has_selection () +{ + if (mp_control_panel && mp_control_panel->has_focus ()) { + return mp_control_panel->has_selection (); + } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + return mp_hierarchy_panel->has_selection (); + } else { + return lay::LayoutViewBase::has_selection (); + } +} + +void +LayoutView::do_paste () +{ + // let the receivers sort out who is pasting what .. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->paste (); + } + if (mp_control_panel) { + mp_control_panel->paste (); + } +} + +void +LayoutView::copy () +{ + if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + mp_hierarchy_panel->copy (); + } else if (mp_control_panel && mp_control_panel->has_focus ()) { + mp_control_panel->copy (); + } else { + LayoutViewBase::copy (); + } +} + +void +LayoutView::cut () +{ + if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + // TODO: currently the hierarchy panel's cut function does it's own transaction handling. + // Otherwise the cut function is not working propertly. + mp_hierarchy_panel->cut (); + } else if (mp_control_panel && mp_control_panel->has_focus ()) { + db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); + mp_control_panel->cut (); + } else { + LayoutViewBase::cut (); + } +} + +int +LayoutView::active_cellview_index () const +{ + return mp_hierarchy_panel->active (); +} + +void +LayoutView::set_active_cellview_index (int index) +{ + if (index >= 0 && index < int (cellviews ())) { + mp_hierarchy_panel->select_active (index); + } +} + +void +LayoutView::selected_cells_paths (int cv_index, std::vector &paths) const +{ + mp_hierarchy_panel->selected_cells (cv_index, paths); +} + +void +LayoutView::current_cell_path (int cv_index, cell_path_type &path) const +{ + mp_hierarchy_panel->current_cell (cv_index, path); +} + +void +LayoutView::set_current_cell_path (int cv_index, const cell_path_type &path) +{ + mp_hierarchy_panel->set_current_cell (cv_index, path); +} + +void +LayoutView::activate () +{ + if (! m_activated) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { + if ((*p)->browser_interface () && (*p)->browser_interface ()->active ()) { + (*p)->browser_interface ()->show (); + } + } + mp_timer->start (timer_interval); + m_activated = true; + update_content (); + } +} + +void +LayoutView::deactivate () +{ + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { + if ((*p)->browser_interface ()) { + (*p)->browser_interface ()->hide (); + } + } + + emit clear_current_pos (); + free_resources (); + mp_timer->stop (); + m_activated = false; +} + +bool +LayoutView::is_activated () const +{ + return m_activated; +} + +void +LayoutView::deactivate_all_browsers () +{ + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { + if ((*p)->browser_interface ()) { + (*p)->browser_interface ()->deactivate (); + } + } +} + +void +LayoutView::update_content_for_cv (int cellview_index) +{ + if (mp_hierarchy_panel) { + mp_hierarchy_panel->do_update_content (cellview_index); + } +} + +void +LayoutView::current_pos (double x, double y) +{ + if (m_activated) { + if (dbu_coordinates ()) { + double dx = 0.0, dy = 0.0; + if (active_cellview_index () >= 0) { + double dbu = cellview (active_cellview_index ())->layout ().dbu (); + dx = x / dbu; + dy = y / dbu; + } + emit current_pos_changed (dx, dy, true); + } else { + emit current_pos_changed (x, y, false); + } + } +} + +void +LayoutView::emit_edits_enabled_changed () +{ + emit edits_enabled_changed (); +} + +void +LayoutView::emit_title_changed () +{ + emit title_changed (); +} + +void +LayoutView::emit_dirty_changed () +{ + emit dirty_changed (); +} + +void +LayoutView::emit_layer_order_changed () +{ + emit layer_order_changed (); +} + +void +LayoutView::signal_selection_changed () +{ + if (selection_size () > 1) { + message (tl::sprintf (tl::to_string (tr ("selected: %ld objects")), selection_size ())); + } + + lay::Editables::signal_selection_changed (); +} + +void +LayoutView::message (const std::string &s, int timeout) +{ + emit show_message (s, timeout * 1000); +} + +void +LayoutView::mode (int m) +{ + if (mode () != m) { + + LayoutViewBase::mode (m); + + lay::EditorOptionsPages *eo_pages = editor_options_pages (); + if (eo_pages) { + + // TODO: this is very inefficient as each "activate" will regenerate the tabs + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + bool is_active = false; + if ((*op)->plugin_declaration () == 0) { + is_active = true; + } else if (active_plugin () && active_plugin ()->plugin_declaration () == (*op)->plugin_declaration ()) { + is_active = true; + } + (*op)->activate (is_active); + } + + } + + } +} + +void +LayoutView::switch_mode (int m) +{ + if (mode () != m) { + mode (m); + emit mode_change (m); + } +} + +void +LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) +{ + lay::NetlistBrowserDialog *l2ndb_browser = get_plugin (); + if (l2ndb_browser) { + l2ndb_browser->load (l2ndb_index, cv_index); + } +} + +void +LayoutView::open_rdb_browser (int rdb_index, int cv_index) +{ + rdb::MarkerBrowserDialog *rdb_browser = get_plugin (); + if (rdb_browser) { + rdb_browser->load (rdb_index, cv_index); + } +} + +QSize +LayoutView::sizeHint () const +{ + if ((options () & LV_Naked) != 0) { + return QSize (200, 200); + } else if ((options () & LV_NoLayers) != 0 || (options () & LV_NoHierarchyPanel) != 0 || (options () & LV_NoLibrariesView) != 0) { + return QSize (400, 200); + } else { + return QSize (600, 200); + } +} + +} // namespace lay + +#endif + diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h new file mode 100644 index 000000000..fe65fde62 --- /dev/null +++ b/src/layview/layview/layLayoutView_qt.h @@ -0,0 +1,743 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#if defined(HAVE_QT) + +#ifndef HDR_layLayoutViewQt +#define HDR_layLayoutViewQt + +#include "layviewCommon.h" + +#include "layLayoutViewBase.h" +#include "layLayerProperties.h" +#include "layAbstractMenu.h" +#include "layAnnotationShapes.h" +#include "layDispatcher.h" +#include "layLayoutCanvas.h" +#include "layColorPalette.h" +#include "layStipplePalette.h" +#include "layLineStylePalette.h" +#include "layCellView.h" +#include "layViewOp.h" +#include "layEditable.h" +#include "layPlugin.h" +#include "layDisplayState.h" +#include "layBookmarkList.h" +#include "layEditorOptionsFrame.h" +#include "gsi.h" +#include "tlException.h" +#include "tlEvents.h" +#include "dbInstElement.h" + +#include +#include +#include +#include +#include +#include + +#include + +class QSpinBox; + +namespace rdb { + class Database; +} + +namespace db { + class Layout; + class Manager; + class SaveLayoutOptions; + class LayoutToNetlist; +} + +namespace lay { + +class AbstractMenu; +class LayerControlPanel; +class HierarchyControlPanel; +class LibrariesView; +class BookmarksView; +class MouseTracker; +class ZoomService; +class SelectionService; +class MoveService; +class Browser; +class ColorButton; +class ConfigureAction; +class EditorOptionsPages; + +/** + * @brief The layout view object + * + * The layout view is responsible for displaying one or a set of layouts. + * It is composed of a canvas and controls to control the appearance. + * It manages the layer display list, bookmark list etc. + */ +class LAYVIEW_PUBLIC LayoutView + : public LayoutViewBase +{ +Q_OBJECT + +public: + /** + * @brief Constructor + */ + LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Constructor (clone from another view) + */ + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Destructor + */ + ~LayoutView (); + + /** + * @brief Makes this view the current one + */ + void set_current (); + + /** + * @brief Makes the given view the current one + * + * The argument can be 0 which means there is no current view. + */ + static void set_current (LayoutView *); + + /** + * @brief Gets the current view + */ + static LayoutView *current (); + + /** + * @brief Determine if there is something to copy + * + * This reimplementation of the lay::Editables interface additionally + * looks for content providers in the tree views for example. + */ + virtual bool has_selection (); + + /** + * @brief Displays a status message + */ + void message (const std::string &s = "", int timeout = 10); + + /** + * @brief Select a certain mode (by index) + */ + virtual void mode (int m); + + /** + * @brief Gets the current mode + */ + int mode () const + { + return LayoutViewBase::mode (); + } + + /** + * @brief Switches the application's mode + * + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. + */ + virtual void switch_mode (int m); + + /** + * @brief Updates the menu for the given view + * If the view is 0, the menu shall be updated to reflect "no view active" + */ + static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); + + /** + * @brief Create all plugins + * + * If plugins already exist, they are deleted and created again + */ + virtual void create_plugins (const lay::PluginDeclaration *except_this = 0); + + /** + * @brief Sets the currently active layer by layer properties and cell view index + * + * This method will look up that layer in the layer view tree and select that layer. + * This method will also select this layer. + * + * Returns false if the layer is not a valid one. + */ + bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties) + { + return LayoutViewBase::set_current_layer (cv_index, properties); + } + + /** + * @brief Sets the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. This method will also select this layer. + */ + virtual void set_current_layer (const lay::LayerPropertiesConstIterator &l); + + /** + * @brief Retrieve the index of the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. + * This method returns a null iterator, if no layer is active. + */ + virtual lay::LayerPropertiesConstIterator current_layer () const; + + /** + * @brief Return the layers that are selected in the layer browser + * + * Returns an empty list if no layer is selected. + */ + std::vector selected_layers () const; + + /** + * @brief Sets the layers that are selected in the layer browser + */ + void set_selected_layers (const std::vector &sel); + + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + int active_cellview_index () const; + + /** + * @brief Select a certain cellview for the active one + */ + virtual void set_active_cellview_index (int index); + + /** + * @brief Cell paths of the selected cells + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + void selected_cells_paths (int cv_index, std::vector &paths) const; + + /** + * @brief Cell path of the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + void current_cell_path (int cv_index, cell_path_type &path) const; + + /** + * @brief Cell path of the current cell in the active cellview + * + * This is a convenience function returning the path for the active cellview. + */ + void current_cell_path (cell_path_type &path) const + { + current_cell_path (active_cellview_index (), path); + } + + /** + * @brief Set the path to the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * cell given by the path is highlighted and scrolled into view. + */ + virtual void set_current_cell_path (int cv_index, const cell_path_type &path); + + /** + * @brief Internal method: check, if the layer tree is and an consistent state. + * + * This method is used by the layer tree model to check, if the tree has been brought into + * a consistent state. + * HINT: for the layout this is solved more consistently with the "under construction" attribute + * of the layout. There is no equivalent object for the layer tree currently. + */ + bool layer_model_updated (); + + /** + * @brief Returns true, if the layer source shall be shown always in the layer properties tree + */ + virtual bool always_show_source () const + { + return m_always_show_source; + } + + /** + * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree + */ + virtual bool always_show_ld () const + { + return m_always_show_ld; + } + + /** + * @brief Returns true, if the layout index shall be shown always in the layer properties tree + */ + virtual bool always_show_layout_index () const + { + return m_always_show_layout_index; + } + + /** + * @brief Indicates the current position + */ + virtual void current_pos (double x, double y); + + /** + * @brief Asks for a bookmark name and bookmark the current view under this name + */ + void bookmark_current_view (); + + /** + * @brief Show the bookmark management form + */ + void manage_bookmarks (); + + /** + * @brief Open the RDB browser for a given database and associated cv index + */ + virtual void open_rdb_browser (int rdb_index, int cv_index); + + /** + * @brief Open the L2NDB browser for a given database and associated cv index + */ + virtual void open_l2ndb_browser (int l2ndb_index, int cv_index); + + /** + * @brief Gets the editor options pages + */ + virtual lay::EditorOptionsPages *editor_options_pages (); + + /** + * @brief Gets the container with the layer control panel + */ + QWidget *layer_control_frame () + { + return mp_control_frame; + } + + /** + * @brief Gets the layer control panel + */ + virtual lay::LayerControlPanel *control_panel () + { + return mp_control_panel; + } + + /** + * @brief Gets the container with the hierarchy control panel + */ + QWidget *hierarchy_control_frame () + { + return mp_hierarchy_frame; + } + + /** + * @brief Gets the hierarchy panel + */ + virtual lay::HierarchyControlPanel *hierarchy_panel () + { + return mp_hierarchy_panel; + } + + /** + * @brief Gets the container with the libraries view + */ + QWidget *libraries_frame () + { + return mp_libraries_frame; + } + + /** + * @brief Gets the container with the bookmarks view + */ + QWidget *bookmarks_frame () + { + return mp_bookmarks_frame; + } + + /** + * @brief Gets the container with the editor options + */ + QWidget *editor_options_frame () + { + return mp_editor_options_frame; + } + + /** + * @brief Resizes the view to the given width and height in pixels + */ + void resize (unsigned int width, unsigned int height) + { + LayoutViewBase::resize (width, height); + } + + /** + * @brief Copies to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for copy providers in the tree views for example. + */ + virtual void copy (); + + /** + * @brief Cuts to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for cut & copy providers in the tree views for example. + */ + virtual void cut (); + + /** + * @brief Deliver a size hint (reimplementation of QWidget) + */ + virtual QSize sizeHint () const; + + /** + * @brief An event signalling that the view is going to close + */ + tl::Event close_event; + + /** + * @brief An event signalling that the view is going to become visible + */ + tl::Event show_event; + + /** + * @brief An event signalling that the view is going to become invisible + */ + tl::Event hide_event; + +public slots: + /** + * @brief Store the current state on the "previous states" stack + */ + void store_state () + { + LayoutViewBase::store_state (); + } + + /** + * @brief Cancels all edit operations, clears the selection and resets the mode to "Select" + */ + void cancel_esc () + { + LayoutViewBase::cancel_esc (); + } + + /** + * @brief Cancels all edit operations and clears the selection + */ + void cancel () + { + LayoutViewBase::cancel (); + } + + /** + * @brief Cancels all edit operations but maintains selection + */ + void cancel_edits () + { + LayoutViewBase::cancel_edits (); + } + + /** + * @brief Select all levels of hierarchy available + */ + void max_hier () + { + LayoutViewBase::max_hier (); + } + + /** + * @brief Stop activities like shape browser and redrawing thread + */ + void stop () + { + LayoutViewBase::stop (); + } + + /** + * @brief Stop redrawing thread + */ + void stop_redraw () + { + LayoutViewBase::stop_redraw (); + } + + /** + * @brief Select last display state + */ + void prev_display_state () + { + LayoutViewBase::prev_display_state (); + } + + /** + * @brief Select next display state + */ + void next_display_state () + { + LayoutViewBase::next_display_state (); + } + + /** + * @brief Ensure the selection is visible + */ + void ensure_selection_visible () + { + LayoutViewBase::ensure_selection_visible (); + } + + /** + * @brief Select a cell by index for a certain cell view + * + * This will be forwarded to select_cell or select_cell_fit depending + * on the m_fit_new_cell flag. + */ + void select_cell_dispatch (const cell_path_type &path, int cellview_index) + { + LayoutViewBase::select_cell_dispatch (path, cellview_index); + } + + /** + * @brief Called when the current layer changed + */ + void current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) + { + LayoutViewBase::current_layer_changed_slot (iter); + } + + // zoom slots + void zoom_fit () + { + LayoutViewBase::zoom_fit (); + } + + void zoom_fit_sel () + { + LayoutViewBase::zoom_fit_sel (); + } + + void zoom_in () + { + LayoutViewBase::zoom_in (); + } + + void zoom_out () + { + LayoutViewBase::zoom_out (); + } + + void pan_left () + { + LayoutViewBase::pan_left (); + } + + void pan_up () + { + LayoutViewBase::pan_up (); + } + + void pan_right () + { + LayoutViewBase::pan_right (); + } + + void pan_down () + { + LayoutViewBase::pan_down (); + } + + void pan_left_fast () + { + LayoutViewBase::pan_left_fast (); + } + + void pan_up_fast () + { + LayoutViewBase::pan_up_fast (); + } + + void pan_right_fast () + { + LayoutViewBase::pan_right_fast (); + } + + void pan_down_fast () + { + LayoutViewBase::pan_down_fast (); + } + + // called by children and owner + void redraw () + { + LayoutViewBase::redraw (); + } + + void redraw_layer (unsigned int index) + { + LayoutViewBase::redraw_layer (index); + } + + void redraw_deco_layer () + { + LayoutViewBase::redraw_deco_layer (); + } + + void redraw_cell_boxes () + { + LayoutViewBase::redraw_cell_boxes (); + } + + void layer_tab_changed (); + void layer_order_changed (); + + void timer () + { + LayoutViewBase::timer (); + } + + void min_hier_changed (int i); + void max_hier_changed (int i); + + void deactivate_all_browsers (); + +private slots: + void active_cellview_changed (int index) + { + LayoutViewBase::active_cellview_changed (index); + } + + void active_library_changed (int index); + void side_panel_destroyed (); + +signals: + /** + * @brief This signal is emitted when the title changes + */ + void title_changed (); + + /** + * @brief This signal is emitted when the "dirty" flag changes + */ + void dirty_changed (); + + /** + * @brief This signal is emitted when the view wants to show a message for the given time (of infinitely for ms == 0) + */ + void show_message (const std::string &s, int ms); + + /** + * @brief This signal is emitted when the view wants to indicate a mouse position change + */ + void current_pos_changed (double x, double y, bool dbu_units); + + /** + * @brief This signal is emitted when the view wants to clear the mouse position + */ + void clear_current_pos (); + + /** + * @brief This signal is sent when the "edits_enabled" state has changed + */ + void edits_enabled_changed (); + + /** + * @brief This signal is sent when the view wants to update the menu + */ + void menu_needs_update (); + + /** + * @brief The view initiated a mode change + */ + void mode_change (int m); + + /** + * @brief The current layer changed + */ + void current_layer_changed (const lay::LayerPropertiesConstIterator &l); + +private: + QTimer *mp_timer; + bool m_activated; + QFrame *mp_left_frame; + lay::LayerControlPanel *mp_control_panel; + lay::HierarchyControlPanel *mp_hierarchy_panel; + lay::LibrariesView *mp_libraries_view; + lay::BookmarksView *mp_bookmarks_view; + QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_bookmarks_frame; + lay::EditorOptionsFrame *mp_editor_options_frame; + QSpinBox *mp_min_hier_spbx; + QSpinBox *mp_max_hier_spbx; + bool m_always_show_source; + bool m_always_show_ld; + bool m_always_show_layout_index; + + tl::DeferredMethod dm_setup_editor_option_pages; + + void init_ui (); + void init_menu (); + void do_setup_editor_options_pages (); + +protected: + void activate (); + void deactivate (); + + virtual bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent (QShowEvent *); + virtual void hideEvent (QHideEvent *); + + virtual bool configure (const std::string &name, const std::string &value); + virtual void config_finalize (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); + virtual void begin_layer_updates (); + virtual void end_layer_updates (); + virtual void update_content_for_cv (int cv_index); + virtual void do_set_no_stipples (bool no_stipples); + virtual void do_set_phase (int phase); + virtual bool set_hier_levels_basic (std::pair l); + virtual void do_change_active_cellview (); + virtual bool is_activated () const; + virtual void bookmarks_changed (); + + // overrides Editables method to display a message + void signal_selection_changed (); + + virtual void emit_edits_enabled_changed (); + virtual void emit_title_changed (); + virtual void emit_dirty_changed (); + virtual void emit_layer_order_changed (); + +private: + using LayoutViewBase::ui; +}; + +} + +#endif + +#endif diff --git a/src/layview/layview/layview.pro b/src/layview/layview/layview.pro new file mode 100644 index 000000000..30d92982f --- /dev/null +++ b/src/layview/layview/layview.pro @@ -0,0 +1,62 @@ + +DESTDIR = $$OUT_PWD/../.. +TARGET = klayout_layview + +include($$PWD/../../lib.pri) + +DEFINES += MAKE_LAYVIEW_LIBRARY + +RESOURCES = \ + +SOURCES = \ + layGridNet.cc \ + layviewForceLink.cc \ + +HEADERS = \ + layGridNet.h \ + layLayoutView.h \ + layviewForceLink.h \ + +!equals(HAVE_QT, "0") { + + FORMS = \ + GridNetConfigPage.ui \ + + SOURCES += \ + layGridNetConfigPage.cc \ + layLayoutView_qt.cc \ + gsiDeclLayLayoutView_qt.cc \ + + HEADERS += \ + layGridNetConfigPage.h \ + layLayoutView_qt.h \ + +} else { + + SOURCES += \ + layLayoutView_noqt.cc \ + gsiDeclLayLayoutView_noqt.cc \ + + HEADERS += \ + layLayoutView_noqt.h \ + +} + +INCLUDEPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_laybasic -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb + +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$QTBASIC_INC $$LAYUI_INC + DEPENDPATH += $$QTBASIC_INC $$LAYUI_INC + LIBS += -lklayout_layui + + equals(HAVE_QTBINDINGS, "1") { + LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore + greaterThan(QT_MAJOR_VERSION, 4) { + LIBS += -lklayout_QtWidgets + } + } + +} diff --git a/src/layview/layview/layviewCommon.h b/src/layview/layview/layviewCommon.h new file mode 100644 index 000000000..dced42bd8 --- /dev/null +++ b/src/layview/layview/layviewCommon.h @@ -0,0 +1,51 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#if !defined(HDR_layviewCommon_h) +# define HDR_layviewCommon_h + +# if defined _WIN32 || defined __CYGWIN__ + +# ifdef MAKE_LAYVIEW_LIBRARY +# define LAYVIEW_PUBLIC __declspec(dllexport) +# else +# define LAYVIEW_PUBLIC __declspec(dllimport) +# endif +# define LAYVIEW_LOCAL +# define LAYVIEW_PUBLIC_TEMPLATE + +# else + +# if __GNUC__ >= 4 || defined(__clang__) +# define LAYVIEW_PUBLIC __attribute__ ((visibility ("default"))) +# define LAYVIEW_PUBLIC_TEMPLATE __attribute__ ((visibility ("default"))) +# define LAYVIEW_LOCAL __attribute__ ((visibility ("hidden"))) +# else +# define LAYVIEW_PUBLIC +# define LAYVIEW_PUBLIC_TEMPLATE +# define LAYVIEW_LOCAL +# endif + +# endif + +#endif diff --git a/src/layview/layview/layviewForceLink.cc b/src/layview/layview/layviewForceLink.cc new file mode 100644 index 000000000..400307cba --- /dev/null +++ b/src/layview/layview/layviewForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layviewForceLink.h" + +namespace layview +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/layview/layview/layviewForceLink.h b/src/layview/layview/layviewForceLink.h new file mode 100644 index 000000000..f7cdf749d --- /dev/null +++ b/src/layview/layview/layviewForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_layviewForceLink +#define HDR_layviewForceLink + +#include "layviewCommon.h" + +/** + * @file Include this function to force linking of the layview module + */ + +namespace layview +{ + LAYVIEW_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/layview/unit_tests/layLayoutViewTests.cc b/src/layview/unit_tests/layLayoutViewTests.cc new file mode 100644 index 000000000..1507d8cfd --- /dev/null +++ b/src/layview/unit_tests/layLayoutViewTests.cc @@ -0,0 +1,348 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layLayoutView.h" + +#include "tlUnitTest.h" +#include "tlTimer.h" +#include "tlSleep.h" + +#if defined(HAVE_QT) + +# include +# include + +static bool compare_images (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images_mono (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + // NOTE: slooooow ... + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if ((qimg.scanLine (j)[i / 8] & (0x80 >> (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x80 >> (i % 8)))) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +#endif + +static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) +{ + return img == img2; +} + +static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) +{ + return img == img2; +} + +#if defined(HAVE_QT) +TEST(1) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +TEST(2) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +// monochrome +TEST(3) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), true); + + EXPECT_EQ (qimg.format () == QImage::Format_MonoLSB, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); +} +#endif + +TEST(4) +{ + lay::LayoutView lv (0, false, 0); + lv.set_drawing_workers (2); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lv.resize (42, 117); + tl::msleep (250); + + lay::PixelBuffer img = lv.get_screenshot_pb (); + EXPECT_EQ ((int) img.width (), 42); + EXPECT_EQ ((int) img.height (), 117); + + lv.resize (142, 217); + + img = lv.get_screenshot_pb (); + EXPECT_EQ ((int) img.width (), 142); + EXPECT_EQ ((int) img.height (), 217); +} + +#if defined(HAVE_PNG) +TEST(11) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::PixelBuffer img; + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +TEST(12) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::PixelBuffer img; + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +// monochrome +TEST(13) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::BitmapBuffer img; + img = lv.get_pixels_with_options_mono (500, 500, 1, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + lay::BitmapBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} +#endif + +#if defined(HAVE_PNG) && defined(HAVE_QT) +TEST(21) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + lay::PixelBuffer img; + { + tl::InputStream stream (tmp); + img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +TEST(22) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + lay::PixelBuffer img; + { + tl::InputStream stream (tmp); + img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +// monochrome +TEST(23) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), true); + + lay::BitmapBuffer img; + { + tl::InputStream stream (tmp); + img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + lay::BitmapBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} +#endif diff --git a/src/layview/unit_tests/unit_tests.pro b/src/layview/unit_tests/unit_tests.pro new file mode 100644 index 000000000..52017fc45 --- /dev/null +++ b/src/layview/unit_tests/unit_tests.pro @@ -0,0 +1,16 @@ + +DESTDIR_UT = $$OUT_PWD/../.. +DESTDIR = $$OUT_PWD/.. + +TARGET = layview_tests + +include($$PWD/../../lib_ut.pri) + +SOURCES = \ + layLayoutViewTests.cc \ + +INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$LAYVIEW_INC $$LAYUI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../layview +DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$LAYVIEW_INC $$LAYUI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../layview + +LIBS += -L$$DESTDIR_UT -lklayout_layview -lklayout_db -lklayout_tl -lklayout_gsi + diff --git a/src/lym/lym/gsiDeclLymMacro.cc b/src/lym/lym/gsiDeclLymMacro.cc index 7d22afa72..3bce22d44 100644 --- a/src/lym/lym/gsiDeclLymMacro.cc +++ b/src/lym/lym/gsiDeclLymMacro.cc @@ -27,6 +27,7 @@ #include "gsiEnums.h" #include "lymMacroInterpreter.h" #include "lymMacro.h" +#include "lymMacroCollection.h" #include "rba.h" #include "tlClassRegistry.h" @@ -204,7 +205,7 @@ public: lym::Macro *create_template (const std::string &url) { if (! mp_registration) { - throw std::runtime_error (tl::to_string (QObject::tr ("MacroInterpreter::create_template must be called after register"))); + throw std::runtime_error (tl::to_string (tr ("MacroInterpreter::create_template must be called after register"))); } lym::Macro *m = new lym::Macro (); @@ -472,7 +473,11 @@ gsi::ClassExt inject_Format_in_parent (decl_FormatEnum.def static lym::Macro *macro_by_path (const std::string &path) { +#if defined(HAVE_QT) return lym::MacroCollection::root ().find_macro (path); +#else + return 0; +#endif } static std::string real_path (const std::string &path, int line) diff --git a/src/lym/lym/lym.pro b/src/lym/lym/lym.pro index 18dff3666..c05c34e79 100644 --- a/src/lym/lym/lym.pro +++ b/src/lym/lym/lym.pro @@ -8,13 +8,16 @@ DEFINES += MAKE_LYM_LIBRARY SOURCES = \ gsiDeclLymMacro.cc \ + lymForceLink.cc \ lymMacroInterpreter.cc \ + lymMacroCollection.cc \ lymMacro.cc \ HEADERS = \ lymCommon.h \ - lymInclude.h \ + lymForceLink.h \ lymMacroInterpreter.h \ + lymMacroCollection.h \ lymMacro.h \ INCLUDEPATH += $$TL_INC $$GSI_INC diff --git a/src/lym/lym/lymForceLink.cc b/src/lym/lym/lymForceLink.cc new file mode 100644 index 000000000..2f1b61cf7 --- /dev/null +++ b/src/lym/lym/lymForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "lymForceLink.h" + +namespace lym +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/lym/lym/lymForceLink.h b/src/lym/lym/lymForceLink.h new file mode 100644 index 000000000..f47b70955 --- /dev/null +++ b/src/lym/lym/lymForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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_lymForceLink +#define HDR_lymForceLink + +#include "lymCommon.h" + +/** + * @file Include this function to force linking of the lym module + */ + +namespace lym +{ + LYM_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/lym/lym/lymMacro.cc b/src/lym/lym/lymMacro.cc index 429a4fbf2..26fbd4708 100644 --- a/src/lym/lym/lymMacro.cc +++ b/src/lym/lym/lymMacro.cc @@ -22,6 +22,7 @@ #include "lymMacro.h" +#include "lymMacroCollection.h" #include "lymMacroInterpreter.h" #include "tlExceptions.h" #include "gsiDecl.h" @@ -39,39 +40,42 @@ #include "rba.h" #include "pya.h" -#include -#include -#include -#include +#include "tlFileUtils.h" +#include "tlUri.h" #include #include #include #include + namespace lym { // ---------------------------------------------------------------------- Macro::Macro () - : m_modified (true), m_readonly (false), m_autorun (false), m_autorun_default (false), m_autorun_early (false), m_priority (0), m_show_in_menu (false), m_is_file (false), mp_parent (0), m_interpreter (None), m_format (Macro::NoFormat) + : m_modified (true), m_readonly (false), m_autorun (false), m_autorun_default (false), m_autorun_early (false), m_priority (0), m_show_in_menu (false), m_is_file (false), m_interpreter (None), m_format (Macro::NoFormat) { - // .. nothing yet .. + mp_parent = 0; } void Macro::on_menu_needs_update () { +#if defined(HAVE_QT) // forward the signal to the root collection - the main window will attach to this MacroCollection::root ().on_menu_needs_update (); +#endif } void Macro::on_changed () { +#if defined(HAVE_QT) emit changed (); if (mp_parent) { mp_parent->on_macro_changed (this); } +#endif } void Macro::assign (const lym::Macro &other) @@ -133,8 +137,7 @@ bool Macro::del () if (tl::verbosity () >= 20) { tl::log << "Deleting macro " << path (); } - QFile f (tl::to_qstring (path ())); - return f.remove (); + return tl::rm_file (path ()); } else { return true; } @@ -254,7 +257,7 @@ void Macro::load_from (const std::string &fn) } } else { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to determine format for file from suffix or format spec ")) + fn); + throw tl::Exception (tl::to_string (tr ("Unable to determine format for file from suffix or format spec ")) + fn); } m_modified = true; @@ -270,7 +273,7 @@ void Macro::load_from_string (const std::string &text, const std::string &url) tl::log << "Loading macro from " << url; } - if (format_from_suffix (tl::to_string (QUrl (tl::to_qstring (url)).path ()), m_interpreter, m_dsl_interpreter, m_autorun_default, m_format)) { + if (format_from_suffix (tl::URI (url).path (), m_interpreter, m_dsl_interpreter, m_autorun_default, m_format)) { m_autorun = m_autorun_default; @@ -291,7 +294,7 @@ void Macro::load_from_string (const std::string &text, const std::string &url) } } else { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to determine format for file from suffix ")) + url); + throw tl::Exception (tl::to_string (tr ("Unable to determine format for file from suffix ")) + url); } m_modified = true; @@ -306,8 +309,7 @@ void Macro::load () bool Macro::format_from_suffix (const std::string &fn, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format) { - std::string suffix = tl::to_string (QFileInfo (tl::to_qstring (fn)).suffix ()); - return format_from_suffix_string (suffix, interpreter, dsl_name, autorun_pref, format); + return format_from_suffix_string (tl::extension (fn), interpreter, dsl_name, autorun_pref, format); } std::pair @@ -425,10 +427,9 @@ std::string Macro::path () const std::string suffix = suffix_for_format (m_interpreter, m_dsl_interpreter, m_format); if (mp_parent) { - return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_name + suffix)).filePath ()); - } else { - return m_name + suffix; + return tl::combine_path (mp_parent->path (), m_name + suffix); } + return m_name + suffix; } void Macro::set_file_path (const std::string &fp) @@ -459,8 +460,7 @@ bool Macro::rename (const std::string &n) if (tl::verbosity () >= 20) { tl::log << "Renaming macro " << path () << " to " << n; } - QFile f (tl::to_qstring (path ())); - if (! f.rename (QFileInfo (QDir (tl::to_qstring (parent ()->path ())), tl::to_qstring (n + suffix)).filePath ())) { + if (! tl::rename_file (path (), tl::combine_path (parent ()->path (), n + suffix))) { return false; } } @@ -478,9 +478,8 @@ std::string Macro::dir () const { if (mp_parent) { return mp_parent->path (); - } else { - return std::string (); } + return tl::dirname (path ()); } std::string Macro::display_string () const @@ -948,7 +947,7 @@ void Macro::install_doc () const --i; if (cls) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("Duplicate @class")); + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("Duplicate @class")); return; } @@ -970,7 +969,7 @@ void Macro::install_doc () const } } if (! super_cls) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("Cannot find super class: ")) << super_cls_name; + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("Cannot find super class: ")) << super_cls_name; return; } } @@ -986,7 +985,7 @@ void Macro::install_doc () const } else if (ex.test ("@method") || (st = ex.test ("@static_method")) == true) { if (cls == 0) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("@method without preceding @class")); + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("@method without preceding @class")); } else { std::string n; @@ -1082,932 +1081,5 @@ int Macro::run () const return 0; } -// ---------------------------------------------------------------------- - -static MacroCollection ms_root; - -MacroCollection::MacroCollection () - : mp_parent (0), m_virtual_mode (ProjectFolder), m_readonly (false) -{ - // .. nothing yet .. -} - -MacroCollection::~MacroCollection () -{ - do_clear (); -} - -void MacroCollection::do_clear () -{ - for (iterator m = begin (); m != end (); ++m) { - delete m->second; - } - m_macros.clear (); - - for (child_iterator mm = begin_children (); mm != end_children (); ++mm) { - delete mm->second; - } - m_folders.clear (); -} - -void MacroCollection::begin_changes () -{ - // Note: it is very important that each on_changed occurs after exactly one begin_changes. - // (See #459 for example) - if (mp_parent) { - mp_parent->begin_changes (); - } else { - emit about_to_change (); - } -} - -void MacroCollection::on_menu_needs_update () -{ - emit menu_needs_update (); -} - -void MacroCollection::on_changed () -{ - // Note: it is very important that each on_changed occurs after exactly one begin_changes. - // (See #459 for example) - emit changed (); - on_macro_collection_changed (this); -} - -void MacroCollection::on_macro_collection_changed (MacroCollection *mc) -{ - if (mp_parent) { - mp_parent->on_macro_collection_changed (mc); - } else { - emit macro_collection_changed (mc); - } -} - -void MacroCollection::on_child_deleted (MacroCollection *mc) -{ - emit child_deleted (mc); - on_macro_collection_deleted (mc); -} - -void MacroCollection::on_macro_collection_deleted (MacroCollection *mc) -{ - if (mp_parent) { - mp_parent->on_macro_collection_deleted (mc); - } else { - emit macro_collection_deleted (mc); - } -} - -void MacroCollection::on_macro_deleted_here (Macro *macro) -{ - emit macro_deleted_here (macro); - on_macro_deleted (macro); -} - -void MacroCollection::on_macro_deleted (Macro *macro) -{ - if (mp_parent) { - mp_parent->on_macro_deleted (macro); - } else { - emit macro_deleted (macro); - } -} - -void MacroCollection::on_macro_changed (Macro *macro) -{ - if (mp_parent) { - mp_parent->on_macro_changed (macro); - } else { - emit macro_changed (macro); - } -} - -void MacroCollection::collect_used_nodes (std::set ¯os, std::set ¯o_collections) -{ - for (MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { - macro_collections.insert (c->second); - c->second->collect_used_nodes (macros, macro_collections); - } - for (MacroCollection::iterator c = begin (); c != end (); ++c) { - macros.insert (c->second); - } -} - -Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) -{ - std::multimap ::iterator i = m_macros.find (name); - while (i != m_macros.end () && i->first == name) { - if (format == Macro::NoFormat || i->second->format () == format) { - return i->second; - } - ++i; - } - return 0; -} - -const Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) const -{ - std::multimap ::const_iterator i = m_macros.find (name); - while (i != m_macros.end () && i->first == name) { - if (format == Macro::NoFormat || i->second->format () == format) { - return i->second; - } - ++i; - } - return 0; -} - -MacroCollection *MacroCollection::folder_by_name (const std::string &name) -{ - std::map ::iterator i = m_folders.find (name); - if (i != m_folders.end ()) { - return i->second; - } else { - return 0; - } -} - -const MacroCollection *MacroCollection::folder_by_name (const std::string &name) const -{ - std::map ::const_iterator i = m_folders.find (name); - if (i != m_folders.end ()) { - return i->second; - } else { - return 0; - } -} - -std::string MacroCollection::path () const -{ - if (m_virtual_mode) { - return m_path; - } else if (mp_parent) { - return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_path)).filePath ()); - } else { - return m_path; - } -} - -std::string MacroCollection::display_string () const -{ - if (m_virtual_mode) { - return "[" + m_description + "]"; - } else { - std::string r = name (); - if (! m_description.empty ()) { - r += " - " + m_description; - } - return r; - } -} - -void -MacroCollection::make_readonly (bool f) -{ - if (m_readonly != f) { - begin_changes (); - m_readonly = f; - on_changed (); - } -} - -MacroCollection * -MacroCollection::add_folder (const std::string &description, const std::string &path, const std::string &cat, bool readonly, bool force_create) -{ - if (! path.empty () && path[0] == ':') { - readonly = true; - } else { - - QFileInfo file_info (tl::to_qstring (path)); - - if (! file_info.exists ()) { - - // Try to create the folder since it does not exist yet or skip that one - if (! force_create) { - - if (tl::verbosity () >= 20) { - tl::log << "Folder does not exist - skipping: " << path; - } - return 0; - - } else { - - if (tl::verbosity () >= 20) { - tl::log << "Folder does not exist yet - trying to create it: " << path; - } - if (! QDir::root ().mkpath (file_info.absoluteFilePath ())) { - if (tl::verbosity () >= 10) { - tl::error << "Unable to create folder path: " << path; - } - return 0; - } - } - - file_info.refresh (); - - } - - if (! file_info.isDir ()) { - if (tl::verbosity () >= 10) { - tl::error << "Folder is not a directory: " << path; - } - return 0; - } - - QString cp = file_info.canonicalFilePath (); - if (cp.isEmpty ()) { - return 0; - } - - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - // skip, if that folder is in the collection already - if (QFileInfo (tl::to_qstring (f->first)).canonicalFilePath () == cp) { - return 0; - } - } - - if (! readonly && ! file_info.isWritable ()) { - readonly = true; - if (tl::verbosity () >= 20) { - tl::log << "Folder is read-only: " << path; - } - } - - } - - begin_changes (); - - MacroCollection *mc = m_folders.insert (std::make_pair (path, new MacroCollection ())).first->second; - mc->set_name (path); - mc->set_description (description); - mc->set_category (cat); - mc->set_readonly (readonly); - mc->scan (path); - mc->set_parent (this); - - on_changed (); - on_macro_changed (0); - - return mc; -} - -void MacroCollection::rescan () -{ - for (std::map ::const_iterator m = m_folders.begin (); m != m_folders.end (); ++m) { - m->second->scan (m->first); - } -} - -namespace { - - /** - * @brief A QResource variant that allows access to the children - */ - class ResourceWithChildren - : public QResource - { - public: - ResourceWithChildren (const QString &path) : QResource (path) { } - using QResource::children; - }; - -} - -void MacroCollection::scan (const std::string &path) -{ - if (tl::verbosity () >= 20) { - tl::info << "Scanning macro path " << path << " (readonly=" << m_readonly << ")"; - } - - if (! path.empty () && path[0] == ':') { - - ResourceWithChildren res (tl::to_qstring (path)); - QStringList children = res.children (); - children.sort (); - - for (QStringList::const_iterator c = children.begin (); c != children.end (); ++c) { - - std::string url = path + "/" + tl::to_string (*c); - QResource res (tl::to_qstring (url)); - if (res.size () > 0) { - - QByteArray data; -#if QT_VERSION >= 0x60000 - if (res.compressionAlgorithm () == QResource::ZlibCompression) { -#else - if (res.isCompressed ()) { -#endif - data = qUncompress ((const unsigned char *)res.data (), (int)res.size ()); - } else { - data = QByteArray ((const char *)res.data (), (int)res.size ()); - } - - try { - - Macro::Format format = Macro::NoFormat; - Macro::Interpreter interpreter = Macro::None; - std::string dsl_name; - bool autorun = false; - - if (Macro::format_from_suffix (tl::to_string (*c), interpreter, dsl_name, autorun, format)) { - - std::string n = tl::to_string (QFileInfo (*c).baseName ()); - - iterator mm = m_macros.find (n); - bool found = false; - while (mm != m_macros.end () && mm->first == n && ! found) { - if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && - (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && - mm->second->format () == format) { - found = true; - } - ++mm; - } - if (! found) { - Macro *m = m_macros.insert (std::make_pair (n, new Macro ()))->second; - m->set_interpreter (interpreter); - m->set_autorun_default (autorun); - m->set_autorun (autorun); - m->set_dsl_interpreter (dsl_name); - m->set_format (format); - m->set_name (n); - m->load_from_string (std::string (data.constData (), data.size ()), url); - m->set_readonly (m_readonly); - m->reset_modified (); - m->set_is_file (); - m->set_parent (this); - } - - } - - } catch (tl::Exception &ex) { - tl::error << "Reading " << url << ": " << ex.msg (); - } - - } - - } - - } else { - - QDir dir (tl::to_qstring (path)); - QStringList filters; - filters << QString::fromUtf8 ("*.lym"); - filters << QString::fromUtf8 ("*.txt"); - // TODO: should be either *.rb or *.python, depending on the category. - // Right now we rely on the folders not containing foreign files. - filters << QString::fromUtf8 ("*.rb"); - filters << QString::fromUtf8 ("*.py"); - - // add the suffixes in the DSL interpreter declarations - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if (! cls->suffix ().empty ()) { - filters << tl::to_qstring ("*." + cls->suffix ()); - } - } - - QStringList files = dir.entryList (filters, QDir::Files); - for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { - - std::unique_ptr new_macro; - - try { - - std::string n = tl::to_string (QFileInfo (*f).completeBaseName ()); - std::string mp = tl::to_string (dir.absoluteFilePath (*f)); - - Macro::Format format = Macro::NoFormat; - Macro::Interpreter interpreter = Macro::None; - std::string dsl_name; - bool autorun = false; - - if (Macro::format_from_suffix (tl::to_string (*f), interpreter, dsl_name, autorun, format)) { - - iterator mm = m_macros.find (n); - bool found = false; - while (mm != m_macros.end () && mm->first == n && ! found) { - if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && - (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && - mm->second->format () == format) { - found = true; - } - ++mm; - } - if (! found) { - Macro *m = new Macro (); - new_macro.reset (m); - m->set_format (format); - m->set_autorun_default (autorun); - m->set_autorun (autorun); - m->set_interpreter (interpreter); - m->set_dsl_interpreter (dsl_name); - m->set_name (n); - m->load_from (mp); - m->reset_modified (); - m->set_readonly (m_readonly); - m->set_parent (this); - } - - } - - if (new_macro.get ()) { - m_macros.insert (std::make_pair (n, new_macro.release ())); - } - - } catch (tl::Exception &ex) { - tl::error << "Reading " << tl::to_string (*f) << " in " << path << ": " << ex.msg (); - } - - } - - QStringList folders = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot); - for (QStringList::ConstIterator f = folders.begin (); f != folders.end (); ++f) { - - try { - - std::string n = tl::to_string (*f); - MacroCollection *&mc = m_folders.insert (std::make_pair (n, (MacroCollection *) 0)).first->second; - if (! mc) { - mc = new MacroCollection (); - mc->set_name (n); - mc->set_virtual_mode (NotVirtual); - bool ro = (m_readonly || ! QFileInfo (dir.filePath (*f)).isWritable ()); - mc->set_readonly (ro); - mc->scan (tl::to_string (dir.filePath (*f))); - mc->set_parent (this); - } - - } catch (tl::Exception &ex) { - tl::error << ex.msg (); - } - - } - - } -} - -void MacroCollection::clear () -{ - begin_changes (); - do_clear (); - on_changed (); -} - -void MacroCollection::erase (lym::Macro *mp) -{ - for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { - if (m->second == mp) { - begin_changes (); - on_macro_deleted_here (mp); - m_macros.erase (m); - delete mp; - on_changed (); - return; - } - } -} - -void MacroCollection::erase (lym::MacroCollection *mp) -{ - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - if (f->second == mp) { - begin_changes (); - on_child_deleted (mp); - m_folders.erase (f); - delete mp; - on_changed (); - return; - } - } -} - -void MacroCollection::erase (iterator i) -{ - begin_changes (); - on_macro_deleted_here (i->second); - delete i->second; - m_macros.erase (i); - on_changed (); -} - -void MacroCollection::erase (child_iterator i) -{ - begin_changes (); - on_child_deleted (i->second); - delete i->second; - m_folders.erase (i); - on_changed (); -} - -void MacroCollection::save () -{ - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - f->second->save (); - } - - for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { - if (m->second->is_modified () && ! m->second->is_readonly () && ! m->second->path ().empty ()) { - try { - m->second->save (); - } catch (tl::Exception &ex) { - tl::error << ex.msg (); - } - } - } -} - -bool MacroCollection::rename (const std::string &n) -{ - if (tl::verbosity () >= 20) { - tl::info << "Renaming macro folder " << path () << " to " << n; - } - QFile f (tl::to_qstring (path ())); - begin_changes (); - if (! f.rename (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (n)).filePath ())) { - on_changed (); - return false; - } else { - m_path = n; - on_changed (); - return true; - } -} - -lym::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir) -{ - std::string name; - int n = 0; - do { - name = (prefix ? prefix : "new_folder"); - if (n > 0) { - name += "_" + tl::to_string (n); - } - if (m_folders.find (name) == m_folders.end ()) { - break; - } - ++n; - } while (true); - - if (mkdir && ! QDir (tl::to_qstring (path ())).mkdir (tl::to_qstring (name))) { - return 0; - } - - begin_changes (); - - lym::MacroCollection *m = m_folders.insert (std::make_pair (name, new lym::MacroCollection ())).first->second; - m->set_virtual_mode (NotVirtual); - m->set_name (name); - m->set_parent (this); - - on_changed (); - - return m; -} - -lym::Macro *MacroCollection::create (const char *prefix, Macro::Format format) -{ - std::string name; - int n = 0; - do { - name = (prefix ? prefix : "new_macro"); - if (n > 0) { - name += "_" + tl::to_string (n); - } - if (! macro_by_name (name, format)) { - break; - } - ++n; - } while (true); - - begin_changes (); - - lym::Macro *m = m_macros.insert (std::make_pair (name, new lym::Macro ()))->second; - m->set_name (name); - m->set_parent (this); - - on_changed (); - - return m; -} - -void MacroCollection::add_unspecific (lym::Macro *m) -{ - begin_changes (); - m_macros.insert (std::make_pair (m->name (), m)); - m->set_parent (this); - on_changed (); -} - -bool MacroCollection::add (lym::Macro *m) -{ - QDir d (tl::to_qstring (path ())); - QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir (); - - if (d == dd) { - - begin_changes (); - m_macros.insert (std::make_pair (m->name (), m)); - m->set_parent (this); - on_changed (); - return true; - - } else { - - for (child_iterator c = begin_children (); c != end_children (); ++c) { - if (c->second->add (m)) { - return true; - } - } - - // try to detect new child folders. If that is the case, create that folder and add - // the macro there. - QDir dm (tl::to_qstring (m->dir ())); - while (true) { - - std::string folder_name = tl::to_string (dm.dirName ()); - if (! dm.cdUp ()) { - break; - } - - if (dm == d) { - begin_changes (); - lym::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second; - mc->set_virtual_mode (NotVirtual); - mc->set_parent (this); - on_changed (); - return mc->add (m); - } - - } - - } - - return false; -} - -bool MacroCollection::del () -{ - if (tl::verbosity () >= 20) { - tl::info << "Deleting macro folder " << path (); - } - return QDir ().rmdir (tl::to_qstring (path ())); -} - -void MacroCollection::rename_macro (Macro *macro, const std::string &new_name) -{ - iterator m = m_macros.find (macro->name ()); - while (m != m_macros.end () && m->first == macro->name ()) { - if (m->second == macro) { - m_macros.erase (m); - m_macros.insert (std::make_pair (new_name, macro)); - return; - } - ++m; - } -} - -lym::Macro *MacroCollection::find_macro (const std::string &path) -{ - for (iterator m = begin (); m != end (); ++m) { - if (m->second->path () == path) { - return m->second; - } - } - - for (child_iterator mc = begin_children (); mc != end_children (); ++mc) { - lym::Macro *macro = mc->second->find_macro (path); - if (macro) { - return macro; - } - } - - return 0; -} - -MacroCollection &MacroCollection::root () -{ - return ms_root; -} - -static bool sync_macros (lym::MacroCollection *current, lym::MacroCollection *actual, bool safe) -{ - bool ret = false; - - if (actual) { - current->make_readonly (actual->is_readonly ()); - } - - std::vector folders_to_delete; - - for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) { - lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0; - if (! cm) { - folders_to_delete.push_back (m->second); - } - } - - if (actual) { - for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) { - lym::MacroCollection *cm = current->folder_by_name (m->first); - if (! cm) { - cm = current->create_folder (m->first.c_str (), false); - ret = true; - } - if (sync_macros(cm, m->second, safe)) { - ret = true; - } - } - } - - // delete folders which do no longer exist - for (std::vector::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { - ret = true; - sync_macros (*m, 0, safe); - current->erase (*m); - } - - std::vector macros_to_delete; - - for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) { - lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0; - if (! cm) { - macros_to_delete.push_back (m->second); - } - } - - if (actual) { - for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) { - lym::Macro *cm = current->macro_by_name (m->first, m->second->format ()); - if (cm) { - if (*cm != *m->second && (! safe || ! cm->is_modified ())) { - cm->assign (*m->second); - } - cm->set_readonly (m->second->is_readonly ()); - } else { - cm = current->create (m->first.c_str (), m->second->format ()); - cm->assign (*m->second); - cm->set_readonly (m->second->is_readonly ()); - ret = true; - } - } - } - - // erase macros from collection which are no longer used - for (std::vector::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) { - current->erase (*m); - ret = true; - } - - return ret; -} - -void MacroCollection::reload (bool safe) -{ - // create a new collection and synchronize - - lym::MacroCollection new_collection; - for (lym::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { - new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */); - } - - // and synchronize current with the actual one - sync_macros (this, &new_collection, safe); -} - -static bool has_autorun_for (const lym::MacroCollection &collection, bool early) -{ - for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - if (has_autorun_for (*c->second, early)) { - return true; - } - } - - for (lym::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) { - if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) { - return true; - } - } - - return false; -} - -bool MacroCollection::has_autorun () const -{ - return has_autorun_for (*this, false); -} - -bool MacroCollection::has_autorun_early () const -{ - return has_autorun_for (*this, true); -} - -static int collect_priority (lym::MacroCollection &collection, bool early, int from_prio) -{ - int p = -1; - - for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - int pp = collect_priority (*c->second, early, from_prio); - if (pp >= from_prio && (p < 0 || pp < p)) { - p = pp; - } - } - - for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { - if (c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { - int pp = c->second->priority (); - if (pp >= from_prio && (p < 0 || pp < p)) { - p = pp; - } - } - } - - return p; -} - -static void autorun_for_prio (lym::MacroCollection &collection, bool early, std::set *executed_already, int prio) -{ - for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - autorun_for_prio (*c->second, early, executed_already, prio); - } - - for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { - - if (c->second->priority () == prio && c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { - - if (!executed_already || executed_already->find (c->second->path ()) == executed_already->end ()) { - - BEGIN_PROTECTED_SILENT - c->second->run (); - c->second->install_doc (); - END_PROTECTED_SILENT - - if (executed_already) { - executed_already->insert (c->second->path ()); - } - - } - - } - - } -} - -static void autorun_for (lym::MacroCollection &collection, bool early, std::set *executed_already) -{ - int prio = 0; - while (true) { - int p = collect_priority (collection, early, prio); - if (p < prio) { - break; - } - autorun_for_prio (collection, early, executed_already, p); - prio = p + 1; - } -} - -void MacroCollection::autorun (std::set *already_executed) -{ - autorun_for (*this, false, already_executed); -} - -void MacroCollection::autorun_early (std::set *already_executed) -{ - autorun_for (*this, true, already_executed); -} - -void MacroCollection::dump (int l) -{ - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("----\n"); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection: %s\n", name ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection-path: %s\n", path ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection-description: %s\n", description ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf("Collection-readonly: %d\n", is_readonly ()); - printf ("\n"); - - for (iterator m = begin (); m != end (); ++m) { - for (int i = 0; i < l; ++i) { printf (" "); } - printf("Name: %s%s\n", m->second->name ().c_str (), m->second->is_modified() ? "*" : ""); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Path: %s\n", m->second->path ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Readonly: %d\n", m->second->is_readonly ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Autorun: %d\n", m->second->is_autorun ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Autorun-early: %d\n", m->second->is_autorun_early ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Description: %s\n", m->second->description ().c_str ()); - } - - for (child_iterator m = begin_children (); m != end_children (); ++m) { - m->second->dump (l + 1); - } -} - } diff --git a/src/lym/lym/lymMacro.h b/src/lym/lym/lymMacro.h index 619be68a6..29ce328ea 100644 --- a/src/lym/lym/lymMacro.h +++ b/src/lym/lym/lymMacro.h @@ -31,7 +31,9 @@ #include #include -#include +#if defined(HAVE_QT) +# include +#endif namespace lym { @@ -55,11 +57,15 @@ class MacroCollection; * a macro can be bound to an arbitrary interpreter and decides * by itself which interpreter to use. */ -class LYM_PUBLIC Macro - : public QObject, +class LYM_PUBLIC Macro : +#if defined(HAVE_QT) + public QObject, +#endif public tl::Object { -Q_OBJECT +#if defined(HAVE_QT) +Q_OBJECT +#endif public: /** @@ -587,12 +593,14 @@ public: return !(*this == other); } +#if defined(HAVE_QT) signals: /** * @brief This signal is sent when the macro changes */ void changed (); - +#endif + private: friend class MacroCollection; @@ -646,517 +654,6 @@ private: Macro &operator= (const Macro &d); }; -/** - * @brief Represents a collection of macros - * - * A collection is representing a set of macros, usually associated with - * a folder containing *.lym, *.rb or other script files. - */ -class LYM_PUBLIC MacroCollection - : public QObject -{ -Q_OBJECT - -public: - typedef std::multimap ::iterator iterator; - typedef std::multimap ::const_iterator const_iterator; - typedef std::map ::iterator child_iterator; - typedef std::map ::const_iterator const_child_iterator; - - /** - * @brief Some constants for virtual_mode - */ - enum FolderType { - NotVirtual = 0, - ProjectFolder = 1, - TechFolder = 2, - SaltFolder = 3 - }; - - /** - * @brief Constructor - * - * The default constructor create - */ - MacroCollection (); - - /** - * @brief Destructor - */ - ~MacroCollection (); - - /** - * @brief Add a folder (will also scan the folder) - * - * @return A pointer to the new collection if successful - * - * If force_create is true (the default), the folder will be created if it does not - * exist yet. On error, 0 is returned. - */ - MacroCollection *add_folder (const std::string &description, const std::string &path, const std::string &category, bool readonly, bool force_create = true); - - /** - * @brief Gets the category tag of the collection - * - * A category tag can be used to categorize the collections. For example, DRC categories are handled differently - * from the other categories. - */ - const std::string &category () const - { - return m_category; - } - - /** - * @brief Sets the category tags - */ - void set_category (const std::string &d) - { - m_category = d; - } - - /** - * @brief Collect all Macro and MacroCollection objects inside a tree starting from this collection - */ - void collect_used_nodes(std::set ¯os, std::set ¯o_collections); - - /** - * @brief Saves all macros in the collection - * - * Saves only those macros that have is_modified and whose path is set. - */ - void save (); - - /** - * @brief Delete the original folder (the directory behind the macro) - * - * Returns true if the folder was deleted successfully. - * The folder cannot be deleted if it contains any files, also some that are not listed because - * they don't end with .lym, .rb or similar. - */ - bool del (); - - /** - * @brief Gets the name of the collection - * - * For virtual collections this is the path. - */ - std::string name () const - { - return m_path; - } - - /** - * @brief Gets the path of the folder representing that collection - */ - std::string path () const; - - /** - * @brief Returns the parent of the macro collection - * - * Returns 0, if there is no parent of this collection (this is the root) - */ - lym::MacroCollection *parent () - { - return mp_parent; - } - - /** - * @brief Returns the parent of the macro collection (const version) - * - * Returns 0, if there is no parent of this collection (this is the root) - */ - const lym::MacroCollection *parent () const - { - return mp_parent; - } - - /** - * @brief Returns != 0, if the macro collection is a virtual node - * - * A virtual node does not correspond to a location in the file system. - * A virtual node cannot have macros but only children. - * The return value indicates the kind of virtual use. - */ - int virtual_mode () const - { - return m_virtual_mode; - } - - /** - * @brief Sets the virtual mode - * - * See virtual_mode for details about the virtual mode. - */ - void set_virtual_mode (int m) - { - m_virtual_mode = m; - } - - /** - * @brief Gets a value indicating whether the macro collection is readonly - */ - bool is_readonly () const - { - return m_readonly; - } - - /** - * @brief Sets a value indicating whether the macro is readonly - * In contrast to the private \set_readonly method, this version delivers a "changed" signal when - * the flag changed. - */ - void make_readonly (bool f); - - /** - * @brief Gets the macro collection's description text - */ - const std::string &description () const - { - return m_description; - } - - /** - * @brief Sets the description - */ - void set_description (const std::string &d) - { - m_description = d; - } - - /** - * @brief Gets the display string - */ - std::string display_string () const; - - /** - * @brief Rename a Macro - * - * Renames the macro. If the macro is a file, the file will be renamed as well. - * This method will return true, if the rename was successful. - */ - bool rename (const std::string &n); - - /** - * @brief Adds a macro to the collection - * - * If a macro with the name of the new macro already exists, it is replaced - * (like in the file system). This method will traverse the tree to find - * the location of the macro using the path information of the macro and insert - * the macro there. - * - * The collection becomes the owner of the object passed to this method - * - * @return true, if the macro could be added successfully. - */ - bool add (lym::Macro *m); - - /** - * @brief Adds a macro in an unspecific way - * - * "unspecific" means that the path is not looked up - the macro is - * added irregardless whether the path matches or not. - * This is a way to build macro collections without connection - * to some file system point. - */ - void add_unspecific (lym::Macro *m); - - /** - * @brief Empties the collection - * Note: only the unspecific on_changed event is generated. - */ - void clear (); - - /** - * @brief Erases the given macro from the list - * - * This does not remove the file but just remove the macro object. - * This will also delete the macro object. - */ - void erase (lym::Macro *m); - - /** - * @brief Erases the entry with the given iterator - */ - void erase (iterator i); - - /** - * @brief Erases the given macro collection from the list of child collections - * - * This does not remove the directory but just removes the macro collection object. - * This will also delete the macro collection object. - */ - void erase (lym::MacroCollection *m); - - /** - * @brief Erases the folder with the given iterator - */ - void erase (child_iterator i); - - /** - * @brief Creates a new macro in that collection (with a new name) - * - * If a name is given, it is used as a prefix to create a unique name for a macro with that format. - */ - lym::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat); - - /** - * @brief Creates a new macro collection in that collection (with a new name) - * - * If a name is given, it is used as a prefix to create a unique name. - * This method will also create the directory for this folder. - * If not successful, it will return 0. - */ - lym::MacroCollection *create_folder (const char *name = 0, bool mkdir = true); - - /** - * @brief Gets the begin iterator of the macros - */ - iterator begin () - { - return m_macros.begin (); - } - - /** - * @brief Gets the end iterator of the macros - */ - iterator end () - { - return m_macros.end (); - } - - /** - * @brief Gets the begin iterator of the macros (const version) - */ - const_iterator begin () const - { - return m_macros.begin (); - } - - /** - * @brief Gets the end iterator of the macros (const version) - */ - const_iterator end () const - { - return m_macros.end (); - } - - /** - * @brief Gets the begin iterator of the folders - */ - child_iterator begin_children () - { - return m_folders.begin (); - } - - /** - * @brief Gets the end iterator of the folders - */ - child_iterator end_children () - { - return m_folders.end (); - } - - /** - * @brief Gets the begin iterator of the folders (const version) - */ - const_child_iterator begin_children () const - { - return m_folders.begin (); - } - - /** - * @brief Gets the end iterator of the folders (const version) - */ - const_child_iterator end_children () const - { - return m_folders.end (); - } - - /** - * @brief Gets a macro by name - * - * If no macro with that name exists, this method will return 0. - */ - Macro *macro_by_name (const std::string &name, Macro::Format format); - - /** - * @brief Gets a macro by name - * - * If no macro with that name exists, this method will return 0. - */ - const Macro *macro_by_name (const std::string &name, Macro::Format format) const; - - /** - * @brief Gets a folder by name - * - * If no folder with that name exists, this method will return 0. - */ - MacroCollection *folder_by_name (const std::string &name); - - /** - * @brief Gets a folder by name - * - * If no folder with that name exists, this method will return 0. - */ - const MacroCollection *folder_by_name (const std::string &name) const; - - /** - * @brief Finds a macro by path - * - * This method is called from the root collection and delivers the macro which - * matches the given path or 0. - */ - lym::Macro *find_macro (const std::string &path); - - /** - * @brief Returns true, if the collection has an autorun macro - */ - bool has_autorun () const; - - /** - * @brief Runs all macros marked with auto-run - */ - void autorun (std::set *already_executed = 0); - - /** - * @brief Returns true, if the collection has an early autorun macro - */ - bool has_autorun_early () const; - - /** - * @brief Runs all macros marked with early auto-run - */ - void autorun_early (std::set *already_executed = 0); - - /** - * @brief Redo the scan (will add new files or folders) - * - * This method must be called on root. - */ - void rescan (); - - /** - * @brief Reloads the macro collection - * - * This method is similar to rescan, but it will also remove folders and macros. - * In safe mode (safe = true), modified macros won't be overwritten. - */ - void reload (bool safe); - - /** - * @brief Gets the root of the macro hierarchy corresponding to the configuration space - */ - static MacroCollection &root (); - - /** - * @brief Dump the macro tree (for debugging) - */ - void dump (int l = 0); - -signals: - /** - * @brief This signal is sent when the collection changes - */ - void changed (); - - /** - * @brief This signal is sent by collection when a child collection is deleted in this collection - */ - void child_deleted (lym::MacroCollection *); - - /** - * @brief This signal is sent by the root object when a macro collection is deleted - */ - void macro_collection_deleted (lym::MacroCollection *); - - /** - * @brief This signal is sent by collection when a macro is deleted in this collection - */ - void macro_deleted_here (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro is deleted - */ - void macro_deleted (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro changes - * - * This signal is only emitted by the root, but it may originate from a - * macro inside the tree. - */ - void macro_changed (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro collection changes - * - * This signal is only emitted by the root, but it may originate from a - * macro collection inside the tree. - */ - void macro_collection_changed (lym::MacroCollection *); - - /** - * @brief This signal is sent by the root object befor the macro collection changes - */ - void about_to_change (); - - /** - * @brief This signal is emitted from the collection root if the menu needs to be updated - */ - void menu_needs_update (); - -private: - friend class Macro; - - std::string m_path; - std::string m_description; - std::string m_category; - std::multimap m_macros; - std::map m_folders; - lym::MacroCollection *mp_parent; - int m_virtual_mode; - bool m_readonly; - - void on_child_deleted (MacroCollection *mc); - void on_macro_collection_deleted (MacroCollection *mc); - void on_macro_deleted_here (Macro *macro); - void on_macro_deleted (Macro *macro); - void on_macro_changed (Macro *macro); - void on_macro_collection_changed (MacroCollection *mc); - void on_changed (); - void on_menu_needs_update (); - - /** - * @brief Scans a folder creating the macro collection - */ - void scan (const std::string &path); - - void rename_macro (Macro *macro, const std::string &new_name); - - void begin_changes (); - - void set_name (const std::string &n) - { - m_path = n; - } - - void set_parent (lym::MacroCollection *parent) - { - mp_parent = parent; - } - - void set_readonly (bool f) - { - m_readonly = f; - } - - void do_clear (); - - // no copying - MacroCollection (const MacroCollection &d); - MacroCollection &operator= (const MacroCollection &d); -}; - } #endif diff --git a/src/lym/lym/lymMacroCollection.cc b/src/lym/lym/lymMacroCollection.cc new file mode 100644 index 000000000..5ea264937 --- /dev/null +++ b/src/lym/lym/lymMacroCollection.cc @@ -0,0 +1,987 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "lymMacroCollection.h" + +#if defined(HAVE_QT) + +#include "lymMacroInterpreter.h" +#include "tlExceptions.h" +#include "gsiDecl.h" +#include "gsiInterpreter.h" + +#include "tlString.h" +#include "tlStableVector.h" +#include "tlClassRegistry.h" +#include "tlLog.h" +#include "tlXMLParser.h" +#include "tlGlobPattern.h" +#include "tlInclude.h" +#include "tlProgress.h" + +#include "rba.h" +#include "pya.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace lym +{ + +// ---------------------------------------------------------------------- + +static MacroCollection ms_root; + +MacroCollection::MacroCollection () + : mp_parent (0), m_virtual_mode (ProjectFolder), m_readonly (false) +{ + // .. nothing yet .. +} + +MacroCollection::~MacroCollection () +{ + do_clear (); +} + +void MacroCollection::do_clear () +{ + for (iterator m = begin (); m != end (); ++m) { + delete m->second; + } + m_macros.clear (); + + for (child_iterator mm = begin_children (); mm != end_children (); ++mm) { + delete mm->second; + } + m_folders.clear (); +} + +void MacroCollection::begin_changes () +{ + // Note: it is very important that each on_changed occurs after exactly one begin_changes. + // (See #459 for example) + if (mp_parent) { + mp_parent->begin_changes (); + } else { + emit about_to_change (); + } +} + +void MacroCollection::on_menu_needs_update () +{ + emit menu_needs_update (); +} + +void MacroCollection::on_changed () +{ + // Note: it is very important that each on_changed occurs after exactly one begin_changes. + // (See #459 for example) + emit changed (); + on_macro_collection_changed (this); +} + +void MacroCollection::on_macro_collection_changed (MacroCollection *mc) +{ + if (mp_parent) { + mp_parent->on_macro_collection_changed (mc); + } else { + emit macro_collection_changed (mc); + } +} + +void MacroCollection::on_child_deleted (MacroCollection *mc) +{ + emit child_deleted (mc); + on_macro_collection_deleted (mc); +} + +void MacroCollection::on_macro_collection_deleted (MacroCollection *mc) +{ + if (mp_parent) { + mp_parent->on_macro_collection_deleted (mc); + } else { + emit macro_collection_deleted (mc); + } +} + +void MacroCollection::on_macro_deleted_here (Macro *macro) +{ + emit macro_deleted_here (macro); + on_macro_deleted (macro); +} + +void MacroCollection::on_macro_deleted (Macro *macro) +{ + if (mp_parent) { + mp_parent->on_macro_deleted (macro); + } else { + emit macro_deleted (macro); + } +} + +void MacroCollection::on_macro_changed (Macro *macro) +{ + if (mp_parent) { + mp_parent->on_macro_changed (macro); + } else { + emit macro_changed (macro); + } +} + +void MacroCollection::collect_used_nodes (std::set ¯os, std::set ¯o_collections) +{ + for (MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { + macro_collections.insert (c->second); + c->second->collect_used_nodes (macros, macro_collections); + } + for (MacroCollection::iterator c = begin (); c != end (); ++c) { + macros.insert (c->second); + } +} + +Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) +{ + std::multimap ::iterator i = m_macros.find (name); + while (i != m_macros.end () && i->first == name) { + if (format == Macro::NoFormat || i->second->format () == format) { + return i->second; + } + ++i; + } + return 0; +} + +const Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) const +{ + std::multimap ::const_iterator i = m_macros.find (name); + while (i != m_macros.end () && i->first == name) { + if (format == Macro::NoFormat || i->second->format () == format) { + return i->second; + } + ++i; + } + return 0; +} + +MacroCollection *MacroCollection::folder_by_name (const std::string &name) +{ + std::map ::iterator i = m_folders.find (name); + if (i != m_folders.end ()) { + return i->second; + } else { + return 0; + } +} + +const MacroCollection *MacroCollection::folder_by_name (const std::string &name) const +{ + std::map ::const_iterator i = m_folders.find (name); + if (i != m_folders.end ()) { + return i->second; + } else { + return 0; + } +} + +std::string MacroCollection::path () const +{ + if (m_virtual_mode) { + return m_path; + } else if (mp_parent) { + return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_path)).filePath ()); + } else { + return m_path; + } +} + +std::string MacroCollection::display_string () const +{ + if (m_virtual_mode) { + return "[" + m_description + "]"; + } else { + std::string r = name (); + if (! m_description.empty ()) { + r += " - " + m_description; + } + return r; + } +} + +void +MacroCollection::make_readonly (bool f) +{ + if (m_readonly != f) { + begin_changes (); + m_readonly = f; + on_changed (); + } +} + +MacroCollection * +MacroCollection::add_folder (const std::string &description, const std::string &path, const std::string &cat, bool readonly, bool force_create) +{ + if (! path.empty () && path[0] == ':') { + readonly = true; + } else { + + QFileInfo file_info (tl::to_qstring (path)); + + if (! file_info.exists ()) { + + // Try to create the folder since it does not exist yet or skip that one + if (! force_create) { + + if (tl::verbosity () >= 20) { + tl::log << "Folder does not exist - skipping: " << path; + } + return 0; + + } else { + + if (tl::verbosity () >= 20) { + tl::log << "Folder does not exist yet - trying to create it: " << path; + } + if (! QDir::root ().mkpath (file_info.absoluteFilePath ())) { + if (tl::verbosity () >= 10) { + tl::error << "Unable to create folder path: " << path; + } + return 0; + } + } + + file_info.refresh (); + + } + + if (! file_info.isDir ()) { + if (tl::verbosity () >= 10) { + tl::error << "Folder is not a directory: " << path; + } + return 0; + } + + QString cp = file_info.canonicalFilePath (); + if (cp.isEmpty ()) { + return 0; + } + + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + // skip, if that folder is in the collection already + if (QFileInfo (tl::to_qstring (f->first)).canonicalFilePath () == cp) { + return 0; + } + } + + if (! readonly && ! file_info.isWritable ()) { + readonly = true; + if (tl::verbosity () >= 20) { + tl::log << "Folder is read-only: " << path; + } + } + + } + + begin_changes (); + + MacroCollection *mc = m_folders.insert (std::make_pair (path, new MacroCollection ())).first->second; + mc->set_name (path); + mc->set_description (description); + mc->set_category (cat); + mc->set_readonly (readonly); + mc->scan (path); + mc->set_parent (this); + + on_changed (); + on_macro_changed (0); + + return mc; +} + +void MacroCollection::rescan () +{ + for (std::map ::const_iterator m = m_folders.begin (); m != m_folders.end (); ++m) { + m->second->scan (m->first); + } +} + +namespace { + + /** + * @brief A QResource variant that allows access to the children + */ + class ResourceWithChildren + : public QResource + { + public: + ResourceWithChildren (const QString &path) : QResource (path) { } + using QResource::children; + }; + +} + +void MacroCollection::scan (const std::string &path) +{ + if (tl::verbosity () >= 20) { + tl::info << "Scanning macro path " << path << " (readonly=" << m_readonly << ")"; + } + + if (! path.empty () && path[0] == ':') { + + ResourceWithChildren res (tl::to_qstring (path)); + QStringList children = res.children (); + children.sort (); + + for (QStringList::const_iterator c = children.begin (); c != children.end (); ++c) { + + std::string url = path + "/" + tl::to_string (*c); + QResource res (tl::to_qstring (url)); + if (res.size () > 0) { + + QByteArray data; +#if QT_VERSION >= 0x60000 + if (res.compressionAlgorithm () == QResource::ZlibCompression) { +#else + if (res.isCompressed ()) { +#endif + data = qUncompress ((const unsigned char *)res.data (), (int)res.size ()); + } else { + data = QByteArray ((const char *)res.data (), (int)res.size ()); + } + + try { + + Macro::Format format = Macro::NoFormat; + Macro::Interpreter interpreter = Macro::None; + std::string dsl_name; + bool autorun = false; + + if (Macro::format_from_suffix (tl::to_string (*c), interpreter, dsl_name, autorun, format)) { + + std::string n = tl::to_string (QFileInfo (*c).baseName ()); + + iterator mm = m_macros.find (n); + bool found = false; + while (mm != m_macros.end () && mm->first == n && ! found) { + if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && + (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && + mm->second->format () == format) { + found = true; + } + ++mm; + } + if (! found) { + Macro *m = m_macros.insert (std::make_pair (n, new Macro ()))->second; + m->set_interpreter (interpreter); + m->set_autorun_default (autorun); + m->set_autorun (autorun); + m->set_dsl_interpreter (dsl_name); + m->set_format (format); + m->set_name (n); + m->load_from_string (std::string (data.constData (), data.size ()), url); + m->set_readonly (m_readonly); + m->reset_modified (); + m->set_is_file (); + m->set_parent (this); + } + + } + + } catch (tl::Exception &ex) { + tl::error << "Reading " << url << ": " << ex.msg (); + } + + } + + } + + } else { + + QDir dir (tl::to_qstring (path)); + QStringList filters; + filters << QString::fromUtf8 ("*.lym"); + filters << QString::fromUtf8 ("*.txt"); + // TODO: should be either *.rb or *.python, depending on the category. + // Right now we rely on the folders not containing foreign files. + filters << QString::fromUtf8 ("*.rb"); + filters << QString::fromUtf8 ("*.py"); + + // add the suffixes in the DSL interpreter declarations + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + if (! cls->suffix ().empty ()) { + filters << tl::to_qstring ("*." + cls->suffix ()); + } + } + + QStringList files = dir.entryList (filters, QDir::Files); + for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { + + std::unique_ptr new_macro; + + try { + + std::string n = tl::to_string (QFileInfo (*f).completeBaseName ()); + std::string mp = tl::to_string (dir.absoluteFilePath (*f)); + + Macro::Format format = Macro::NoFormat; + Macro::Interpreter interpreter = Macro::None; + std::string dsl_name; + bool autorun = false; + + if (Macro::format_from_suffix (tl::to_string (*f), interpreter, dsl_name, autorun, format)) { + + iterator mm = m_macros.find (n); + bool found = false; + while (mm != m_macros.end () && mm->first == n && ! found) { + if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && + (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && + mm->second->format () == format) { + found = true; + } + ++mm; + } + if (! found) { + Macro *m = new Macro (); + new_macro.reset (m); + m->set_format (format); + m->set_autorun_default (autorun); + m->set_autorun (autorun); + m->set_interpreter (interpreter); + m->set_dsl_interpreter (dsl_name); + m->set_name (n); + m->load_from (mp); + m->reset_modified (); + m->set_readonly (m_readonly); + m->set_parent (this); + } + + } + + if (new_macro.get ()) { + m_macros.insert (std::make_pair (n, new_macro.release ())); + } + + } catch (tl::Exception &ex) { + tl::error << "Reading " << tl::to_string (*f) << " in " << path << ": " << ex.msg (); + } + + } + + QStringList folders = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot); + for (QStringList::ConstIterator f = folders.begin (); f != folders.end (); ++f) { + + try { + + std::string n = tl::to_string (*f); + MacroCollection *&mc = m_folders.insert (std::make_pair (n, (MacroCollection *) 0)).first->second; + if (! mc) { + mc = new MacroCollection (); + mc->set_name (n); + mc->set_virtual_mode (NotVirtual); + bool ro = (m_readonly || ! QFileInfo (dir.filePath (*f)).isWritable ()); + mc->set_readonly (ro); + mc->scan (tl::to_string (dir.filePath (*f))); + mc->set_parent (this); + } + + } catch (tl::Exception &ex) { + tl::error << ex.msg (); + } + + } + + } +} + +void MacroCollection::clear () +{ + begin_changes (); + do_clear (); + on_changed (); +} + +void MacroCollection::erase (lym::Macro *mp) +{ + for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { + if (m->second == mp) { + begin_changes (); + on_macro_deleted_here (mp); + m_macros.erase (m); + delete mp; + on_changed (); + return; + } + } +} + +void MacroCollection::erase (lym::MacroCollection *mp) +{ + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + if (f->second == mp) { + begin_changes (); + on_child_deleted (mp); + m_folders.erase (f); + delete mp; + on_changed (); + return; + } + } +} + +void MacroCollection::erase (iterator i) +{ + begin_changes (); + on_macro_deleted_here (i->second); + delete i->second; + m_macros.erase (i); + on_changed (); +} + +void MacroCollection::erase (child_iterator i) +{ + begin_changes (); + on_child_deleted (i->second); + delete i->second; + m_folders.erase (i); + on_changed (); +} + +void MacroCollection::save () +{ + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + f->second->save (); + } + + for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { + if (m->second->is_modified () && ! m->second->is_readonly () && ! m->second->path ().empty ()) { + try { + m->second->save (); + } catch (tl::Exception &ex) { + tl::error << ex.msg (); + } + } + } +} + +bool MacroCollection::rename (const std::string &n) +{ + if (tl::verbosity () >= 20) { + tl::info << "Renaming macro folder " << path () << " to " << n; + } + QFile f (tl::to_qstring (path ())); + begin_changes (); + if (! f.rename (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (n)).filePath ())) { + on_changed (); + return false; + } else { + m_path = n; + on_changed (); + return true; + } +} + +lym::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir) +{ + std::string name; + int n = 0; + do { + name = (prefix ? prefix : "new_folder"); + if (n > 0) { + name += "_" + tl::to_string (n); + } + if (m_folders.find (name) == m_folders.end ()) { + break; + } + ++n; + } while (true); + + if (mkdir && ! QDir (tl::to_qstring (path ())).mkdir (tl::to_qstring (name))) { + return 0; + } + + begin_changes (); + + lym::MacroCollection *m = m_folders.insert (std::make_pair (name, new lym::MacroCollection ())).first->second; + m->set_virtual_mode (NotVirtual); + m->set_name (name); + m->set_parent (this); + + on_changed (); + + return m; +} + +lym::Macro *MacroCollection::create (const char *prefix, Macro::Format format) +{ + std::string name; + int n = 0; + do { + name = (prefix ? prefix : "new_macro"); + if (n > 0) { + name += "_" + tl::to_string (n); + } + if (! macro_by_name (name, format)) { + break; + } + ++n; + } while (true); + + begin_changes (); + + lym::Macro *m = m_macros.insert (std::make_pair (name, new lym::Macro ()))->second; + m->set_name (name); + m->set_parent (this); + + on_changed (); + + return m; +} + +void MacroCollection::add_unspecific (lym::Macro *m) +{ + begin_changes (); + m_macros.insert (std::make_pair (m->name (), m)); + m->set_parent (this); + on_changed (); +} + +bool MacroCollection::add (lym::Macro *m) +{ + QDir d (tl::to_qstring (path ())); + QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir (); + + if (d == dd) { + + begin_changes (); + m_macros.insert (std::make_pair (m->name (), m)); + m->set_parent (this); + on_changed (); + return true; + + } else { + + for (child_iterator c = begin_children (); c != end_children (); ++c) { + if (c->second->add (m)) { + return true; + } + } + + // try to detect new child folders. If that is the case, create that folder and add + // the macro there. + QDir dm (tl::to_qstring (m->dir ())); + while (true) { + + std::string folder_name = tl::to_string (dm.dirName ()); + if (! dm.cdUp ()) { + break; + } + + if (dm == d) { + begin_changes (); + lym::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second; + mc->set_virtual_mode (NotVirtual); + mc->set_parent (this); + on_changed (); + return mc->add (m); + } + + } + + } + + return false; +} + +bool MacroCollection::del () +{ + if (tl::verbosity () >= 20) { + tl::info << "Deleting macro folder " << path (); + } + return QDir ().rmdir (tl::to_qstring (path ())); +} + +void MacroCollection::rename_macro (Macro *macro, const std::string &new_name) +{ + iterator m = m_macros.find (macro->name ()); + while (m != m_macros.end () && m->first == macro->name ()) { + if (m->second == macro) { + m_macros.erase (m); + m_macros.insert (std::make_pair (new_name, macro)); + return; + } + ++m; + } +} + +lym::Macro *MacroCollection::find_macro (const std::string &path) +{ + for (iterator m = begin (); m != end (); ++m) { + if (m->second->path () == path) { + return m->second; + } + } + + for (child_iterator mc = begin_children (); mc != end_children (); ++mc) { + lym::Macro *macro = mc->second->find_macro (path); + if (macro) { + return macro; + } + } + + return 0; +} + +MacroCollection &MacroCollection::root () +{ + return ms_root; +} + +static bool sync_macros (lym::MacroCollection *current, lym::MacroCollection *actual, bool safe) +{ + bool ret = false; + + if (actual) { + current->make_readonly (actual->is_readonly ()); + } + + std::vector folders_to_delete; + + for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) { + lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0; + if (! cm) { + folders_to_delete.push_back (m->second); + } + } + + if (actual) { + for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) { + lym::MacroCollection *cm = current->folder_by_name (m->first); + if (! cm) { + cm = current->create_folder (m->first.c_str (), false); + ret = true; + } + if (sync_macros(cm, m->second, safe)) { + ret = true; + } + } + } + + // delete folders which do no longer exist + for (std::vector::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { + ret = true; + sync_macros (*m, 0, safe); + current->erase (*m); + } + + std::vector macros_to_delete; + + for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) { + lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0; + if (! cm) { + macros_to_delete.push_back (m->second); + } + } + + if (actual) { + for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) { + lym::Macro *cm = current->macro_by_name (m->first, m->second->format ()); + if (cm) { + if (*cm != *m->second && (! safe || ! cm->is_modified ())) { + cm->assign (*m->second); + } + cm->set_readonly (m->second->is_readonly ()); + } else { + cm = current->create (m->first.c_str (), m->second->format ()); + cm->assign (*m->second); + cm->set_readonly (m->second->is_readonly ()); + ret = true; + } + } + } + + // erase macros from collection which are no longer used + for (std::vector::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) { + current->erase (*m); + ret = true; + } + + return ret; +} + +void MacroCollection::reload (bool safe) +{ + // create a new collection and synchronize + + lym::MacroCollection new_collection; + for (lym::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { + new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */); + } + + // and synchronize current with the actual one + sync_macros (this, &new_collection, safe); +} + +static bool has_autorun_for (const lym::MacroCollection &collection, bool early) +{ + for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + if (has_autorun_for (*c->second, early)) { + return true; + } + } + + for (lym::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) { + if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) { + return true; + } + } + + return false; +} + +bool MacroCollection::has_autorun () const +{ + return has_autorun_for (*this, false); +} + +bool MacroCollection::has_autorun_early () const +{ + return has_autorun_for (*this, true); +} + +static int collect_priority (lym::MacroCollection &collection, bool early, int from_prio) +{ + int p = -1; + + for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + int pp = collect_priority (*c->second, early, from_prio); + if (pp >= from_prio && (p < 0 || pp < p)) { + p = pp; + } + } + + for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { + if (c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { + int pp = c->second->priority (); + if (pp >= from_prio && (p < 0 || pp < p)) { + p = pp; + } + } + } + + return p; +} + +static void autorun_for_prio (lym::MacroCollection &collection, bool early, std::set *executed_already, int prio) +{ + for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + autorun_for_prio (*c->second, early, executed_already, prio); + } + + for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { + + if (c->second->priority () == prio && c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { + + if (!executed_already || executed_already->find (c->second->path ()) == executed_already->end ()) { + + BEGIN_PROTECTED_SILENT + c->second->run (); + c->second->install_doc (); + END_PROTECTED_SILENT + + if (executed_already) { + executed_already->insert (c->second->path ()); + } + + } + + } + + } +} + +static void autorun_for (lym::MacroCollection &collection, bool early, std::set *executed_already) +{ + int prio = 0; + while (true) { + int p = collect_priority (collection, early, prio); + if (p < prio) { + break; + } + autorun_for_prio (collection, early, executed_already, p); + prio = p + 1; + } +} + +void MacroCollection::autorun (std::set *already_executed) +{ + autorun_for (*this, false, already_executed); +} + +void MacroCollection::autorun_early (std::set *already_executed) +{ + autorun_for (*this, true, already_executed); +} + +void MacroCollection::dump (int l) +{ + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("----\n"); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection: %s\n", name ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection-path: %s\n", path ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection-description: %s\n", description ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf("Collection-readonly: %d\n", is_readonly ()); + printf ("\n"); + + for (iterator m = begin (); m != end (); ++m) { + for (int i = 0; i < l; ++i) { printf (" "); } + printf("Name: %s%s\n", m->second->name ().c_str (), m->second->is_modified() ? "*" : ""); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Path: %s\n", m->second->path ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Readonly: %d\n", m->second->is_readonly ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Autorun: %d\n", m->second->is_autorun ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Autorun-early: %d\n", m->second->is_autorun_early ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Description: %s\n", m->second->description ().c_str ()); + } + + for (child_iterator m = begin_children (); m != end_children (); ++m) { + m->second->dump (l + 1); + } +} + +} + +#endif diff --git a/src/lym/lym/lymMacroCollection.h b/src/lym/lym/lymMacroCollection.h new file mode 100644 index 000000000..9df9f3d87 --- /dev/null +++ b/src/lym/lym/lymMacroCollection.h @@ -0,0 +1,594 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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_lymMacroCollection +#define HDR_lymMacroCollection + +#include "lymCommon.h" +#include "lymMacro.h" + +#if defined(HAVE_QT) + +#include +#include +#include + +#include + +namespace lym +{ + +/** + * @brief Represents a collection of macros + * + * A collection is representing a set of macros, usually associated with + * a folder containing *.lym, *.rb or other script files. + */ +class LYM_PUBLIC MacroCollection + : public QObject +{ +Q_OBJECT + +public: + typedef std::multimap ::iterator iterator; + typedef std::multimap ::const_iterator const_iterator; + typedef std::map ::iterator child_iterator; + typedef std::map ::const_iterator const_child_iterator; + + /** + * @brief Some constants for virtual_mode + */ + enum FolderType { + NotVirtual = 0, + ProjectFolder = 1, + TechFolder = 2, + SaltFolder = 3 + }; + + /** + * @brief Constructor + * + * The default constructor create + */ + MacroCollection (); + + /** + * @brief Destructor + */ + ~MacroCollection (); + + /** + * @brief Add a folder (will also scan the folder) + * + * @return A pointer to the new collection if successful + * + * If force_create is true (the default), the folder will be created if it does not + * exist yet. On error, 0 is returned. + */ + MacroCollection *add_folder (const std::string &description, const std::string &path, const std::string &category, bool readonly, bool force_create = true); + + /** + * @brief Gets the category tag of the collection + * + * A category tag can be used to categorize the collections. For example, DRC categories are handled differently + * from the other categories. + */ + const std::string &category () const + { + return m_category; + } + + /** + * @brief Sets the category tags + */ + void set_category (const std::string &d) + { + m_category = d; + } + + /** + * @brief Collect all Macro and MacroCollection objects inside a tree starting from this collection + */ + void collect_used_nodes(std::set ¯os, std::set ¯o_collections); + + /** + * @brief Saves all macros in the collection + * + * Saves only those macros that have is_modified and whose path is set. + */ + void save (); + + /** + * @brief Delete the original folder (the directory behind the macro) + * + * Returns true if the folder was deleted successfully. + * The folder cannot be deleted if it contains any files, also some that are not listed because + * they don't end with .lym, .rb or similar. + */ + bool del (); + + /** + * @brief Gets the name of the collection + * + * For virtual collections this is the path. + */ + std::string name () const + { + return m_path; + } + + /** + * @brief Gets the path of the folder representing that collection + */ + std::string path () const; + + /** + * @brief Returns the parent of the macro collection + * + * Returns 0, if there is no parent of this collection (this is the root) + */ + lym::MacroCollection *parent () + { + return mp_parent; + } + + /** + * @brief Returns the parent of the macro collection (const version) + * + * Returns 0, if there is no parent of this collection (this is the root) + */ + const lym::MacroCollection *parent () const + { + return mp_parent; + } + + /** + * @brief Returns != 0, if the macro collection is a virtual node + * + * A virtual node does not correspond to a location in the file system. + * A virtual node cannot have macros but only children. + * The return value indicates the kind of virtual use. + */ + int virtual_mode () const + { + return m_virtual_mode; + } + + /** + * @brief Sets the virtual mode + * + * See virtual_mode for details about the virtual mode. + */ + void set_virtual_mode (int m) + { + m_virtual_mode = m; + } + + /** + * @brief Gets a value indicating whether the macro collection is readonly + */ + bool is_readonly () const + { + return m_readonly; + } + + /** + * @brief Sets a value indicating whether the macro is readonly + * In contrast to the private \set_readonly method, this version delivers a "changed" signal when + * the flag changed. + */ + void make_readonly (bool f); + + /** + * @brief Gets the macro collection's description text + */ + const std::string &description () const + { + return m_description; + } + + /** + * @brief Sets the description + */ + void set_description (const std::string &d) + { + m_description = d; + } + + /** + * @brief Gets the display string + */ + std::string display_string () const; + + /** + * @brief Rename a Macro + * + * Renames the macro. If the macro is a file, the file will be renamed as well. + * This method will return true, if the rename was successful. + */ + bool rename (const std::string &n); + + /** + * @brief Adds a macro to the collection + * + * If a macro with the name of the new macro already exists, it is replaced + * (like in the file system). This method will traverse the tree to find + * the location of the macro using the path information of the macro and insert + * the macro there. + * + * The collection becomes the owner of the object passed to this method + * + * @return true, if the macro could be added successfully. + */ + bool add (lym::Macro *m); + + /** + * @brief Adds a macro in an unspecific way + * + * "unspecific" means that the path is not looked up - the macro is + * added irregardless whether the path matches or not. + * This is a way to build macro collections without connection + * to some file system point. + */ + void add_unspecific (lym::Macro *m); + + /** + * @brief Empties the collection + * Note: only the unspecific on_changed event is generated. + */ + void clear (); + + /** + * @brief Erases the given macro from the list + * + * This does not remove the file but just remove the macro object. + * This will also delete the macro object. + */ + void erase (lym::Macro *m); + + /** + * @brief Erases the entry with the given iterator + */ + void erase (iterator i); + + /** + * @brief Erases the given macro collection from the list of child collections + * + * This does not remove the directory but just removes the macro collection object. + * This will also delete the macro collection object. + */ + void erase (lym::MacroCollection *m); + + /** + * @brief Erases the folder with the given iterator + */ + void erase (child_iterator i); + + /** + * @brief Creates a new macro in that collection (with a new name) + * + * If a name is given, it is used as a prefix to create a unique name for a macro with that format. + */ + lym::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat); + + /** + * @brief Creates a new macro collection in that collection (with a new name) + * + * If a name is given, it is used as a prefix to create a unique name. + * This method will also create the directory for this folder. + * If not successful, it will return 0. + */ + lym::MacroCollection *create_folder (const char *name = 0, bool mkdir = true); + + /** + * @brief Gets the begin iterator of the macros + */ + iterator begin () + { + return m_macros.begin (); + } + + /** + * @brief Gets the end iterator of the macros + */ + iterator end () + { + return m_macros.end (); + } + + /** + * @brief Gets the begin iterator of the macros (const version) + */ + const_iterator begin () const + { + return m_macros.begin (); + } + + /** + * @brief Gets the end iterator of the macros (const version) + */ + const_iterator end () const + { + return m_macros.end (); + } + + /** + * @brief Gets the begin iterator of the folders + */ + child_iterator begin_children () + { + return m_folders.begin (); + } + + /** + * @brief Gets the end iterator of the folders + */ + child_iterator end_children () + { + return m_folders.end (); + } + + /** + * @brief Gets the begin iterator of the folders (const version) + */ + const_child_iterator begin_children () const + { + return m_folders.begin (); + } + + /** + * @brief Gets the end iterator of the folders (const version) + */ + const_child_iterator end_children () const + { + return m_folders.end (); + } + + /** + * @brief Gets a macro by name + * + * If no macro with that name exists, this method will return 0. + */ + Macro *macro_by_name (const std::string &name, Macro::Format format); + + /** + * @brief Gets a macro by name + * + * If no macro with that name exists, this method will return 0. + */ + const Macro *macro_by_name (const std::string &name, Macro::Format format) const; + + /** + * @brief Gets a folder by name + * + * If no folder with that name exists, this method will return 0. + */ + MacroCollection *folder_by_name (const std::string &name); + + /** + * @brief Gets a folder by name + * + * If no folder with that name exists, this method will return 0. + */ + const MacroCollection *folder_by_name (const std::string &name) const; + + /** + * @brief Finds a macro by path + * + * This method is called from the root collection and delivers the macro which + * matches the given path or 0. + */ + lym::Macro *find_macro (const std::string &path); + + /** + * @brief Returns true, if the collection has an autorun macro + */ + bool has_autorun () const; + + /** + * @brief Runs all macros marked with auto-run + */ + void autorun (std::set *already_executed = 0); + + /** + * @brief Returns true, if the collection has an early autorun macro + */ + bool has_autorun_early () const; + + /** + * @brief Runs all macros marked with early auto-run + */ + void autorun_early (std::set *already_executed = 0); + + /** + * @brief Redo the scan (will add new files or folders) + * + * This method must be called on root. + */ + void rescan (); + + /** + * @brief Reloads the macro collection + * + * This method is similar to rescan, but it will also remove folders and macros. + * In safe mode (safe = true), modified macros won't be overwritten. + */ + void reload (bool safe); + + /** + * @brief Gets the root of the macro hierarchy corresponding to the configuration space + */ + static MacroCollection &root (); + + /** + * @brief Dump the macro tree (for debugging) + */ + void dump (int l = 0); + +signals: + /** + * @brief This signal is sent when the collection changes + */ + void changed (); + + /** + * @brief This signal is sent by collection when a child collection is deleted in this collection + */ + void child_deleted (lym::MacroCollection *); + + /** + * @brief This signal is sent by the root object when a macro collection is deleted + */ + void macro_collection_deleted (lym::MacroCollection *); + + /** + * @brief This signal is sent by collection when a macro is deleted in this collection + */ + void macro_deleted_here (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro is deleted + */ + void macro_deleted (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro changes + * + * This signal is only emitted by the root, but it may originate from a + * macro inside the tree. + */ + void macro_changed (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro collection changes + * + * This signal is only emitted by the root, but it may originate from a + * macro collection inside the tree. + */ + void macro_collection_changed (lym::MacroCollection *); + + /** + * @brief This signal is sent by the root object befor the macro collection changes + */ + void about_to_change (); + + /** + * @brief This signal is emitted from the collection root if the menu needs to be updated + */ + void menu_needs_update (); + +private: + friend class Macro; + + std::string m_path; + std::string m_description; + std::string m_category; + std::multimap m_macros; + std::map m_folders; + lym::MacroCollection *mp_parent; + int m_virtual_mode; + bool m_readonly; + + void on_child_deleted (MacroCollection *mc); + void on_macro_collection_deleted (MacroCollection *mc); + void on_macro_deleted_here (Macro *macro); + void on_macro_deleted (Macro *macro); + void on_macro_changed (Macro *macro); + void on_macro_collection_changed (MacroCollection *mc); + void on_changed (); + void on_menu_needs_update (); + + /** + * @brief Scans a folder creating the macro collection + */ + void scan (const std::string &path); + + void rename_macro (Macro *macro, const std::string &new_name); + + void begin_changes (); + + void set_name (const std::string &n) + { + m_path = n; + } + + void set_parent (lym::MacroCollection *parent) + { + mp_parent = parent; + } + + void set_readonly (bool f) + { + m_readonly = f; + } + + void do_clear (); + + // no copying + MacroCollection (const MacroCollection &d); + MacroCollection &operator= (const MacroCollection &d); +}; + +} + +#else // without QT: + +#include + +namespace lym +{ + +/** + * @brief Dummy implementation for Qt-less builds. + * + * This dummy implementation does not provide any services but acts as a dummy anchor + * for lym::Macro. + * + * Without Qt, the MacroCollection does not make much sense as there is no + * application specific file system without an Application object. + */ +class LYM_PUBLIC MacroCollection +{ +public: + MacroCollection () + { + // .. nothing yet .. + } + + std::string path () const + { + return std::string (); + } + + void rename_macro (lym::Macro *, const std::string &) + { + // .. nothing yet .. + } +}; + +} + +#endif + +#endif + diff --git a/src/lym/lym/lymMacroInterpreter.cc b/src/lym/lym/lymMacroInterpreter.cc index 77f437345..532bff93d 100644 --- a/src/lym/lym/lymMacroInterpreter.cc +++ b/src/lym/lym/lymMacroInterpreter.cc @@ -29,13 +29,15 @@ #include "tlClassRegistry.h" #include "tlInclude.h" +#include + namespace lym { tl::Executable * MacroInterpreter::executable (const lym::Macro *) const { - throw tl::Exception (tl::to_string (QObject::tr ("executable() implementation missing for DSL interpreter"))); + throw tl::Exception (tl::to_string (tr ("executable() implementation missing for DSL interpreter"))); } bool @@ -131,7 +133,7 @@ MacroInterpreter::execute_macro (const lym::Macro *macro) } } - throw tl::Exception (tl::to_string (QObject::tr ("No interpreter registered for DSL type '")) + macro->dsl_interpreter () + "'"); + throw tl::Exception (tl::to_string (tr ("No interpreter registered for DSL type '")) + macro->dsl_interpreter () + "'"); } std::string diff --git a/src/plugins/lay_plugin.pri b/src/plugins/lay_plugin.pri index be3655cd2..3710c7ff7 100644 --- a/src/plugins/lay_plugin.pri +++ b/src/plugins/lay_plugin.pri @@ -3,9 +3,9 @@ include($$PWD/../klayout.pri) TEMPLATE = lib -INCLUDEPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAY_INC $$PWD/common -DEPENDPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAY_INC $$PWD/common -LIBS += -L$$DESTDIR/.. -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_lay +INCLUDEPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$LAYUI_INC $$LAY_INC $$PWD/common +DEPENDPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$LAYUI_INC $$LAY_INC $$PWD/common +LIBS += -L$$DESTDIR/.. -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layui -lklayout_layview -lklayout_lay -lklayout_lay DEFINES += MAKE_LAY_PLUGIN_LIBRARY diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc index b8b92a68e..82e93d64e 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc @@ -28,6 +28,7 @@ #include "layPlugin.h" #include "layMainWindow.h" #include "layFileDialog.h" +#include "dbTechnology.h" #include "tlLog.h" #include "tlTimer.h" #include "tlXMLParser.h" diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc index e5f0c966f..ffb1e3574 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc @@ -62,7 +62,7 @@ BooleanOptionsDialog::cv_changed (int) } bool -BooleanOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_r, int &layer_r, int &mode, int &hier_mode, bool &min_coherence) +BooleanOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_r, int &layer_r, int &mode, int &hier_mode, bool &min_coherence) { mp_view = view; @@ -183,7 +183,7 @@ SizingOptionsDialog::cv_changed (int) } bool -SizingOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence) +SizingOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence) { mp_view = view; @@ -309,7 +309,7 @@ MergeOptionsDialog::cv_changed (int) } bool -MergeOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, unsigned int &min_wc, int &hier_mode, bool &min_coherence) +MergeOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, unsigned int &min_wc, int &hier_mode, bool &min_coherence) { mp_view = view; diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h index ae53f9849..875c42054 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h @@ -37,7 +37,7 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; /** * @brief The boolean operation options @@ -52,7 +52,7 @@ public: BooleanOptionsDialog (QWidget *parent); virtual ~BooleanOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_res, int &layer_res, int &mode, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_res, int &layer_res, int &mode, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -60,7 +60,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -76,7 +76,7 @@ public: SizingOptionsDialog (QWidget *parent); virtual ~SizingOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -84,7 +84,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -100,7 +100,7 @@ public: MergeOptionsDialog (QWidget *parent); virtual ~MergeOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, unsigned int &min_wc, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, unsigned int &min_wc, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -108,7 +108,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 668f159e6..f8ccfd1ba 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -26,7 +26,7 @@ #include "layPlugin.h" #include "layTipDialog.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbShapeProcessor.h" @@ -39,7 +39,7 @@ class BooleanOperationsPlugin : public lay::Plugin { public: - BooleanOperationsPlugin (Plugin *parent, lay::LayoutView *view) + BooleanOperationsPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { m_boolean_cva = -1; @@ -100,7 +100,7 @@ public: } - lay::BooleanOptionsDialog dialog (mp_view); + lay::BooleanOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvb, m_boolean_layerb, m_boolean_cvr, m_boolean_layerr, m_boolean_mode, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -237,7 +237,7 @@ public: } - lay::MergeOptionsDialog dialog (mp_view); + lay::MergeOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvr, m_boolean_layerr, m_boolean_minwc, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -352,7 +352,7 @@ public: } - lay::SizingOptionsDialog dialog (mp_view); + lay::SizingOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvr, m_boolean_layerr, m_boolean_sizex, m_boolean_sizey, m_boolean_size_mode, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -445,7 +445,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_boolean_cva, m_boolean_cvb, m_boolean_cvr; int m_boolean_layera, m_boolean_layerb, m_boolean_layerr; int m_boolean_hier_mode, m_boolean_mode; @@ -494,7 +494,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BooleanOperationsPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 7cc1a6f52..8d22390ed 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -24,6 +24,7 @@ #include "layDispatcher.h" #include "layPlugin.h" +#include "layLayoutViewBase.h" namespace lay { @@ -32,7 +33,7 @@ class DiffPlugin : public lay::Plugin { public: - DiffPlugin (Plugin *parent, lay::LayoutView *view) + DiffPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::DiffToolDialog (0); @@ -58,7 +59,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::DiffToolDialog *mp_dialog; }; @@ -102,7 +103,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new DiffPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc index e85ae117b..c56f6e7da 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc @@ -30,7 +30,7 @@ #include "tlTimer.h" #include "tlProgress.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "ui_DiffToolDialog.h" @@ -608,7 +608,7 @@ DiffToolDialog::~DiffToolDialog () } int -DiffToolDialog::exec_dialog (lay::LayoutView *view) +DiffToolDialog::exec_dialog (lay::LayoutViewBase *view) { mp_view = view; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h index b91744c50..e823f3b13 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h @@ -36,7 +36,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace lay @@ -57,7 +57,7 @@ public: DiffToolDialog (QWidget *parent); ~DiffToolDialog (); - int exec_dialog (lay::LayoutView *view); + int exec_dialog (lay::LayoutViewBase *view); protected slots: void xor_changed () { update (); } @@ -69,7 +69,7 @@ protected: private: Ui::DiffToolDialog *mp_ui; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc index f175b1c82..f77581b7b 100644 --- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc +++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc @@ -339,13 +339,13 @@ NetTracerSymbolInfo::parse (tl::Extractor &ex) // Net implementation NetTracerNet::NetTracerNet () - : m_dbu (0.001), m_incomplete (true), m_trace_path (false) + : m_dbu (0.001), m_incomplete (true), m_color (0), m_trace_path (false) { // .. nothing yet .. } NetTracerNet::NetTracerNet (const NetTracer &tracer, const db::ICplxTrans &trans, const db::Layout &layout, db::cell_index_type cell_index, const std::string &layout_filename, const std::string &layout_name, const NetTracerData &data) - : m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_trace_path (false) + : m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_color (0), m_trace_path (false) { m_dbu = layout.dbu (); m_top_cell_name = layout.cell_name (cell_index); diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h index 2262bcf7e..ec98182e2 100644 --- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h +++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h @@ -196,11 +196,10 @@ public: return m_net_shapes.size (); } -#if defined(HAVE_QT) /** * @brief Gets the color in which the net is drawn */ - QColor color () const + uint32_t color () const { return m_color; } @@ -208,11 +207,10 @@ public: /** * @brief Sets the color in which the net is drawn */ - void set_color (QColor c) + void set_color (uint32_t c) { m_color = c; } -#endif /** * @brief Get a name for the net @@ -355,9 +353,7 @@ private: db::Shapes m_shapes; std::map > m_layers; std::map m_cell_names; -#if defined(HAVE_QT) - QColor m_color; -#endif + uint32_t m_color; db::DBox m_start_search_box, m_stop_search_box; bool m_trace_path; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h index 91c02f9ce..395a87d20 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h @@ -28,6 +28,7 @@ #include "ui_NetTracerConfigPage.h" #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" namespace lay diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index cf543dfa2..cbbf1c069 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -53,7 +53,7 @@ namespace lay // ----------------------------------------------------------------------------------- // NetTracerDialog implementation -NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view) +NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "net_tracer_dialog"), lay::ViewService (view->view_object_widget ()), m_cv_index (0), @@ -68,7 +68,8 @@ NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view) m_marker_intensity (0), m_auto_color_enabled (false), m_auto_color_index (0), - m_mouse_state (0) + m_mouse_state (0), + mp_view (view) { mp_export_file_dialog = new lay::FileDialog (this, tl::to_string (QObject::tr ("Export Net")), tl::to_string (QObject::tr ("KLayout net files (*.lyn);;All files (*)"))); @@ -187,7 +188,7 @@ NetTracerDialog::mouse_click_event (const db::DPoint &p, unsigned int buttons, b // do auto coloring if (m_auto_color_enabled) { if (m_auto_color_index < int (m_auto_colors.colors ())) { - mp_nets.back ()->set_color (QColor (m_auto_colors.color_by_index (m_auto_color_index))); + mp_nets.back ()->set_color (m_auto_colors.color_by_index (m_auto_color_index)); } ++m_auto_color_index; if (m_auto_color_index >= int (m_auto_colors.colors ())) { @@ -476,7 +477,7 @@ NetTracerDialog::configure (const std::string &name, const std::string &value) } else if (name == cfg_nt_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } @@ -594,7 +595,7 @@ NetTracerDialog::net_color_changed (QColor color) int item_index = net_list->row (*item); if (item_index >= 0 && item_index < int (mp_nets.size ())) { if (color != mp_nets [item_index]->color ()) { - mp_nets [item_index]->set_color (color); + mp_nets [item_index]->set_color (color.rgb ()); changed = true; } } @@ -1092,7 +1093,7 @@ NetTracerDialog::update_list () item->setData (Qt::DisplayRole, tl::to_qstring (mp_nets [i]->name ())); - if (mp_nets [i]->color ().isValid ()) { + if (lay::Color (mp_nets [i]->color ()).is_valid ()) { QPixmap pxmp (icon_size); QPainter pxpainter (&pxmp); @@ -1595,7 +1596,7 @@ NetTracerDialog::update_highlights () std::map llmap; - QColor net_color = mp_nets [item_index]->color (); + lay::Color net_color = mp_nets [item_index]->color (); // Create markers for the shapes for (db::NetTracerNet::iterator net_shape = mp_nets [item_index]->begin (); net_shape != mp_nets [item_index]->end () && n_marker < m_max_marker_count; ++net_shape) { @@ -1639,7 +1640,7 @@ NetTracerDialog::update_highlights () mp_markers.back ()->set_line_width (original->width (true)); mp_markers.back ()->set_vertex_size (1); mp_markers.back ()->set_dither_pattern (original->dither_pattern (true)); - if (view ()->background_color ().green () < 128) { + if (! view ()->background_color ().to_mono ()) { mp_markers.back ()->set_color (original->eff_fill_color_brighter (true, (m_marker_intensity * 255) / 100)); mp_markers.back ()->set_frame_color (original->eff_frame_color_brighter (true, (m_marker_intensity * 255) / 100)); } else { @@ -1648,10 +1649,10 @@ NetTracerDialog::update_highlights () } } - if (net_color.isValid ()) { + if (net_color.is_valid ()) { mp_markers.back ()->set_color (net_color); mp_markers.back ()->set_frame_color (net_color); - } else if (m_marker_color.isValid ()) { + } else if (m_marker_color.is_valid ()) { mp_markers.back ()->set_color (m_marker_color); mp_markers.back ()->set_frame_color (m_marker_color); } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h index 6acf2cf93..63e2a2236 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h @@ -57,7 +57,7 @@ class NetTracerDialog Q_OBJECT public: - NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view); + NetTracerDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); virtual ~NetTracerDialog (); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); @@ -92,7 +92,7 @@ private: nt_window_type m_window; double m_window_dim; unsigned int m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; @@ -108,6 +108,8 @@ private: lay::FileDialog *mp_export_file_dialog; std::string m_export_file_name; + lay::LayoutViewBase *mp_view; + void commit (); size_t get_trace_depth (); void update_highlights (); @@ -121,6 +123,11 @@ private: db::NetTracerNet *do_trace (const db::DBox &start_search_box, const db::DBox &stop_search_box, bool trace_path); bool get_net_tracer_setup (const lay::CellView &cv, db::NetTracerData &data); void trace_all_nets (db::LayoutToNetlist *l2ndb, const lay::CellView &cv, bool flat); + + lay::LayoutViewBase *view () + { + return mp_view; + } }; } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 9d7eb3d27..619d12e53 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -28,6 +28,7 @@ #include "layConverters.h" #include "layCellView.h" +#include "layLayoutView.h" #include "gsiDecl.h" @@ -75,7 +76,7 @@ public: menu_entries.push_back (lay::menu_item ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); } - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new NetTracerDialog (root, view); } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc index c6830127c..4bb1601c8 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc @@ -67,7 +67,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new D25View (root, view); } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index 019dedecd..026864e70 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -38,7 +38,7 @@ namespace lay const double initial_elevation = 15.0; -D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view) +D25View::D25View (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "d25_view"), dm_rerun_macro (this, &D25View::rerun_macro), dm_fit (this, &D25View::fit) @@ -94,7 +94,7 @@ D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view) mp_ui->material_list->addAction (mp_ui->hide_selected_action); mp_ui->material_list->setContextMenuPolicy (Qt::ActionsContextMenu); - connect (mp_ui->material_list, SIGNAL (itemChanged (QListWidgetItem *)), this, SLOT (material_item_changed (QListWidgetItem *))); + connect (mp_ui->material_list, SIGNAL (itemChanged(QListWidgetItem *)), this, SLOT (material_item_changed(QListWidgetItem *))); } D25View::~D25View () @@ -146,7 +146,7 @@ D25View::menu_activated (const std::string &symbol) } D25View * -D25View::open (lay::LayoutView *view) +D25View::open (lay::LayoutViewBase *view) { D25View *d25_view = view->get_plugin (); if (d25_view) { diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.h b/src/plugins/tools/view_25d/lay_plugin/layD25View.h index 724c14e25..62847e787 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.h @@ -37,7 +37,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace db @@ -57,14 +57,14 @@ class D25View Q_OBJECT public: - D25View (lay::Dispatcher *root, lay::LayoutView *view); + D25View (lay::Dispatcher *root, lay::LayoutViewBase *view); ~D25View (); virtual void menu_activated (const std::string &symbol); virtual void deactivated (); virtual void activated (); - static D25View *open (lay::LayoutView *view); + static D25View *open (lay::LayoutViewBase *view); void close (); void clear (); void begin (const std::string &generator); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 94e7f2705..475953c1e 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -711,7 +711,7 @@ D25ViewWidget::finish () } void -D25ViewWidget::attach_view (LayoutView *view) +D25ViewWidget::attach_view (LayoutViewBase *view) { mp_view = view; } @@ -1089,11 +1089,11 @@ D25ViewWidget::paintGL () const qreal retina_scale = devicePixelRatio (); glViewport (0, 0, width () * retina_scale, height () * retina_scale); - QColor c = mp_view->background_color (); - float foreground_rgb = (c.green () > 128 ? 0.0f : 1.0f); - float ambient = (c.green () > 128 ? 0.8f : 0.25f); - float mist_factor = (c.green () > 128 ? 0.2f : 0.4f); - float mist_add = (c.green () > 128 ? 0.8f : 0.2f); + lay::Color c = mp_view->background_color (); + float foreground_rgb = (c.to_mono () ? 0.0f : 1.0f); + float ambient = (c.to_mono () ? 0.8f : 0.25f); + float mist_factor = (c.to_mono () ? 0.2f : 0.4f); + float mist_add = (c.to_mono () ? 0.8f : 0.2f); glClearColor (float (c.red ()) / 255.0f, float (c.green ()) / 255.0f, float (c.blue ()) / 255.0f, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h index af5dd0a54..180a9cb89 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h @@ -57,7 +57,7 @@ namespace tl namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesNode; class D25ViewWidget; @@ -106,7 +106,7 @@ public: void mouseReleaseEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); - void attach_view(lay::LayoutView *view); + void attach_view(lay::LayoutViewBase *view); QVector3D hit_point_with_scene(const QVector3D &line_dir); void refresh (); @@ -187,7 +187,7 @@ private: double m_scale_factor; double m_vscale_factor; QVector3D m_displacement; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::DBox m_bbox; double m_zmin, m_zmax; bool m_zset; diff --git a/src/plugins/tools/view_25d/view_25d.pro b/src/plugins/tools/view_25d/view_25d.pro index 138f0890d..3fa284d8a 100644 --- a/src/plugins/tools/view_25d/view_25d.pro +++ b/src/plugins/tools/view_25d/view_25d.pro @@ -1,12 +1,16 @@ TEMPLATE = subdirs -contains(QT_CONFIG, opengl) { +!equals(HAVE_QT, "0") { + + contains(QT_CONFIG, opengl) { + + greaterThan(QT_MAJOR_VERSION, 4) { + SUBDIRS = lay_plugin unit_tests + } + + unit_tests.depends += lay_plugin - greaterThan(QT_MAJOR_VERSION, 4) { - SUBDIRS = lay_plugin unit_tests } - unit_tests.depends += lay_plugin - } diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index f6f9f79e1..6c38c4d85 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -26,6 +26,7 @@ #include "layDispatcher.h" #include "layPlugin.h" +#include "layLayoutView.h" namespace lay { @@ -34,7 +35,7 @@ class XORPlugin : public lay::Plugin { public: - XORPlugin (Plugin *parent, lay::LayoutView *view) + XORPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::XORToolDialog (0); @@ -60,7 +61,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::XORToolDialog *mp_dialog; }; @@ -110,7 +111,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new XORPlugin (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc index ff8c7888b..f5141f114 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc @@ -186,7 +186,7 @@ XORToolDialog::~XORToolDialog () } int -XORToolDialog::exec_dialog (lay::LayoutView *view) +XORToolDialog::exec_dialog (lay::LayoutViewBase *view) { mp_view = view; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h index adeb9fb1b..e2178ee62 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h @@ -34,7 +34,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace lay @@ -61,7 +61,7 @@ public: XORToolDialog (QWidget *parent); ~XORToolDialog (); - int exec_dialog (lay::LayoutView *view); + int exec_dialog (lay::LayoutViewBase *view); protected: void accept (); @@ -74,7 +74,7 @@ protected slots: private: Ui::XORToolDialog *mp_ui; - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; } diff --git a/src/pya/pya/pyaConvert.cc b/src/pya/pya/pyaConvert.cc index e7f536bcd..09fccb5e7 100644 --- a/src/pya/pya/pyaConvert.cc +++ b/src/pya/pya/pyaConvert.cc @@ -455,7 +455,9 @@ object_to_python (void *obj, PYAObjectBase *self, const gsi::ClassBase *cls, boo // of the exposed property. Hence copying is safer. PyTypeObject *type = PythonModule::type_for_cls (clsact); - tl_assert (type != NULL); + if (!type) { + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Requested type %s.%s is not bound to a Python class (did you load the '%s' module?)")), clsact->module (), clsact->name (), clsact->module ())); + } // create a instance and copy the value PyObject *new_pyobject = type->tp_alloc (type, 0); @@ -477,7 +479,9 @@ object_to_python (void *obj, PYAObjectBase *self, const gsi::ClassBase *cls, boo } else { PyTypeObject *type = PythonModule::type_for_cls (clsact); - tl_assert (type != NULL); + if (!type) { + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Requested type %s.%s is not bound to a Python class (did you load the '%s' module?)")), clsact->module (), clsact->name (), clsact->module ())); + } // create a instance and copy the value PyObject *new_pyobject = type->tp_alloc (type, 0); diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 0f962fa7e..5eff6c85d 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -2403,6 +2403,11 @@ public: PyTypeObject *make_class (const gsi::ClassBase *cls, bool as_static) { + // drop non-standard names + if (tl::verbosity () >= 40) { + tl::info << tl::sprintf (tl::to_string (tr ("Creating class %s.%s")), PyModule_GetName (mp_module->module ()), cls->name ()); + } + // NOTE: with as_static = true, this method produces a mixin. This is a class entirely consisting // of static constants and child classes only. It can be mixed into an existing class for emulation // additional base classes. diff --git a/src/pymod/__init__.py.qtless b/src/pymod/__init__.py.qtless index 776d25ace..782df0624 100644 --- a/src/pymod/__init__.py.qtless +++ b/src/pymod/__init__.py.qtless @@ -1,4 +1,4 @@ # klayout library definition file -__all__ = [ "tl", "db", "lib", "rdb" ] +__all__ = [ "tl", "db", "lib", "rdb", "lay" ] diff --git a/src/pymod/ant/ant.pro b/src/pymod/ant/ant.pro new file mode 100644 index 000000000..6df7c0d5a --- /dev/null +++ b/src/pymod/ant/ant.pro @@ -0,0 +1,12 @@ + +TARGET = ant + +include($$PWD/../pymod.pri) + +SOURCES = \ + antMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_ant + diff --git a/src/pymod/ant/antMain.cc b/src/pymod/ant/antMain.cc new file mode 100644 index 000000000..1ec947f0d --- /dev/null +++ b/src/pymod/ant/antMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "../pymodHelper.h" + +// to force linking of the ant module +# include "../../ant/ant/antForceLink.h" + +DEFINE_PYMOD(antcore, "ant", "KLayout core module 'ant'") diff --git a/src/pymod/distutils_src/klayout/lay/__init__.py b/src/pymod/distutils_src/klayout/lay/__init__.py new file mode 100644 index 000000000..3f8edad9e --- /dev/null +++ b/src/pymod/distutils_src/klayout/lay/__init__.py @@ -0,0 +1,5 @@ +import klayout.laycore + +from klayout.laycore import * + +__all__ = klayout.laycore.__all__ diff --git a/src/pymod/distutils_src/pya/__init__.py b/src/pymod/distutils_src/pya/__init__.py index 08879d72b..ff9d59e2e 100644 --- a/src/pymod/distutils_src/pya/__init__.py +++ b/src/pymod/distutils_src/pya/__init__.py @@ -6,3 +6,4 @@ from klayout.db import * # noqa from klayout.lib import * # noqa from klayout.tl import * # noqa from klayout.rdb import * # noqa +from klayout.lay import * # noqa diff --git a/src/pymod/edt/edt.pro b/src/pymod/edt/edt.pro new file mode 100644 index 000000000..f2b8fe8b4 --- /dev/null +++ b/src/pymod/edt/edt.pro @@ -0,0 +1,12 @@ + +TARGET = edt + +include($$PWD/../pymod.pri) + +SOURCES = \ + edtMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_edt + diff --git a/src/pymod/edt/edtMain.cc b/src/pymod/edt/edtMain.cc new file mode 100644 index 000000000..5ae69e64b --- /dev/null +++ b/src/pymod/edt/edtMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "../pymodHelper.h" + +// to force linking of the edt module +# include "../../edt/edt/edtForceLink.h" + +DEFINE_PYMOD(edtcore, "edt", "KLayout core module 'edt'") diff --git a/src/pymod/edt/lay.pro b/src/pymod/edt/lay.pro new file mode 100644 index 000000000..5555294e0 --- /dev/null +++ b/src/pymod/edt/lay.pro @@ -0,0 +1,12 @@ + +TARGET = lay + +include($$PWD/../pymod.pri) + +SOURCES = \ + layMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lay + diff --git a/src/pymod/img/img.pro b/src/pymod/img/img.pro new file mode 100644 index 000000000..ca520540a --- /dev/null +++ b/src/pymod/img/img.pro @@ -0,0 +1,12 @@ + +TARGET = img + +include($$PWD/../pymod.pri) + +SOURCES = \ + imgMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_img + diff --git a/src/pymod/img/imgMain.cc b/src/pymod/img/imgMain.cc new file mode 100644 index 000000000..db7eb4d79 --- /dev/null +++ b/src/pymod/img/imgMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrimgy 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 "../pymodHelper.h" + +// to force linking of the img module +# include "../../img/img/imgForceLink.h" + +DEFINE_PYMOD(imgcore, "img", "KLayout core module 'img'") diff --git a/src/pymod/img/lay.pro b/src/pymod/img/lay.pro new file mode 100644 index 000000000..5555294e0 --- /dev/null +++ b/src/pymod/img/lay.pro @@ -0,0 +1,12 @@ + +TARGET = lay + +include($$PWD/../pymod.pri) + +SOURCES = \ + layMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lay + diff --git a/src/pymod/lay/lay.pro b/src/pymod/lay/lay.pro index 5555294e0..d62c2c847 100644 --- a/src/pymod/lay/lay.pro +++ b/src/pymod/lay/lay.pro @@ -1,5 +1,6 @@ -TARGET = lay +TARGET = laycore +REALMODULE = lay include($$PWD/../pymod.pri) @@ -8,5 +9,13 @@ SOURCES = \ HEADERS += \ -LIBS += -lklayout_lay +LIBS += -lklayout_layview + +!equals(HAVE_QT, "0") { + LIBS += -lklayout_layui + LIBS += -lklayout_lay +} + +# hard linked as they contribute GSI classes to "lay" module: +LIBS += -lklayout_laybasic -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index 6d13a6ab0..a622fc2f2 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -22,10 +22,18 @@ #include "../pymodHelper.h" -// to force linking of the lay module -#include "../../lay/lay/layForceLink.h" +// to force linking of the layview module +#if defined(HAVE_QT) +# include "../../lay/lay/layForceLink.h" +#else +# include "../../layview/layview/layviewForceLink.h" +#endif -// NOTE: img, ant, edt and rdb don't need to be force-linked -// as they are hard-linked by lay +// Force-include other dependencies +// NOTE: these libraries contribute to the "lay" module space. Hence we have to include them. +#include "../../ant/ant/antForceLink.h" +#include "../../img/img/imgForceLink.h" +#include "../../edt/edt/edtForceLink.h" +#include "../../lym/lym/lymForceLink.h" -DEFINE_PYMOD(lay, "lay", "KLayout core module 'lay'") +DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") diff --git a/src/pymod/lym/lym.pro b/src/pymod/lym/lym.pro new file mode 100644 index 000000000..4e1e5983e --- /dev/null +++ b/src/pymod/lym/lym.pro @@ -0,0 +1,12 @@ + +TARGET = lym + +include($$PWD/../pymod.pri) + +SOURCES = \ + lymMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lym + diff --git a/src/pymod/lym/lymMain.cc b/src/pymod/lym/lymMain.cc new file mode 100644 index 000000000..0d34f46ca --- /dev/null +++ b/src/pymod/lym/lymMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "../pymodHelper.h" + +// to force linking of the lym module +# include "../../lym/lym/lymForceLink.h" + +DEFINE_PYMOD(lymcore, "lym", "KLayout core module 'lym'") diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index cb205bcdb..b8f7744ea 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -7,11 +7,10 @@ SUBDIRS = \ tl \ rdb \ lib \ + lay \ !equals(HAVE_QT, "0") { - SUBDIRS += lay - equals(HAVE_QTBINDINGS, "1") { SUBDIRS += \ diff --git a/src/pymod/tl/tlMain.cc b/src/pymod/tl/tlMain.cc index d1f69e21d..b9617364e 100644 --- a/src/pymod/tl/tlMain.cc +++ b/src/pymod/tl/tlMain.cc @@ -23,4 +23,3 @@ #include "../pymodHelper.h" DEFINE_PYMOD(tlcore, "tl", "KLayout core module 'tl'") - diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 441bcae6d..b9dd8ae03 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -87,11 +87,10 @@ PYMODTEST (bridge, "bridge.py") PYMODTEST (import_tl, "import_tl.py") PYMODTEST (import_db, "import_db.py") PYMODTEST (import_rdb, "import_rdb.py") +PYMODTEST (import_lay, "import_lay.py") #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) -PYMODTEST (import_lay, "import_lay.py") - PYMODTEST (import_QtCore, "import_QtCore.py") #if QT_VERSION >= 0x60000 PYMODTEST (import_QtGui, "import_QtGui_Qt6.py") @@ -146,8 +145,4 @@ PYMODTEST (import_QtCore5Compat, "import_QtCore5Compat.py") PYMODTEST (import_pya, "pya_tests.py") -#elif defined(HAVE_QT) - -PYMODTEST (import_lay, "import_lay_noqt.py") - #endif diff --git a/src/rba/unit_tests/rbaTests.cc b/src/rba/unit_tests/rbaTests.cc index d222d57f0..300637249 100644 --- a/src/rba/unit_tests/rbaTests.cc +++ b/src/rba/unit_tests/rbaTests.cc @@ -143,6 +143,7 @@ RUBYTEST (layLayoutView, "layLayoutView.rb") RUBYTEST (layMarkers, "layMarkers.rb") RUBYTEST (layMacro, "layMacro.rb") RUBYTEST (layMenuTest, "layMenuTest.rb") +RUBYTEST (layPixelBuffer, "layPixelBuffer.rb") RUBYTEST (laySession, "laySession.rb") RUBYTEST (layTechnologies, "layTechnologies.rb") RUBYTEST (laySaveLayoutOptions, "laySaveLayoutOptions.rb") diff --git a/src/tl/tl/tlCopyOnWrite.h b/src/tl/tl/tlCopyOnWrite.h index 717688592..984f52eec 100644 --- a/src/tl/tl/tlCopyOnWrite.h +++ b/src/tl/tl/tlCopyOnWrite.h @@ -26,6 +26,7 @@ #include "tlCommon.h" #include "tlThreads.h" +#include namespace tl { @@ -143,6 +144,19 @@ public: release (); } + /** + * @brief Swaps two pointers + */ + void swap (copy_on_write_ptr &other) + { + if (this == &other) { + return; + } + + tl::MutexLocker locker (&ms_lock); + std::swap (mp_holder, other.mp_holder); + } + /** * @brief Gets a writable object * This is when we will create a new copy if the object is shared. @@ -236,7 +250,6 @@ public: } private: - X *mp_x; copy_on_write_holder *mp_holder; void release () diff --git a/src/tl/unit_tests/tlFileSystemWatcherTests.cc b/src/tl/unit_tests/tlFileSystemWatcherTests.cc index fda2a0157..da732dd60 100644 --- a/src/tl/unit_tests/tlFileSystemWatcherTests.cc +++ b/src/tl/unit_tests/tlFileSystemWatcherTests.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlFileSystemWatcher.h" #include "tlString.h" @@ -218,3 +219,4 @@ TEST(3) EXPECT_EQ (changed_spy.count (), 0); } +#endif diff --git a/src/tl/unit_tests/unit_tests.pro b/src/tl/unit_tests/unit_tests.pro index 667e447bd..768faad17 100644 --- a/src/tl/unit_tests/unit_tests.pro +++ b/src/tl/unit_tests/unit_tests.pro @@ -36,11 +36,10 @@ SOURCES = \ tlUniqueIdTests.cc \ tlListTests.cc \ tlEquivalenceClustersTests.cc \ - tlUniqueNameTests.cc \ - tlGlobPatternTests.cc \ - tlRecipeTests.cc \ - tlUriTests.cc \ - tlUtilsTests.cc \ + tlUniqueNameTests.cc \ + tlGlobPatternTests.cc \ + tlRecipeTests.cc \ + tlUriTests.cc \ tlVariantTests.cc \ tlWebDAVTests.cc \ tlXMLParserTests.cc diff --git a/src/with_all_libs.pri b/src/with_all_libs.pri index b3bed76b0..23ea4963e 100644 --- a/src/with_all_libs.pri +++ b/src/with_all_libs.pri @@ -1,20 +1,15 @@ -INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC -DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC +INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC +DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC -LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lib +LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_ant -lklayout_img -lklayout_edt -lklayout_lib !equals(HAVE_QT, "0") { - INCLUDEPATH += $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC - DEPENDPATH += $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC + INCLUDEPATH += $$LAYUI_INC $$LAY_INC + DEPENDPATH += $$LAYUI_INC $$LAY_INC - LIBS += -L$$DESTDIR -lklayout_lym -lklayout_laybasic -lklayout_lay -lklayout_ant -lklayout_img -lklayout_edt - - # Note: this accounts for UI-generated headers placed into the output folders in - # shadow builds: - INCLUDEPATH += $$DESTDIR/laybasic $$DESTDIR/lay $$DESTDIR/ext - DEPENDPATH += $$DESTDIR/laybasic $$DESTDIR/lay $$DESTDIR/ext + LIBS += -L$$DESTDIR -lklayout_layui -lklayout_lay equals(HAVE_QTBINDINGS, "1") { LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore diff --git a/testdata/lay/au.png b/testdata/lay/au.png new file mode 100644 index 000000000..bc4c91684 Binary files /dev/null and b/testdata/lay/au.png differ diff --git a/testdata/lay/au_diff.png b/testdata/lay/au_diff.png new file mode 100644 index 000000000..f29dacca6 Binary files /dev/null and b/testdata/lay/au_diff.png differ diff --git a/testdata/lay/au_gs.png b/testdata/lay/au_gs.png new file mode 100644 index 000000000..427b121bd Binary files /dev/null and b/testdata/lay/au_gs.png differ diff --git a/testdata/lay/au_lv1.png b/testdata/lay/au_lv1.png new file mode 100644 index 000000000..e3837aa1f Binary files /dev/null and b/testdata/lay/au_lv1.png differ diff --git a/testdata/lay/au_lv2.png b/testdata/lay/au_lv2.png new file mode 100644 index 000000000..b0de56c46 Binary files /dev/null and b/testdata/lay/au_lv2.png differ diff --git a/testdata/lay/au_lv3.png b/testdata/lay/au_lv3.png new file mode 100644 index 000000000..aaeaa9290 Binary files /dev/null and b/testdata/lay/au_lv3.png differ diff --git a/testdata/lay/au_mono.png b/testdata/lay/au_mono.png new file mode 100644 index 000000000..5b7781c39 Binary files /dev/null and b/testdata/lay/au_mono.png differ diff --git a/testdata/lay/png1.png b/testdata/lay/png1.png new file mode 100644 index 000000000..6c49d37b2 Binary files /dev/null and b/testdata/lay/png1.png differ diff --git a/testdata/lay/png2.png b/testdata/lay/png2.png new file mode 100644 index 000000000..0bb1a8a00 Binary files /dev/null and b/testdata/lay/png2.png differ diff --git a/testdata/lay/png3.png b/testdata/lay/png3.png new file mode 100644 index 000000000..23ea8d767 Binary files /dev/null and b/testdata/lay/png3.png differ diff --git a/testdata/lay/png4.png b/testdata/lay/png4.png new file mode 100644 index 000000000..c22aa09cc Binary files /dev/null and b/testdata/lay/png4.png differ diff --git a/testdata/pymod/import_lay.py b/testdata/pymod/import_lay.py index bb5127a93..3d37f0e5e 100755 --- a/testdata/pymod/import_lay.py +++ b/testdata/pymod/import_lay.py @@ -16,28 +16,42 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import testprep -import klayout.QtCore -import klayout.QtGui -if not "QApplication" in klayout.QtGui.__all__: - import klayout.QtWidgets # Qt5 +import klayout.db as db import klayout.lay as lay import unittest import sys +def can_create_layoutview(): + if not "MainWindow" in lay.__dict__: + return True # Qt-less + elif not "Application" in lay.__dict__: + return False # cannot instantiate Application + elif lay.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + # Tests the basic abilities of the module class BasicTest(unittest.TestCase): def test_1(self): - self.assertEqual("Annotation" in lay.__all__, True) + + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be instantiated") + return + + lv = lay.LayoutView() + lv.resize(800, 600) + lv.zoom_box(db.DBox(-42, -17, 142, 117)) + bx = lv.box() + self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)") def test_2(self): - # Some smoke test - ant = lay.Annotation() - ant.style = lay.Annotation.StyleRuler - self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) - ant.fmt_x = "abc" - self.assertEqual(ant.fmt_x, "abc") + + p = lay.LayerPropertiesNode() + p.name = "u" + self.assertEqual(p.name, "u") # run unit tests if __name__ == '__main__': diff --git a/testdata/pymod/import_lay_noqt.py b/testdata/pymod/import_lay_noqt.py deleted file mode 100755 index f12c4b34c..000000000 --- a/testdata/pymod/import_lay_noqt.py +++ /dev/null @@ -1,47 +0,0 @@ -# KLayout Layout Viewer -# Copyright (C) 2006-2022 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 - -import testprep -import klayout.db as db -import klayout.lay as lay -import unittest -import sys - -# Tests the basic abilities of the module - -class BasicTest(unittest.TestCase): - - def test_1(self): - self.assertEqual("Annotation" in lay.__all__, True) - - def test_2(self): - # Some smoke test - ant = lay.Annotation() - ant.style = lay.Annotation.StyleRuler - self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) - ant.fmt_x = "abc" - self.assertEqual(ant.fmt_x, "abc") - -# run unit tests -if __name__ == '__main__': - suite = unittest.TestSuite() - suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest) - - if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): - sys.exit(1) - - diff --git a/testdata/pymod/pya_tests.py b/testdata/pymod/pya_tests.py index c026e721b..a0c12e856 100644 --- a/testdata/pymod/pya_tests.py +++ b/testdata/pymod/pya_tests.py @@ -18,6 +18,10 @@ import dbPolygonTest import dbReaders import dbRegionTest import dbTransTest +import dbLayoutToNetlist +import dbLayoutVsSchematic +import dbNetlistCrossReference +import layLayers if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(tlTest.TLTest) @@ -27,6 +31,10 @@ if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(dbReaders.DBReadersTests) suite = unittest.TestLoader().loadTestsFromTestCase(dbRegionTest.DBRegionTest) suite = unittest.TestLoader().loadTestsFromTestCase(dbTransTest.DBTransTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutToNetlist.DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutVsSchematic.DBLayoutVsSchematicTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbNetlistCrossReference.DBNetlistCrossReferenceTests) + suite = unittest.TestLoader().loadTestsFromTestCase(layLayers.LAYLayersTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/dbLayoutVsSchematic.py b/testdata/python/dbLayoutVsSchematic.py index 3b67b9fbf..3e8f0f0d4 100644 --- a/testdata/python/dbLayoutVsSchematic.py +++ b/testdata/python/dbLayoutVsSchematic.py @@ -23,7 +23,7 @@ import unittest import sys import os -class DBLayoutToNetlistTests(unittest.TestCase): +class DBLayoutVsSchematicTests(unittest.TestCase): def test_1_Basic(self): @@ -177,7 +177,7 @@ class DBLayoutToNetlistTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutVsSchematicTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/dbNetlistCrossReference.py b/testdata/python/dbNetlistCrossReference.py index bc9f26055..7ed25ea57 100644 --- a/testdata/python/dbNetlistCrossReference.py +++ b/testdata/python/dbNetlistCrossReference.py @@ -23,7 +23,7 @@ import unittest import sys import os -class DBLayoutToNetlistTests(unittest.TestCase): +class DBNetlistCrossReferenceTests(unittest.TestCase): def test_1_Basic(self): @@ -179,7 +179,7 @@ class DBLayoutToNetlistTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBNetlistCrossReferenceTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/layLayers.py b/testdata/python/layLayers.py index d636b772e..b0af39c26 100644 --- a/testdata/python/layLayers.py +++ b/testdata/python/layLayers.py @@ -21,13 +21,23 @@ import unittest import os import sys +def can_create_layoutview(): + if not "MainWindow" in pya.__dict__: + return True # Qt-less + elif not "Application" in pya.__dict__: + return False # cannot instantiate Application + elif pya.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + def astr(a): astr = [] for i in a: astr.append(str(i)) return "[" + ", ".join(astr) + "]" -class LAYLayersTest(unittest.TestCase): +class LAYLayersTests(unittest.TestCase): def lnode_str(self, space, l): return space + l.current().source_(True) + "\n"; @@ -57,14 +67,13 @@ class LAYLayersTest(unittest.TestCase): def test_1(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -203,18 +212,19 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(self.lnodes_str("", cv.begin_layers()), "*/*@*\n 1/0@1\n 1/0@2\n%5@2\n %5@2\n") - mw.close_all() + cv._destroy() def test_1a(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) + mgr = pya.Manager() - cv = mw.current_view() + cv = pya.LayoutView(False, mgr) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -396,7 +406,7 @@ class LAYLayersTest(unittest.TestCase): cv.delete_layers(0, a) self.assertEqual(cv.begin_layers(0).at_end(), True) cv.commit() - mw.cm_undo() + mgr.undo() self.assertEqual(cv.begin_layers(0).at_end(), False) cv.transaction("Delete") @@ -407,10 +417,10 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(i, 2) self.assertEqual(cv.begin_layers(0).at_end(), True) cv.commit() - mw.cm_undo() + mgr.undo() self.assertEqual(cv.begin_layers(0).at_end(), False) - mw.close_all() + cv._destroy() def test_2(self): @@ -655,14 +665,14 @@ class LAYLayersTest(unittest.TestCase): # direct replacement of objects and attributes def test_3(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", 2) + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True) - cv = mw.current_view() self.assertEqual(self.lnodes_str("", cv.begin_layers()), "1/0@1\n2/0@1\n1/0@2\n2/0@2\n3/0@2\n3/1@2\n4/0@2\n5/0@2\n6/0@2\n6/1@2\n7/0@2\n8/0@2\n8/1@2\n") cv.clear_layers() @@ -772,19 +782,18 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(self.lnodes_str("", cv.begin_layers()), "TOP@1\n nn1@1\n nn1@1\n") self.assertEqual(self.lnodes_str2(cv), "TOP@1\nnn1@1\nnn1@1") - mw.close_all() + cv._destroy() # propagation of "real" attributes through the hierarchy def test_4(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -807,18 +816,18 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(pos.first_child().current().visible_(True), False) self.assertEqual(pos.first_child().current().visible_(False), True) - mw.close_all() + cv._destroy() # delete method of iterator def test_5(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) - cv = mw.current_view() cv.clear_layers() new_p = pya.LayerProperties() @@ -899,18 +908,17 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(pc.at_end(), True) self.assertEqual(pc.current().is_valid(), False) - mw.close_all() + cv._destroy() # custom stipples and line styles def test_6(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.clear_stipples() @@ -944,7 +952,7 @@ class LAYLayersTest(unittest.TestCase): cv.clear_line_styles() self.assertEqual(cv.get_line_style(index), "") - mw.close_all() + cv._destroy() # run unit tests @@ -952,7 +960,7 @@ if __name__ == '__main__': suite = unittest.TestSuite() # NOTE: Use this instead of loadTestsfromTestCase to select a specific test: # suite.addTest(BasicTest("test_26")) - suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTest) + suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTests) # Only runs with Application available if "Application" in pya.__all__ and not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 0a2a69d21..456480a0d 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -423,6 +423,64 @@ class LAYLayoutView_TestClass < TestBase end + def test_4 + + # check if PNG support is compiled in + # TODO: remove this once PNG support is available on all platforms + begin + RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv1.png")) + rescue => ex + # PNG support missing + puts "WARNING: PNG support not compiled in - skipping test" + return + end + + # standalone image generation (see C++ tests) + lv = RBA::LayoutView::new + lv.set_config("inst-color", "#000000") + lv.set_config("background-color", "#ffffff") + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), true) + + img = lv.get_pixels_with_options(500, 500, 1, 1, 1.0, RBA::DBox::new) + au = RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv1.png")) + if au + assert_equal(au == img, true) + end + + lv.set_config("full-hierarchy-new-cell", "true") + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), false) + + img = lv.get_pixels_with_options(500, 500, 1, 1, 1.0, RBA::DBox::new) + au = RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv2.png")) + if au + assert_equal(au == img, true) + end + + img = lv.get_pixels_with_options_mono(500, 500, 1, RBA::DBox::new) + au = RBA::BitmapBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv3.png")) + if au + assert_equal(au == img, true) + end + + end + + def test_5 + + lv = RBA::LayoutView::new + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), true) + + lv.resize(42, 117) + img = lv.get_screenshot_pixels + assert_equal(img.width, 42) + assert_equal(img.height, 117) + + lv.resize(142, 217) + img = lv.get_screenshot_pixels + assert_equal(img.width, 142) + assert_equal(img.height, 217) + + end + end load("test_epilogue.rb") diff --git a/testdata/ruby/layPixelBuffer.rb b/testdata/ruby/layPixelBuffer.rb new file mode 100644 index 000000000..400df1338 --- /dev/null +++ b/testdata/ruby/layPixelBuffer.rb @@ -0,0 +1,235 @@ +# encoding: UTF-8 + +# KLayout Layout Viewer +# Copyright (C) 2006-2022 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 + +if !$:.member?(File::dirname($0)) + $:.push(File::dirname($0)) +end + +load("test_prologue.rb") + +class LAYPixelBuffer_TestClass < TestBase + + def compare(pb1, pb2) + if pb1.width != pb2.width || pb1.height != pb2.height + return false + end + pb1.width.times do |x| + pb1.height.times do |y| + if pb1.pixel(x, y) != pb2.pixel(x, y) + return false + end + end + end + return true + end + + def test_1 + + pb_null = RBA::PixelBuffer::new + assert_equal(pb_null.width, 0) + assert_equal(pb_null.height, 0) + + pb = RBA::PixelBuffer::new(10, 20) + assert_equal(compare(pb_null, pb), false) + assert_equal(pb_null == pb, false) + assert_equal(pb.width, 10) + assert_equal(pb.height, 20) + assert_equal(pb.transparent, false) + + pb_copy = pb.dup + pb.transparent = true + assert_equal(pb.transparent, true) + assert_equal(pb_copy == pb, false) + + pb.fill(0xf0010203) + assert_equal(pb.pixel(0, 0), 0xf0010203) + assert_equal(pb.pixel(1, 2), 0xf0010203) + + pb.set_pixel(1, 2, 0xff102030) + assert_equal(pb.pixel(0, 0), 0xf0010203) + assert_equal(pb.pixel(1, 2), 0xff102030) + + pb.transparent = false + assert_equal(pb.transparent, false) + + pb_copy = pb.dup + assert_equal(compare(pb_copy, pb), true) + assert_equal(pb_copy == pb, true) + pb.set_pixel(1, 2, 0x112233) + assert_equal(pb.pixel(0, 0), 0xf0010203) + assert_equal(pb.pixel(1, 2), 0xff112233) + assert_equal(pb_copy.pixel(1, 2), 0xff102030) + + assert_equal(compare(pb_copy, pb), false) + assert_equal(pb_copy == pb, false) + + pb_copy.swap(pb) + assert_equal(pb_copy.pixel(1, 2), 0xff112233) + assert_equal(pb.pixel(1, 2), 0xff102030) + + end + + def test_2 + + pb = RBA::PixelBuffer::new(10, 20) + pb.fill(0xf0010203) + + pb1 = pb.dup + pb.set_pixel(1, 2, 0x112233) + + assert_equal(compare(pb1, pb), false) + assert_equal(pb1 == pb, false) + + diff = pb1.diff(pb) + pb1.patch(diff) + assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) + + end + + def test_3 + + pb = RBA::PixelBuffer::new(10, 20) + pb.fill(0xf0010203) + + pb1 = pb.dup + pb.set_pixel(1, 2, 0x112233) + + pb1 = pb.dup + pb.set_pixel(1, 2, 0xf0112233) + assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) # not transparent -> alpha is ignored + + pb1.transparent = true + pb.transparent = true + assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) + + pb.set_pixel(1, 2, 0xf0112233) + assert_equal(compare(pb1, pb), false) + assert_equal(pb1 == pb, false) # now, alpha matters + + end + + def test_4 + + pb = RBA::PixelBuffer::new(10, 20) + pb.transparent = true + pb.fill(0xf0010203) + + if pb.respond_to?(:to_qimage) + assert_equal(pb.to_qimage.pixel(2, 3), 0xf0010203) + pb_copy = RBA::PixelBuffer::from_qimage(pb.to_qimage) + assert_equal(compare(pb, pb_copy), true) + end + + png = nil + begin + png = pb.to_png_data + rescue => ex + # No PNG support + end + + if png + + assert_equal(png.size > 20 && png.size < 200, true) # some range because implementations may differ + pb_copy = RBA::PixelBuffer.from_png_data(png) + assert_equal(compare(pb, pb_copy), true) + + tmp = File::join($ut_testtmp, "tmp.png") + pb.write_png(tmp) + pb_copy = RBA::PixelBuffer.read_png(tmp) + assert_equal(compare(pb, pb_copy), true) + + end + + end + + def test_11 + + pb = RBA::BitmapBuffer::new + assert_equal(pb.width, 0) + assert_equal(pb.height, 0) + + pb = RBA::BitmapBuffer::new(10, 20) + assert_equal(pb.width, 10) + assert_equal(pb.height, 20) + + pb.fill(false) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), false) + + pb.set_pixel(1, 2, true) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), true) + + pb_copy = pb.dup + assert_equal(compare(pb_copy, pb), true) + pb.set_pixel(1, 3, true) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), true) + assert_equal(pb.pixel(1, 3), true) + assert_equal(pb_copy.pixel(1, 3), false) + + assert_equal(compare(pb_copy, pb), false) + + pb_copy.swap(pb) + assert_equal(pb.pixel(1, 3), false) + assert_equal(pb_copy.pixel(1, 3), true) + + end + + def test_12 + + pb = RBA::BitmapBuffer::new(10, 20) + pb.fill(false) + pb.set_pixel(2, 3, true) + + if pb.respond_to?(:to_qimage) + assert_equal(pb.to_qimage.pixel(0, 0), 0xff000000) + assert_equal(pb.to_qimage.pixel(2, 3), 0xffffffff) + pb_copy = RBA::BitmapBuffer::from_qimage(pb.to_qimage) + assert_equal(compare(pb, pb_copy), true) + end + + png = nil + begin + png = pb.to_png_data + rescue => ex + # No PNG support + end + + if png + + assert_equal(png.size > 20 && png.size < 200, true) # some range because implementations may differ + pb_copy = RBA::BitmapBuffer.from_png_data(png) + assert_equal(compare(pb, pb_copy), true) + + tmp = File::join($ut_testtmp, "tmp.png") + pb.write_png(tmp) + pb_copy = RBA::BitmapBuffer.read_png(tmp) + assert_equal(compare(pb, pb_copy), true) + + end + + end + +end + +load("test_epilogue.rb")