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