Salome HOME
Merge from BR_PORTING_VTK6 01/03/2013
[modules/visu.git] / src / OBJECT / VISU_ScalarMapAct.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_MeshAct.hxx
25 //  Author : Laurent CORNABE with the help of Nicolas REJNERI
26 //  Module : VISU
27 //  $Header$
28 //
29 #include "VISU_ScalarMapAct.h"
30 #include "VISU_LookupTable.hxx"
31 #include "VISU_ScalarBarActor.hxx"
32 #include "VISU_PipeLine.hxx"
33
34 #include "VISU_OpenGLPointSpriteMapper.hxx"
35 #include "VISU_GaussPtsDeviceActor.h"
36 #include "VISU_DeformedShapePL.hxx"
37 #include "VISU_PipeLineUtils.hxx"
38
39
40 #include <SUIT_ResourceMgr.h>
41 #include <SUIT_Session.h>
42
43 #include <SALOME_ExtractGeometry.h>
44 #include <SALOME_ExtractPolyDataGeometry.h>
45
46 #include <vtkObjectFactory.h>
47 #include <vtkRenderer.h>
48 #include <vtkProperty.h>
49 #include <vtkMatrix4x4.h>
50 #include <vtkMapper.h>
51 #include <vtkDataSetMapper.h>
52
53 #include <vtkRenderWindowInteractor.h>
54 #include <vtkCallbackCommand.h>
55 #include <vtkRenderWindow.h>
56 #include <vtkImageData.h>
57
58
59 //============================================================================
60 class VISU_PointsDeviceActor: public VISU_GaussDeviceActorBase
61 {
62  public:
63   vtkTypeMacro(VISU_PointsDeviceActor, VISU_GaussDeviceActorBase);
64
65   static 
66   VISU_PointsDeviceActor* 
67   New();
68  
69
70   //----------------------------------------------------------------------------
71   virtual
72   void
73   SetInput(vtkDataSet* theDataSet)
74   {
75     myGeomFilter->SetInputData( theDataSet );
76   }
77
78
79   //----------------------------------------------------------------------------
80   void
81   SetInteractor(vtkRenderWindowInteractor* theInteractor)
82   {
83     if(theInteractor == myInteractor)
84       return;
85
86     if(myInteractor)
87       myInteractor->RemoveObserver(myEventCallbackCommand);
88     
89     if(theInteractor)
90       theInteractor->AddObserver(vtkCommand::CharEvent, 
91                                  myEventCallbackCommand, 
92                                  0.0);
93
94     myInteractor = theInteractor;
95   }
96
97
98   //----------------------------------------------------------------------------
99   void
100   DoMapperShallowCopy( vtkMapper* theMapper,
101                        bool theIsCopyInput )
102   {
103     Superclass::DoMapperShallowCopy( theMapper, theIsCopyInput );
104
105     vtkDataSet* aDataSet = theMapper->GetInput();
106     double aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
107
108     GetPointSpriteMapper()->SetAverageCellSize( aScaleFactor );
109   }
110
111
112   //----------------------------------------------------------------------------
113   void
114   DeepCopy( VISU_PointsDeviceActor *theActor )
115   {
116     VISU::CopyPointSpriteDataMapper( GetPointSpriteMapper(), theActor->GetPointSpriteMapper(), false );
117   }
118
119  protected:
120   //----------------------------------------------------------------------------
121   VISU_PointsDeviceActor():
122     myGeomFilter( VTKViewer_GeometryFilter::New() ),
123     myEventCallbackCommand( vtkCallbackCommand::New() ),
124     myInteractor( NULL )
125   {
126     myGeomFilter->SetInside(true);
127
128     VISU_OpenGLPointSpriteMapper* aMapper = VISU_OpenGLPointSpriteMapper::New();
129     aMapper->SetInputConnection( myGeomFilter->GetOutputPort() );
130
131     std::string aRootDir( getenv( "VISU_ROOT_DIR") );
132     std::string aMainTexture = aRootDir + "/share/salome/resources/visu/sprite_texture.bmp";
133     std::string anAlphaTexture = aRootDir + "/share/salome/resources/visu/sprite_alpha.bmp";
134     VISU::TTextureValue aTextureValue = VISU::GetTexture( aMainTexture, anAlphaTexture );
135     aMapper->SetImageData( aTextureValue.GetPointer() );
136
137     aMapper->SetUseLookupTableScalarRange(true);
138     aMapper->SetColorModeToMapScalars();
139     aMapper->SetScalarVisibility(true);
140
141     SetPointSpriteMapper( aMapper );
142
143     myGeomFilter->SetAppendCoincident3D(true);
144
145     aMapper->Delete();
146
147     myEventCallbackCommand->SetClientData( this );
148     myEventCallbackCommand->SetCallback( VISU_PointsDeviceActor::ProcessEvents );
149   }
150
151
152   //----------------------------------------------------------------------------
153   ~VISU_PointsDeviceActor()
154   {
155     SetInteractor( NULL );
156     myGeomFilter->Delete();
157     myEventCallbackCommand->Delete();
158   }
159
160
161   //----------------------------------------------------------------------------
162   static
163   void
164   ProcessEvents(vtkObject* theObject, 
165                 unsigned long theEvent,
166                 void* theClientData, 
167                 void* theCallData)
168   {
169     if ( VISU_PointsDeviceActor* self = reinterpret_cast<VISU_PointsDeviceActor*>( theClientData ) )
170       self->OnInteractorEvent( theEvent );
171   }
172
173
174   //----------------------------------------------------------------------------
175   void
176   OnInteractorEvent(unsigned long theEvent)
177   {
178     switch ( theEvent ) {
179     case vtkCommand::CharEvent: {
180       switch( myInteractor->GetKeyCode() ) {
181       case 'M' :
182       case 'm' : {
183         if ( !GetVisibility() )
184           return;
185
186         static double anIncrement = 2;
187         double aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification();
188         double coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement;
189
190         GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient );
191
192         myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
193         break;
194       }
195       default:
196         return;
197       }
198       break;
199     }
200     default:
201       return;
202     }
203   }
204
205
206   //----------------------------------------------------------------------------
207   vtkCallbackCommand* myEventCallbackCommand;
208   vtkRenderWindowInteractor* myInteractor;
209   VTKViewer_GeometryFilter* myGeomFilter;
210
211  private:
212   VISU_PointsDeviceActor(const VISU_PointsDeviceActor&); // Not implemented
213   void operator=(const VISU_PointsDeviceActor&); // Not implemented
214 };
215
216 vtkStandardNewMacro(VISU_PointsDeviceActor);
217
218 //----------------------------------------------------------------------------
219 vtkStandardNewMacro(VISU_ScalarMapAct);
220 static double EPS = 1.0 / VTK_LARGE_FLOAT;
221
222 //----------------------------------------------------------------------------
223 VISU_ScalarMapAct
224 ::VISU_ScalarMapAct()
225 {
226   myScalarBar = VISU_ScalarBarActor::New();
227
228   vtkProperty* aProperty = GetProperty();
229   aProperty->SetAmbient(1.0); 
230   aProperty->SetDiffuse(0.0);
231   aProperty->SetSpecular(0.0);
232   
233   myProperty->DeepCopy(aProperty);
234
235   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
236
237   mySurfaceActor= SVTK_DeviceActor::New();
238   mySurfaceActor->SetRepresentation(VTKViewer::Representation::Surface);
239   mySurfaceActor->SetProperty(aProperty);
240   mySurfaceActor->SetUserMatrix(aMatrix);
241   mySurfaceActor->SetCoincident3DAllowed(true);
242
243   myEdgeActor = SVTK_DeviceActor::New();
244   myEdgeActor->SetRepresentation(VTKViewer::Representation::Wireframe);
245   myEdgeActor->SetUserMatrix(aMatrix);
246   myEdgeActor->GetProperty()->SetColor(255.,255.,255.);
247
248   myEdgeActor->SetCoincident3DAllowed(true);
249
250   myPointsActor = SVTK_DeviceActor::New();
251   myPointsActor->SetRepresentation(VTKViewer::Representation::Points);
252   myPointsActor->SetProperty(aProperty);
253   myPointsActor->SetUserMatrix(aMatrix);
254
255   myPointSpriteActor = VISU_PointsDeviceActor::New();
256   myPointSpriteActor->SetProperty(aProperty);
257   myPointSpriteActor->SetUserMatrix(aMatrix);
258
259   aMatrix->Delete();
260
261   myIsPointSpriteMode = false;
262
263   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
264   //Quadratic 2D elements representation
265   if(aResourceMgr) {
266     //----------------------------------------------------------------------------
267     int aQuadraticAngle = aResourceMgr->integerValue( "VISU", "max_angle", 2);
268     mySurfaceActor->SetQuadraticArcAngle(aQuadraticAngle);
269     myEdgeActor->SetQuadraticArcAngle(aQuadraticAngle);
270
271     int anElem0DSize = aResourceMgr->integerValue( "VISU", "elem0d_size", 5);
272     mySurfaceActor->GetProperty()->SetPointSize(anElem0DSize);
273   }
274 }
275
276 //----------------------------------------------------------------------------
277 VISU_ScalarMapAct
278 ::~VISU_ScalarMapAct()
279 {
280   myScalarBar->Delete();
281
282   myPointsActor->Delete();
283   myPointSpriteActor->Delete();
284
285   mySurfaceActor->Delete();
286   myEdgeActor->Delete();
287 }
288
289 void
290 VISU_ScalarMapAct
291 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
292 {
293   VISU_DataSetActor::ShallowCopyPL( thePipeLine );
294
295   myEdgeActor->GetMapper()->ScalarVisibilityOff();
296
297   myPointSpriteActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
298
299   VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false );
300   VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false );
301 }
302
303 //----------------------------------------------------------------------------
304 void
305 VISU_ScalarMapAct
306 ::SetMapperInput(vtkDataSet* theDataSet)
307 {
308   Superclass::SetMapperInput( theDataSet );
309
310 //    myPointsActor->SetInput( theDataSet );
311 //    mySurfaceActor->SetInput( theDataSet );
312 //    myEdgeActor->SetInput( theDataSet );
313
314   if (theDataSet->IsA("vtkPolyData")) {
315     myPointSpriteActor->SetInput( myPolyDataExtractor->GetOutput() );
316     myPointsActor->SetInput( myPolyDataExtractor->GetOutput() );
317     mySurfaceActor->SetInput( myPolyDataExtractor->GetOutput() );
318     myEdgeActor->SetInput( myPolyDataExtractor->GetOutput() );
319   } else {
320     myPointSpriteActor->SetInput( myExtractor->GetOutput() );
321     myPointsActor->SetInput( myExtractor->GetOutput() );
322     mySurfaceActor->SetInput( myExtractor->GetOutput() );
323     myEdgeActor->SetInput( myExtractor->GetOutput() );
324   }
325 }
326
327 //----------------------------------------------------------------------------
328 void
329 VISU_ScalarMapAct
330 ::SetTransform(VTKViewer_Transform* theTransform)
331 {
332   Superclass::SetTransform(theTransform);
333
334   myPointsActor->SetTransform(theTransform);
335   myPointSpriteActor->SetTransform(theTransform);
336
337   mySurfaceActor->SetTransform(theTransform);
338   myEdgeActor->SetTransform(theTransform);
339 }
340
341 //----------------------------------------------------------------------------
342 vtkProperty* 
343 VISU_ScalarMapAct
344 ::GetEdgeProperty()
345 {
346   return myEdgeActor->GetProperty();
347 }
348
349 //----------------------------------------------------------------------------
350 void
351 VISU_ScalarMapAct
352 ::SetShrinkable(bool theIsShrinkable)
353 {
354   Superclass::SetShrinkable(theIsShrinkable);
355
356   mySurfaceActor->SetShrinkable(theIsShrinkable);
357   myEdgeActor->SetShrinkable(theIsShrinkable);
358 }
359
360 void
361 VISU_ScalarMapAct
362 ::SetShrinkFactor(double theValue)
363 {
364   Superclass::SetShrinkFactor(theValue);
365
366   mySurfaceActor->SetShrinkFactor(theValue);
367   myEdgeActor->SetShrinkFactor(theValue);
368 }
369
370 //----------------------------------------------------------------------------
371 void
372 VISU_ScalarMapAct
373 ::SetShrink()
374 {
375   if(myRepresentation == VTK_POINTS)
376     return;
377
378   Superclass::SetShrink();
379
380   mySurfaceActor->SetShrink();
381   myEdgeActor->SetShrink();
382 }
383
384 void
385 VISU_ScalarMapAct
386 ::UnShrink()
387 {
388   Superclass::UnShrink();
389
390   mySurfaceActor->UnShrink();
391   myEdgeActor->UnShrink();
392 }
393
394 //----------------------------------------------------------------------------
395 void
396 VISU_ScalarMapAct
397 ::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
398 {
399   Superclass::SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
400
401   mySurfaceActor->SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
402 }
403
404 void
405 VISU_ScalarMapAct
406 ::SetFeatureEdgesAngle(double theValue)
407 {
408   Superclass::SetFeatureEdgesAngle(theValue);
409
410   mySurfaceActor->SetFeatureEdgesAngle(theValue);
411 }
412
413 void
414 VISU_ScalarMapAct
415 ::SetFeatureEdgesFlags(bool theIsFeatureEdges,
416                        bool theIsBoundaryEdges,
417                        bool theIsManifoldEdges,
418                        bool theIsNonManifoldEdges)
419 {
420   Superclass::SetFeatureEdgesFlags(theIsFeatureEdges,
421                                    theIsBoundaryEdges,
422                                    theIsManifoldEdges,
423                                    theIsNonManifoldEdges);
424
425   mySurfaceActor->SetFeatureEdgesFlags(theIsFeatureEdges,
426                                        theIsBoundaryEdges,
427                                        theIsManifoldEdges,
428                                        theIsNonManifoldEdges);
429 }
430
431 void
432 VISU_ScalarMapAct
433 ::SetFeatureEdgesColoring(bool theIsColoring)
434 {
435   Superclass::SetFeatureEdgesColoring(theIsColoring);
436
437   mySurfaceActor->SetFeatureEdgesColoring(theIsColoring);
438 }
439
440 //----------------------------------------------------------------------------
441 void
442 VISU_ScalarMapAct
443 ::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
444 {
445   if(theIsFeatureEdgesEnabled && myRepresentation == VTK_POINTS)
446     return;
447
448   Superclass::SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
449
450   mySurfaceActor->SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
451 }
452
453 //----------------------------------------------------------------------------
454 void
455 VISU_ScalarMapAct
456 ::SetOpacity(double theValue)
457 {
458   mySurfaceActor->GetProperty()->SetOpacity(theValue);
459
460   double aPointSpriteOpacity = theValue > 0.0 ? 1.0 : 0.0;
461   myPointSpriteActor->GetPointSpriteMapper()->SetPointSpriteOpacity(aPointSpriteOpacity);
462 }
463
464 double
465 VISU_ScalarMapAct
466 ::GetOpacity()
467 {
468   return mySurfaceActor->GetProperty()->GetOpacity();
469 }
470
471 //----------------------------------------------------------------------------
472 void
473 VISU_ScalarMapAct
474 ::SetLineWidth(double theLineWidth)
475 {
476   mySurfaceActor->GetProperty()->SetLineWidth(theLineWidth);
477 }
478
479 double
480 VISU_ScalarMapAct::GetLineWidth()
481 {
482   return mySurfaceActor->GetProperty()->GetLineWidth();
483 }
484
485 //----------------------------------------------------------------------------
486 void
487 VISU_ScalarMapAct
488 ::DeepCopy(VISU_Actor *theActor)
489 {
490   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
491     Superclass::DeepCopy(theActor);
492     SetBarVisibility(anActor->GetBarVisibility());
493     myPointSpriteActor->DeepCopy( anActor->myPointSpriteActor );
494     SetShading(anActor->IsShading());
495   }
496 }
497
498
499 //----------------------------------------------------------------------------
500 void
501 VISU_ScalarMapAct
502 ::AddToRender(vtkRenderer* theRenderer)
503 {
504   Superclass::AddToRender(theRenderer);
505
506   myPointSpriteActor->SetInteractor( myInteractor );
507
508   if(myScalarBar)
509     theRenderer->AddActor2D(myScalarBar);
510 }
511
512 //----------------------------------------------------------------------------
513 void
514 VISU_ScalarMapAct
515 ::RemoveFromRender(vtkRenderer* theRenderer)
516 {
517   if(myScalarBar)
518     theRenderer->RemoveActor(myScalarBar);
519
520   if ( vtkWindow* aWindow = theRenderer->GetRenderWindow() ) {
521     myPointSpriteActor->ReleaseGraphicsResources( aWindow );
522     myPointsActor->ReleaseGraphicsResources( aWindow );
523     mySurfaceActor->ReleaseGraphicsResources( aWindow );
524     myEdgeActor->ReleaseGraphicsResources( aWindow );
525   }
526
527   Superclass::RemoveFromRender(theRenderer);
528 }
529
530 //----------------------------------------------------------------------------
531 void
532 VISU_ScalarMapAct
533 ::SetVisibility(int theMode)
534 {
535   Superclass::SetVisibility( theMode );
536
537   myPointSpriteActor->SetVisibility( theMode );
538   myPointsActor->SetVisibility( theMode );
539
540   if(myScalarBar) 
541     myScalarBar->SetVisibility(myBarVisibility && theMode);
542 }
543
544 //----------------------------------------------------------------------------
545 int 
546 VISU_ScalarMapAct
547 ::GetBarVisibility()
548 {
549   return myBarVisibility;
550 }
551
552 //----------------------------------------------------------------------------
553 VISU_ScalarBarActor*
554 VISU_ScalarMapAct
555 ::GetScalarBar()
556 {
557   return myScalarBar;
558 }
559
560 //----------------------------------------------------------------------------
561 void
562 VISU_ScalarMapAct
563 ::SetBarVisibility(bool theMode)
564 {
565   myBarVisibility = theMode;
566   if(myScalarBar) 
567     myScalarBar->SetVisibility(myBarVisibility && GetVisibility());
568 }
569
570
571 //----------------------------------------------------------------------------
572 void
573 VISU_ScalarMapAct
574 ::SetRepresentation(int theMode) 
575
576   bool anIsShanding = IsShading();
577
578   Superclass::SetRepresentation(theMode);
579
580   if(theMode == VTKViewer::Representation::Surfaceframe)
581     mySurfaceActor->SetRepresentation(VTKViewer::Representation::Surface);
582   else
583     mySurfaceActor->SetRepresentation(theMode);
584
585   myPointSpriteActor->SetProperty( mySurfaceActor->GetProperty() );
586   myPointsActor->SetProperty( mySurfaceActor->GetProperty() );
587
588   SetShading(anIsShanding);
589 }
590
591
592 //----------------------------------------------------------------------------
593 void
594 VISU_ScalarMapAct
595 ::SetShading(bool theOn)
596 {
597   vtkProperty* aProperty = mySurfaceActor->GetProperty();
598
599   if (theOn) {
600     aProperty->SetAmbient(0.0); 
601     aProperty->SetDiffuse(1.0);
602   } else {
603     aProperty->SetAmbient(1.0); 
604     aProperty->SetDiffuse(0.0);
605   }
606 }
607
608 //----------------------------------------------------------------------------
609 bool
610 VISU_ScalarMapAct
611 ::IsShading()
612 {
613   vtkProperty* aProperty = mySurfaceActor->GetProperty();
614   
615   return (fabs(aProperty->GetAmbient()) < EPS && fabs(aProperty->GetDiffuse() - 1.) < EPS);
616 }
617
618 int
619 VISU_ScalarMapAct
620 ::RenderOpaqueGeometry(vtkViewport *ren)
621 {
622   GetMatrix(myEdgeActor->GetUserMatrix());
623   GetMatrix(mySurfaceActor->GetUserMatrix());
624   GetMatrix(myPointsActor->GetUserMatrix());
625   GetMatrix(myPointSpriteActor->GetUserMatrix());
626
627   using namespace VTKViewer::Representation;
628   switch ( GetRepresentation() ) {
629
630   case Surfaceframe:
631     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
632     mySurfaceActor->RenderOpaqueGeometry(ren);
633
634     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
635     myEdgeActor->RenderOpaqueGeometry(ren);
636     break;
637
638   case Points:
639     if( myIsPointSpriteMode ) {
640       myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
641       myPointSpriteActor->RenderOpaqueGeometry(ren);
642     } else {
643       myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
644       myPointsActor->RenderOpaqueGeometry(ren);
645     }
646     break;
647
648   default:
649     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
650     mySurfaceActor->RenderOpaqueGeometry(ren);
651   }
652
653   return 1;
654 }
655
656 int
657 VISU_ScalarMapAct
658 #if (VTK_XVERSION < 0x050100)
659 ::RenderTranslucentGeometry(vtkViewport *ren)
660 #else
661 ::RenderTranslucentPolygonalGeometry(vtkViewport *ren)
662 #endif
663 {
664   GetMatrix(myEdgeActor->GetUserMatrix());
665   GetMatrix(mySurfaceActor->GetUserMatrix());
666
667   using namespace VTKViewer::Representation;
668   switch ( GetRepresentation() ) {
669
670   case Surfaceframe:
671     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
672 #if (VTK_XVERSION < 0x050100)
673     mySurfaceActor->RenderTranslucentGeometry(ren);
674 #else
675     mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
676 #endif
677
678     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
679 #if (VTK_XVERSION < 0x050100)
680     myEdgeActor->RenderTranslucentGeometry(ren);
681 #else
682     myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
683 #endif
684     break;
685
686   case Points:
687     if( myIsPointSpriteMode ) {
688       myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
689 #if (VTK_XVERSION < 0x050100)
690       myPointSpriteActor->RenderTranslucentGeometry(ren);
691 #else
692       myPointSpriteActor->RenderTranslucentPolygonalGeometry(ren);
693 #endif
694     } else {
695       myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
696 #if (VTK_XVERSION < 0x050100)
697       myPointsActor->RenderTranslucentGeometry(ren);
698 #else
699       myPointsActor->RenderTranslucentPolygonalGeometry(ren);
700 #endif
701     }
702     break;
703
704   default:
705     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
706 #if (VTK_XVERSION < 0x050100)
707     mySurfaceActor->RenderTranslucentGeometry(ren);
708 #else
709     mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
710 #endif
711   }
712
713   return 1;
714 }
715
716 //----------------------------------------------------------------------------
717 #if (VTK_XVERSION >= 0x050100)
718 int
719 VISU_ScalarMapAct
720 ::HasTranslucentPolygonalGeometry()
721 {
722   int result = 0; 
723
724   using namespace VTKViewer::Representation;
725   switch ( GetRepresentation() ) {
726   case Surfaceframe:
727     result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
728     result |= myEdgeActor->HasTranslucentPolygonalGeometry();
729     break;
730   case Points:
731     if( myIsPointSpriteMode )
732       result |= myPointSpriteActor->HasTranslucentPolygonalGeometry();
733     else
734       result |= myPointsActor->HasTranslucentPolygonalGeometry();
735     break;
736   default:
737     result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
738   }
739
740   return result;
741 }
742 #endif
743
744 //----------------------------------------------------------------------------
745 unsigned long int
746 VISU_ScalarMapAct
747 ::GetMemorySize()
748 {
749   unsigned long int aSize = Superclass::GetMemorySize();
750
751   aSize += myPointSpriteActor->GetMemorySize();
752
753   return aSize;
754 }
755
756 //----------------------------------------------------------------------------
757
758 VISU_Actor::EQuadratic2DRepresentation 
759 VISU_ScalarMapAct
760 ::GetQuadratic2DRepresentation() const
761 {
762   bool mode = (mySurfaceActor->GetQuadraticArcMode() && myEdgeActor->GetQuadraticArcMode());
763   if(mode){
764     return VISU_Actor::eArcs;
765   }
766   else
767     return VISU_Actor::eLines;
768 }
769   
770 void VISU_ScalarMapAct::SetQuadratic2DRepresentation( VISU_Actor::EQuadratic2DRepresentation theMode )
771 {
772   Superclass::SetQuadratic2DRepresentation( theMode );
773   switch(theMode) {
774   case VISU_Actor::eArcs:
775     mySurfaceActor->SetQuadraticArcMode(true);
776     myEdgeActor->SetQuadraticArcMode(true);
777     break;
778   case VISU_Actor::eLines:
779     mySurfaceActor->SetQuadraticArcMode(false);
780     myEdgeActor->SetQuadraticArcMode(false);
781     break;
782   default:
783     break;
784   }
785 }
786
787 void VISU_ScalarMapAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
788 {
789   Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
790   myPointsActor->SetMarkerStd( theMarkerType, theMarkerScale );
791
792   myIsPointSpriteMode = theMarkerType == VTK::MT_POINT_SPRITE;
793 }
794
795 void VISU_ScalarMapAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
796 {
797   Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
798   myPointsActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
799
800   myIsPointSpriteMode = false;
801 }
802
803 /**
804  * Set size of the 0D elements.
805  */
806 void VISU_ScalarMapAct::Set0DElemSize(double theValue) {
807   mySurfaceActor->GetProperty()->SetPointSize(theValue);
808 }
809
810 /**
811  * Get size of the 0D elements.
812  */
813 double VISU_ScalarMapAct::Get0DElemSize() {
814   return mySurfaceActor->GetProperty()->GetPointSize();
815 }
816