VTK/Examples/Cxx/Visualization/LegendScaleActor

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Revision as of 10:29, 2 August 2010 by Lorensen (talk | contribs)
Jump to navigationJump to search
VTK Examples Baseline Visualization TestLegendScaleActor.png

LegendScaleActor.cxx

#include <vtkSmartPointer.h>
#include <vtkLegendScaleActor.h>
#include <vtkPolyData.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkLegendScaleActor.h>

int main(int, char *[])
{
  
  vtkSmartPointer<vtkSphereSource> sphereSource = 
      vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->Update();
  
    //Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(sphereSource->GetOutputPort());
  vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
 
  //Create a renderer, render window, and interactor
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);
 
  vtkSmartPointer<vtkLegendScaleActor> legendScaleActor = 
      vtkSmartPointer<vtkLegendScaleActor>::New();
  
  //Add the actor to the scene
  renderer->AddActor(actor);
  renderer->AddActor(legendScaleActor);
  
  renderer->SetBackground(.3, .2, .3);
 
  //Render and interact
  renderWindow->Render();
  renderWindowInteractor->Start();
  
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
PROJECT(LegendScaleActor)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(LegendScaleActor LegendScaleActor.cxx)
TARGET_LINK_LIBRARIES(LegendScaleActor vtkHybrid)