Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,45 @@ 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.
# See: https://docs.github.com/en/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
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_gcc11
os: ubuntu-22.04
build-cc: gcc
build-cxx: g++
build-compiler: gcc
build-cversion: 11
build-config: Release
build-os: Linux
build-libcxx: libstdc++

- name: Macos_xcode13.4
os: macos-12
build-compiler: apple-clang
build-cversion: 13
build-config: Release
build-os: Macos
build-xcode-version: 13.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
Expand All @@ -75,12 +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.11"

- name: Start ssh key agent
uses: webfactory/ssh-agent@v0.7.0
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }}

Expand Down Expand Up @@ -111,21 +90,23 @@ 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}}
conan-cc: gcc-${{matrix.build-cversion}}
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}}
conan-compiler-version: ${{matrix.build-cversion}}
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}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,4 @@ FodyWeavers.xsd

Build/
.DS_Store
*.bak
107 changes: 62 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
cmake_minimum_required(VERSION 3.17)
cmake_minimum_required(VERSION 3.22)

set(SVPLUGIN "SpectralViewPlugin")
option(MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF)

PROJECT(${SVPLUGIN})
# -----------------------------------------------------------------------------
# SpectralView Plugin
# -----------------------------------------------------------------------------
set(SVPLUGIN "SpectralViewPlugin")
PROJECT(${SVPLUGIN}
DESCRIPTION "View plugin for ManiVault for spectral data"
LANGUAGES CXX
)

# -----------------------------------------------------------------------------
# CMake Options
# -----------------------------------------------------------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus /W3")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG /NODEFAULTLIB:LIBCMT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif(MSVC)

# 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")

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus /W3")
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()
file(TO_CMAKE_PATH ${MV_INSTALL_DIR} MV_INSTALL_DIR)

find_package(Qt6 6.3.1 COMPONENTS Widgets WebEngineWidgets Concurrent REQUIRED)
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
find_package(Qt6 COMPONENTS Widgets WebEngineWidgets Concurrent REQUIRED)

find_package(ManiVault COMPONENTS Core PointData ClusterData ImageData CONFIG QUIET)

