ParaView C++ Examples(二)SimpleParaView

简介

ParaView例子中的一个案例。位于Examples/CustomApplications/SimpleParaView

该实例代码组织结构如下:

编译连接安装后的文件结构:

 

构建成功后运行界面如下:

插件菜单栏:

CMakeLists.txt

顶层CMAKE文件,加载paraview模块,定义了输出路径,然后先后加载plugins和clinet子文件。

cmake_minimum_required(VERSION 3.8)
project(SimpleParaView)

find_package(ParaView REQUIRED)

if (NOT PARAVIEW_USE_QT)
  message(STATUS
    "Skipping example: ${PROJECT_NAME} example requires PARAVIEW_USE_QT "
    "to be enabled. Please rebuild ParaView (or point to a different build of "
    "ParaView) with PARAVIEW_USE_QT set to TRUE")
  return ()
endif()

include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

add_subdirectory(plugins) # 插件代码
add_subdirectory(client) # 主界面代码

client

client中存放了该程序的主界面,myMainWindow.h以及myMainWindow.cxx是主界面的代码,myMainWindow.ui是主界面的用户界面,该三个文件是Qt开发的必要文件。.ui会使用uic进行解析,生成对应的c++文件。下面逐个文件进行分析。

client/CMakeLists.txt

该文件用于处理

set(CMAKE_AUTOMOC 1) # qt设置,自动处理qt相关的代码,比如信号槽的定义,将其展开成c++代码
set(CMAKE_AUTOUIC 1) # qt设置,自动处理qt界面代码,将*.ui转换成ui_name.h c++代码

set(sources
  myMainWindow.cxx
  myMainWindow.h)
set(ui_files
  myMainWindow.ui)
set(xml_files
  ParaViewFilters.xml)

# The main cmake macro to create a paraview based application
paraview_client_add(
  NAME simple_paraview
  VERSION "1.0.1"
  SOURCES ${sources} ${ui_files}
  PLUGINS_TARGETS simple_paraview_plugins
  REQUIRED_PLUGINS SimpleParaViewCustomFilters # plugin下的插件的名称
  APPLICATION_XMLS ${xml_files}
  MAIN_WINDOW_CLASS myMainWindow
  ORGANIZATION "Kitware SAS."
  TITLE "Simple ParaView")

client/myMainWindow.h

myMainWindow主界面的头文件,只是定义了类,其中私有变量pqInternals会在该类的源文件中通过继承myMainWindow.ui生成的类,属于界面元素。在qt中,界面元素一般会作为类的成员变量,然后调用setupUI函数进行初始化。QScopedPointer为qt中的智能指针,自动析构指针指向的内容。

class myMainWindow : public QMainWindow
{
  Q_OBJECT
  typedef QMainWindow Superclass;

public:
  myMainWindow();
  ~myMainWindow() override;

private:
  Q_DISABLE_COPY(myMainWindow)

  class pqInternals;
  QScopedPointer<pqInternals> Internals;
};

client/myMainWindow.cxx

pqInternals继承自ui_myMainWindow.h中定义的类,该文件是由qt通过myMainWindow.ui文件生成的,该文件中定义了UI元素。*.ui文件可以使用Qt设计器打开。

pqLoadDataReaction类。该类用于加载多种数据文件。该类在paraview中已经实现了功能, 会使用工程模式进行文件的加载。

buildFiltersMenu是pqParaViewMenuBuilders中的静态函数,用与自动生成滤波器菜单,并生成滤波器相关的工具栏按钮。

buildPipelineBrowserContextMenu也是pqParaViewMenuBuilders中的静态函数,用于生成管线属性浏览器中的右键菜单。

/*=========================================================================

   Program: ParaView
   Module:    myMainWindow.cxx

   Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
   All rights reserved.

   ParaView is a free software; you can redistribute it and/or modify it
   under the terms of the ParaView license version 1.2.

   See License_v1.2.txt for the full ParaView license.
   A copy of this license can be obtained by contacting
   Kitware Inc.
   28 Corporate Drive
   Clifton Park, NY 12065
   USA

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

========================================================================*/
#include "myMainWindow.h"
#include "ui_myMainWindow.h" // *.ui文件经过uic处理后生成该文件

