Skip to content

Commit b863c4a

Browse files
committed
Implemented skeleton code for actions example plugin
1 parent 1b0b7b5 commit b863c4a

6 files changed

Lines changed: 249 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ add_subdirectory(ExampleLoader)
3131
add_subdirectory(ExampleWriter)
3232
add_subdirectory(ExampleData)
3333
add_subdirectory(ExampleDependencies)
34+
add_subdirectory(ExampleActions)
3435

35-
set_target_properties(ExampleViewPlugin ExampleViewJSPlugin ExampleViewOpenGLPlugin ExampleAnalysisPlugin ExampleTransformationPlugin ExampleLoaderPlugin ExampleWriterPlugin ExampleDataPlugin ExampleDependenciesPlugin
36+
set_target_properties(ExampleViewPlugin ExampleViewJSPlugin ExampleViewOpenGLPlugin ExampleAnalysisPlugin ExampleTransformationPlugin ExampleLoaderPlugin ExampleWriterPlugin ExampleDataPlugin ExampleDependenciesPlugin ExampleActionsPlugin
3637
PROPERTIES
3738
FOLDER ExamplePlugins
3839
)

ExampleActions/CMakeLists.txt

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
3+
option(MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF)
4+
5+
# -----------------------------------------------------------------------------
6+
# ExampleView Plugin
7+
# -----------------------------------------------------------------------------
8+
PROJECT("ExampleActionsPlugin" LANGUAGES CXX)
9+
10+
# -----------------------------------------------------------------------------
11+
# CMake Options
12+
# -----------------------------------------------------------------------------
13+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
14+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
15+
set(CMAKE_AUTOMOC ON)
16+
17+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus")
19+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
20+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
21+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
22+
endif()
23+
24+
# -----------------------------------------------------------------------------
25+
# Dependencies
26+
# -----------------------------------------------------------------------------
27+
find_package(Qt6 COMPONENTS Widgets WebEngineWidgets REQUIRED)
28+
29+
find_package(ManiVault COMPONENTS Core PointData CONFIG QUIET)
30+
31+
# -----------------------------------------------------------------------------
32+
# Include Common directory
33+
# -----------------------------------------------------------------------------
34+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../Common ${CMAKE_CURRENT_BINARY_DIR}/Common)
35+
36+
# -----------------------------------------------------------------------------
37+
# Source files
38+
# -----------------------------------------------------------------------------
39+
# Define the plugin sources
40+
set(PLUGIN_SOURCES
41+
src/ExampleActionsPlugin.h
42+
src/ExampleActionsPlugin.cpp
43+
PluginInfo.json
44+
)
45+
46+
set(PLUGIN_MOC_HEADERS
47+
src/ExampleActionsPlugin.h
48+
)
49+
50+
source_group(Plugin FILES ${PLUGIN_SOURCES})
51+
source_group(Common FILES ${COMMON_FILES})
52+
53+
# -----------------------------------------------------------------------------
54+
# CMake Target
55+
# -----------------------------------------------------------------------------
56+
# Create dynamic library for the plugin
57+
add_library(${PROJECT_NAME} SHARED ${PLUGIN_SOURCES} ${COMMON_FILES})
58+
59+
# -----------------------------------------------------------------------------
60+
# Target include directories
61+
# -----------------------------------------------------------------------------
62+
# Include ManiVault headers, including system data plugins
63+
target_include_directories(${PROJECT_NAME} PRIVATE "${ManiVault_INCLUDE_DIR}")
64+
65+
# -----------------------------------------------------------------------------
66+
# Target properties
67+
# -----------------------------------------------------------------------------
68+
# Request C++20
69+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
70+
71+
# Enable unity build
72+
if(MV_UNITY_BUILD)
73+
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
74+
endif()
75+
76+
# -----------------------------------------------------------------------------
77+
# Target library linking
78+
# -----------------------------------------------------------------------------
79+
# Link to Qt libraries
80+
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets)
81+
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::WebEngineWidgets)
82+
83+
# Link to ManiVault and data plugins
84+
target_link_libraries(${PROJECT_NAME} PRIVATE ManiVault::Core)
85+
target_link_libraries(${PROJECT_NAME} PRIVATE ManiVault::PointData)
86+
87+
# -----------------------------------------------------------------------------
88+
# Target installation
89+
# -----------------------------------------------------------------------------
90+
# Install the shared plugin library to the "Plugins" folder in the ManiVault install directory
91+
install(TARGETS ${PROJECT_NAME}
92+
RUNTIME DESTINATION Plugins COMPONENT PLUGINS # Windows .dll
93+
LIBRARY DESTINATION Plugins COMPONENT PLUGINS # Linux/Mac .so
94+
)
95+
96+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
97+
COMMAND "${CMAKE_COMMAND}"
98+
--install ${CMAKE_CURRENT_BINARY_DIR}
99+
--config $<CONFIGURATION>
100+
--prefix ${ManiVault_INSTALL_DIR}/$<CONFIGURATION>
101+
)
102+
103+
# Append plugin version to output file
104+
# 0 disables automatic folder placement (same as plugin type)
105+
# since we want to place all example plugins in a separate folder
106+
mv_handle_plugin_config(${PROJECT_NAME} 0)
107+
108+
# -----------------------------------------------------------------------------
109+
# Miscellaneous
110+
# -----------------------------------------------------------------------------
111+
# Automatically set the debug environment (command + working directory) for MSVC
112+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
113+
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${ManiVault_INSTALL_DIR}/Debug,$<IF:$<CONFIG:RELWITHDEBINFO>,${ManiVault_INSTALL_DIR}/RelWithDebInfo,${ManiVault_INSTALL_DIR}/Release>>)
114+
set_property(TARGET ${PROJECT_NAME} 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">>)
115+
endif()

ExampleActions/PluginInfo.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name" : "Example Actions",
3+
"version" : {
4+
"plugin" : "1.4",
5+
"core" : ["1.3"]
6+
},
7+
"type" : "View",
8+
"dependencies" : ["Points"]
9+
}

