[vtkusers] VTK custom subclass: basic implementation
Marcos
fotosentido at gmail.com
Wed Sep 2 14:33:48 EDT 2015
Hi,
I'm thought there was a macro for my new class... but it was the superclass.
You're right, it was that and linking in Cmake.
Now it compiles.
It doesn't work, but it compiles.
I commented all inside OnLeftButton(), the method overriden.
And asigned my interactor to my widget:
vtkSmartPointer<DcmInteractorStyle> interactorStyle =
vtkSmartPointer<DcmInteractorStyle>::New();
widget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(interactorStyle);
imageViewer->SetRenderWindow(widget->GetRenderWindow());
imageViewer->SetupInteractor(widget->GetRenderWindow()->GetInteractor());
widget->update();
My widget shouldn't do anything when I press left button but... it does the
same as always (vtkinteractorstyleimage, which is the default style because
of the vtkimageviewer2).
Thank you, Cory. At least now I can try different things to find out how to
make it work.
2015-09-02 19:25 GMT+02:00 Cory Quammen <cory.quammen at kitware.com>:
> Marcos,
>
> You should change the line from
>
> vtkStandardNewMacro(vtkInteractorStyleImage);
>
> to
>
> vtkStandardNewMacro(DcmInteractorStyle);
>
> HTH,
> Cory
>
> On Wed, Sep 2, 2015 at 1:15 PM, Marcos <fotosentido at gmail.com> wrote:
>
>> Hi,
>>
>> I created an vtkinteractor subclass. This is the header:
>>
>> #include "vtkInteractionStyleModule.h" // For export macro
>>
>> #include "vtkInteractorStyleImage.h"
>>
>>
>> class DcmInteractorStyle : public vtkInteractorStyleImage
>>
>> {
>>
>> public:
>>
>> static DcmInteractorStyle* New();
>>
>> vtkTypeRevisionMacro(DcmInteractorStyle, vtkInteractorStyleImage)
>>
>>
>> virtual void OnLeftButtonDown();
>>
>>
>> };
>>
>>
>> I just want to override mouse events.
>> I'm following the example:
>> http://www.vtk.org/Wiki/VTK/Tutorials/InteractorStyleSubclass
>>
>> It doesn't show .cpp contents, so I went inside mine with:
>>
>> vtkStandardNewMacro(vtkInteractorStyleImage);
>>
>>
>> void DcmInteractorStyle::OnLeftButtonDown()
>>
>> {
>>
>> // here my code
>>
>> }
>>
>>
>>
>> But the compiler (with CMakeLists.txt) says:
>> ui_qt.lib(viewerwidget.cpp.obj):-1: error: LNK2019: unresolved external
>> symbol "public: static class DcmInteractorStyle * __cdecl
>> DcmInteractorStyle::New(void)" (?New at DcmInteractorStyle@@SAPAV1 at XZ)
>> referenced in function "public: static class vtkSmartPointer<class
>> DcmInteractorStyle> __cdecl vtkSmartPointer<class
>> DcmInteractorStyle>::New(void)" (?New@
>> ?$vtkSmartPointer at VDcmInteractorStyle@@@@SA?AV1 at XZ)
>>
>> At CMake mail list someone told me it was because I don't have the New()
>> method defined (what about the macro then?).
>>
>> My constructor won't do anything different, just the same as the
>> superclass.
>> I tried:
>>
>> DcmInteractorStyle* DcmInteractorStyle::New() : vtkInteractorStyleImage::New()
>>
>> {
>>
>>
>> }
>>
>>
>> It gives me:
>>
>> error: C2550: 'DcmInteractorStyle::New' : constructor initializer lists are only allowed on constructor definitions
>>
>>
>> Any help, please?
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Cory Quammen
> R&D Engineer
> Kitware, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150902/ff21031e/attachment.html>
More information about the vtkusers
mailing list