[Paraview] paraview plugins and python

Pat Marion pat.marion at kitware.com
Wed May 2 13:05:28 EDT 2012


This will do it:

# CMakeLists.txt

include(wrap-python.cmake)

add_paraview_plugin(${library_name} ...)
target_link_libraries(${library_name} ${deps})

if(VTK_WRAP_PYTHON)
  wrap_python(${library_name} "${sources}")
endif()




# wrap-python.cmake
if(NOT DEFINED VTK_CMAKE_DIR)
  message(SEND_ERROR "VTK_CMAKE_DIR is not defined, cannot load
vtkWrapPython.cmake")
endif()

if(NOT VTK_WRAP_PYTHON)
  message(FATAL_ERROR "VTK was built without Python enabled
(VTK_WRAP_PYTHON=FALSE).")
endif()

include(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
function(wrap_python library_name sources)
  vtk_wrap_python3(${library_name}Python generated_python_sources
"${sources}")
  add_library(${library_name}PythonD ${generated_python_sources})
  add_library(${library_name}Python MODULE ${library_name}PythonInit.cxx)
  target_link_libraries(${library_name}PythonD ${library_name})
  foreach(c ${VTK_LIBRARIES})
    target_link_libraries(${library_name}PythonD ${c}PythonD)
  endforeach(c)
  target_link_libraries(${library_name}Python ${library_name}PythonD)
  set_target_properties(${library_name}Python PROPERTIES PREFIX "")
  if(WIN32 AND NOT CYGWIN)
    set_target_properties(${library_name}Python PROPERTIES SUFFIX ".pyd")
  endif(WIN32 AND NOT CYGWIN)
endfunction()



Pat


On Wed, May 2, 2012 at 11:56 AM, Sebastien Jourdain <
sebastien.jourdain at kitware.com> wrote:

> Hi Paul,
>
> it is not a CMake option but a CMake macro/function that need to be
> called inside your Plugin CMake file... But I have no clue how, has I
> took another path when I solved that exact same problem.
> In my case, I simply extended ParaView itself instead of relying on a
> plugin...
>
> Seb
>
> On Wed, May 2, 2012 at 11:49 AM, Paul Edwards <paul.m.edwards at gmail.com>
> wrote:
> > I'm actually wanting the VTK classes rather than the proxy.
> >
> > Sebastian: are you referring to the VTK_WRAP_PYTHON_SIP option?  I don't
> > have that enabled atm but could try...
> >
> > Thanks,
> > Paul
> >
> >
> > On 2 May 2012 16:43, Andy Bauer <andy.bauer at kitware.com> wrote:
> >>
> >> I'm not sure this is what you're looking for but the proxy does get
> >> wrapped such that it's available through pvpython and pvbatch.  When you
> >> load the plugin, do "LoadPlugin("<shared lib location>", True,
> globals())"
> >> and it should be available.  If you're want the actual VTK class to by
> >> python wrapped, I think Sebastien is correct though.
> >>
> >> Andy
> >>
> >>
> >> On Wed, May 2, 2012 at 11:32 AM, Sebastien Jourdain
> >> <sebastien.jourdain at kitware.com> wrote:
> >>>
> >>> Hi Paul,
> >>>
> >>> your vtk class are not "python" wrapped automatically when provided
> >>> from plugin. But you might be able to use a CMake macro that has been
> >>> defined in ParaView to force your vtk classes to be Python wrapped.
> >>> Although, I'm not fully certain that will just work.
> >>> Unfortunately I don't have much insight on where to look.
> >>>
> >>> Dave DeMarle might be able to point you to the right direction...
> >>>
> >>> Seb
> >>>
> >>> On Wed, May 2, 2012 at 10:56 AM, Paul Edwards <
> paul.m.edwards at gmail.com>
> >>> wrote:
> >>> > Hi,
> >>> >
> >>> > Do my VTK classes get wrapped when I create a paraview plugin?  If
> so,
> >>> > how
> >>> > do I access them? And, if not, is it possible to do this?
> >>> >
> >>> > Thanks,
> >>> > Paul
> >>> >
> >>> > _______________________________________________
> >>> > 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://www.paraview.org/mailman/listinfo/paraview
> >>> >
> >>> _______________________________________________
> >>> 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://www.paraview.org/mailman/listinfo/paraview
> >>
> >>
> >
> _______________________________________________
> 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://www.paraview.org/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120502/3468a415/attachment-0001.htm>


More information about the ParaView mailing list