Slicer学习笔记(三十)slicer编写c++扩展
1、c++扩展模块 CMake文件
准备操作,参考我的笔记十 Slicer学习笔记(十)怎样写一个slicer c++ 扩展模块 和笔记十二 Slicer学习笔记(十二)编写扩展模块
cmake_minimum_required(VERSION 3.13.4)
project(cpp_regist_seg)
set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/cpp_regist_seg")
set(EXTENSION_CATEGORY "Examples")
set(EXTENSION_CONTRIBUTORS "wmz (AnyWare Corp.)")
set(EXTENSION_DESCRIPTION "This is an example of a simple extension")
set(EXTENSION_ICONURL "http://www.example.com/Slicer/Extensions/cpp_regist_seg.png")
set(EXTENSION_SCREENSHOTURLS "http://www.example.com/Slicer/Extensions/cpp_regist_seg/Screenshots/1.png")
set(EXTENSION_DEPENDS "NA")
set(Slicer_DIR F:/Slicer/Slicer-build)
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
add_subdirectory(cpp_regist_seg)
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
正常生成的文件的CMakeLists.txt 不包含下面一行,是我添加进去的。
set(Slicer_DIR F:/Slicer/Slicer-build)
2、程序执行
然后生成visual studio项目, 编译后生成exe可执行文件,直接双击闪退,提示信息如下:
SlicerWithcpp_regist_seg.exe
error: Application does NOT exists [D:/documents/slicer/cpp_regist_seg/build/F:/Slicer/Slicer-build/./Slicer.exe]
Usage
SlicerWithcpp_regist_seg [options]
Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-load-environment Specify the saved environment to load.
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
--launcher-additional-settings Additional settings file to consider
--launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
- 提示信息说明了不能直接启动的原因是没有找到Slicer.exe文件,(这个可以有其他办法解决无法找到启动文件的问题)。
- 同时也提供了命令行启动的方式,使用如下方式可以启动程序:
SlicerWithcpp_regist_seg.exe --launch F:/Slicer/Slicer-build/./Slicer.exe
启动后可以从下面箭头所示的位置打开自己的c++扩展程序 默认的界面如下图所示:
3、编辑UI
项目的UI文件在这里: 设置UI的打开方式 参考:Documentation/Nightly/Developers/Tutorials/QtDesigner
在VS项目中,右键UI文件,选择“打开方式”,编辑打开方式。 选择“添加” 填上相应的内容并点击“确定”按钮。 其中“程序”路径在不同人的电脑上可能略有差异,使用“everything”软件搜一下自己安装的Slicer.exe软件所在位置,填进去就可以了。 然后就可以打开ui文件了,打开后显示如下: 小控件在Widget文件夹下的ui文件
4、 编辑代码
|