[Paraview] HOWto create / extend sources?

B.W.H. van Beest bwvb at xs4all.nl
Tue Sep 30 14:09:58 EDT 2014


Utkash,

I followed-up on your suggestions, but apparently I am doing something
wrong. I hope you or somebody else can point me to the solution.

This is what I did.

1) new class: sphBoxSource.  I extended class vtkCubeSource with one
data member, with corresponding get/set method. (Code below)
2) I added an xml-file, with the source description taken from
source.xml (CubeSource). (Below)
3) I modified the CMakeList.txt accordingly.  (Below)

Magically, the new source appeared in the menu. But when clicking it,
the program crashed.
 The error message I get is:

ERROR: In
/usr/local/git/ParaView/ParaViewCore/ServerImplementation/Core/vtkSIProxy.cxx,
line 307
vtkSISourceProxy (0x30289e0): Failed to create sphBoxSource. Aborting
for debugging purposes.


I noticed that several people running into similar problems, but so far
I haven't been able to find the clue to the solution.


Before showing the code, I give the result of the compilation.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

chopin Plugins/SPHToolbar# make clean
chopin Plugins/SPHToolbar# make
[  0%] Generating Documentation HTMLs from xmls
Processing wiki sources
Processing wiki filters
Processing wiki writers
Processing wiki readers
[ 10%] Generating qrc_sph_icons.cxx
[ 10%] Compiling Qt help project SPHToolbar.qhp
Building up file structure...
Insert custom filters...
Insert help data for filter section (1 of 1)...
Insert files...
Warning: The file
/usr/local/git/ParaView/build/Examples/All/Plugins/SPHToolbar/doc/*.css
does not exist! Skipping it.
Warning: The file
/usr/local/git/ParaView/build/Examples/All/Plugins/SPHToolbar/doc/*.png
does not exist! Skipping it.
Warning: The file
/usr/local/git/ParaView/build/Examples/All/Plugins/SPHToolbar/doc/*.jpg
does not exist! Skipping it.
Insert contents...
Insert indices...
Documentation successfully generated.
[ 10%] Generating SPHToolbar_doc.h
-- Generate module: SPHToolbar
[ 10%] Generating vtkSMXML_SPHToolbar.h
-- Generate module: sph_sources
[ 20%] Generating moc_SPHToolbarActions.cpp
[ 20%] Generating moc_sphBActionCreateSource.cpp
[ 30%] Generating moc_sphBAction.cpp
[ 30%] Generating moc_SPHToolbarActionsImplementation.cpp
[ 40%] Generating moc_SPHToolbar_Plugin.cpp
Scanning dependencies of target SPHToolbar
[ 50%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/qrc_sph_icons.o
[ 50%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/moc_SPHToolbarActions.o
[ 60%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/moc_sphBActionCreateSource.o
[ 60%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/moc_sphBAction.o
[ 60%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/SPHToolbarActionsImplementation.o
[ 70%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/moc_SPHToolbarActionsImplementation.o
[ 70%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/SPHToolbarActions.o
[ 80%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/sphBActionCreateSource.o
[ 80%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/sphBActionRegionInventory.o
[ 90%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/sphBoxSource.o
[ 90%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/sphUndoStack.o
[ 90%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/sphObjectTracer.o
[100%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/SPHToolbar_Plugin.o
[100%] Building CXX object
Plugins/SPHToolbar/CMakeFiles/SPHToolbar.dir/moc_SPHToolbar_Plugin.o
Linking CXX shared library
/usr/local/git/ParaView/build/lib/libSPHToolbar.so
[100%] Built target SPHToolbar
chopin Plugins/SPHToolbar#

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@










======================================================
Here is the new class:

#include "vtkCubeSource.h"
class sphBoxSource : public vtkCubeSource
{
private:
   int _type;

public:
  static sphBoxSource *New();                                 // Monkey
see, monkey do ??????????????
   vtkTypeMacro(sphBoxSource,vtkCubeSource);     // Monkey see, monkey
do ??????????????

public:
   sphBoxSource( double=1.0, double=1.0, double=1.0 );
   ~sphBoxSource();

public:
   void setType( int );
   int getType() const;
};
============================================================

XML-file "sph_sources.xml": (adapted from sources.xml)
============================================================
<ServerManagerConfiguration>
  <ProxyGroup name="sources">
    <SourceProxy class="sphBoxSource"
                 label="SPHBox"
                 name="SPHBoxSource">
      <Documentation long_help="Create a box with specified X, Y, and Z
lengths."
                     short_help="3D box with specified X, Y, and Z
lengths">The
                     Box source can be used to add a box to the 3D
scene. The
                     output of the Box source is polygonal data
containing both
                     normals and texture coordinates.</Documentation>
      <DoubleVectorProperty animateable="1"
                            command="SetXLength"
                            default_values="1.0"
                            name="XLength"
                            number_of_elements="1"
                            panel_visibility="default">
        <DoubleRangeDomain min="0"
                           name="range" />
        <Documentation>This property specifies the length of the box in
the X
        direction.</Documentation>
      </DoubleVectorProperty>
      <DoubleVectorProperty animateable="1"
                            command="SetYLength"
                            default_values="1.0"
                            name="YLength"
                            number_of_elements="1"
                            panel_visibility="default">
        <DoubleRangeDomain min="0"
                           name="range" />
        <Documentation>This property specifies the length of the box in
the Y
        direction.</Documentation>
      </DoubleVectorProperty>
      <DoubleVectorProperty animateable="1"
                            command="SetZLength"
                            default_values="1.0"
                            name="ZLength"
                            number_of_elements="1"
                            panel_visibility="default">
        <DoubleRangeDomain min="0"
                           name="range" />
        <Documentation>This property specifies the length of the box in
the Z
        direction.</Documentation>
      </DoubleVectorProperty>
      <DoubleVectorProperty animateable="1"
                            command="SetCenter"
                            default_values="0.0 0.0 0.0"
                            name="Center"
                            number_of_elements="3"
                            panel_visibility="default">
        <DoubleRangeDomain name="range" />
        <Documentation>This property specifies the center of the
        box.</Documentation>
      </DoubleVectorProperty>
      <!-- End Box -->
    </SourceProxy>
  </ProxyGroup>
</ServerManagerConfiguration>
======================================================================

Finally, the CMakeList.txt reads:
======================================================================

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

IF(NOT ParaView_BINARY_DIR)
  FIND_PACKAGE(ParaView REQUIRED)
  INCLUDE(${PARAVIEW_USE_FILE})
ENDIF(NOT ParaView_BINARY_DIR)

IF(PARAVIEW_BUILD_QT_GUI)
  # We need to wrap for Qt stuff such as signals/slots etc. to work
correctly.
  IF (PARAVIEW_QT_VERSION VERSION_GREATER "4")
    QT5_WRAP_CPP(MOC_SRCS SPHToolbarActions.h sphBActionCreateSource.h
sphBAction.h )
  ELSE ()
    QT4_WRAP_CPP(MOC_SRCS SPHToolbarActions.h sphBActionCreateSource.h
sphBAction.h )
  ENDIF ()

  # This is a macro for adding QActionGroup subclasses automatically as
toolbars.
  ADD_PARAVIEW_ACTION_GROUP(IFACES IFACE_SRCS
                            CLASS_NAME SPHToolbarActions
                            GROUP_NAME "ToolBar/SPHToolbar")

  # Now create a plugin for the toolbar. Here we pass IFACES and IFACE_SRCS
  # which are filled up by the above macro with relevant entries
  ADD_PARAVIEW_PLUGIN(SPHToolbar "1.0"
                      GUI_INTERFACES ${IFACES}
                      GUI_RESOURCES sph_icons.qrc
                      SERVER_MANAGER_XML sph_sources.xml
                      SOURCES ${MOC_SRCS} ${IFACE_SRCS}
                                SPHToolbarActions.cpp
sphBActionCreateSource.cpp sphBActionRegionInventory.cpp
                                sphBoxSource.cpp
                                sphUndoStack.cpp sphObjectTracer.cpp )
ENDIF(PARAVIEW_BUILD_QT_GUI)

======================================================================

On 09/29/2014 02:46 PM, Utkarsh Ayachit wrote:
>> a) How to create a new source ("MyNewSource")
> You define the 'proxy' under the "sources" group, rather than filters.
> It will automatically show up in the Menu. Look at sources.xml under
> [1] to see other source proxy definitions.
>
>> b) How can I extend an existing source (box, sphere, etc.) with new
>> properties and methods ("MyBox, "MySphere").
> Similar to the filters, you basically need to write a new VTK
> algorithm with these new methods. You can subclass the existing VTK
> source. Looking at sources.xml, you can find out which proxy using
> which VTK algorithm, e.g. "SphereSource" (labelled as "Sphere") uses
> "vtkSphereSource". After adding the methods on the VTK algorithm, next
> part is exposing those methods as properties using the XML.
>
> [1] https://github.com/Kitware/ParaView/tree/master/ParaViewCore/ServerManager/SMApplication/Resources
>
>> Any help or suggestions are greatly appreciated.
>>
>> Kind Regards,
>> Bertwim
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview



More information about the ParaView mailing list