[vtkusers] VTK custom subclass: basic implementation

Cory Quammen cory.quammen at kitware.com
Wed Sep 2 13:25:36 EDT 2015


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/fb66e1d3/attachment.html>


More information about the vtkusers mailing list