[vtkusers] Label vtkActor

Cory Quammen cory.quammen at kitware.com
Wed Sep 23 10:04:08 EDT 2015


I have also used a vtkVectorText source to produce a label and then display
it with a vtkFollower (which is a subclass of vtkActor), which keeps the
label geometry facing the screen. You can specify the 3D position of the
vtkFollower and it should move with your image.

HTH,
Cory

On Wed, Sep 23, 2015 at 9:56 AM, David Lonie <david.lonie at kitware.com>
wrote:

> Sounds like vtkCaptionActor2D is what you're looking for:
>
> http://www.vtk.org/doc/nightly/html/classvtkCaptionActor2D.html
>
> On Wed, Sep 23, 2015 at 9:32 AM, joaoroberto88 <joaorobertojr88 at gmail.com>
> wrote:
>
>> Hi Cory,
>>
>> Thanks for your reply. I tried to use vtkTextActor, but I'm having some
>> issue about positioning it near to the station icon actor (see attached
>> image and code below). As you can see I'm using the same station icon
>> coordinate and the label "Station #1" isn't positioned correctly. Do you
>> have any clues? Also, since vtkTextActor is two-dimesional I think the
>> text
>> won't follow the image actor while the user interacts with the rendered
>> map.
>>
>> Here is the main code that creates both actors:
>>
>>     vtkSmartPointer<vtkPNGReader> iconReader =
>> vtkSmartPointer<vtkPNGReader>::New();
>>     iconReader->SetFileName("~/station.png");
>>     iconReader->Update();
>>
>>     vtkSmartPointer<vtkImageData> imageData = iconReader->GetOutput();
>>     imageData->SetOrigin(station->getUtmX(), station->getUtmY(), 0);  //
>> the
>> UTM-X and UTM-Y from UI
>>
>>     vtkSmartPointer<vtkImageChangeInformation> imageResize =
>> vtkSmartPointer<vtkImageChangeInformation>::New();
>>     imageResize->SetInputData(imageData);
>>     imageResize->SetOutputSpacing(2, 2, 1); // Resizes the image
>>     imageResize->Update();
>>
>>     vtkSmartPointer<vtkDataSetMapper> iconMapper =
>> vtkSmartPointer<vtkDataSetMapper>::New();
>>     iconMapper->SetInputData(imageResize->GetOutput());
>>
>>     vtkSmartPointer<vtkActor> iconActor =
>> vtkSmartPointer<vtkActor>::New();
>>     iconActor->SetMapper(iconMapper);
>>
>>     vtkSmartPointer<vtkTextActor> textActor =
>> vtkSmartPointer<vtkTextActor>::New();
>>     textActor->GetTextProperty()->SetFontSize ( 12 );
>>     textActor->SetPosition2 ( iconActor->GetPosition()[0],
>> iconActor->GetPosition()[1] - 20 );
>>     renderer->AddActor2D ( textActor );
>>     textActor->SetInput( station->getName().toStdString().c_str() );
>>     textActor->GetTextProperty()->SetColor ( 1.0,0.0,0.0 );
>>
>>     renderer->AddActor(textActor);
>>     renderer->AddActor(iconActor);
>>
>> Thanks,
>>
>> Joao.
>>
>>
>>
>> --
>> View this message in context:
>> http://vtk.1045678.n5.nabble.com/Label-vtkActor-tp5734069p5734072.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>


-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150923/3863e0ed/attachment.html>


More information about the vtkusers mailing list