[vtkusers] Refreshing window level of vtkImagePlaneWidget

Dean Inglis inglis.dl at gmail.com
Thu Mar 2 08:51:40 EST 2017


Hi Girish,

the following additional events could help with formulating and maintaining
your design:

vtkCommand::StartWindowLevelEvent
   - record the shared (global) window and level initial values

vtkCommand::WindowLevelEvent
  -  record current global window level vales, broadcast the event to all
other listeners and have
   them  update to current window level values

vtkCommand::EndWindowLevelEvent
  - could delay updating all widget window level values until the current
interactive widget is done

vtkCommand::ResetWindowLevelEvent
  - set the window level to all widgets back to the global initial values

- Dean



On Thu, Mar 2, 2017 at 3:55 AM, Girish Lande <girish.lande at agiliad.com>
wrote:

> Hi All,
>
> I am creating 3 vtkImagePlaneWidgets Each showing some image.
> I want to update their window/level at the same time.
> that is when I update window level of one widget others should reflect the
> same.
>
> For that I am using callbacks. (following is my code)
> Each imageplanewidget is in different view.
> Though window / level is updated its not refreshing changes.
> I see changes only when I try to update window/level of other image plane
> widgets.
>
> Could you please help me with this ? I want to refresh all widgets to see
> that
> window level is getting updated simultaneouly
>
> --
> thanks & regards,
> Girish
>
>
>
> void MainWindow::RegisterCallbackWith2DPlaneWidget()
> {
>     vtkSmartPointer<MyCallback> cbk =
>             vtkSmartPointer<MyCallback>::New();
>     cbk->m_window = this;
>     for (int i = 0; i < 3; i++)
>     {
>         cbk->m_PlaneWidget[i] = m_2DPlaneWidget[i];
>         m_2DPlaneWidget[i]->AddObserver(vtkCommand::WindowLevelEvent,cbk);
>     }
> }
>
>
> class MyCallback : public vtkCommand
> {
> public:
>     static MyCallback *New()
>     { return new MyCallback; }
>
>     void Execute( vtkObject *caller, unsigned long ev,
>                   void *callData )
>     {
>         if (ev == vtkCommand::WindowLevelEvent)
>         {
>             vtkImagePlaneWidget* ipw =
>                     dynamic_cast< vtkImagePlaneWidget* >( caller );
>             if (ipw)
>             {
>                 double* wl = static_cast<double*>( callData );
>
>                 if ( ipw == this->m_PlaneWidget[0] )
>                 {
>                     this->m_PlaneWidget[1]->SetWindowLevel(wl[0],wl[1],1);
>                     this->m_PlaneWidget[2]->SetWindowLevel(wl[0],wl[1],1);
>                 }
>                 else if( ipw == this->m_PlaneWidget[1] )
>                 {
>                     this->m_PlaneWidget[0]->SetWindowLevel(wl[0],wl[1],1);
>                     this->m_PlaneWidget[2]->SetWindowLevel(wl[0],wl[1],1);
>                 }
>                 else if (ipw == this->m_PlaneWidget[2])
>                 {
>                     this->m_PlaneWidget[0]->SetWindowLevel(wl[0],wl[1],1);
>                     this->m_PlaneWidget[1]->SetWindowLevel(wl[0],wl[1],1);
>                 }
>             }
>             this->m_PlaneWidget[0]->GetInteractor()->
> GetRenderWindow()->Render();
>             this->m_PlaneWidget[1]->GetInteractor()->
> GetRenderWindow()->Render();
>             this->m_PlaneWidget[2]->GetInteractor()->
> GetRenderWindow()->Render();
>             this->m_PlaneWidget[0]->UpdatePlacement();
>             this->m_PlaneWidget[1]->UpdatePlacement();
>             this->m_PlaneWidget[2]->UpdatePlacement();
>         }
> }
>
> vtkImagePlaneWidget* m_PlaneWidget[3];
>
> }
>
> ------------------------------------------------------------
> -------------------------------------------------------------
> *Disclaimer:* This email message including any attachments is
> confidential, and may be privileged and proprietary to Agiliad. If you are
> not the intended recipient, please notify us immediately by replying to
> this message and destroy all copies of this message including any
> attachments. You are NOT authorized to read, print, retain, copy,
> disseminate, distribute, or use this message or any part thereof. Thank you.
> ------------------------------------------------------------
> ------------------------------------------------------------
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170302/b8f9d613/attachment.html>


More information about the vtkusers mailing list