#include <pqApplicationCore.h>
#include <pqCategoryToolbarsBehavior.h>
#include <pqColorToolbar.h>
#include <pqDeleteReaction.h>
#include <pqHelpReaction.h>
#include <pqLoadDataReaction.h>
#include <pqParaViewBehaviors.h>
#include <pqParaViewMenuBuilders.h>
#include <pqRepresentationToolbar.h>

//-----------------------------------------------------------------------------
class myMainWindow::pqInternals : public Ui::pqClientMainWindow
{
};

//-----------------------------------------------------------------------------
myMainWindow::myMainWindow()
  : Internals(new pqInternals())
{
  // Setup default GUI layout.
  this->Internals->setupUi(this);

  // Setup the dock window corners to give the vertical docks more room.
  // 设置停靠区,qt中有上下左右四个停靠区。
  this->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
  this->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);

  // Setup color editor
  // Provide access to the color-editor panel for the application and hide it
  pqApplicationCore::instance()->registerManager(
    "COLOR_EDITOR_PANEL", this->Internals->colorMapEditorDock);
  this->Internals->colorMapEditorDock->hide();

  // Create a custom file menu with only Open and close
  // 可以从myMainWindow.ui
  QList<QAction*> actionList = this->Internals->menu_File->actions();
  QAction* action = actionList.at(0);

  // 调用pqActiveObjects的instance类,获取其静态变量,然后连接信号槽
  // pqLoadDataReaction的基类是pqReaction,pqReaction的基类是QObject
  // 构造函数的传入参数是父指针,即此处new的pqLoadDataReaction的父类是action
  // 因此创建的该实例会交由action进行管理,当action析构时,会先析构此处创建的类
  // 该类的作用是打开文件,即给该QAction按钮添加打开paraview文件的功能。
  // 该类中,onTriggered函数会发送loadedData信号
  new pqLoadDataReaction(action); 

  // actionList.at(1)是第二个按钮,即退出(Quit)按钮
  // 信号triggered和槽函数closeAllWindows进行连接,当点击该按钮时退出程序。
  QObject::connect(
    actionList.at(1), SIGNAL(triggered()), QApplication::instance(), SLOT(closeAllWindows()));

  // Build the filters menu
  // menuFilters是QMenu指针类型,为Qt的菜单元素。
  // buildFiltersMenu是类静态函数,用于自动创建Filters菜单,并同时生成需要的工具栏按钮。
  pqParaViewMenuBuilders::buildFiltersMenu(*this->Internals->menuFilters, this);

  // Setup the context menu for the pipeline browser.
  // pipelineBrowser的类型为pqPipelineBrowserWidget
  // buildPipelineBrowserContextMenu是类静态函数
  // 创建上下文菜单,该上下文菜单在数据管线属性浏览器中出现
  // 用于对属性进行操作
  pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(
    *this->Internals->pipelineBrowser->contextMenu());

  // Add the ColorToolbar
  QToolBar* colorToolbar = new pqColorToolbar(this);
  colorToolbar->layout()->setSpacing(0);
  this->addToolBar(colorToolbar);

  // Add the Representation Toolbar
  QToolBar* reprToolbar = new pqRepresentationToolbar(this);
  reprToolbar->setObjectName("Representation");
  reprToolbar->layout()->setSpacing(0);
  this->addToolBar(reprToolbar);

  // Enable help from the properties panel.
  // This is not really working as the documentation is not built in this app
  // proxyTabWidget是pqPropertiesPanel类型
  QObject::connect(this->Internals->proxyTabWidget, &pqPropertiesPanel::helpRequested,
    &pqHelpReaction::showProxyHelp);

  // hook delete to pqDeleteReaction.
  QAction* tempDeleteAction = new QAction(this);
  pqDeleteReaction* handler = new pqDeleteReaction(tempDeleteAction);
  handler->connect(this->Internals->proxyTabWidget, SIGNAL(deleteRequested(pqProxy*)),
    SLOT(deleteSource(pqProxy*)));

  // Final step, define application behaviors. Since we want all ParaView
  // behaviors, we use this convenience method.
  new pqParaViewBehaviors(this, this);
}

//-----------------------------------------------------------------------------
myMainWindow::~myMainWindow() = default;

client/myMainWindow.ui

