[vtkusers] SetLineWidth's Problem

huangz2350 huangz2350 at 163.com
Tue Dec 4 03:59:27 EST 2012


 
Hi, I have drawed a line in an Image(JPEGReader->ImageActor),I chang the line's Property->SetLineWidth(2).
When I ZoomIn or ZoomOut, the Line is missing.
how to solve this problem ?Thanks

The SourceCode:

#include <vtkSmartPointer.h>
 
#include <vtkImageViewer2.h>
#include <vtkJPEGReader.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <iostream>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkLineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
int main(int argc, char* argv[])
{
  // Verify input arguments
  if ( argc != 2 )
    {
    std::cout << "Usage: " << argv[0]
              << " Filename(.jpeg)" << std::endl;
    return EXIT_FAILURE;
    }
 
  // Read the image
  vtkSmartPointer<vtkJPEGReader> jpegReader =
    vtkSmartPointer<vtkJPEGReader>::New();
  if(!jpegReader->CanReadFile(argv[1]))
    {
    std::cout << argv[0]
              << ": Error reading file " << argv[1] << std::endl
              << " Exiting..." << std::endl;
    return EXIT_FAILURE;
    }
 
  jpegReader->SetFileName ( argv[1] );
 
  // Visualize
  vtkSmartPointer<vtkImageViewer2> imageViewer =
    vtkSmartPointer<vtkImageViewer2>::New();
  imageViewer->SetInputConnection( jpegReader->GetOutputPort() );
  imageViewer->GetRenderWindow()->SetSize( 500, 500 );
  imageViewer->GetRenderer()->ResetCamera();
 
  // Set up an interactor that does not respond to mouse events
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  imageViewer->GetRenderWindow()->SetInteractor( renderWindowInteractor );
    vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
  renderWindowInteractor->SetInteractorStyle( style );

  vtkSmartPointer<vtkLineSource> pvtkLine_Move = vtkSmartPointer<vtkLineSource>::New();
  vtkSmartPointer<vtkActor> m_MoveActor = vtkSmartPointer<vtkActor>::New();

    pvtkLine_Move->SetPoint1(0,0,0);
    pvtkLine_Move->SetPoint2(50,50,0);
    pvtkLine_Move->Update();
    vtkSmartPointer<vtkPolyDataMapper> mapper =
        vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputConnection(pvtkLine_Move->GetOutputPort());
    m_MoveActor->SetMapper(mapper);
    vtkProperty    *pProperty = m_MoveActor->GetProperty ();
    pProperty->SetColor(1,0,0);
    pProperty->SetLineWidth (2);    //The Line Maybe Miss...
    m_MoveActor->VisibilityOn();
       
 imageViewer->GetRenderer()->AddActor(m_MoveActor);
  imageViewer->Render();
  // Start the event loop
  renderWindowInteractor->Initialize();
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
}

Phoniex




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121204/b9a5f68a/attachment.htm>


More information about the vtkusers mailing list