# -----------------------------------------------------------------------------
# Source files
# -----------------------------------------------------------------------------
set(PLUGIN
src/SpectralViewPlugin.h
src/SpectralViewPlugin.cpp
Expand All @@ -34,10 +44,6 @@ set(PLUGIN
src/Endmember.h
)

set(PLUGIN_MOC_HEADERS
src/SpectralViewPlugin.h
)

set(ACTIONS
src/SettingsAction.h
src/SettingsAction.cpp
Expand Down Expand Up @@ -82,7 +88,7 @@ set(WEB

set(AUX
res/lineplot_resources.qrc
src/SpectralViewPlugin.json
PluginInfo.json
)

qt6_add_resources(RESOURCE_FILES res/lineplot_resources.qrc)
Expand All @@ -95,34 +101,40 @@ source_group(Widget FILES ${WIDGETS})
source_group(Web FILES ${WEB})
source_group(Aux FILES ${AUX})

# -----------------------------------------------------------------------------
# CMake Target
# -----------------------------------------------------------------------------
add_library(${SVPLUGIN} SHARED ${SOURCES} ${WEB} ${AUX} ${RESOURCE_FILES})

qt_wrap_cpp(SV_PARAMETERS_MOC ${PLUGIN_MOC_HEADERS} TARGET ${SVPLUGIN})
target_sources(${SVPLUGIN} PRIVATE ${SV_PARAMETERS_MOC})
# -----------------------------------------------------------------------------
# Target include directories
# -----------------------------------------------------------------------------
target_include_directories(${SVPLUGIN} PRIVATE "${ManiVault_INCLUDE_DIR}")

target_include_directories(${SVPLUGIN} PRIVATE "${MV_INSTALL_DIR}/$<CONFIGURATION>/include/")
# -----------------------------------------------------------------------------
# Target properties
# -----------------------------------------------------------------------------
target_compile_features(${SVPLUGIN} PRIVATE cxx_std_20)

# Request C++17
target_compile_features(${SVPLUGIN} PRIVATE cxx_std_17)
if(MV_UNITY_BUILD)
set_target_properties(${SVPLUGIN} PROPERTIES UNITY_BUILD ON)
endif()

# -----------------------------------------------------------------------------
# Target library linking
# -----------------------------------------------------------------------------
target_link_libraries(${SVPLUGIN} PRIVATE Qt6::Widgets)
target_link_libraries(${SVPLUGIN} PRIVATE Qt6::WebEngineWidgets)
target_link_libraries(${SVPLUGIN} PRIVATE Qt6::Concurrent)

set(MV_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/lib")
set(PLUGIN_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/$<IF:$<CXX_COMPILER_ID:MSVC>,lib,Plugins>")
set(MV_LINK_SUFFIX $<IF:$<CXX_COMPILER_ID:MSVC>,${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}")
set(IMAGEDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}ImageData${MV_LINK_SUFFIX}")
set(CLUSTERDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}ClusterData${MV_LINK_SUFFIX}")

target_link_libraries(${SVPLUGIN} PRIVATE "${MV_LINK_LIBRARY}")
target_link_libraries(${SVPLUGIN} PRIVATE "${POINTDATA_LINK_LIBRARY}")
target_link_libraries(${SVPLUGIN} PRIVATE "${IMAGEDATA_LINK_LIBRARY}")
target_link_libraries(${SVPLUGIN} PRIVATE "${CLUSTERDATA_LINK_LIBRARY}")
target_link_libraries(${SVPLUGIN} PRIVATE ManiVault::Core)
target_link_libraries(${SVPLUGIN} PRIVATE ManiVault::PointData)
target_link_libraries(${SVPLUGIN} PRIVATE ManiVault::ClusterData)
target_link_libraries(${SVPLUGIN} PRIVATE ManiVault::ImageData)

# -----------------------------------------------------------------------------
# Target installation
# -----------------------------------------------------------------------------
install(TARGETS ${SVPLUGIN}
RUNTIME DESTINATION Plugins COMPONENT PLUGINS # Windows .dll
LIBRARY DESTINATION Plugins COMPONENT PLUGINS # Linux/Mac .so
Expand All @@ -132,11 +144,16 @@ add_custom_command(TARGET ${SVPLUGIN} POST_BUILD
COMMAND "${CMAKE_COMMAND}"
--install ${CMAKE_CURRENT_BINARY_DIR}
--config $<CONFIGURATION>
--prefix ${MV_INSTALL_DIR}/$<CONFIGURATION>
--prefix ${ManiVault_INSTALL_DIR}/$<CONFIGURATION>
)

mv_handle_plugin_config(${SVPLUGIN})

# -----------------------------------------------------------------------------
# Miscellaneous
# -----------------------------------------------------------------------------
# Automatically set the debug environment (command + working directory) for MSVC in debug mode
if(MSVC)
set_property(TARGET ${SVPLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${MV_INSTALL_DIR}/debug,${MV_INSTALL_DIR}/release>)
set_property(TARGET ${SVPLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${MV_INSTALL_DIR}/debug/ManiVault Studio.exe","${MV_INSTALL_DIR}/release/ManiVault Studio.exe">)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_property(TARGET ${SVPLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${ManiVault_INSTALL_DIR}/Debug,$<IF:$<CONFIG:RELWITHDEBINFO>,${ManiVault_INSTALL_DIR}/RelWithDebInfo,${ManiVault_INSTALL_DIR}/Release>>)
set_property(TARGET ${SVPLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${ManiVault_INSTALL_DIR}/Debug/ManiVault Studio.exe",$<IF:$<CONFIG:RELWITHDEBINFO>,"${ManiVault_INSTALL_DIR}/RelWithDebInfo/ManiVault Studio.exe","${ManiVault_INSTALL_DIR}/Release/ManiVault Studio.exe">>)
endif()
9 changes: 9 additions & 0 deletions PluginInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name" : "Spectral View",
"version" : {
"plugin" : "1.0.0",
"core" : ["1.3"]
},
"type" : "View",
"dependencies" : ["Points", "Cluster", "Images"]
}
6 changes: 5 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ git clone git@github.com:ManiVaultStudio/SpectralViewPlugin.git
## Usage
How to use:

0. Load a data set, e.g. with the [ENVI](https://github.com/ManiVaultStudio/ENVILoader) or [general image](https://github.com/ManiVaultStudio/ImageLoaderPlugin) loader plugins. **Caveat**: It's encouraged to define dimension names that encode the wavelength of the respective image channel, e.g. "304.7", "1020" or "304.7 nm". This wavelength information will be displayed in the viewer. If no dimension names are given when loading the data, ManiVault automatically numbers the dimensions, i.e. "Dim 0", etc.; in this case, the dimension numbers are displayed on the x-Axis instead of wavelengths.
0. Load a data set, e.g. with the [ENVI](https://github.com/ManiVaultStudio/ENVILoader) or [general image](https://github.com/ManiVaultStudio/ImageLoaderPlugin) loader plugins.
1. Open a spectral viewer and drag & drop the point data into the viewer. At this point you will not see anything yet. Open data in another viewer, e.g. an image viewer, and make a selection. Now you'll see the average spectral values for the selected points.
2. Create cluster for your data set, e.g. using an analysis like [mean shift clustering](https://github.com/ManiVaultStudio/MeanShiftClustering) or through manual annotation in the [scatterplot](https://github.com/ManiVaultStudio/Scatterplot). Drag & drop the cluster data into the main view of the spectral viewer.
3. Perform a mapping like the "Spectral Angle Mapping" algorithm for a selected cluster. This will cerate a new image data set.
> **Caveats**:
> - This viewer only handles point data sets that have a image data set as a child.
> - It's encouraged to define dimension names that encode the wavelength of the respective image channel, e.g. "304.7", "1020" or "304.7 nm". This wavelength information will be displayed in the viewer. If no dimension names are given when loading the data, ManiVault automatically numbers the dimensions, i.e. "Dim 0", etc.; in this case, the dimension numbers are displayed on the x-Axis instead of wavelengths.
> - This viewer expects positive data values (as is common in spectral intensities); negative values might lead to unwanted behaviour.

## References
Based on Popa et al. "Visual Analysis of RIS Data for Endmember Selection" (2022):
Expand Down
Loading
Loading