Projects:ARRA:VTKWidgetsTesting

From NAMIC
Jump to: navigation, search
Home < Projects:ARRA:VTKWidgetsTesting

Setting up Testing

Working from the Slicer3 VTK56 git repository. First wave of changes checked in on August 10, 2010.

First goal is to set up a similar infrastructure as used in Slicer3/Libs/MRML/Testing, which includes a file that defines basic testing macros (Slicer3/TestingMacros.h) that calls methods on super classes and chains macros together as you get down to testing subclasses. The file

 VTK/Widgets/Testing/Cxx/WidgetTestingMacros.h

is set up to define:

  EXERCISE_BASIC_OBJECT_METHODS (copied from Slicer, thanks to Luis Ibanez)
  TEST_SET_GET for various variable types (INT, BOOLEAN, STRING, DOUBLE, VECTOR3, VECTOR2, CHAR)
  EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS for the superclass (could be moved/copied to VTK/Rendering/Testing, no tests yet)
  EXERCISE_BASIC_ABSTRACT_METHODS to test vtkAbstractWidget method
  EXERCISE_BASIC_BORDER_METHODS to test widgets that inherit from vtkBorderWidget (Text)
  EXERCISE_BASIC_HOVER_METHOD to test widgets that inherit from vtkHoverWidget (Balloon)
  EXERCISE_BASIC_PROP_METHODS to test representations that inherit from the vtkProp superclass
  EXERCISE_BASIC_REPRESENTATION_METHODS to test representations that inherit from the vtkWidgetRepresentation superclass
  EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS to test representations that inherit from the vtkAngleRepresentation superclass
  EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS to test representations that inherit from the vtkBorderRepresentation
  TEST_SET_GET_PROPERTY -  test objects that have Property and SelectedProperty set/get, with vtkProperty
  EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS -  test handle representations that inherit from vtkHandleRepresentation (seg faulting)
  EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS 

test handle representations that in herit from vtkAbstractPolygonalHandleRepresentation3D (Polygonal and Oriented Polygonal 3D)

Then new testing .cxx files were crafted and added to the CMakeLists.txt to use these basic macros to test every call.

Priority Widgets

Widgets

Notes made while writing the Widget tests: (priorities taken from here: Priority Widgets, indentation shows inheritance)

  • vtkInteractorObserver defines the Enabled variable and the On/Off methods. Testing them in isolation shows that there are missing checks for having an interactor defined, as the test crashes consistently even after creating a render window and interactor to pass to the widget
    • vtkAbstractWidget Set/Get Parent doesn't work in stand alone tests
      • vtkAngleWidget
        • Would like GetWidgetState macro, GetCurrentHandle macro.
        • Access to HandleWidgets?
      • vtkBidimensionalWidget
        • Would like Get macros for WidgetState, CurrentHandle, HandleLine1Selected, HandleLine2Selected, Line1InnerSelected, Line1OuterSelected, Line2InnerSelected, Line2OuterSelected, CenterSelected.
        • Access to HandleWidgets?
      • vtkImplicitPlaneWidget2 Would like Get macro for WidgetState
      • vtkLineWidget2
        • Would like GetWidgetState macro, GetCurrentHandle macro
        • Access to HandleWidgets?
      • vtkSeedWidget
        • Would like Get macros for WidgetState, Defining.
        • Calling CreateNewHandle crashes if HandleRepresentation is null, need to test for that in *vtkSeedRepresentation::GetHandleRepresentation and in vtkSeedWidget::CreateNewHandle.
        • Test currently failing, suggest that a default handle representation is created. (test fixed)
      • vtkSplineWidget2
        • Would like Get macro for WidgetState
        • Need a method to call to programatically stop and restart adding spoints to the spline (see vtkSeedWidget::CompleteInteraction)
    • vtkBorderWidget Access to SetCursor?
      • vtkCaptionWidget
        • Access to HandleWidget?
        • Only uses text actor 2d
      • vtkTextWidget
      • vtkScalarBarWidget
        • Has GetScalarBarRepresentation
    • vtkHoverWidget Would like GetWidgetState macro
      • vtkBalloonWidget
        • Would like SetBalloonString
        • Failing the basic interactor observer tests, seg faults on destructor of smart pointer
        • Problem with changing text on this widget, doesn't update the representation

