Code Monkey home page Code Monkey logo

pvxmlgen's Introduction

pvxmlgen

License: MIT

Travis CI

Coveralls

Generates ParaView Server Manager XML from C++ headers with specially crafted comments. Full documentation at https://lhofmann.github.io/pvxmlgen/.

Developing ParaView plugins requires the definition of the plugin's interface in an XML format (Server Manager XML). For example, names, labels, data types and default values of the plugin's parameters need to be specified there. Not only does this mean writing lots of boilerplate, but also definitions already specified in the C++ code are duplicated and often desynchronized.

pvxmlgen provides the following features:

  • Fast and less error-prone generation of XML by a sequence of Python commands,
  • Simple integration by adding comments in the C++ header files,
  • Automatic synchronization of default values and names between C++ and XML,
  • Integration with CMake build systems.

Example

A plugin, that has a parameter Position, which is a 3-element double array, needs the following XML definition:

<DoubleVectorProperty command="SetPosition"
                      default_values="1.0 1.0 0.0"
                      name="Position"
                      label="Starting Position"
                      number_of_elements="3"/>

Above XML block has been generated by pvxmlgen from this C++ code:

// pv_( autovector(label='Starting Position') )pv_
double Position[3] {1.0, 1.0, 0.0};

Type, variable name and default values can all be automatically deduced from its C++ definition! Find out more in the documentation.

Usage

Requires Python 3.5+ or 2.7 to run.

Standalone

$ python pvxmlgen.py [input.h] [output.xml]

The result is printed to standard output, if - is passed as output file.

CMake

Add the root directory of pvxmlgen to your CMake project with add_subdirectory. This makes the CMake function pvxmlgen_generate available, which (re-)generates a XML file from a header whenever it is modified. Note, that the XML file in the source directory is overwritten! An example is provided in the subdirectory example/.

add_paraview_plugin(MyFilter 1.0
    SERVER_MANAGER_XML MyFilter.xml
    SERVER_MANAGER_SOURCES vtkMyFilter.cxx)
pvxmlgen_generate(MyFilter INPUT vtkMyFilter.h OUTPUT MyFilter.xml)

Contributing

Run unit tests with pytest and linter with flake8.

$ pip install pytest flake8
$ py.test tests
$ flake8

The directory tests/testcases contains pairs of file.h, file.h.xml, which are automatically tested against each other. Upon test failure, a diff is printed.

pvxmlgen's People

Contributors

lhofmann avatar

Stargazers

Mohamed Mzoughi avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

embeddedmz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.