KWWidgets/Projects/3DWidgets/Widgets/ChangingArchitecture: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 4: Line 4:


==Comparing the two architectures==
==Comparing the two architectures==
==Changing Architecture===
'''Previous Architecture'''
'''Redefined Architecture'''
'''Change Overview'''
'''Methodology'''
* study both architectures
* study source code; vtkBoxWidget (Old) and vtkSliderWidget (new)
* separate source code into new classes
* study events
* compare vtkBoxWidget Old and New
* methods<br>* added<br>* removed<br>* edited
* example code<br>*changes to original
'''Modified Widgets'''
*vtkBoxWidget<br>vtkBoxWidget.h<br>vtkBoxWidget.cxx<br>vtkBoxRepresentation.h<br>vtkBoxRepresentation.cxx<br>
vtkBoxRepresentation2D.h<br>vtkBoxRepresentation2D.cxx<br>vtkBoxRepresentation3D.h<br>vtkBoxRepresentation3D.cxx<br>
[[Media:TestBoxNew.cxx|example code]]
==Widgets==
'''Architecture'''
:In order to apply the redesigned architecture regarding the vtk 3D Widgets, I started by learning how it had been applied to vtkSliderWidget and how I could use this as a basis for comparison with the designated widgets, specifically vtkBoxWidget.
:This I commenced by looking at the vtkSliderWidget and how it interacts with the main classes regarding the restructuring project - the vtkAbstractWidget and vtkWidgetRepresentation classes and their derivatives.
<center>[[Image:Class_Diagram_vtKSliderWidget.png]]</center>
'''Comparing Structure'''
:How to structure the callback?
:After looking at vtkSliderWidget and vtkDistanceWidget, I have come across parts of two methods of dealing with callbacks. One (above) defines the required callback methods in the widget (vtkSliderWidget) whereas the other (below, based on vtkDistanceWidget) provides the possiblity to create CallbackMapper classes inheriting from vtkCallbackMapper to provide preset callback methods.
:I feel that the second method is more inline with the 3DWidget reauthoring - separating events from representation. Also, it provides the possiblity to have different callbacks depending on widget use.
:For example, a program may have a "View" and "Interact" modes. In "View" mode, CallbackMapperA is used where left-clicking will update a window with data XYZ. In "Interact" mode, CallbackMapperB is used where left-clicking selects the object for manipulation.
:Which of these methods is better for the reauthoring?
<center>[[Image:Class_Diagram_vtkMyWidget.jpg]]</center>

Revision as of 08:28, 23 May 2006

Analysis and overview of existing architecture

Analysis and overview of new architecture

Comparing the two architectures

Changing Architecture=

Previous Architecture

Redefined Architecture

Change Overview

Methodology

  • study both architectures
  • study source code; vtkBoxWidget (Old) and vtkSliderWidget (new)
  • separate source code into new classes
  • study events
  • compare vtkBoxWidget Old and New
  • methods
    * added
    * removed
    * edited
  • example code
    *changes to original

Modified Widgets

  • vtkBoxWidget
    vtkBoxWidget.h
    vtkBoxWidget.cxx
    vtkBoxRepresentation.h
    vtkBoxRepresentation.cxx

vtkBoxRepresentation2D.h
vtkBoxRepresentation2D.cxx
vtkBoxRepresentation3D.h
vtkBoxRepresentation3D.cxx
example code

Widgets

Architecture

In order to apply the redesigned architecture regarding the vtk 3D Widgets, I started by learning how it had been applied to vtkSliderWidget and how I could use this as a basis for comparison with the designated widgets, specifically vtkBoxWidget.
This I commenced by looking at the vtkSliderWidget and how it interacts with the main classes regarding the restructuring project - the vtkAbstractWidget and vtkWidgetRepresentation classes and their derivatives.
Class Diagram vtKSliderWidget.png


Comparing Structure

How to structure the callback?
After looking at vtkSliderWidget and vtkDistanceWidget, I have come across parts of two methods of dealing with callbacks. One (above) defines the required callback methods in the widget (vtkSliderWidget) whereas the other (below, based on vtkDistanceWidget) provides the possiblity to create CallbackMapper classes inheriting from vtkCallbackMapper to provide preset callback methods.
I feel that the second method is more inline with the 3DWidget reauthoring - separating events from representation. Also, it provides the possiblity to have different callbacks depending on widget use.
For example, a program may have a "View" and "Interact" modes. In "View" mode, CallbackMapperA is used where left-clicking will update a window with data XYZ. In "Interact" mode, CallbackMapperB is used where left-clicking selects the object for manipulation.
Which of these methods is better for the reauthoring?
Class Diagram vtkMyWidget.jpg