该文件可以使用Qt工具Designer 创建和打开,myMainWindow.ui使用Designer打开如下。一般情况下,使用Designer进行界面元素的开发,在Designer中可以添加Qt界面元素,也可以用“提升”功能添加自定义界面元素。所见即所得,使用Designer会使用户界面开发变得方便快捷。

 client/ParaViewFilters.xml

当使用ParaView提供的自动生成Filters菜单时,该文件对菜单进行配置。

在该文件中,添加了子菜单Simple,并对三个按钮添加的图标,同时生成了工具栏按钮。

<ParaViewFilters>
  <Category name="Simple" menu_label="&amp;Simple" preserve_order="1" show_in_toolbar="1">
    <Proxy group="filters" name="Calculator" icon=":/pqWidgets/Icons/pqCalculator.svg"/>
    <Proxy group="filters" name="Contour" icon=":/pqWidgets/Icons/pqIsosurface.svg"/>
    <Proxy group="filters" name="Clip" icon=":/pqWidgets/Icons/pqClip.svg"/>
  </Category>
</ParaViewFilters>

plugins

plugins文件中存放了该程序的插件代码。在vtk_module_add_module使用了FORCE_STATIC,因此生成的是静态库,在构建client时,会将静态库编译进client的可执行程序中。

plugins/CMakeLists.txt

paraview_plugin_scan根据插件文件进行插件扫描,生成构建插件所需要的变量。其中PLUGIN_FILES是一个列表,每个元素是paraview.plugin的路径,此例子中是相对该CMakeLists.txt的路径,也可以指定绝对路径。其插件结果保存在PROVIDES_PLUGINS后面指定的变量中,在该例子中,plugins中保存了本次扫描得到的可用插件列表。ENABLE_BY_DEFAULT表明在本次扫描中使该插件可用。

paraview_plugin_build用于构建插件,其在paraview的安装目录下的lib/cmake/ParaViewPlugin.cmake中定义。定义如下:

paraview_plugin_build(
  PLUGINS <plugin>...
  [AUTOLOAD <plugin>...]
  [PLUGINS_COMPONENT <component>]

  [TARGET <target>]
  [INSTALL_EXPORT <export>]
  [CMAKE_DESTINATION <destination>]
  [TARGET_COMPONENT <component>]
  [INSTALL_HEADERS <ON|OFF>]

  [HEADERS_DESTINATION <destination>]
  [RUNTIME_DESTINATION <destination>]
  [LIBRARY_DESTINATION <destination>]
  [LIBRARY_SUBDIRECTORY <subdirectory>]
  [ADD_INSTALL_RPATHS <ON|OFF>]

  [PLUGINS_FILE_NAME <filename>]
  [DISABLE_XML_DOCUMENTATION <ON|OFF>])

PLUGINS:必填项,使需要构建的插件的列表。

AUTOLOAD:需要进行自动加载的插件的列表。

PLUGINS_COMPONENT:默认为“paraview_plugins”。已安装插件的安装组件。

TARGET:建议设置。生成接口目标的名字。该接口目标提供了<TARGET>_initialize初始化函数。该函数初始化静态插件。对于动态插件该,让就提供该函数,但是其中不会有任何操作。在该例子中,生成了simple_paraview_plugins.h,其中提供了static void simple_paraview_plugins_initialize()函数。

INSTALL_EXXPORT:如果提供了该参数,则生成的目标会被添加到提供名字的到处集合中。

CMAKE_DESTINATION:如果提供该参数,该插件目标的属性会被卸载一个名字为<TARGET>-paraview-plugin-properties.cmake的文件中。该文件在该参数指定的目录中。

TARGET_COMPONENT:默认为“development”。<TARGET>中使用的组件。

INSTALL_HEADERS:默认为ON,是否安装头文件。

HEADERS_DESTINATION:默认为“${CMAKE_INSTALL_INCLUDEDIR}”,头文件的安装路径。

RUNTIME_DESTINATION:默认为“${CMAKE_INSTALL_BINDIR}”,运行时文件的安装路径。

LIBRARY_DESTINATION:默认为“${CMAKE_INSTALL_LIBDIR}”,构建的插件模块的安装路径。

