]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/QT/RendererWidget.cxx
...
[cpPlugins.git] / lib / cpExtensions / QT / RendererWidget.cxx
1 #include <cpExtensions/QT/RendererWidget.h>
2
3 #ifdef cpExtensions_QT4
4
5 #include <vtkAxesActor.h>
6 #include <vtkCamera.h>
7 #include <vtkImageProperty.h>
8 #include <vtkInteractorStyle.h>
9 #include <vtkOrientationMarkerWidget.h>
10 #include <vtkProperty.h>
11 #include <vtkRenderer.h>
12 #include <vtkRenderWindow.h>
13 #include <cpExtensions/Visualization/LUTImageActor.h>
14 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
15
16 // -------------------------------------------------------------------------
17 cpExtensions::QT::RendererWidget::
18 RendererWidget( QWidget* parent, Qt::WindowFlags f )
19   : Superclass( parent, f ),
20     Superclass2( )
21 {
22   this->m_Renderer = vtkSmartPointer< vtkRenderer >::New( );
23   this->GetRenderWindow( )->AddRenderer( this->m_Renderer );
24
25   vtkAxesActor* axes = vtkAxesActor::New( );
26   axes->AxisLabelsOff( );
27   this->m_Marker = vtkSmartPointer< vtkOrientationMarkerWidget >::New( );
28   this->m_Marker->SetOutlineColor( 1, 1, 1 );
29   this->m_Marker->SetOrientationMarker( axes );
30   this->m_Marker->SetInteractor( this->GetRenderWindow( )->GetInteractor( ) );
31   this->m_Marker->EnabledOn( );
32   this->m_Marker->InteractiveOff( );
33   axes->Delete( );
34   this->SetQuadrant( 0 );
35 }
36
37 // -------------------------------------------------------------------------
38 cpExtensions::QT::RendererWidget::
39 ~RendererWidget( )
40 {
41 }
42
43 // -------------------------------------------------------------------------
44 int cpExtensions::QT::RendererWidget::
45 GetQuadrant( ) const
46 {
47   return( this->m_Quadrant );
48 }
49
50 // -------------------------------------------------------------------------
51 void cpExtensions::QT::RendererWidget::
52 SetQuadrant( int q )
53 {
54   this->m_Quadrant = ( q - 1 ) % 4;
55   if( this->m_Quadrant == 0 )
56     this->m_Marker->SetViewport( 0.85, 0.00, 1.00, 0.15 );
57   else if( this->m_Quadrant == 1 )
58     this->m_Marker->SetViewport( 0.00, 0.00, 0.15, 0.15 );
59   else if( this->m_Quadrant == 2 )
60     this->m_Marker->SetViewport( 0.00, 0.85, 0.15, 1.00 );
61   else if( this->m_Quadrant == 3 )
62     this->m_Marker->SetViewport( 0.85, 0.85, 1.00, 1.00 );
63 }
64
65 // -------------------------------------------------------------------------
66 vtkRenderer* cpExtensions::QT::RendererWidget::
67 GetRenderer( )
68 {
69   return( this->m_Renderer );
70 }
71
72 // -------------------------------------------------------------------------
73 const vtkRenderer* cpExtensions::QT::RendererWidget::
74 GetRenderer( ) const
75 {
76   return( this->m_Renderer );
77 }
78
79 // -------------------------------------------------------------------------
80 vtkInteractorStyle* cpExtensions::QT::RendererWidget::
81 GetStyle( )
82 {
83   auto iren = this->GetInteractor( );
84   if( iren != NULL )
85     return(
86       dynamic_cast< vtkInteractorStyle* >( iren->GetInteractorStyle( ) )
87       );
88   else
89     return( NULL );
90 }
91
92 // -------------------------------------------------------------------------
93 const vtkInteractorStyle* cpExtensions::QT::RendererWidget::
94 GetStyle( ) const
95 {
96   // Ugly, but necessary :-(
97   Self* self = const_cast< Self* >( this );
98   if( self != NULL )
99   {
100     auto iren = self->GetInteractor( );
101     if( iren != NULL )
102       return(
103         dynamic_cast< const vtkInteractorStyle* >(
104           iren->GetInteractorStyle( )
105           )
106         );
107     else
108       return( NULL );
109   }
110   else
111     return( NULL );
112 }
113
114 // -------------------------------------------------------------------------
115 void cpExtensions::QT::RendererWidget::
116 SetStyle( vtkInteractorStyle* style )
117 {
118   this->GetInteractor( )->SetInteractorStyle( style );
119 }
120
121 // -------------------------------------------------------------------------
122 vtkCamera* cpExtensions::QT::RendererWidget::
123 GetActiveCamera( )
124 {
125   return( this->m_Renderer->GetActiveCamera( ) );
126 }
127
128 // -------------------------------------------------------------------------
129 const vtkCamera* cpExtensions::QT::RendererWidget::
130 GetActiveCamera( ) const
131 {
132   return( this->m_Renderer->GetActiveCamera( ) );
133 }
134
135 // -------------------------------------------------------------------------
136 void cpExtensions::QT::RendererWidget::
137 AddViewProp( vtkProp* prop, const std::string& name )
138 {
139   if( prop != NULL )
140   {
141     auto i = this->m_ViewProps.find( name );
142     if( i == this->m_ViewProps.end( ) )
143       i =
144         this->m_ViewProps.insert(
145           TPropCollection::value_type( name, TProps( ) )
146           ).first;
147     i->second.insert( prop );
148     this->m_Renderer->AddViewProp( prop );
149
150   } // fi
151 }
152
153 // -------------------------------------------------------------------------
154 void cpExtensions::QT::RendererWidget::
155 AddViewProps( vtkPropCollection* props, const std::string& name )
156 {
157   if( props != NULL )
158   {
159     auto i = this->m_ViewProps.find( name );
160     if( i == this->m_ViewProps.end( ) )
161       i =
162         this->m_ViewProps.insert(
163           TPropCollection::value_type( name, TProps( ) )
164           ).first;
165     props->InitTraversal( );
166     while( vtkProp* prop = props->GetNextProp( ) )
167     {
168       i->second.insert( prop );
169       this->m_Renderer->AddViewProp( prop );
170
171     } // elihw
172
173   } // fi
174 }
175
176 // -------------------------------------------------------------------------
177 void cpExtensions::QT::RendererWidget::
178 AddAuxViewProp( vtkProp* prop, const std::string& name )
179 {
180   if( prop != NULL )
181   {
182     auto i = this->m_AuxViewProps.find( name );
183     if( i == this->m_AuxViewProps.end( ) )
184       i =
185         this->m_AuxViewProps.insert(
186           TPropCollection::value_type( name, TProps( ) )
187           ).first;
188     i->second.insert( prop );
189     this->m_Renderer->AddViewProp( prop );
190
191   } // fi
192 }
193
194 // -------------------------------------------------------------------------
195 void cpExtensions::QT::RendererWidget::
196 AddAuxViewProps( vtkPropCollection* props, const std::string& name )
197 {
198   if( props != NULL )
199   {
200     auto i = this->m_AuxViewProps.find( name );
201     if( i == this->m_AuxViewProps.end( ) )
202       i =
203         this->m_AuxViewProps.insert(
204           TPropCollection::value_type( name, TProps( ) )
205           ).first;
206     props->InitTraversal( );
207     while( vtkProp* prop = props->GetNextProp( ) )
208     {
209       i->second.insert( prop );
210       this->m_Renderer->AddViewProp( prop );
211
212     } // elhiw
213
214   } // fi
215 }
216
217 // -------------------------------------------------------------------------
218 cpExtensions::QT::RendererWidget::
219 TProps& cpExtensions::QT::RendererWidget::
220 GetViewProps( const std::string& name )
221 {
222   static TProps zero;
223   auto i = this->m_ViewProps.find( name );
224   if( i == this->m_ViewProps.end( ) )
225   {
226     zero.clear( );
227     return( zero );
228   }
229   else
230     return( i->second );
231 }
232
233 // -------------------------------------------------------------------------
234 const cpExtensions::QT::RendererWidget::
235 TProps& cpExtensions::QT::RendererWidget::
236 GetViewProps( const std::string& name ) const
237 {
238   static const TProps zero;
239   auto i = this->m_ViewProps.find( name );
240   if( i == this->m_ViewProps.end( ) )
241     return( zero );
242   else
243     return( i->second );
244 }
245
246 // -------------------------------------------------------------------------
247 cpExtensions::QT::RendererWidget::
248 TProps& cpExtensions::QT::RendererWidget::
249 GetAuxViewProps( const std::string& name )
250 {
251   static TProps zero;
252   auto i = this->m_AuxViewProps.find( name );
253   if( i == this->m_AuxViewProps.end( ) )
254   {
255     zero.clear( );
256     return( zero );
257   }
258   else
259     return( i->second );
260 }
261
262 // -------------------------------------------------------------------------
263 const cpExtensions::QT::RendererWidget::
264 TProps& cpExtensions::QT::RendererWidget::
265 GetAuxViewProps( const std::string& name ) const
266 {
267   static const TProps zero;
268   auto i = this->m_AuxViewProps.find( name );
269   if( i == this->m_AuxViewProps.end( ) )
270     return( zero );
271   else
272     return( i->second );
273 }
274
275 // -------------------------------------------------------------------------
276 void cpExtensions::QT::RendererWidget::
277 RemoveViewProps( const std::string& name )
278 {
279   auto i = this->m_ViewProps.find( name );
280   if( i != this->m_ViewProps.end( ) )
281   {
282     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
283       this->m_Renderer->RemoveViewProp( *p );
284     this->m_ViewProps.erase( i );
285
286   } // fi
287
288   i = this->m_AuxViewProps.find( name );
289   if( i != this->m_AuxViewProps.end( ) )
290   {
291     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
292       this->m_Renderer->RemoveViewProp( *p );
293     this->m_AuxViewProps.erase( i );
294
295   } // fi
296 }
297
298 // -------------------------------------------------------------------------
299 void cpExtensions::QT::RendererWidget::
300 RemoveViewProps( )
301 {
302   this->m_Renderer->RemoveAllViewProps( );
303   this->m_ViewProps.clear( );
304   this->m_AuxViewProps.clear( );
305 }
306
307 // -------------------------------------------------------------------------
308 void cpExtensions::QT::RendererWidget::
309 HideViewProps( const std::string& name )
310 {
311   auto i = this->m_ViewProps.find( name );
312   if( i != this->m_ViewProps.end( ) )
313     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
314       ( *p )->VisibilityOff( );
315   i = this->m_AuxViewProps.find( name );
316   if( i != this->m_AuxViewProps.end( ) )
317     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
318       ( *p )->VisibilityOff( );
319 }
320
321 // -------------------------------------------------------------------------
322 void cpExtensions::QT::RendererWidget::
323 ShowViewProps( const std::string& name )
324 {
325   auto i = this->m_ViewProps.find( name );
326   if( i != this->m_ViewProps.end( ) )
327     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
328       ( *p )->VisibilityOn( );
329   i = this->m_AuxViewProps.find( name );
330   if( i != this->m_AuxViewProps.end( ) )
331     for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
332       ( *p )->VisibilityOn( );
333 }
334
335 // -------------------------------------------------------------------------
336 void cpExtensions::QT::RendererWidget::
337 ResetCamera( )
338 {
339   this->m_Renderer->ResetCamera( );
340 }
341
342 // -------------------------------------------------------------------------
343 void cpExtensions::QT::RendererWidget::
344 Render( )
345 {
346   this->GetRenderWindow( )->Render( );
347 }
348
349 // -------------------------------------------------------------------------
350 std::set< std::string > cpExtensions::QT::RendererWidget::
351 GetActorsNames( ) const
352 {
353   std::set< std::string > names;
354   for(
355     auto p = this->m_ViewProps.begin( );
356     p != this->m_ViewProps.end( );
357     ++p
358     )
359     names.insert( p->first );
360   return( names );
361 }
362
363 // -------------------------------------------------------------------------
364 bool cpExtensions::QT::RendererWidget::
365 IsWindowLevelImageActor( const std::string& name ) const
366 {
367   auto it = this->m_ViewProps.find( name );
368   if( it != this->m_ViewProps.end( ) )
369   {
370     auto a = it->second.begin( );
371     if( a != it->second.end( ) )
372       return( dynamic_cast< TWLActor* >( a->GetPointer( ) ) != NULL );
373     else
374       return( false );
375   }
376   else
377     return( false );
378 }
379
380 // -------------------------------------------------------------------------
381 bool cpExtensions::QT::RendererWidget::
382 IsLUTImageActor( const std::string& name ) const
383 {
384   auto it = this->m_ViewProps.find( name );
385   if( it != this->m_ViewProps.end( ) )
386   {
387     auto a = it->second.begin( );
388     if( a != it->second.end( ) )
389       return( dynamic_cast< TLUTActor* >( a->GetPointer( ) ) != NULL );
390     else
391       return( false );
392   }
393   else
394     return( false );
395 }
396
397 // -------------------------------------------------------------------------
398 bool cpExtensions::QT::RendererWidget::
399 Is3DActor( const std::string& name ) const
400 {
401   auto it = this->m_ViewProps.find( name );
402   if( it != this->m_ViewProps.end( ) )
403   {
404     auto a = it->second.begin( );
405     if( a != it->second.end( ) )
406       return( dynamic_cast< vtkActor* >( a->GetPointer( ) ) != NULL );
407     else
408       return( false );
409   }
410   else
411     return( false );
412 }
413
414 // -------------------------------------------------------------------------
415 void cpExtensions::QT::RendererWidget::
416 GetScalarRange( const std::string& name, double r[ 2 ] ) const
417 {
418   auto it = this->m_ViewProps.find( name );
419   if( it != this->m_ViewProps.end( ) )
420   {
421     auto p = it->second.begin( );
422     TWLActor* a = NULL;
423     while( a == NULL && p != it->second.end( ) )
424     {
425       a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
426       p++;
427
428     } // elihw
429     if( a != NULL )
430       a->GetRange( r );
431
432   } // fi
433 }
434
435 // -------------------------------------------------------------------------
436 void cpExtensions::QT::RendererWidget::
437 GetWindowLevel( const std::string& name, double wl[ 2 ] ) const
438 {
439   auto it = this->m_ViewProps.find( name );
440   if( it != this->m_ViewProps.end( ) )
441   {
442     auto p = it->second.begin( );
443     TWLActor* a = NULL;
444     while( a == NULL && p != it->second.end( ) )
445     {
446       a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
447       p++;
448
449     } // elihw
450     if( a != NULL )
451       a->GetWindowLevel( wl );
452
453   } // fi
454 }
455
456 // -------------------------------------------------------------------------
457 double cpExtensions::QT::RendererWidget::
458 GetWindow( const std::string& name ) const
459 {
460   auto it = this->m_ViewProps.find( name );
461   if( it != this->m_ViewProps.end( ) )
462   {
463     auto p = it->second.begin( );
464     TWLActor* a = NULL;
465     while( a == NULL && p != it->second.end( ) )
466     {
467       a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
468       p++;
469
470     } // elihw
471     if( a != NULL )
472       return( a->GetWindow( ) );
473     else
474       return( 0 );
475   }
476   else
477     return( 0 );
478 }
479
480 // -------------------------------------------------------------------------
481 double cpExtensions::QT::RendererWidget::
482 GetLevel( const std::string& name ) const
483 {
484   auto it = this->m_ViewProps.find( name );
485   if( it != this->m_ViewProps.end( ) )
486   {
487     auto p = it->second.begin( );
488     TWLActor* a = NULL;
489     while( a == NULL && p != it->second.end( ) )
490     {
491       a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
492       p++;
493
494     } // elihw
495     if( a != NULL )
496       return( a->GetLevel( ) );
497     else
498       return( 0 );
499   }
500   else
501     return( 0 );
502 }
503
504 // -------------------------------------------------------------------------
505 char cpExtensions::QT::RendererWidget::
506 GetImageInterpolation( const std::string& name ) const
507 {
508   auto it = this->m_ViewProps.find( name );
509   if( it != this->m_ViewProps.end( ) )
510   {
511     auto p = it->second.begin( );
512     TWLActor* a = NULL;
513     while( a == NULL && p != it->second.end( ) )
514     {
515       a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
516       p++;
517
518     } // elihw
519     if( a != NULL )
520     {
521       int int_type = a->GetProperty( )->GetInterpolationType( );
522       char ret = 0;
523       switch( int_type )
524       {
525       case VTK_NEAREST_INTERPOLATION: ret = 'N'; break;
526       case VTK_LINEAR_INTERPOLATION: ret = 'L'; break;
527       case VTK_CUBIC_INTERPOLATION: ret = 'C'; break;
528       default: ret = 0; break;
529       } // hctiws
530       return( ret );
531     }
532     else
533       return( 0 );
534   }
535   else
536     return( 0 );
537 }
538
539 // -------------------------------------------------------------------------
540 void cpExtensions::QT::RendererWidget::
541 GetColor( const std::string& name, double& r, double& g, double& b ) const
542 {
543   auto it = this->m_ViewProps.find( name );
544   if( it != this->m_ViewProps.end( ) )
545   {
546     auto p = it->second.begin( );
547     vtkActor* a = NULL;
548     while( a == NULL && p != it->second.end( ) )
549     {
550       a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
551       p++;
552
553     } // elihw
554     if( a != NULL )
555       return( a->GetProperty( )->GetColor( r, g, b ) );
556
557   } // fi
558 }
559
560 // -------------------------------------------------------------------------
561 double cpExtensions::QT::RendererWidget::
562 GetOpacity( const std::string& name ) const
563 {
564   auto it = this->m_ViewProps.find( name );
565   if( it != this->m_ViewProps.end( ) )
566   {
567     auto p = it->second.begin( );
568     vtkActor* a = NULL;
569     vtkImageSlice* s = NULL;
570     while( a == NULL && s == NULL && p != it->second.end( ) )
571     {
572       a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
573       s = dynamic_cast< vtkImageSlice* >( p->GetPointer( ) );
574       p++;
575
576     } // elihw
577     if( a != NULL )
578       return( a->GetProperty( )->GetOpacity( ) );
579     else if( s != NULL )
580       return( s->GetProperty( )->GetOpacity( ) );
581     else
582       return( 0 );
583   }
584   return( 0 );
585 }
586
587 // -------------------------------------------------------------------------
588 double cpExtensions::QT::RendererWidget::
589 GetPointSize( const std::string& name ) const
590 {
591   auto it = this->m_ViewProps.find( name );
592   if( it != this->m_ViewProps.end( ) )
593   {
594     auto p = it->second.begin( );
595     vtkActor* a = NULL;
596     while( a == NULL && p != it->second.end( ) )
597     {
598       a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
599       p++;
600
601     } // elihw
602     if( a != NULL )
603       return( a->GetProperty( )->GetPointSize( ) );
604     else
605       return( 0 );
606   }
607   return( 0 );
608 }
609
610 // -------------------------------------------------------------------------
611 double cpExtensions::QT::RendererWidget::
612 GetLineWidth( const std::string& name ) const
613 {
614   auto it = this->m_ViewProps.find( name );
615   if( it != this->m_ViewProps.end( ) )
616   {
617     auto p = it->second.begin( );
618     vtkActor* a = NULL;
619     while( a == NULL && p != it->second.end( ) )
620     {
621       a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
622       p++;
623
624     } // elihw
625     if( a != NULL )
626       return( a->GetProperty( )->GetLineWidth( ) );
627     else
628       return( 0 );
629   }
630   return( 0 );
631 }
632
633 // -------------------------------------------------------------------------
634 int cpExtensions::QT::RendererWidget::
635 GetRepresentation( const std::string& name ) const
636 {
637   auto it = this->m_ViewProps.find( name );
638   if( it != this->m_ViewProps.end( ) )
639   {
640     auto p = it->second.begin( );
641     vtkActor* a = NULL;
642     while( a == NULL && p != it->second.end( ) )
643     {
644       a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
645       p++;
646
647     } // elihw
648     if( a != NULL )
649       return( a->GetProperty( )->GetRepresentation( ) );
650     else
651       return( -1 );
652   }
653   return( -1 );
654 }
655
656 // -------------------------------------------------------------------------
657 void cpExtensions::QT::RendererWidget::
658 SetScalarRange( const std::string& name, double r[ 2 ] )
659 {
660   this->SetScalarRange( name, r[ 0 ], r[ 1 ] );
661 }
662
663 // -------------------------------------------------------------------------
664 void cpExtensions::QT::RendererWidget::
665 SetScalarRange( const std::string& name, double min, double max )
666 {
667   auto it = this->m_ViewProps.find( name );
668   if( it != this->m_ViewProps.end( ) )
669   {
670     bool render = false;
671     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
672     {
673       TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
674       if( a != NULL )
675       {
676         render = true;
677         a->SetRange( min, max );
678
679       } // fi
680
681     } // rof
682     if( render )
683       this->Render( );
684
685   } // fi
686 }
687
688 // -------------------------------------------------------------------------
689 void cpExtensions::QT::RendererWidget::
690 SetWindowLevel( const std::string& name, double wl[ 2 ] )
691 {
692   this->SetWindowLevel( name, wl[ 0 ], wl[ 1 ] );
693 }
694
695 // -------------------------------------------------------------------------
696 void cpExtensions::QT::RendererWidget::
697 SetWindowLevel( const std::string& name, double w, double l )
698 {
699   auto it = this->m_ViewProps.find( name );
700   if( it != this->m_ViewProps.end( ) )
701   {
702     bool render = false;
703     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
704     {
705       TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
706       if( a != NULL )
707       {
708         render = true;
709         a->SetWindowLevel( w, l );
710
711       } // fi
712
713     } // rof
714     if( render )
715       this->Render( );
716
717   } // fi
718 }
719
720 // -------------------------------------------------------------------------
721 void cpExtensions::QT::RendererWidget::
722 SetWindow( const std::string& name, double w )
723 {
724   auto it = this->m_ViewProps.find( name );
725   if( it != this->m_ViewProps.end( ) )
726   {
727     bool render = false;
728     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
729     {
730       TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
731       if( a != NULL )
732       {
733         render = true;
734         a->SetWindow( w );
735
736       } // fi
737
738     } // rof
739     if( render )
740       this->Render( );
741
742   } // fi
743 }
744
745 // -------------------------------------------------------------------------
746 void cpExtensions::QT::RendererWidget::
747 SetLevel( const std::string& name, double l )
748 {
749   auto it = this->m_ViewProps.find( name );
750   if( it != this->m_ViewProps.end( ) )
751   {
752     bool render = false;
753     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
754     {
755       TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
756       if( a != NULL )
757       {
758         render = true;
759         a->SetLevel( l );
760
761       } // fi
762
763     } // rof
764     if( render )
765       this->Render( );
766
767   } // fi
768 }
769
770 // -------------------------------------------------------------------------
771 void cpExtensions::QT::RendererWidget::
772 SetImageInterpolation( const std::string& name, char i )
773 {
774   auto it = this->m_ViewProps.find( name );
775   if( it != this->m_ViewProps.end( ) )
776   {
777     bool render = false;
778     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
779     {
780       TWLActor* a = dynamic_cast< TWLActor* >( p->GetPointer( ) );
781       if( a != NULL )
782       {
783         render = true;
784         int int_type = VTK_NEAREST_INTERPOLATION;
785         switch( i )
786         {
787         case 'L': int_type = VTK_LINEAR_INTERPOLATION; break;
788         case 'C': int_type = VTK_CUBIC_INTERPOLATION; break;
789         default:  int_type = VTK_NEAREST_INTERPOLATION; break;
790         } // hctiws
791         a->GetProperty( )->SetInterpolationType( int_type );
792
793       } // fi
794
795     } // rof
796     if( render )
797       this->Render( );
798
799   } // fi
800 }
801
802 // -------------------------------------------------------------------------
803 void cpExtensions::QT::RendererWidget::
804 SetColor( const std::string& name, double r, double g, double b )
805 {
806   auto it = this->m_ViewProps.find( name );
807   if( it != this->m_ViewProps.end( ) )
808   {
809     bool render = false;
810     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
811     {
812       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
813       if( a != NULL )
814       {
815         render = true;
816         a->GetProperty( )->SetColor( r, g, b );
817
818       } // fi
819
820     } // rof
821     if( render )
822       this->Render( );
823
824   } // fi
825 }
826
827 // -------------------------------------------------------------------------
828 void cpExtensions::QT::RendererWidget::
829 SetOpacity( const std::string& name, double o )
830 {
831   auto it = this->m_ViewProps.find( name );
832   if( it != this->m_ViewProps.end( ) )
833   {
834     bool render = false;
835     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
836     {
837       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
838       vtkImageSlice* s = dynamic_cast< vtkImageSlice* >( p->GetPointer( ) );
839       if( a != NULL )
840       {
841         render = true;
842         a->GetProperty( )->SetOpacity( o );
843       }
844       else if( s != NULL )
845       {
846         render = true;
847         s->GetProperty( )->SetOpacity( o );
848
849       } // fi
850
851     } // rof
852     if( render )
853       this->Render( );
854
855   } // fi
856 }
857
858 // -------------------------------------------------------------------------
859 void cpExtensions::QT::RendererWidget::
860 SetPointSize( const std::string& name, double s )
861 {
862   auto it = this->m_ViewProps.find( name );
863   if( it != this->m_ViewProps.end( ) )
864   {
865     bool render = false;
866     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
867     {
868       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
869       if( a != NULL )
870       {
871         render = true;
872         a->GetProperty( )->SetPointSize( s );
873
874       } // fi
875
876     } // rof
877     if( render )
878       this->Render( );
879
880   } // fi
881 }
882
883 // -------------------------------------------------------------------------
884 void cpExtensions::QT::RendererWidget::
885 SetLineWidth( const std::string& name, double w )
886 {
887   auto it = this->m_ViewProps.find( name );
888   if( it != this->m_ViewProps.end( ) )
889   {
890     bool render = false;
891     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
892     {
893       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
894       if( a != NULL )
895       {
896         render = true;
897         a->GetProperty( )->SetLineWidth( w );
898
899       } // fi
900
901     } // rof
902     if( render )
903       this->Render( );
904
905   } // fi
906 }
907
908 // -------------------------------------------------------------------------
909 void cpExtensions::QT::RendererWidget::
910 SetRepresentationToPoints( const std::string& name )
911 {
912   auto it = this->m_ViewProps.find( name );
913   if( it != this->m_ViewProps.end( ) )
914   {
915     bool render = false;
916     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
917     {
918       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
919       if( a != NULL )
920       {
921         render = true;
922         a->GetProperty( )->SetRepresentationToPoints( );
923
924       } // fi
925
926     } // rof
927     if( render )
928       this->Render( );
929
930   } // fi
931 }
932
933 // -------------------------------------------------------------------------
934 void cpExtensions::QT::RendererWidget::
935 SetRepresentationToSurface( const std::string& name )
936 {
937   auto it = this->m_ViewProps.find( name );
938   if( it != this->m_ViewProps.end( ) )
939   {
940     bool render = false;
941     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
942     {
943       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
944       if( a != NULL )
945       {
946         render = true;
947         a->GetProperty( )->SetRepresentationToSurface( );
948
949       } // fi
950
951     } // rof
952     if( render )
953       this->Render( );
954
955   } // fi
956 }
957
958 // -------------------------------------------------------------------------
959 void cpExtensions::QT::RendererWidget::
960 SetRepresentationToWireframe( const std::string& name )
961 {
962   auto it = this->m_ViewProps.find( name );
963   if( it != this->m_ViewProps.end( ) )
964   {
965     bool render = false;
966     for( auto p = it->second.begin( ); p != it->second.end( ); ++p )
967     {
968       vtkActor* a = dynamic_cast< vtkActor* >( p->GetPointer( ) );
969       if( a != NULL )
970       {
971         render = true;
972         a->GetProperty( )->SetRepresentationToWireframe( );
973
974       } // fi
975
976     } // rof
977     if( render )
978       this->Render( );
979
980   } // fi
981 }
982
983 #endif // cpExtensions_QT4
984
985 // eof - $RCSfile$