diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0f77cc..4b51097 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,21 +4,25 @@ on: push: pull_request: workflow_dispatch: - inputs: - forceMacBuild: - description: 'If set true override the ENABLE_MACOS_BUILD to force a build' - type: boolean - default: false env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release - MACENABLED: ${{ inputs.forceMacBuild }} # for matrix check https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners jobs: + prepare_matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix_setup.outputs.matrix }} + steps: + - name: Get matrix from file + id: matrix_setup + uses: ManiVaultStudio/github-actions/matrix_setup@main + cross-platform-build: name: Cross platform build + needs: prepare_matrix # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. @@ -26,44 +30,19 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - include: - - name: Windows-msvc2019 - os: windows-2019 - compiler: msvc-2019 - build-cversion: 16 - build-runtime: MD - build-config: Release - - - name: Linux_gcc10 - os: ubuntu-22.04 - build-cc: gcc - build-cxx: g++ - build-compiler: gcc - build-cversion: 10 - build-config: Release - build-os: Linux - build-libcxx: libstdc++ - - - name: Macos_xcode12.4 - os: macos-11 - build-compiler: apple-clang - build-cversion: "12.0" - build-config: Release - build-os: Macos - build-xcode-version: 12.4 - build-libcxx: libc++ + include: ${{ fromJson(needs.prepare_matrix.outputs.matrix) }} steps: - name: Checkout the source if: github.event_name != 'pull_request' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: Checkout the source - pull request if: github.event_name == 'pull_request' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 @@ -75,19 +54,12 @@ jobs: sudo xcode-select -switch /Applications/Xcode_${{matrix.build-xcode-version}}.app - name: Setup python version - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: - python-version: "3.7" - - # windows-2016 need the SSHAgentFeature added - - name: Start ssh key agent - if: matrix.os == 'windows-2016' - run: | - choco install --no-progress -my openssh --params '"/SSHAgentFeature"' - refreshenv + python-version: "3.11" - name: Start ssh key agent - uses: webfactory/ssh-agent@v0.5.0 + uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }} @@ -118,6 +90,7 @@ jobs: conan-libcxx-version: ${{matrix.build-libcxx}} conan-build-type: ${{matrix.build-config}} conan-build-os: ${{matrix.build-os}} + build-arch: ${{matrix.build-arch}} conan-user: ${{secrets.LKEB_UPLOAD_USER}} conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}} conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}} @@ -125,7 +98,7 @@ jobs: conan-cxx: g++-${{matrix.build-cversion}} - name: Mac build - if: startsWith(matrix.os, 'macos') && (env.MACENABLED == 'true' || vars.ENABLE_MACOS_BUILD == 'True') + if: startsWith(matrix.os, 'macos') uses: ManiVaultStudio/github-actions/conan_linuxmac_build@main with: conan-compiler: ${{matrix.build-compiler}} @@ -133,6 +106,7 @@ jobs: conan-libcxx-version: ${{matrix.build-libcxx}} conan-build-type: ${{matrix.build-config}} conan-build-os: ${{matrix.build-os}} + build-arch: ${{matrix.build-arch}} conan-user: ${{secrets.LKEB_UPLOAD_USER}} conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}} conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/CMakeLists.txt b/CMakeLists.txt index a4f9ac9..37b66ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,56 +1,77 @@ -cmake_minimum_required(VERSION 3.17) +cmake_minimum_required(VERSION 3.22) +# ----------------------------------------------------------------------------- +# PointDataConversion Plugin +# ----------------------------------------------------------------------------- set(PROJECT "PointDataConversionPlugin") -PROJECT(${PROJECT}) +PROJECT(${PROJECT} + DESCRIPTION "point data conversion plugin for ManiVault" + LANGUAGES CXX +) +# ----------------------------------------------------------------------------- +# CMake Options +# ----------------------------------------------------------------------------- set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -if(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") -endif(MSVC) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") +endif() +# ----------------------------------------------------------------------------- +# Dependencies +# ----------------------------------------------------------------------------- find_package(Qt6 COMPONENTS Widgets WebEngineWidgets REQUIRED) +find_package(ManiVault COMPONENTS Core PointData CONFIG QUIET) + +# ----------------------------------------------------------------------------- +# Source files +# ----------------------------------------------------------------------------- set(SOURCES src/PointDataConversionPlugin.h src/PointDataConversionPlugin.cpp - src/PointDataConversionPlugin.json ) -source_group(Plugin FILES ${SOURCES}) +set(AUX + PluginInfo.json +) -# Check if the directory to the ManiVault installation has been provided -if(NOT DEFINED MV_INSTALL_DIR) - set(MV_INSTALL_DIR "" CACHE PATH "Directory where ManiVault is installed") - message(FATAL_ERROR "Please set MV_INSTALL_DIR to the directory where ManiVault is installed") -endif() -file(TO_CMAKE_PATH ${MV_INSTALL_DIR} MV_INSTALL_DIR) +source_group(Plugin FILES ${SOURCES} ${AUX}) -add_library(${PROJECT} SHARED ${SOURCES}) +# ----------------------------------------------------------------------------- +# CMake Target +# ----------------------------------------------------------------------------- +add_library(${PROJECT} SHARED ${SOURCES} ${AUX}) -target_include_directories(${PROJECT} PRIVATE "${MV_INSTALL_DIR}/$/include/") +# ----------------------------------------------------------------------------- +# Target include directories +# ----------------------------------------------------------------------------- +target_include_directories(${PROJECT} PRIVATE "${ManiVault_INCLUDE_DIR}") -target_compile_features(${PROJECT} PRIVATE cxx_std_17) +# ----------------------------------------------------------------------------- +# Target properties +# ----------------------------------------------------------------------------- +target_compile_features(${PROJECT} PRIVATE cxx_std_20) +# ----------------------------------------------------------------------------- +# Target library linking +# ----------------------------------------------------------------------------- target_link_libraries(${PROJECT} PRIVATE Qt6::Widgets) target_link_libraries(${PROJECT} PRIVATE Qt6::WebEngineWidgets) -set(MV_LINK_PATH "${MV_INSTALL_DIR}/$/lib") -set(PLUGIN_LINK_PATH "${MV_INSTALL_DIR}/$/$,lib,Plugins>") -set(MV_LINK_SUFFIX $,${CMAKE_LINK_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>) - -set(MV_LINK_LIBRARY "${MV_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}MV_Public${MV_LINK_SUFFIX}") -set(POINTDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}PointData${MV_LINK_SUFFIX}") - -target_link_libraries(${PROJECT} PRIVATE "${MV_LINK_LIBRARY}") -target_link_libraries(${PROJECT} PRIVATE "${POINTDATA_LINK_LIBRARY}") +target_link_libraries(${PROJECT} PRIVATE ManiVault::Core) +target_link_libraries(${PROJECT} PRIVATE ManiVault::PointData) +# ----------------------------------------------------------------------------- +# Target installation +# ----------------------------------------------------------------------------- install(TARGETS ${PROJECT} RUNTIME DESTINATION Plugins COMPONENT PLUGINS # Windows .dll LIBRARY DESTINATION Plugins COMPONENT PLUGINS # Linux/Mac .so @@ -60,12 +81,17 @@ add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND "${CMAKE_COMMAND}" --install ${CMAKE_CURRENT_BINARY_DIR} --config $ - --prefix ${MV_INSTALL_DIR}/$ + --prefix ${ManiVault_INSTALL_DIR}/$ --verbose ) +mv_handle_plugin_config(${PROJECT}) + +# ----------------------------------------------------------------------------- +# Misc +# ----------------------------------------------------------------------------- # Automatically set the debug environment (command + working directory) for MSVC -if(MSVC) - set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $,${MV_INSTALL_DIR}/debug,${MV_INSTALL_DIR}/release>) - set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_COMMAND $,"${MV_INSTALL_DIR}/debug/ManiVault Studio.exe","${MV_INSTALL_DIR}/release/ManiVault Studio.exe">) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $,${ManiVault_INSTALL_DIR}/Debug,$,${ManiVault_INSTALL_DIR}/RelWithDebInfo,${ManiVault_INSTALL_DIR}/Release>>) + set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_COMMAND $,"${ManiVault_INSTALL_DIR}/Debug/ManiVault Studio.exe",$,"${ManiVault_INSTALL_DIR}/RelWithDebInfo/ManiVault Studio.exe","${ManiVault_INSTALL_DIR}/Release/ManiVault Studio.exe">>) endif() diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4b7725f --- /dev/null +++ b/LICENSE @@ -0,0 +1,167 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + END OF TERMS AND CONDITIONS diff --git a/PluginInfo.json b/PluginInfo.json new file mode 100644 index 0000000..b498d0a --- /dev/null +++ b/PluginInfo.json @@ -0,0 +1,9 @@ +{ + "name": "PointDataConversion", + "version" : { + "plugin" : "1.0.0", + "core" : ["1.3"] + }, + "type" : "Transformation", + "dependencies": [ "Points" ] +} diff --git a/README.md b/README.md index 6b7769e..93bd74b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ -# Point data conversion plugin -HDPS plugin for point data conversion +# Point data conversion plugin ![Build Status](https://github.com/ManiVaultStudio/PointDataConversionPlugin/actions/workflows/build.yml/badge.svg?branch=main) + +Point data conversion plugin for the [ManiVault](https://github.com/ManiVaultStudio/core) visual analytics framework. + +```bash +git clone git@github.com:ManiVaultStudio/PointDataConversionPlugin.git +``` + +Applies an element-wise transformation to a selected dataset in-place. + +Implemented transformations: +- [Inverse hyperbolic sine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) (`asinh`) +- [Binary logarithm](https://en.wikipedia.org/wiki/Binary_logarithm) (`log2`) + +## How to use +- Right-click on a point dataset and select `Transform` -> `Conversion` and chose the transformation function diff --git a/conanfile.py b/conanfile.py index 68c03ca..850b06f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,16 +11,16 @@ class PointDataConversionPluginConan(ConanFile): """Class to package the PointDataConversionPlugin using conan - Packages both RELEASE and DEBUG. - Uses rules_support (github.com/hdps/rulessupport) to derive + Packages both RELEASE and RELWITHDEBINFO. + Uses rules_support (github.com/ManiVaultStudio/rulessupport) to derive versioninfo based on the branch naming convention - as described in https://github.com/hdps/core/wiki/Branch-naming-rules + as described in https://github.com/ManiVaultStudio/core/wiki/Branch-naming-rules """ name = "PointDataConversionPlugin" description = "Convert point data" topics = ("hdps", "plugin", "data", "point data conversion") - url = "https://github.com/hdps/PointDataConversionPlugin" + url = "https://github.com/ManiVaultStudio/PointDataConversionPlugin" author = "B. van Lew b.van_lew@lumc.nl" # conan recipe author license = "MIT" # conan recipe license @@ -81,25 +81,26 @@ def generate(self): generator = "Xcode" if self.settings.os == "Linux": generator = "Ninja Multi-Config" - # Use the Qt provided .cmake files - qtpath = pathlib.Path(self.deps_cpp_info["qt"].rootpath) - qt_root = str(list(qtpath.glob("**/Qt6Config.cmake"))[0].parents[3].as_posix()) tc = CMakeToolchain(self, generator=generator) - if self.settings.os == "Windows" and self.options.shared: - tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True - if self.settings.os == "Linux" or self.settings.os == "Macos": - tc.variables["CMAKE_CXX_STANDARD_REQUIRED"] = "ON" - tc.variables["CMAKE_PREFIX_PATH"] = qt_root - - # Set the installation directory for ManiVault based on the MV_INSTALL_DIR environment variable - # or if none is specified, set it to the build/install dir. - if not os.environ.get("MV_INSTALL_DIR", None): - os.environ["MV_INSTALL_DIR"] = os.path.join(self.build_folder, "install") - print("MV_INSTALL_DIR: ", os.environ["MV_INSTALL_DIR"]) - self.install_dir = pathlib.Path(os.environ["MV_INSTALL_DIR"]).as_posix() - # Give the installation directory to CMake - tc.variables["MV_INSTALL_DIR"] = self.install_dir + + tc.variables["CMAKE_CXX_STANDARD_REQUIRED"] = "ON" + + # Use the Qt provided .cmake files + qt_path = pathlib.Path(self.deps_cpp_info["qt"].rootpath) + qt_cfg = list(qt_path.glob("**/Qt6Config.cmake"))[0] + qt_dir = qt_cfg.parents[0].as_posix() + + tc.variables["Qt6_DIR"] = qt_dir + + # Use the ManiVault .cmake file to find ManiVault with find_package + mv_core_root = self.deps_cpp_info["hdps-core"].rootpath + manivault_dir = pathlib.Path(mv_core_root, "cmake", "mv").as_posix() + print("ManiVault_DIR: ", manivault_dir) + tc.variables["ManiVault_DIR"] = manivault_dir + + # Set some build options + tc.variables["MV_UNITY_BUILD"] = "ON" tc.generate() @@ -110,22 +111,16 @@ def _configure_cmake(self): return cmake def build(self): - print("Build OS is : ", self.settings.os) - - hdps_pkg_root = self.deps_cpp_info["hdps-core"].rootpath - print("Install dir type: ", self.install_dir) - shutil.copytree(hdps_pkg_root, self.install_dir) + print("Build OS is: ", self.settings.os) cmake = self._configure_cmake() - cmake.build(build_type="Debug") - cmake.install(build_type="Debug") - - # cmake_release = self._configure_cmake() + cmake.build(build_type="RelWithDebInfo") cmake.build(build_type="Release") - cmake.install(build_type="Release") def package(self): - package_dir = os.path.join(self.build_folder, "package") + package_dir = pathlib.Path(self.build_folder, "package") + relWithDebInfo_dir = package_dir / "RelWithDebInfo" + release_dir = package_dir / "Release" print("Packaging install dir: ", package_dir) subprocess.run( [ @@ -133,9 +128,9 @@ def package(self): "--install", self.build_folder, "--config", - "Debug", + "RelWithDebInfo", "--prefix", - os.path.join(package_dir, "Debug"), + relWithDebInfo_dir, ] ) subprocess.run( @@ -146,15 +141,15 @@ def package(self): "--config", "Release", "--prefix", - os.path.join(package_dir, "Release"), + release_dir, ] ) self.copy(pattern="*", src=package_dir) def package_info(self): - self.cpp_info.debug.libdirs = ["Debug/lib"] - self.cpp_info.debug.bindirs = ["Debug/Plugins", "Debug"] - self.cpp_info.debug.includedirs = ["Debug/include", "Debug"] + self.cpp_info.relwithdebinfo.libdirs = ["RelWithDebInfo/lib"] + self.cpp_info.relwithdebinfo.bindirs = ["RelWithDebInfo/Plugins", "RelWithDebInfo"] + self.cpp_info.relwithdebinfo.includedirs = ["RelWithDebInfo/include", "RelWithDebInfo"] self.cpp_info.release.libdirs = ["Release/lib"] self.cpp_info.release.bindirs = ["Release/Plugins", "Release"] - self.cpp_info.release.includedirs = ["Release/include", "Release"] + self.cpp_info.release.includedirs = ["Release/include", "Release"] \ No newline at end of file diff --git a/src/PointDataConversionPlugin.cpp b/src/PointDataConversionPlugin.cpp index 32c3f59..bfa1dd2 100644 --- a/src/PointDataConversionPlugin.cpp +++ b/src/PointDataConversionPlugin.cpp @@ -8,13 +8,13 @@ #include -Q_PLUGIN_METADATA(IID "nl.BioVault.PointDataConversionPlugin") +Q_PLUGIN_METADATA(IID "studio.manivault.PointDataConversionPlugin") using namespace mv; -const QMap PointDataConversionPlugin::types = QMap({ - { PointDataConversionPlugin::Type::Log2, "Log2" }, - { PointDataConversionPlugin::Type::ArcSin, "Arcsin" } +const QMap PointDataConversionPlugin::types = QMap({ + { Type::Log2, "Log2" }, + { Type::ArcSin, "Arcsin" } }); PointDataConversionPlugin::PointDataConversionPlugin(const PluginFactory* factory) : @@ -25,55 +25,50 @@ PointDataConversionPlugin::PointDataConversionPlugin(const PluginFactory* factor void PointDataConversionPlugin::transform() { - for (auto inputDataset : getInputDatasets()) { - auto points = Dataset(inputDataset); + auto points = getInputDataset(); - if (!points.isValid()) - continue; + if (!points.isValid()) + return; - QApplication::processEvents(); - - auto& task = points->getTask(); - - task.setName("Converting"); - task.setRunning(); - task.setProgressDescription(QString("%1 conversion").arg(getTypeName(_type))); + QApplication::processEvents(); - points->visitData([this, &points, &task](auto pointData) { - std::uint32_t noPointsProcessed = 0; + auto& task = points->getTask(); - for (auto point : pointData) { - for (std::int32_t dimensionIndex = 0; dimensionIndex < points->getNumDimensions(); dimensionIndex++) { - switch (_type) - { - case PointDataConversionPlugin::Type::Log2: - point[dimensionIndex] = log2(point[dimensionIndex] + 1); - break; + task.setName("Converting"); + task.setRunning(); + task.setProgressDescription(QString("%1 conversion").arg(getTypeName(_type))); + + points->visitData([this, &points, &task](auto pointData) { + std::uint32_t noPointsProcessed = 0; - case PointDataConversionPlugin::Type::ArcSin: - point[dimensionIndex] = asinh(point[dimensionIndex] / 5.0f); - break; + for (auto point : pointData) { + for (std::int32_t dimensionIndex = 0; dimensionIndex < points->getNumDimensions(); dimensionIndex++) { + switch (_type) + { + case Type::Log2: + point[dimensionIndex] = std::log2f(point[dimensionIndex] + 1.0f); + break; - default: - break; - } + case Type::ArcSin: + point[dimensionIndex] = std::asinhf(point[dimensionIndex] / 5.0f); + break; } + } - ++noPointsProcessed; + ++noPointsProcessed; - if (noPointsProcessed % 1000 == 0) { - task.setProgress(static_cast(noPointsProcessed) / static_cast(points->getNumPoints())); + if (noPointsProcessed % 1000 == 0) { + task.setProgress(static_cast(noPointsProcessed) / static_cast(points->getNumPoints())); - QApplication::processEvents(); - } + QApplication::processEvents(); } - }); + } + }); - task.setProgress(1.0f); - task.setFinished(); + task.setProgress(1.0f); + task.setFinished(); - events().notifyDatasetDataChanged(points); - } + events().notifyDatasetDataChanged(points); } PointDataConversionPlugin::Type PointDataConversionPlugin::getType() const @@ -115,11 +110,11 @@ PluginTriggerActions PointDataConversionPluginFactory::getPluginTriggerActions(c const auto addPluginTriggerAction = [this, &pluginTriggerActions, datasets](const PointDataConversionPlugin::Type& type) -> void { const auto typeName = PointDataConversionPlugin::getTypeName(type); - auto pluginTriggerAction = new PluginTriggerAction(const_cast(this), this, QString("Conversion/%1").arg(typeName), QString("Perform %1 data conversion").arg(typeName), getIcon(), [this, datasets, type](PluginTriggerAction& pluginTriggerAction) -> void { - for (auto dataset : datasets) { + auto pluginTriggerAction = new PluginTriggerAction(const_cast(this), this, QString("Conversion/%1").arg(typeName), QString("Perform %1 data conversion").arg(typeName), icon(), [this, datasets, type](PluginTriggerAction& pluginTriggerAction) -> void { + for (const auto& dataset : datasets) { auto pluginInstance = dynamic_cast(plugins().requestPlugin(getKind())); - pluginInstance->setInputDatasets(datasets); + pluginInstance->setInputDataset(dataset); pluginInstance->setType(type); pluginInstance->transform(); } @@ -144,11 +139,11 @@ PluginTriggerActions PointDataConversionPluginFactory::getPluginTriggerActions(c const auto addPluginTriggerAction = [this, &pluginTriggerActions](const PointDataConversionPlugin::Type& type) -> void { const auto typeName = PointDataConversionPlugin::getTypeName(type); - auto pluginTriggerAction = new PluginTriggerAction(const_cast(this), this, QString("Conversion/%1").arg(typeName), QString("Perform %1 data conversion").arg(typeName), getIcon(), [this, type](PluginTriggerAction& pluginTriggerAction) -> void { - for (auto dataset : Datasets()) { + auto pluginTriggerAction = new PluginTriggerAction(const_cast(this), this, QString("Conversion/%1").arg(typeName), QString("Perform %1 data conversion").arg(typeName), icon(), [this, type](PluginTriggerAction& pluginTriggerAction) -> void { + for (const auto& dataset : pluginTriggerAction.getDatasets()) { auto pluginInstance = dynamic_cast(plugins().requestPlugin(getKind())); - pluginInstance->setInputDatasets(Datasets()); + pluginInstance->setInputDataset(dataset); pluginInstance->setType(type); pluginInstance->transform(); } @@ -186,9 +181,6 @@ WidgetAction* PointDataConversionPluginFactory::getConfigurationAction(const Poi case PointDataConversionPlugin::Type::ArcSin: return createGroupAction(_arcSinFactorAction); - - default: - break; } return nullptr; diff --git a/src/PointDataConversionPlugin.h b/src/PointDataConversionPlugin.h index 2a39d89..6745b59 100644 --- a/src/PointDataConversionPlugin.h +++ b/src/PointDataConversionPlugin.h @@ -1,15 +1,13 @@ #pragma once -#include - #include +#include +#include using namespace mv::plugin; using namespace mv::gui; using namespace mv::util; -class QLabel; - /** * Point data conversion plugin class * @@ -79,8 +77,8 @@ class PointDataConversionPluginFactory : public TransformationPluginFactory { Q_INTERFACES(mv::plugin::TransformationPluginFactory mv::plugin::PluginFactory) Q_OBJECT - Q_PLUGIN_METADATA(IID "nl.BioVault.PointDataConversionPlugin" - FILE "PointDataConversionPlugin.json") + Q_PLUGIN_METADATA(IID "studio.manivault.PointDataConversionPlugin" + FILE "PluginInfo.json") public: diff --git a/src/PointDataConversionPlugin.json b/src/PointDataConversionPlugin.json deleted file mode 100644 index c010cb0..0000000 --- a/src/PointDataConversionPlugin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "PointDataConversion", - "version": "1", - "dependencies": [ "Points" ] -}