LIBRARY_SUBDIRECTORY:默认为空(""),在哪里安装插件本身。每个插件都位于`<RUNTIME_DESTINATION>/<LIBRARY_SUBDIRECTORY> `(对于Windows)或`<LIBRARY_DESTINATION>/<LIBRARY_SUBDIRECTORY> `(对于其他平台)中以其名称命名的目录中。

ADD_INSTALL_RPATHS:默认为ON,如果指定,将添加一个从插件的“LIBRARY_DESTINATION”加载相关库的RPATH。

PLUGINS_FILE_NAME:生成的XML插件文件的名字,里面有对插件的描述。该文件在<LIVRARY_DESTINATION>/<LIBRARY_SUBDIRECTORY>中。并且它会随着插件一块安装。

DISABLE_XML_DOCUMENTATION:默认为OFF,是否强制关闭XML文件。

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

# Classic plugin scan/build
# Each plugin should be listed in the PLUGIN_FILES arg of paraview_plugin_scan

paraview_plugin_scan(
  PLUGIN_FILES
    SimpleParaViewCustomFilters/paraview.plugin
  PROVIDES_PLUGINS plugins
  ENABLE_BY_DEFAULT ON
  HIDE_PLUGINS_FROM_CACHE ON)

# 1>-- CMAKE_INSTALL_BINDIR=bin
# 1>-- CMAKE_INSTALL_LIBDIR=lib
# 1>-- PARAVIEW_PLUGIN_SUBDIR=paraview-5.11/plugins
paraview_plugin_build(
  RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
  LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}"
  PLUGINS_FILE_NAME "SimpleParaView.xml"
  INSTALL_EXPORT SimpleParaViewPlugins
  CMAKE_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SimpleParaView
  LIBRARY_SUBDIRECTORY "SimpleParaView"
  PLUGINS ${plugins}
  TARGET simple_paraview_plugins)

SimpleParaViewCustomFilters/paraview.plugin

该文件定义了插件的名称,描述,以及依赖的模块。在该例子中,在windows平台下会生成SimpleParaViewCustomFilters.dll文件。其需要依赖与VTK::CommonCore和VTK::FilterCore模块。

NAME
  SimpleParaViewCustomFilters
DESCRIPTION
  An example paraview plugin to be loaded in SimpleParaview
  Copied from ElevationFilters example
REQUIRES_MODULES
  VTK::CommonCore
  VTK::FiltersCore

SimpleParaViewCustomFilters/CMakeLists.txt

该文件中调用了paraview_add_plugin函数。

paraview_add_plugin(SimpleParaViewCustomFilters
  VERSION "1.0"
  MODULES ElevationFiltersApp
  MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ElevationFiltersApp/vtk.module")

paraview_add_plugin函数用于添加paraview插件,其在paraview的安装目录下的lib/cmake/ParaViewPlugin.cmake中定义。定义如下:

paraview_add_plugin(<name>
  [REQUIRED_ON_SERVER] [REQUIRED_ON_CLIENT]
  VERSION <version>

  [MODULE_FILES <vtk.module>...]
  [MODULE_ARGS <arg>...]
  [MODULES <module>...]
  [SOURCES <source>...]
  [SERVER_MANAGER_XML <xml>...]
  [MODULE_INSTALL_EXPORT <export>]

  [UI_INTERFACES <interface>...]
  [UI_RESOURCES <resource>...]
  [UI_FILES <file>...]

  [PYTHON_MODULES <module>...]

  [INITIALIZERS <initializerFunction>...]

  [EXTRA_INCLUDES <file>...]

  [REQUIRED_PLUGINS <plugin>...]

  [EULA <eula>]
  [XML_DOCUMENTATION <ON|OFF>]
  [DOCUMENTATION_DIR <directory>]
  [DOCUMENTATION_ADD_PATTERNS <pattern>...]
  [DOCUMENTATION_TOC <string>]
  [DOCUMENTATION_DEPENDENCIES <target>...]

  [FORCE_STATIC <ON|OFF>])

  [TRANSLATIONS_DIRECTORY <directory>]
  [TRANSLATIONS_TARGET    <target>])

REQUIRED_ON_SERVER:表明该插件加载在服务端。

REQUIRED_ON_CLINET:表明该插件加载在客户端。

VERSION:必填项,插件的版本。

