修改"参数视图属性"面板 (5.7.0) 上的默认属性
Modify Default properties on Paraview Properties Panel (5.7.0)
我尝试使用自定义插件修改 Paraview 中属性的默认值。 当我在管道中添加Dicom文件时,默认表示形式在属性面板中设置为"Outline
",但我希望它是"Volume
"。 目标是与 Paraview 中的现有属性进行交互
我git克隆了paraview存储库,并使用CMake获取.sln文件并使用Visual Studio对其进行编译。我对 Paraview 本身提供的示例插件(如工具栏或属性小部件以了解其工作原理(做同样的事情,现在一切正常。 但是当我尝试将数据表示设置为"音量"时,没有任何效果(没有结果,它仍然是统一的。
我尝试过(从我的插件(:
pqApplicationCore* applicationCore = pqApplicationCore::instance();
pqObjectBuilder* objectBuilder = applicationCore->getObjectBuilder();
pqServerManagerModel* serverManagerModel = applicationCore->getServerManagerModel();
if (serverManagerModel->getNumberOfItems<pqServer*>() == 1)
{
// Getting the first (and only) server
pqServer* server = serverManagerModel->getItemAtIndex<pqServer*>(0);
//Creating a reader for dicom files
pqPipelineSource* pipelineSource =
objectBuilder->createReader("sources", "DICOMReader", { file }, server);
// Getting the first view
pqView* v = serverManagerModel->getItemAtIndex<pqView*>(0);
// Setting the data representation to Volume, at least, i try to set it.
pqDataRepresentation* data = objectBuilder->createDataRepresentation(
pipelineSource->getOutputPorts().at(0), v, "UniformGridRepresentation");
// SOLUTION
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), "DICOMImage", vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
// wrong
data->setProperty("VolumeRendering", "volume");
data->setVisible(true);
}
CMakeList.txt
set(interfaces)
set(sources
MyToolBar.cxx
MyToolBar.h
MyToolBarActions.cxx
MyToolBarActions.h)
paraview_plugin_add_action_group(…….)
paraview_plugin_add_toolbar(…..)
paraview_add_plugin(pluginName
VERSION "1.0"
UI_INTERFACES ${interfaces}
SOURCES ${sources})
target_link_libraries(cmakePluginName PRIVATE ParaView::ServerManagerRendering)
我预计"表示"字段位于"卷"上,但仍在"大纲"中 我还尝试将"UniformGridRepresentation"更改为其他内容,除了奇怪的事情和崩溃之外,没有任何结果。
有什么想法吗?
您使用的setProperty
涉及Qt属性(此类继承自QObject(,而不是ParaView Proxy属性。
应将此行替换为以下内容:
编辑:添加设置标量着色部分
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), <ArrayName>, vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
<ArrayName>
是要用于着色的数据。如果未指定,则使用唯一的Solid Color
,但不可用于体积渲染。
如果<ArrayName>
与像元而不是点相关联,也可以vtkDataObject::CELL
vtkDataObject::POINT
。
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- C++概念:如何使用'concept'检查模板化结构的属性?
- 子目录是否继承属性,例如add_definitions,include_directories和父Cmakelist.t
- 通过指向指针数组的指针访问子类的属性
- MSVC是否支持C++11样式的属性而不是__declspec
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 类的C++属性似乎已重新初始化
- Qt Quick-如何仅从c++代码与qml属性交互
- 用概念检查属性的类型
- C++如何将同一类的实例作为属性
- 按多个属性排序
- 主函数参数的属性
- "perf_event_attr"结构的"read_format"属性的选项到底是什么?
- C++删除未使用的类属性会导致 std::logic_error
- 无法使用 SWIG 在 Python 中实例化C++类(获取属性错误)
- 使用内存地址访问结构的属性值
- C++调用具有 *this 属性的单个帮助程序函数
- C++ 在堆栈中包含多态属性的类对象存储
- C++ 命名参数习惯用语 - 未设置字符串属性
- 使用 CTRP 时,是否访问访问父构造函数 UB 中的子属性?