# The problem in vtkInteractorStyleImage to set DICOM slice by mousewheel

**URL:** https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732
**Category:** Support
**Created:** [November 3, 2022, 10:26am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732 "2022-11-03T10:26:49Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [November 3, 2022, 10:26am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/1 "2022-11-03T10:26:49Z")

</div>

When I want to use vtkInteractorStyleImage to overide the mousewheel event,  
#1 New();  
#2 vtkTypeMacro( ,);  
are show “doesn’t find the function definition”  
How can I do to solve it?

use  
VTK 9.2.0rc2  
VTK-DICOM  
QT 5.14.2

Thanks!

```auto
class myVtkInteractorStyleImage : public vtkInteractorStyleImage
{
public:
	static myVtkInteractorStyleImage* New();//#1
	vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);//#2
};
vtkStandardNewMacro(myVtkInteractorStyleImage);

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 6, 2022, 12:47pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/2 "2022-11-06T12:47:42Z")

</div>

Hello,

Please, make sure you’ve `#include`d `vtkObjectFactory.h`.

regards,

Paulo

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [November 7, 2022, 8:15am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/3 "2022-11-07T08:15:48Z")

</div>

OK, I will tried it.  
Thanks Paulo

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 8, 2022, 1:15pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/4 "2022-11-08T13:15:39Z")

</div>

Did it work?

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 3, 2022, 10:04am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/5 "2022-12-03T10:04:42Z")

</div>

It’s still not defined !~

I think it’s my fault that if there has “not define” in the code, still can run!! ( Maybe because it’s a “macro” ?)  
Sorry about that, maybe before rewrite the code, some other mistake occured.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 3, 2022, 9:37pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/6 "2022-12-03T21:37:59Z")

</div>

Make sure you put this:

```cpp
#include <vtkObjectFactory.h>

```

In the `myVtkInteractorStyleImage.h` file or whatever header file you’re defining the `myVtkInteractorStyleImage` class.

Also, you are probably running old code. C++ compilers quit with undefined symbols errors.

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 6, 2022, 6:27am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/7 "2022-12-06T06:27:05Z")

</div>

I am sure that I include this header file, `myVtkViewer.h` with the code below.

```auto
#include <vtkActor.h>
#include <vtkNamedColors.h>
#include <vtkColor.h>
#include <vtkNew.h>
#include <vtkObjectFactory.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>

#include <vtkActor2D.h>
#include <vtkDICOMImageReader.h>
#include <vtkImageViewer2.h>
#include <vtkInteractorStyleImage.h>
#include <vtkTextMapper.h>
#include <vtkTextProperty.h>
#include <vtkNamedColors.h>

#include <sstream>

namespace 
{
	// Define own interaction style
	class myVtkInteractorStyleImage : public vtkInteractorStyleImage
	{
	public:
		static myVtkInteractorStyleImage* New(); //not define
		vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);//not define
        ...
       };
	vtkStandardNewMacro(myVtkInteractorStyleImage);//defined!!
} // namespace
```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 6, 2022, 12:12pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/8 "2022-12-06T12:12:23Z")

</div>

So, please, copy and paste the error message as it is here.

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 6, 2022, 12:57pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/9 "2022-12-06T12:57:14Z")

</div>

I used Chineese version, sorry about that.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/6/67c09b5a7d525144b7d3608793fc30e87c1f3fe6.png)

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/927b5cb179db26ffacfaccb82c9e2f8470aad6a6.png)

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 6, 2022, 1:03pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/10 "2022-12-06T13:03:26Z")

</div>

That’s the definition of the vtkTypeMacro macro. We need the text of the error message output by the compiler.

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 7, 2022, 5:37am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/11 "2022-12-07T05:37:50Z")

</div>

Why I said “not define” is base on what I seem the green waveline in this code(now still has), the error message hasn’t show any error now (after I rewrite it).

The earlier code I am sure that I had include the header file `#include <vtkObjectFactory.h>`, but I cleared the old one.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 7, 2022, 1:57pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/12 "2022-12-07T13:57:28Z")

</div>

Please, try to compile the program anyway. The compiler will surely issue an error message. Then copy and paste it here.

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 7, 2022, 2:16pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/13 "2022-12-07T14:16:49Z")

</div>

Like this? I can’t get the point

 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/a5430e392d0fe13d9d96b841a0762ddc1274da19.png)

It run correctly and also build a \*.exe

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 7, 2022, 10:38pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/14 "2022-12-07T22:38:16Z")

</div>

Yes, that’s one of the many errors. Now it’s necessary to translate the messages to English.

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 10, 2022, 5:12am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/15 "2022-12-10T05:12:21Z")

</div>

```auto
Error (active)	E2512	the argument to a feature-test macro must be a simple identifier

```

maybe is like this  
all the error is E2512

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 10, 2022, 12:04pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/16 "2022-12-10T12:04:07Z")

</div>