MODULE_FILES:需要添加插件的vtk.module文件路径列表。

MODULE_ARGS:传递给vtk_module_build的已包含模块的参数。

MODULES:该插件需要包含的模块。这些模块会被服务端或者客户端封装,并且并处理它们的服务器管理器XML文件。

SOURCES:插件的源文件。

SERVER_MANAGER_XML:插件的服务器管理器XML文件。

UI_INTERFACES:用于初始化的接口,会按给定的顺序初始化。更多细节见插件接口部分。

MODULE_INSTALL_EXPORT:默认和<NAME>参数一致。如果提供,模块都会添加到该导出集中。

UI_RESOURCES:插件用到的Qt资源文件。

UI_FILES:Qt的*.ui文件,用于该插件的界面。

PYTHON_MODULES:插件所需的python模块。

INITIALIZERS:加载插件时调用的自由函数(free functions)的有序列表(如果需要,在‘EXTRA_INCLUDES’中声明)。每个函数必须是可调用的,没有参数。

EXTRA_INCLUDES:头文件列表,其中包含了用于产生插件的代码(比如在INITIALIZERS中需要的)。不带引号传递的文件路径会被加上双引号,以尖括号或双引号开头的路径不会被加上双引号。

REQUIRED_PLUGINS:本插件所需要的其他插件。这些插件不需要在构建阶段可用,因此此处不会检查这些插件是否已经存在。

EULA:运行时插件初始化之前,包含显示为最终用户许可协议的内容的文件。

XML_DOCUMENTATION:默认为ON。如果开启,将为关联的XML文件生成文档。

DOCUMENTATION_DIR:如果设置,该参数指定的目录下的`*.html`, `*.css`, `*.png`, `*.js`, and `*.jpg`文件会被用来生成文档,并会随之一起进行复制。

DOCUMENTATION_ADD_PATTERNS:如果指定,则为“DOCUMENTATION_DIR”中的文档文件添加除默认模式之外的模式(参见“DOCUMENTATION_DIR”帮助)。

DOCUMENTATION_TOC:如果指定,使用此字符串描述文档的目录。

DOCUMENTATION_DEPENDENCIES:创建该文档需要的其他已经构建的目标。

EXPORT:已经弃用。使用paraview_plugin_build(INSTALL_EXPORT)代替。

FORCE_STATIC:默认为OFF。强制生成静态库。因此该插件会被插入到应用程序的可执行文件中。

TRANSLATIONS_DIRECTORY:默认为 "${CMAKE_CURRENT_BINARY_DIR}/Translations"。翻译源文件存储的文件。

TRANSLATION_TARGET:目标的名称,使用该目标添加ts文件作为依赖。

SimpleParaViewCustomFilters/ElevationFiltersApp

vtk模块的代码

ElevationFiltersApp/vtk.module

指明了模块的名称,以及其依赖的模块。

NAME
  ElevationFiltersApp
DEPENDS
  VTK::FiltersCore
PRIVATE_DEPENDS
  VTK::CommonCore

ElevationFiltersApp/CMakeLists.txt

在该CMakeLists.txt中,调用了vtk_module_add_module创建模块库,名称为ElevationFiltersApp,生成静态库,类名为vtkMyElevationFilter。该函数中的CLASSES参数会自动定义SOURCES vtkMyElevationFilter.cxx,以及HEADERS vtkMyElevationFilter.h。

然后调用了paraview_add_server_manager_xmls指明了xml文件的名字。

set(classes
  vtkMyElevationFilter)

vtk_module_add_module(ElevationFiltersApp
  FORCE_STATIC # Using FORCE_STATIC build the vtk module statically into the plugin library, to avoid confusion when loading
  CLASSES ${classes})

paraview_add_server_manager_xmls(
  XMLS  MyElevationFilter.xml)

paraview_add_server_manager_xmls函数定义在lib/cmake/ParaViewServerManager.cmake模块中。模块可能有关联的XML文件。可以使用这个函数将它们添加到模块目标中。

ElevationFiltersApp/MyElevationFilter.xml

该文件中说明了插件的输入数据类型,参数,以及一些配置界面。

