diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d5d9110..cd5d1d7 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -30,7 +30,17 @@ set (libSourceFiles "src/implementation/CziWriterManager.cpp" "src/implementation/CziWriterManager.h" "src/functions/func_open.cpp" - "src/functions/func_open.h" "src/functions/func_getsubblockbitmap.cpp" "src/functions/func_getsubblockbitmap.h") + "src/functions/func_open.h" + "src/functions/func_getsubblockbitmap.cpp" + "src/functions/func_getsubblockbitmap.h" + "src/functions/func_getmultichannelscalingtilecomposite.cpp" + "src/functions/func_getmultichannelscalingtilecomposite.h" + "src/functions/func_getinfo.cpp" + "src/functions/func_getinfo.h" + "src/functions/func_getmetadataxml.cpp" + "src/functions/func_getmetadataxml.h" + "src/functions/func_getscaling.cpp" + "src/functions/func_getscaling.h") if(CMAKE_BUILD_TYPE MATCHES Debug) set(lib_ENABLE_LOGGING 1) @@ -44,7 +54,7 @@ set(lib_LOGLEVEL 1) set(lib_VERSION_MAJOR ${MEXCZI_MAJOR}) set(lib_VERSION_MINOR ${MEXCZI_MINOR}) set(lib_VERSION_PATCH ${MEXCZI_PATCH}) -set(lib_VERSION_EXT ${MEXCZI_EXT}) +set(lib_VERSION_EXT ${MEXCZI_EXT}) configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/lib_config.h.in" diff --git a/lib/src/functions/func_getinfo.cpp b/lib/src/functions/func_getinfo.cpp new file mode 100644 index 0000000..baaa6e6 --- /dev/null +++ b/lib/src/functions/func_getinfo.cpp @@ -0,0 +1,29 @@ +#include "func_getinfo.h" +#include +#include "../implementation/argsutils.h" +#include "../implementation/utils.h" + +using namespace std; + +void MexFunction_GetInfo_CheckArguments(MatlabArgs* args) +{ + if (args->nrhs < 2) + { + throw invalid_argument("not enough arguments"); + } + + if (!CArgsUtils::IsNumericArrayOfMinSize(args->prhs[1], 1, args->app_functions)) + { + throw invalid_argument("2nd argument must be an integer"); + } +} + +void MexFunction_GetInfo_Execute(MatlabArgs* args) +{ + int id; + bool b = CArgsUtils::TryGetInt32(args->prhs[1], &id, args->app_functions); + const std::shared_ptr reader = ::Utils::GetReaderOrThrow(id); + + auto* info = reader->GetInfo(args->app_functions); + args->plhs[0] = info; +} \ No newline at end of file diff --git a/lib/src/functions/func_getinfo.h b/lib/src/functions/func_getinfo.h new file mode 100644 index 0000000..2c0c714 --- /dev/null +++ b/lib/src/functions/func_getinfo.h @@ -0,0 +1,6 @@ +#pragma once + +#include "../mexFunctions.h" + +void MexFunction_GetInfo_CheckArguments(MatlabArgs* args); +void MexFunction_GetInfo_Execute(MatlabArgs* args); \ No newline at end of file diff --git a/lib/src/functions/func_getmetadataxml.cpp b/lib/src/functions/func_getmetadataxml.cpp new file mode 100644 index 0000000..60b09d0 --- /dev/null +++ b/lib/src/functions/func_getmetadataxml.cpp @@ -0,0 +1,30 @@ +#include "func_getmetadataxml.h" +#include +#include "../implementation/argsutils.h" +#include "../implementation/utils.h" + +using namespace std; + +// How to parse an XML-string with MATLAB -> http://undocumentedmatlab.com/articles/parsing-xml-strings + +void MexFunction_GetMetadataXml_CheckArguments(MatlabArgs* args) +{ + if (args->nrhs < 2) + { + throw invalid_argument("not enough arguments"); + } + + if (!CArgsUtils::IsNumericArrayOfMinSize(args->prhs[1], 1, args->app_functions)) + { + throw invalid_argument("2nd argument must be an integer"); + } +} + +void MexFunction_GetMetadataXml_Execute(MatlabArgs* args) +{ + int id; + bool b = CArgsUtils::TryGetInt32(args->prhs[1], &id, args->app_functions); + std::shared_ptr reader = ::Utils::GetReaderOrThrow(id); + auto* m = reader->GetMetadataXmlAsMxArray(args->app_functions); + args->plhs[0] = m; +} diff --git a/lib/src/functions/func_getmetadataxml.h b/lib/src/functions/func_getmetadataxml.h new file mode 100644 index 0000000..322f079 --- /dev/null +++ b/lib/src/functions/func_getmetadataxml.h @@ -0,0 +1,6 @@ +#pragma once + +#include "../mexFunctions.h" + +void MexFunction_GetMetadataXml_CheckArguments(MatlabArgs* args); +void MexFunction_GetMetadataXml_Execute(MatlabArgs* args); diff --git a/lib/src/functions/func_getmultichannelscalingtilecomposite.cpp b/lib/src/functions/func_getmultichannelscalingtilecomposite.cpp new file mode 100644 index 0000000..3853ac5 --- /dev/null +++ b/lib/src/functions/func_getmultichannelscalingtilecomposite.cpp @@ -0,0 +1,68 @@ +#include "func_getmultichannelscalingtilecomposite.h" +#include "../implementation/CziReaderManager.h" +#include +#include +#include "../implementation/argsutils.h" +#include "../implementation/utils.h" + +using namespace std; +using namespace libCZI; + +void MexFunction_GetMultiChannelScalingTileComposite_CheckArguments(MatlabArgs* args) +{ + // arguments: + // (1) handle + // (2) ROI -> array of >=4 numbers + // (3) plane-coordinate + // (4) zoom (number) + // (5) (optional) display-settings + if (args->nrhs < 5) + { + throw invalid_argument("not enough arguments"); + } + + if (!CArgsUtils::IsNumericArrayOfMinSize(args->prhs[1], 1, args->app_functions)) + { + throw invalid_argument("1st argument must be an integer"); + } + + if (!CArgsUtils::IsNumericArrayOfMinSize(args->prhs[2], 4, args->app_functions)) + { + throw invalid_argument("2nd argument must be a ROI"); + } + + if (!CArgsUtils::TryGetDimCoordinate(args->prhs[3], nullptr, args->app_functions)) + { + throw invalid_argument("3nd argument must be a string (specifying a coordinate)"); + } + + if (!CArgsUtils::TryGetSingle(args->prhs[4], nullptr, args->app_functions)) + { + throw invalid_argument("4th argument must be a number"); + } +} + +void MexFunction_GetMultiChannelScalingTileComposite_Execute(MatlabArgs* args) +{ + int id; + bool b = CArgsUtils::TryGetInt32(args->prhs[1], &id, args->app_functions); + + std::shared_ptr reader = ::Utils::GetReaderOrThrow(id); + IntRect rect; + b = CArgsUtils::TryGetIntRect(args->prhs[2], &rect, args->app_functions); + + CDimCoordinate coord; + b = CArgsUtils::TryGetDimCoordinate(args->prhs[3], &coord, args->app_functions); + + float zoom; + b = CArgsUtils::TryGetSingle(args->prhs[4], &zoom, args->app_functions); + + auto* out = reader->GetMultiChannelScalingTileComposite( + rect, + &coord, + (float)zoom, + (const char*)nullptr/*displaySettingsString*/, + args->app_functions); + + args->plhs[0] = out; +} \ No newline at end of file diff --git a/lib/src/functions/func_getmultichannelscalingtilecomposite.h b/lib/src/functions/func_getmultichannelscalingtilecomposite.h new file mode 100644 index 0000000..26d6e7b --- /dev/null +++ b/lib/src/functions/func_getmultichannelscalingtilecomposite.h @@ -0,0 +1,6 @@ +#pragma once + +#include "../mexFunctions.h" + +void MexFunction_GetMultiChannelScalingTileComposite_CheckArguments(MatlabArgs* args); +void MexFunction_GetMultiChannelScalingTileComposite_Execute(MatlabArgs* args); \ No newline at end of file diff --git a/lib/src/functions/func_getscaling.cpp b/lib/src/functions/func_getscaling.cpp new file mode 100644 index 0000000..472c42e --- /dev/null +++ b/lib/src/functions/func_getscaling.cpp @@ -0,0 +1,33 @@ +#include "func_getscaling.h" +#include +#include "../implementation/argsutils.h" +#include "../implementation/utils.h" + +using namespace std; + +void MexFunction_GetScaling_CheckArguments(MatlabArgs* args) +{ + if (args->nrhs < 2) + { + throw invalid_argument("not enough arguments"); + } + + if (!CArgsUtils::IsNumericArrayOfMinSize(args->prhs[1], 1, args->app_functions)) + { + throw invalid_argument("2nd argument must be an integer"); + } +} + +void MexFunction_GetScaling_Execute(MatlabArgs* args) +{ + int id; + const bool b = CArgsUtils::TryGetInt32(args->prhs[1], &id, args->app_functions); + if (!b) + { + throw invalid_argument("2nd argument must be an integer"); + } + + std::shared_ptr reader = ::Utils::GetReaderOrThrow(id); + auto* m = reader->GetScalingAsMatlabStruct(args->app_functions); + args->plhs[0] = m; +} \ No newline at end of file diff --git a/lib/src/functions/func_getscaling.h b/lib/src/functions/func_getscaling.h new file mode 100644 index 0000000..5734c6a --- /dev/null +++ b/lib/src/functions/func_getscaling.h @@ -0,0 +1,6 @@ +#pragma once + +#include "../mexFunctions.h" + +void MexFunction_GetScaling_CheckArguments(MatlabArgs* args); +void MexFunction_GetScaling_Execute(MatlabArgs* args); \ No newline at end of file diff --git a/lib/src/mexFunctions.cpp b/lib/src/mexFunctions.cpp index d86562a..3b98498 100644 --- a/lib/src/mexFunctions.cpp +++ b/lib/src/mexFunctions.cpp @@ -4,12 +4,13 @@ #include "functions/func_getversion.h" #include "functions/func_open.h" #include "functions/func_getsubblockbitmap.h" +#include "functions/func_getmultichannelscalingtilecomposite.h" +#include "functions/func_getinfo.h" +#include "functions/func_getscaling.h" +#include "functions/func_getmetadataxml.h" /* #include "src/func_close.h" #include "src/func_getmultichannelscalingtilecomposite.h" -#include "src/func_getinfo.h" -#include "src/func_getmetadataxml.h" -#include "src/func_getscaling.h" #include "src/func_getsinglechannelscalingtilecomposite.h" #include "src/func_getdefaultdisplaysettings.h" #include "src/func_getsubblock.h" @@ -23,11 +24,11 @@ {u8"GetVersion", {MexFunction_GetVersion_CheckArguments,MexFunction_GetVersion_Execute}}, {u8"Open", {MexFunction_Open_CheckArguments,MexFunction_Open_Execute}}, {u8"GetSubBlockBitmap", {MexFunction_GetSubBlockBitmap_CheckArguments,MexFunction_GetSubBlockBitmap_Execute}}, - /* {u8"GetMultiChannelScalingTileComposite", {MexFunction_GetMultiChannelScalingTileComposite_CheckArguments,MexFunction_GetMultiChannelScalingTileComposite_Execute}}, {u8"GetInfo", {MexFunction_GetInfo_CheckArguments,MexFunction_GetInfo_Execute}}, {u8"GetScaling", {MexFunction_GetScaling_CheckArguments,MexFunction_GetScaling_Execute}}, {u8"GetMetadataXml", {MexFunction_GetMetadataXml_CheckArguments,MexFunction_GetMetadataXml_Execute}}, + /* {u8"GetSingleChannelScalingTileComposite", {MexFunction_GetSingleChannelScalingTileComposite_CheckArguments,MexFunction_GetSingleChannelScalingTileComposite_Execute}}, {u8"Close", {MexFunction_Close_CheckArguments,MexFunction_Close_Execute}}, {u8"GetDefaultDisplaySettings", {MexFunction_GetDefaultDisplaySettings_CheckArguments,MexFunction_GetDefaultDisplaySettings_Execute}},