My understanding is that templates are not permitted in public API of VTK classes, only in internal implementation (see VTK coding standards).
This is not a limitation, but a really nice feature. Although templated classes can be easier to write and maintain for VTK developers, they are generally less convenient for VTK users (templated implementations are more rigid, as you need to commit to specific types at compile time).
For example, look at how much simpler to use your vtkMyInteractorStyleImage class without templates in the public API:
Thanks! I didn’t know I couldn’t use template classes. From your reply, My understanding is that I can write 2 SetViewer() as overloading function, am I right?
But if so ,how to initialize the member of class vtkMyInteractorStyleImage?
Assume I wrote my own InteractorStyle class.
The function of this style is when I move forward the mouse wheel then change the slice.
The vtkMyInteractorStyleImage Class like this:
class myVtkInteractorStyleImage : public vtkInteractorStyleImage
{
public:
static myVtkInteractorStyleImage* New();
vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);
protected:
int _Slice;
int _MinSlice;
int _MaxSlice;
vtkimageviewer2 * _ImageViewer;
public:
void Setviewer(vtkimageviewer2 * Viewer){
_ImageViewer = Viewer;
_MinSlice = imageViewer->GetSliceMin();
_MaxSlice = imageViewer->GetSliceMax();
_Slice = _MinSlice;
}