ExampleActions/src/.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2+
root = true
3+
4+
# All files
5+
[*]
6+
indent_style = space
7+
8+
# Cpp files
9+
[*.{h,cpp}]
10+
indent_size = 4
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include "ExampleActionsPlugin.h"
2+
3+
#include "../Common/common.h"
4+
5+
#include <QDebug>
6+
7+
Q_PLUGIN_METADATA(IID "studio.manivault.ExampleActionsPlugin")
8+
9+
using namespace mv;
10+
11+
ExampleActionsPlugin::ExampleActionsPlugin(const PluginFactory* factory) :
12+
ViewPlugin(factory)
13+
{
14+
}
15+
16+
void ExampleActionsPlugin::init()
17+
{
18+
// Create layout
19+
auto layout = new QVBoxLayout();
20+
21+
layout->setContentsMargins(0, 0, 0, 0);
22+
}
23+
24+
ExampleActionsPluginFactory::ExampleActionsPluginFactory()
25+
{
26+
getPluginMetadata().setDescription("Example actions view plugin");
27+
getPluginMetadata().setSummary("This example shows how to use action GUI building blocks in ManiVault Studio.");
28+
getPluginMetadata().setCopyrightHolder({ "BioVault (Biomedical Visual Analytics Unit LUMC - TU Delft)" });
29+
getPluginMetadata().setAuthors({
30+
{ "T. Kroes", { "Lead software architect" }, { "LUMC" } }
31+
});
32+
getPluginMetadata().setOrganizations({
33+
{ "LUMC", "Leiden University Medical Center", "https://www.lumc.nl/en/" },
34+
{ "TU Delft", "Delft university of technology", "https://www.tudelft.nl/" }
35+
});
36+
getPluginMetadata().setLicenseText("This plugin is distributed under the [LGPL v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html) license.");
37+
}
38+
39+
ViewPlugin* ExampleActionsPluginFactory::produce()
40+
{
41+
return new ExampleActionsPlugin(this);
42+
}
43+
44+
mv::DataTypes ExampleActionsPluginFactory::supportedDataTypes() const
45+
{
46+
return {};
47+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#pragma once
2+
3+
#include <ViewPlugin.h>
4+
5+
#include <QWidget>
6+
7+
/** All plugin related classes are in the ManiVault plugin namespace */
8+
using namespace mv::plugin;
9+
10+
/** Drop widget used in this plugin is located in the ManiVault gui namespace */
11+
using namespace mv::gui;
12+
13+
/** Dataset reference used in this plugin is located in the ManiVault util namespace */
14+
using namespace mv::util;
15+
16+
class QLabel;
17+
18+
/**
19+
* Example view plugin class
20+
*
21+
* @authors T. Kroes
22+
*/
23+
class ExampleActionsPlugin : public ViewPlugin
24+
{
25+
Q_OBJECT
26+
27+
public:
28+
29+
/**
30+
* Constructor
31+
* @param factory Pointer to the plugin factory
32+
*/
33+
ExampleActionsPlugin(const PluginFactory* factory);
34+
35+
/** Destructor */
36+
~ExampleActionsPlugin() override = default;
37+
38+
/** This function is called by the core after the view plugin has been created */
39+
void init() override;
40+
41+
private:
42+
};
43+
44+
/**
45+
* Example actions view plugin factory class
46+
*
47+
* Note: Factory does not need to be altered (merely responsible for generating new plugins when requested)
48+
*/
49+
class ExampleActionsPluginFactory : public ViewPluginFactory
50+
{
51+
Q_INTERFACES(mv::plugin::ViewPluginFactory mv::plugin::PluginFactory)
52+
Q_OBJECT
53+
Q_PLUGIN_METADATA(IID "studio.manivault.ExampleActionsPlugin"
54+
FILE "PluginInfo.json")
55+
56+
public:
57+
58+
/** Default constructor */
59+
ExampleActionsPluginFactory();
60+
61+
/** Creates an instance of the example view plugin */
62+
ViewPlugin* produce() override;
63+
64+
/** Returns the data types that are supported by the example view plugin */
65+
mv::DataTypes supportedDataTypes() const override;
66+
};

0 commit comments

Comments
 (0)