[vtkusers] Cannot render polygen data immediately
lor fal
lorfalwit at gmail.com
Sat May 19 03:40:42 EDT 2018
Strangely enough, If I called vtkRenderer::ResetCamera() after
vtkRenderer::AddActor(), the polygon will be drawn correctly. It seems that
just vtkRenderWindow::Render() does not work.
On Sat, May 19, 2018 at 1:12 AM, lorfalwit at gmail.com <lorfalwit at gmail.com>
wrote:
> Thanks Todd. I am using Qt 5.10 on Windows 10. I have tried to call
> update() function to refresh the window, but it doesn't work.
>
> ---Original---
> *From:* "Todd"<nztoddler at yahoo.com>
> *Date:* Fri, May 18, 2018 20:22 PM
> *To:* "lor fal"<lorfalwit at gmail.com>;
> *Cc:* "vtkusers"<vtkusers at vtk.org>;
> *Subject:* Re: [vtkusers] Cannot render polygen data immediately
>
> Hi Hugh
>
> You haven't said what platform you're using. Try invalidating the window
> region/rectangle, using the platform's window API.
>
> On 18 May 2018 10:02 p.m., lor fal <lorfalwit at gmail.com> wrote:
>
> Hi all:
> I have hundreds of images to display by using vtkResliceImageViewer. I
> need to draw a marker when the left mouse button is clicked. My current
> solution is to use vtkRegularPolygonSource to draw a circle. The problem is
> that the circle does not render immediately even if I called render()
> afterwards. However, if I scroll the mouse wheel, the circle will be
> rendered correctly.
> The code snippet is attached below:
>
> void add_marker()
> {
> auto _circle_source = vtkSmartPointer<
> vtkRegularPolygonSource>::New();
> _circle_source->SetNormal(1, 0, 0);
> _circle_source->SetRadius(1);
> _circle_source->SetGeneratePolygon(false);
> _circle_source->SetNumberOfSides(50);
> _circle_source->Update();
> auto _mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
> _mapper->SetInputData(_circle_source->GetOutput());
> auto _actor = vtkSmartPointer<vtkActor>::New();
> _actor->SetMapper(_mapper);
> auto _cam_pos_x = _in->GetRenderWindow()->GetRenderers()->
> GetFirstRenderer()->GetActiveCamera()->GetPosition()[0];
> _actor->SetPosition(_cam_pos_x - 10, nipple[0], nipple[1]);
>
>
> _actor->GetProperty()->SetColor(1.0, 1.0, 0.0);
> _in->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(_
> actor);
> }
>
> The add_marker function was called in the callback of vtkCommand::
> LeftButtonPressEvent.
> Anyone could help me to solve this problem?
> Thank you.
>
> --
> Best regards,
> Hugh Lo
>
>
>
--
Best regards,
Hugh Lo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180519/6b875b09/attachment.html>
More information about the vtkusers
mailing list