[vtkusers] How to create my custom Image Style class?

arwtyxouymz arw.tyx-ouy_mz at ezweb.ne.jp
Tue Jun 26 06:43:51 EDT 2018


Hi,

I try to create my style class inherited from `vtkInteractorStyleImage.h`
Actually i created, but it doesn't work.

This is compile error
```
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make[2]: *** [src/Main] Error 1
make[1]: *** [src/CMakeFiles/Main.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
```

This is my code:

mySytleImage class
```cpp
class StyleImage : public vtkInteractorStyleImage {
public:
    static StyleImage* New();
    vtkTypeMacro(StyleImage, vtkInteractorStyleImage);

    StyleImage();
    virtual ~StyleImage();

    void SetImageViewer(vtkResliceImageViewer* viewer);

private:
    vtkSmartPointer<vtkResliceImageViewer> m_viewer;
};

/**
 * @brief Constructor
 */
StyleImage::StyleImage() = default;

/**
 * @brief Destructor
 */
StyleImage::~StyleImage() = default;

/*
 * @brief Set Image Viewer
 */
void StyleImage::SetImageViewer(vtkResliceImageViewer* viewer)
{
    m_viewer = viewer;
}
```

And I use like this
```cpp
    vtkSmartPointer<vtkResliceImageViewer> imageViewer =
        vtkSmartPointer<vtkResliceImageViewer>::New();
    imageViewer->SetInputData( m_image );
    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
        vtkSmartPointer<vtkRenderWindowInteractor>::New();
    imageViewer->SetupInteractor(renderWindowInteractor);
    imageViewer->Render();
    imageViewer->GetRenderer()->ResetCamera();
    imageViewer->Render();

    vtkSmartPointer<StyleImage> style =
        vtkSmartPointer<StyleImage>::New();
    style->SetImageViewer(imageViewer);
    renderWindowInteractor->SetInteractorStyle(style);
    renderWindowInteractor->Start();
```


What's wrong?

I think i need `vtkStandardNewMacro`, but i don't understand why this macro
is needed and how to use it.
please help me





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list