It seems to be an incompatiblity between the Qt version and VS version you are using. In your case, I’d recommend to either:  
a) Use Qt Creator IDE to develop your program (VS IDE is bloatware, anyway);  
b) Follow this: [Problem with new Visual Studio update 2017 Version 15.8.0 and Qt 5.9.5 | Qt Forum](https://forum.qt.io/topic/93711/problem-with-new-visual-studio-update-2017-version-15-8-0-and-qt-5-9-5/24) .

---

<div class="post-metadata">

### Author: ![a0980543469](https://discourse.vtk.org/user_avatar/discourse.vtk.org/a0980543469/32/5910_2.png) [@a0980543469](https://discourse.vtk.org/u/a0980543469)
#### Post date: [December 11, 2022, 9:17am UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/17 "2022-12-11T09:17:00Z")

</div>

OKay, thank for your help  
Maybe I’ll try another compiler. Because I have no idea to put the VTK library or others into QT creator~ 🤣, I choose to use VS (which used by my class teacher)

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 11, 2022, 3:08pm UTC](https://discourse.vtk.org/t/the-problem-in-vtkinteractorstyleimage-to-set-dicom-slice-by-mousewheel/9732/18 "2022-12-11T15:08:36Z")

</div>

Hello,

You don’t need to throw away the VS IDE if you don’t feel comfortable. I don’t enjoy much any of Microsoft products, but I support freedom of tool choice. I just suggested using Qt’s IDE because it’ll do the job more efficiently, IMO.

You can still use VS tool chain (its compiler is called `cl.exe`, its Makefile processor is called `nmake` and so on) but you can use a better IDE IMO 🙂.

Adding libraries is not that difficult using alternatives. If you’d like how to setup libraries in `qmake`, you can do something like this in the `.pro` file:

```bash
#========== The VTK include and lib paths and libraries==================
_VTK_INCLUDE = $$(VTK_INCLUDE)
isEmpty(_VTK_INCLUDE){
    error(VTK_INCLUDE environment variable not defined.)
}
_VTK_LIB = $$(VTK_LIB)
isEmpty(_VTK_LIB){
    error(VTK_LIB environment variable not defined.)
}
_VTK_VERSION_SUFFIX = $$(VTK_VERSION_SUFFIX)
isEmpty(_VTK_VERSION_SUFFIX){
    warning(VTK_VERSION_SUFFIX environment variable not defined or empty.)
}
    gcc:QMAKE_CXXFLAGS += -isystem $$_VTK_INCLUDE #This is to suppress the countless compiler warnings from VTK headers
  clang:QMAKE_CXXFLAGS += -isystem $$_VTK_INCLUDE #This is to suppress the countless compiler warnings from VTK headers
  mingw:QMAKE_CXXFLAGS += -isystem $$_VTK_INCLUDE #This is to suppress the countless compiler warnings from VTK headers
msvc:QMAKE_CXXFLAGS += /external:I $$_VTK_INCLUDE #This is to suppress the countless compiler warnings from VTK headers
INCLUDEPATH += $$_VTK_INCLUDE
LIBPATH += $$_VTK_LIB
LIBS += -lvtkGUISupportQt$$_VTK_VERSION_SUFFIX \
               -lvtkCommonCore$$_VTK_VERSION_SUFFIX \
               -lvtkFiltersSources$$_VTK_VERSION_SUFFIX \
               -lvtkRenderingCore$$_VTK_VERSION_SUFFIX \
               -lvtkCommonExecutionModel$$_VTK_VERSION_SUFFIX \
               -lvtkInteractionStyle$$_VTK_VERSION_SUFFIX \
               -lvtkRenderingOpenGL2$$_VTK_VERSION_SUFFIX \
               -lvtkRenderingAnnotation$$_VTK_VERSION_SUFFIX \
               -lvtkRenderingFreeType$$_VTK_VERSION_SUFFIX \
               -lvtkInteractionWidgets$$_VTK_VERSION_SUFFIX \
               -lvtkCommonDataModel$$_VTK_VERSION_SUFFIX \
               -lvtkFiltersGeneral$$_VTK_VERSION_SUFFIX \
               -lvtkCommonTransforms$$_VTK_VERSION_SUFFIX \
               -lvtkImagingSources$$_VTK_VERSION_SUFFIX \
               -lvtkImagingCore$$_VTK_VERSION_SUFFIX \
			   -lvtkFiltersCore$$_VTK_VERSION_SUFFIX \
                           -lvtkFiltersExtraction$$_VTK_VERSION_SUFFIX \
			   -lvtkImagingFourier$$_VTK_VERSION_SUFFIX \
			   -lvtkCommonMisc$$_VTK_VERSION_SUFFIX \
			   -lvtkCommonComputationalGeometry$$_VTK_VERSION_SUFFIX \
			   -lvtkCommonMath$$_VTK_VERSION_SUFFIX \
			   -lvtksys$$_VTK_VERSION_SUFFIX \
			   -lvtkFiltersGeometry$$_VTK_VERSION_SUFFIX \
			   -lvtkCommonColor$$_VTK_VERSION_SUFFIX \
			   -lvtkCommonSystem$$_VTK_VERSION_SUFFIX \
			   -lvtkglew$$_VTK_VERSION_SUFFIX \
			   -lvtkfreetype$$_VTK_VERSION_SUFFIX \
			   -lvtkzlib$$_VTK_VERSION_SUFFIX \
			   -lvtkFiltersHybrid$$_VTK_VERSION_SUFFIX \
			   -lvtkFiltersModeling$$_VTK_VERSION_SUFFIX \
			   -lvtkImagingGeneral$$_VTK_VERSION_SUFFIX \
			   -lvtkRenderingVolume$$_VTK_VERSION_SUFFIX \
			   -lvtkFiltersStatistics$$_VTK_VERSION_SUFFIX \
                -lvtkImagingStencil$$_VTK_VERSION_SUFFIX \
                -lvtkImagingHybrid$$_VTK_VERSION_SUFFIX \
                -lvtkRenderingContext2D$$_VTK_VERSION_SUFFIX \
                -lvtkChartsCore$$_VTK_VERSION_SUFFIX \
                -lvtkRenderingContextOpenGL2$$_VTK_VERSION_SUFFIX \
                -lvtkRenderingVolumeOpenGL2$$_VTK_VERSION_SUFFIX

#=============================================================================

```

If you choose to organize and configure your project with CMake instead of Qt’s `qmake` or VS’s `nmake`, please, take a look at this: [https://vtk.org/Wiki/VTK/Tutorials/CMakeListsFile](https://vtk.org/Wiki/VTK/Tutorials/CMakeListsFile).
