# PickableOff

VTKExamples/Cxx/Interaction/PickableOff

### Code

PickableOff.cxx

    #include <vtkSmartPointer.h>
    #include <vtkActor.h>
    #include <vtkConeSource.h>
    #include <vtkPolyDataMapper.h>
    #include <vtkProperty.h>
    #include <vtkRenderer.h>
    #include <vtkRenderWindow.h>
    #include <vtkRenderWindowInteractor.h>
    #include <vtkInteractorStyleTrackballActor.h>

    int main(int, char *[])
    {
      vtkSmartPointer<vtkConeSource> coneSource0 =
        vtkSmartPointer<vtkConeSource>::New();
      coneSource0->Update();

      vtkSmartPointer<vtkConeSource> coneSource1 =
        vtkSmartPointer<vtkConeSource>::New();
      coneSource1->SetCenter(5,0,0);
      coneSource1->Update();

      // Create mappers and actors
      vtkSmartPointer<vtkPolyDataMapper> coneMapper0 =
        vtkSmartPointer<vtkPolyDataMapper>::New();
      coneMapper0->SetInputConnection(coneSource0->GetOutputPort());

      vtkSmartPointer<vtkPolyDataMapper> coneMapper1 =
        vtkSmartPointer<vtkPolyDataMapper>::New();
      coneMapper1->SetInputConnection(coneSource1->GetOutputPort());

      // Create actors
      vtkSmartPointer<vtkActor> coneActor0 =
        vtkSmartPointer<vtkActor>::New();
      coneActor0->SetMapper(coneMapper0);

      vtkSmartPointer<vtkActor> coneActor1 =
        vtkSmartPointer<vtkActor>::New();
      coneActor1->SetMapper(coneMapper1);
      coneActor1->PickableOff();

      // A renderer and render window
      vtkSmartPointer<vtkRenderer> renderer =
        vtkSmartPointer<vtkRenderer>::New();
      vtkSmartPointer<vtkRenderWindow> renderWindow =
        vtkSmartPointer<vtkRenderWindow>::New();
      renderWindow->AddRenderer(renderer);

      // An interactor
      vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
        vtkSmartPointer<vtkRenderWindowInteractor>::New();
      renderWindowInteractor->SetRenderWindow(renderWindow);

      // Add the actors to the scene
      renderer->AddActor(coneActor0);
      renderer->AddActor(coneActor1);
      renderer->SetBackground(0.5,0.5,0.5);

      renderer->ResetCamera();
      renderWindow->Render();

      vtkSmartPointer<vtkInteractorStyleTrackballActor> style =
        vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();

      renderWindowInteractor->SetInteractorStyle( style );

      // Begin mouse interaction
      renderWindowInteractor->Start();

      return EXIT_SUCCESS;
    }

### CMakeLists.txt

    cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

    project(PickableOff)

    find_package(VTK COMPONENTS
      vtkCommonCore
      vtkFiltersSources
      vtkInteractionStyle
      vtkRenderingCore
      vtkRenderingFreeType
      vtkRenderingOpenGL2 QUIET)
    if (NOT VTK_FOUND)
      message("Skipping PickableOff: ${VTK_NOT_FOUND_MESSAGE}")
      return ()
    endif()
    message (STATUS "VTK_VERSION: ${VTK_VERSION}")
    if (VTK_VERSION VERSION_LESS "8.90.0")
      # old system
      include(${VTK_USE_FILE})
      add_executable(PickableOff MACOSX_BUNDLE PickableOff.cxx )
      target_link_libraries(PickableOff PRIVATE ${VTK_LIBRARIES})
    else ()
      # include all components
      add_executable(PickableOff MACOSX_BUNDLE PickableOff.cxx )
      target_link_libraries(PickableOff PRIVATE ${VTK_LIBRARIES})
      # vtk_module_autoinit is needed
      vtk_module_autoinit(
        TARGETS PickableOff
        MODULES ${VTK_LIBRARIES}
        )
    endif ()

### Download and Build PickableOff

Click here to download PickableOff and its CMakeLists.txt file. Once the tarball PickableOff.tar has been downloaded and extracted,

    cd PickableOff/build

If VTK is installed:

    cmake ..

If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:

    cmake -DVTK_DIR:PATH=/home/me/vtk_build ..

Build the project:

    make

and run it:

    ./PickableOff

WINDOWS USERS

Be sure to add the VTK bin directory to your path. This will resolve the VTK dll's at run time.