Attempt to create Dock Window to configure VR connections in ParaView

Standard way of adding a QDockWidget to a Plugin in ParaView:

  1. Look at ParaView/Examples/Plugins/DockWidget
  2. Use the ADD_PARAVIEW_DOCK_WINDOW macro defined in ParaView/CMake/ParaViewPlugins.cmake
  3. Result of the CMake macro: a file called ${ARG_CLASS_NAME}Implementation.h (which implements the pqDockWindowInterface) is created and compiled into the Qt project via the Qt Meta Object Compiler *
  4. pqPluginDockWidgetsBehavior calls each pqDockWindowInterface::dockWidget to create an instance of the plugin-specific class that extends QDockWidget

Problem: pqVRConfigPanel, which extends QDockWidget, is not aware of VR Plugin instance, and VR Plugin instance is not aware of pqVRConfigPanel class. The QDockWidget signals cannot be connected VR Plugin slots.

Solution attempt 1:

  1. Make pqVRStarter implement pqDockWindowInterface.
  2. Create dockWidget in the pqVRStarter::onStartup() slot. I.e. invoke pqVRStarter::dockWidget() with pqCoreUtilities::mainWidget() as parent parameter (pqCoreUtilities::mainWidget() returns the QMainWindow of the application)

Result:

Runtime error because pqVRStarter::onStartup() is called before ParaViewMainWindow (which extends QMainWindow) is finalized. The dockWidget could not be properly embedded in the UI.

Solution attempt 2 (to do):

  1. Edit VR Plugin’s CMakeLists.txt to register the CMake-generated pqVRStarterImplementation as a pqDockWindowInterface. This may create the VR Plugin’s QDockWidget at the same time as the other QDockWidget’s creation in pqPluginDockWidgetsBehavior

* Qt prohibits a class that inherits from a Qt class to contain multiple inheritance since Qt classes are not implemented via  virtual inheritance. To work around this, Qt interface can be used http://www.qtforum.org/article/13381/multiple-inheritance-and-qobject.html

** CMake Macro for creating pqDockWindowInterface:

# create implementation for a dock window interface
# ADD_PARAVIEW_DOCK_WINDOW(
# OUTIFACES
# OUTSRCS
# CLASS_NAME classname
# [DOCK_AREA areaname]
#
# CLASS_NAME: is the name of the class that implements a QDockWidget
# DOCK_AREA: option to specify the dock area (Left | Right | Top | Bottom)
# Left is the default
MACRO(ADD_PARAVIEW_DOCK_WINDOW OUTIFACES OUTSRCS)
SET(ARG_DOCK_AREA)
PV_PLUGIN_PARSE_ARGUMENTS(ARG "CLASS_NAME;DOCK_AREA" "" ${ARGN} )
IF(NOT ARG_DOCK_AREA)
 SET(ARG_DOCK_AREA Left)
 ENDIF(NOT ARG_DOCK_AREA)
 SET(${OUTIFACES} ${ARG_CLASS_NAME})
CONFIGURE_FILE(${ParaView_CMAKE_DIR}/pqDockWindowImplementation.h.in
 ${CMAKE_CURRENT_BINARY_DIR}/${ARG_CLASS_NAME}Implementation.h @
ONLY)
 CONFIGURE_FILE(${ParaView_CMAKE_DIR}/pqDockWindowImplementation.cxx.in
 ${CMAKE_CURRENT_BINARY_DIR}/${ARG_CLASS_NAME}Implementation.cxx
 @ONLY)
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
 SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${QT_INCLUDE_DIRS};${
PARAVIEW_GUI_INCLUDE_DIRS}")
 SET(ACTION_MOC_SRCS)
 QT4_WRAP_CPP(ACTION_MOC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${ARG_CLASS_NAME}Impl
ementation.h)
 SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
SET(${OUTSRCS}
 ${CMAKE_CURRENT_BINARY_DIR}/${ARG_CLASS_NAME}Implementation.cxx
 ${CMAKE_CURRENT_BINARY_DIR}/${ARG_CLASS_NAME}Implementation.h
 ${ACTION_MOC_SRCS}
 )
ENDMACRO(ADD_PARAVIEW_DOCK_WINDOW)
Advertisements

About Alexis Chan

https://alexisylchan.wordpress.com/about/
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s