<ServerManagerConfiguration>
  <!-- This is the server manager configuration XML. It defines the interface to
       our new filter. As a rule of thumb, try to locate the configuration for
       a filter already in ParaView (in Remoting/Application/Resources/*.xml)
       that matches your filter and then model your xml on it -->
  <ProxyGroup name="filters">
   <SourceProxy name="MyElevationFilter" class="vtkMyElevationFilter" label="MyElevation">
     <Documentation
        long_help="Create point attribute array by projecting points onto an elevation vector."
        short_help="Create a point array representing elevation.">
          The Elevation filter generates point scalar values for an input data
          set along a specified direction vector. The Input menu allows the user
          to select the data set to which this filter will be applied. The Low
          Point and High Point define a line onto which each point of the data
          set is projected. The minimum scalar value is associated with the Low
          Point, and the maximum scalar value is associated with the High Point.
          The scalar value for each point in the data set is determined by the
          location along the line to which that point projects.

          The line can be specified interactively using the 3D line widget. See
          section 7.4 for more information about this widget.
     </Documentation>
     <InputProperty
        name="Input"
        command="SetInputConnection">
           <ProxyGroupDomain name="groups">
             <Group name="sources"/>
             <Group name="filters"/>
           </ProxyGroupDomain>
           <DataTypeDomain name="input_type">
             <DataType value="vtkDataSet"/>
           </DataTypeDomain>
      </InputProperty>

      <DoubleVectorProperty
         name="LowPoint"
         label="Low Point"
         command="SetLowPoint"
         number_of_elements="3"
         animateable="1"
         default_values="0 0 0" >
         <BoundsDomain name="range" mode="normal" default_mode="min" >
           <RequiredProperties>
             <Property name="Input" function="Input" />
           </RequiredProperties>
         </BoundsDomain>
         <Documentation>
           Define one end of the line (small scalar values). Default is (0,0,0).
         </Documentation>
      </DoubleVectorProperty>

      <DoubleVectorProperty
         name="HighPoint"
         label="High Point"
         command="SetHighPoint"
         number_of_elements="3"
         animateable="1"
         default_values="0 0 1" >
         <BoundsDomain name="range" mode="normal" default_mode="max" >
           <RequiredProperties>
             <Property name="Input" function="Input" />
           </RequiredProperties>
         </BoundsDomain>
         <Documentation>
           Define other end of the line (large scalar values). Default is (0,0,1).
         </Documentation>
      </DoubleVectorProperty>

      <PropertyGroup panel_widget="InteractiveLine">
        <Property function="Point1WorldPosition" name="LowPoint" />
        <Property function="Point2WorldPosition" name="HighPoint" />
        <Property function="Input" name="Input" />
      </PropertyGroup>
   <!-- End MyElevationFilter -->
   </SourceProxy>
 </ProxyGroup>
</ServerManagerConfiguration>

ElevationFiltersApp/vtkMyElevationFilter类

该类继承自vtkElevationFilter,未作任何修改。

vtkMyElevationFilter是一个从数据集生成标量值的过滤器。标量值位于用户指定的范围内,通过计算每个数据集点在线上的投影来生成。该线可以任意定向。一个典型的例子是基于平面上方的海拔或高度来生成标量。

// vtkMyElevationFilter.h
#include <vtkElevationFilter.h>

#include "ElevationFiltersAppModule.h" // for export macro

class ELEVATIONFILTERSAPP_EXPORT vtkMyElevationFilter : public vtkElevationFilter
{
public:
  static vtkMyElevationFilter* New();
  vtkTypeMacro(vtkMyElevationFilter, vtkElevationFilter);
  void PrintSelf(ostream& os, vtkIndent indent) override;

protected:
  vtkMyElevationFilter();
  ~vtkMyElevationFilter();

private:
  vtkMyElevationFilter(const vtkMyElevationFilter&) = delete;
  void operator=(const vtkMyElevationFilter&) = delete;
};

// vtkMyElevationFilter.cxx
#include "vtkMyElevationFilter.h"

#include <vtkObjectFactory.h>

vtkStandardNewMacro(vtkMyElevationFilter);

//----------------------------------------------------------------------------
vtkMyElevationFilter::vtkMyElevationFilter() = default;

//----------------------------------------------------------------------------
vtkMyElevationFilter::~vtkMyElevationFilter() = default;

//----------------------------------------------------------------------------
void vtkMyElevationFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值