修改"参数视图属性"面板 (5.7.0) 上的默认属性

Modify Default properties on Paraview Properties Panel (5.7.0)

本文关键字:属性 quot 默认 面板 参数 视图 修改      更新时间:2023-10-16

我尝试使用自定义插件修改 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::CELLvtkDataObject::POINT