General notes:

  • when writing the macro for GetWidgetState, need to move the enum of the states to be public so can check for them.
  • would be very very very useful to have GetXRepresentation defined on the subclasses to return the expected subclass of vtkWidgetRepresentation so that don't have to safe down cast the return values to get at subclass methods.

Representations

Testing the representations:

  • vtkProp
    • vtkWidgetRepresentation
      • no Get macros for Placed, ValidPick
      • declares ComputeInteractionState, clash with Widget
      • vtkAngleRepresentation
        • BuildRepresenation doesn't check for null handle pointers
        • SetXDisplayPosition doesn't have versions with three doubles
        • GetXDisplayPosition doesn't have a version that returns a double*
        • SetHandleRepresentation should be higher up in the .h file as mostly nothing works w/o it being called
        • vtkAngleRepresentation2D
          • BuildRepresentation doesn't check for null handle pointers.
          • GetPoint1WorldPosition, GetCenterWorldPosition, GetPoint2WorldPosition, SetPoint1DisplayPosition, SetCenterDisplayPosition, SetPoint2DisplayPosition, GetPoint1DisplayPosition, GetCenterDisplayPosition, GetPoint2DisplayPosition don't check for null handle pointers
          • HandleSize test fails with the lower clamp bound
        • vtkAngleRepresentation3D
          • TextActorScale is a convenience method that could use set macro that takes x,y,z
          • Also many failures to check for null handle representations
          • Code I'm testing doesn't have set/get color macros for the lines, arcs, text, have to Get the actors and then get properties. Convenience get/set methods would be good.
      • vtkBalloonRepresentation
        • why no HoverRepresentation as a super class?
        • Would like Get macro for TextActor (necessary?)
      • vtkBiDimensionalRepresentation2D
        • missing 3D representation
        • the Get/Set Point 1-4 Display and World positions could use methods with signatures of x,y,z
        • SetLabelText?
        • No Get macros for 4 Point handle representations
        • No Set/Get for CenterWorld
        • Missing some null pointer checks on handle representations
        • crashes in Point3WidgetInteraction, GetWorldLabelPosition - renderer not set up?
        • Label text not updating?
      • vtkBorderRepresentation
        • no Get macro for interaction state
        • defines ComputeInteractionState, may clash with the Widget
        • no Set macro for size
        • uses vtkCoordinate and macro for Position and Position2, missing Get(pos[2]) macro
        • vtkCaptionRepresentation
          • no Get macro for PointWidgetState
          • no Get macro for actor2d's properties
        • vtkTextRepresentation
          • no Get macro for TextProperty, but does have a macro for GetTextActor
        • vtkScalarBarRepresentation
      • vtkImplicitPlaneRepresentation
        • does it match to vtkImplicitPlaneWidget2?
        • no GetPolyData() to return vtkPolyData, ditto GetPlane (but GetPolyDataAlgorithm returns a pointer)
        • has all the GetProperty macros (no set)
        • What are valid values for RepresentationState and how does it clash with InteractionState?
        • No EdgesSelected defined
        • testing fails in ComputeInteraction state with a seg fault if the renderer doesn't have a render window (VTK/Rendering/vtkPicker.cxx:235 doesn't check for null pointer, and in Widgets/vtkWidgetRepresentation.cxx:105 if put in the check, basically BuildRepresentation is fragile)
      • vtkLineRepresentation
        • does it match to LineWidget2?
        • could use SetPointNWorld/DisplayPosition(double, double, double)
        • setting/getting display positions causes a seg fault in vtkRenderer::GetActiveCamera
        • What are valid values for RepresentationState and how does it clash with InteractionState?
        • request ticks on line to show resolution
        • SetDistanceAnnotationScale needs Set(double, double, double) (added)
      • vtkSeedRepresentation
        • defines ComputeInteractionState (NearSeed, Outside), clash with the Widget since one is calculated in screen space and one in world space)
        • might be useful to have IsHandlePresent (GetHandleRepresentation creates one if it doesn't exist).
        • when GetHandleRepresentation, have to safe down cast returns from vtkHandleRepresentation, some utility methods to GetPointHandleRepresentation, etc would be useful
        • need more docs on CreateHandle, e is display position
        • no SetSeedWorldPosition?
        • if don't set handle representation before creating new handle, seg fault since CreateHandle doesn't check for null pointer
      • vtkSplineRepresentation
        • defines ComputeInteractionState, clash with the Widget
        • no access to individual handles to highlight or change colors
        • no Get macro for Centroid
        • no access to MovePoint, Scale, Translate
        • seg faults when call SetProjectionPosition, SetNumberOfHandles, etc, build representation triggers an get active camera call

Handle Representations

Used by the representations, inherit from vtkAbstractWidget: (all of these are seg faulting, need to revisit my top level testing macros to see if I can figure out why, not enabled in the checked in CMakeLists.txt file as of Aug 10/10)

  • vtkHandleRepresentation
    • vtkAbstractPolygonalHandleRepresentation3D
      • defines Property and SelectedProperty here
      • Highlight is protected in this class, public in the superclass (fixed)
      • LabelText missing Set(double, double, double) (fixed)
      • vtkPolygonalHandleRepresentation3D
        • in .h file only defines Offset
      • vtkOrientedPolygonalHandleRepresentation3D
        • doesn't define Offset though comment at top of .h file mentions it
    • vtkSphereHandleRepresentation
      • Highlight is protected in this class, public in the superclass (fixed)
      • Crashes when test StartWidgetInteraction, in VTK/Rendering/vtkPicker.cxx:241, winSize is declared as int* and not initialised if there's no RenderWindow, still crashes when test for it, in vtkCoordinate
    • vtkPointHandleRepresentation2D
      • Property and SelectedProperty might be worthwhile to move up to the HandleRepresentation superclass
      • Highlight is protected in this class, public in the superclass (fixed)
      • SetPointPlacer is protected in this class, public in the superclass (it's not used as the point is constrained to a plane, SetPointPlacer is defined as a macro in the .cxx class) (fixed)
      • Seg faults in GetDisplayPosition while in BuildRepresentation, VTK/Rendering/vtkRenderer.cxx:1363 not checking for null active camera, when check that it's back to crashing like the sphere handle rep, at VTK/Filtering/vtkCoordinate.cxx:202
    • vtkPointHandleRepresentation3D
      • valid values of translation mode?
      • Highlight is protected in this class, public in the superclass (fixed)
    • vtkConstrainedPointHandleRepresentation.h
      • No SetProperty, SetActiveProperty, SetSelectedProperty, have to do Get and then set things on that variable
      • Highlight is protected in this class, public in the superclass (fixed)

Requested Changes

In general, being able to do unit testing on the widgets, representations and handle representations is still dependent on knowledge of how to set up the widgets in a render window. It would be useful to have more checks on the rendering classes, especially those that will prevent segmentation faults.

Culling through my notes above, a high level summary is:

  • Widgets
    • Get macros for widget state
    • Get macros for handle widgets
    • GetXRepresentation defined on the subclasses to return the expected subclass of vtkWidgetRepresentation
    • Spline needs an API to start/stop/add points manually
    • Balloon needs SetBalloonString
  • Representations
    • Get macros, (double, double, double) method signatures
    • Line - ticks
  • Handle Representations
    • fixes to allow unit testing