[vtkusers] drawing a line that doesn't rotate with interaction
Jesse Corrington
corrington_j at hotmail.com
Fri Mar 31 19:35:16 EST 2006
I have tried making the input to the axes actor a linesource, but it still
roates as if 3D. I am also trying something different. Taken from an
example I have been able to create a bounding box around a tea pot, which i
could use as a more advanced scale bar. Would there be a way to make this
box go around a volume. Also, how can I tell how big a volume is in any one
direction. The images may be a certain size, but the actual object (a cell
in this case) is not as big as the images. Here is the code for that
boundnig box. Would it be possible to have it display a scale factor,
rather than just world coordinates. For instance, for my volume I know that
1 pixel is .0065 nano meters. Any help on this scale bar thing would be
great, I have really been spinning my wheels here for the last week. I am
open to doing it a different way.
Thanks so much
Jesse
//here is the code
vtkBYUReader *fohe = vtkBYUReader::New();
fohe->SetGeometryFileName("teapot.g");
//Create a vtkPolyDataNormals filter to calculate the normals of the data
set.
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
normals->SetInputConnection(fohe->GetOutputPort());
//Set up the associated mapper and actor.
vtkPolyDataMapper *foheMapper = vtkPolyDataMapper::New();
foheMapper->SetInputConnection(normals->GetOutputPort());
vtkLODActor *foheActor = vtkLODActor::New();
foheActor->SetMapper (foheMapper);
//Create a vtkOutlineFilter to draw the bounding box of the data set. Also
//create the associated mapper and actor.
vtkOutlineFilter *outline = vtkOutlineFilter::New();
outline->SetInputConnection(normals->GetOutputPort());
vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
mapOutline->SetInputConnection(outline->GetOutputPort());
vtkActor *outlineActor = vtkActor::New();
outlineActor->SetMapper(mapOutline);
// outlineActor->GetProperty()->SetColor( 0, 0, 0, );
vtkProperty *p = outlineActor->GetProperty();
p->SetColor(0, 0,0);
//Create a vtkCamera and renderer
vtkCamera *camera = vtkCamera::New();
vtkRenderer *ren1 = vtkRenderer::New();
ren1->SetActiveCamera (camera);
//Create the RenderWindow and RenderWindowInteractor.
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer (ren1);
renWin->SetWindowName ("VTK - Cube Axes");
renWin->SetSize (600, 300);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();;
iren->SetRenderWindow( renWin);
//Add the actors to the renderer, and set the background.
//ren1->AddViewProp (foheActor);
ren1->AddViewProp (outlineActor);
ren1->SetBackground(0.1, 0.2, 0.4);
//Create a text property for both cube axes
vtkTextProperty *tprop = vtkTextProperty::New();
tprop->SetColor( 1, 1, 1);
tprop->SetFontSize(15);
tprop->ShadowOn();
//Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to
//draw the axes. Add the actor to the renderer.
vtkCubeAxesActor2D *axes = vtkCubeAxesActor2D::New();
axes->SetInput(normals->GetOutput());
axes->SetCamera(ren1->GetActiveCamera());
axes->SetLabelFormat("%6.4g");
axes->SetFlyModeToOuterEdges();
axes->SetFontFactor(1.5);
axes->SetAxisTitleTextProperty(tprop);
axes->SetAxisLabelTextProperty(tprop);
axes->SetNumberOfLabels(0);
axes->SetXLabel("xx microns");
axes->SetYLabel("xx microns");
axes->SetZLabel("xx microns");
ren1->AddViewProp(axes );
ren1->ResetCamera();
renWin->Render();
>From: "wapur.com" <wapur at wapur.com>
>To: "Jesse Corrington" <corrington_j at hotmail.com>
>Subject: Re: [vtkusers] drawing a line that doesn't rotate with interaction
>Date: Sat, 1 Apr 2006 01:33:58 +0300
>
>Try
>vtkCubeAxesActor2D
>
>
>
>----- Original Message ----- From: "Jesse Corrington"
><corrington_j at hotmail.com>
>To: <vtkusers at vtk.org>
>Sent: Friday, March 31, 2006 10:45 PM
>Subject: [vtkusers] drawing a line that doesn't rotate with interaction
>
>
>>I am trying to create a scale bar, And I think the easiest way to do it
>>will be to add a line actor that is only affected by zooming, not
>>rotation. So the line is always vertical in the same position, but it
>>scales as the user zooms in and out. I have not been able to figure out
>>how to do this yet. Here is what I have, to just add the line actor. Any
>>help would be much appreciated. Thanks
>>
>>Jesse
>>
>>
>>//add the scale bar
>>vtkLineSource *lineSource = vtkLineSource::New();
>>lineSource->SetResolution(20);
>>lineSource->SetPoint1(10, 10, 0);
>>lineSource->SetPoint2(10, 400, 0);
>>
>>vtkPolyDataMapper *lineMapper = vtkPolyDataMapper::New();
>>lineMapper->SetInput(lineSource->GetOutput());
>>
>>lineActor = vtkActor::New();
>>lineActor->SetMapper(lineMapper);
>>
>>pvtkRenderer->AddActor2D(lineActor);
>>
>>_________________________________________________________________
>>Express yourself instantly with MSN Messenger! Download today - it's FREE!
>>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>>
>>_______________________________________________
>>This is the private VTK discussion list. Please keep messages on-topic.
>>Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers
>
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
More information about the vtkusers
mailing list