Salome HOME
58a23c1f7f32d9b38fafa16d3fa746a719636043
[modules/visu.git] / src / OBJECT / VISU_ScalarMapAct.cxx
1 // Copyright (C) 2007-2011  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->SetInput( 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     vtkFloatingPointType 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->SetInput( myGeomFilter->GetOutput() );
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     aMapper->Delete();
144
145     myEventCallbackCommand->SetClientData( this );
146     myEventCallbackCommand->SetCallback( VISU_PointsDeviceActor::ProcessEvents );
147   }
148
149
150   //----------------------------------------------------------------------------
151   ~VISU_PointsDeviceActor()
152   {
153     SetInteractor( NULL );
154     myGeomFilter->Delete();
155     myEventCallbackCommand->Delete();
156   }
157
158
159   //----------------------------------------------------------------------------
160   static
161   void
162   ProcessEvents(vtkObject* theObject, 
163                 unsigned long theEvent,
164                 void* theClientData, 
165                 void* theCallData)
166   {
167     if ( VISU_PointsDeviceActor* self = reinterpret_cast<VISU_PointsDeviceActor*>( theClientData ) )
168       self->OnInteractorEvent( theEvent );
169   }
170
171
172   //----------------------------------------------------------------------------
173   void
174   OnInteractorEvent(unsigned long theEvent)
175   {
176     switch ( theEvent ) {
177     case vtkCommand::CharEvent: {
178       switch( myInteractor->GetKeyCode() ) {
179       case 'M' :
180       case 'm' : {
181         if ( !GetVisibility() )
182           return;
183
184         static vtkFloatingPointType anIncrement = 2;
185         vtkFloatingPointType aMagnification = GetPointSpriteMapper()->GetPointSpriteMagnification();
186         vtkFloatingPointType coefficient = myInteractor->GetShiftKey() ? anIncrement : 1 / anIncrement;
187
188         GetPointSpriteMapper()->SetPointSpriteMagnification( aMagnification * coefficient );
189
190         myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
191         break;
192       }
193       default:
194         return;
195       }
196       break;
197     }
198     default:
199       return;
200     }
201   }
202
203
204   //----------------------------------------------------------------------------
205   vtkCallbackCommand* myEventCallbackCommand;
206   vtkRenderWindowInteractor* myInteractor;
207   VTKViewer_GeometryFilter* myGeomFilter;
208
209  private:
210   VISU_PointsDeviceActor(const VISU_PointsDeviceActor&); // Not implemented
211   void operator=(const VISU_PointsDeviceActor&); // Not implemented
212 };
213
214 vtkStandardNewMacro(VISU_PointsDeviceActor);
215
216 //----------------------------------------------------------------------------
217 vtkStandardNewMacro(VISU_ScalarMapAct);
218 static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
219
220 //----------------------------------------------------------------------------
221 VISU_ScalarMapAct
222 ::VISU_ScalarMapAct()
223 {
224   myScalarBar = VISU_ScalarBarActor::New();
225
226   vtkProperty* aProperty = GetProperty();
227   aProperty->SetAmbient(1.0); 
228   aProperty->SetDiffuse(0.0);
229   aProperty->SetSpecular(0.0);
230   
231   myProperty->DeepCopy(aProperty);
232
233   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
234
235   mySurfaceActor= SVTK_DeviceActor::New();
236   mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
237   mySurfaceActor->SetProperty(aProperty);
238   mySurfaceActor->SetUserMatrix(aMatrix);
239
240   myEdgeActor = SVTK_DeviceActor::New();
241   myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
242   myEdgeActor->SetUserMatrix(aMatrix);
243   myEdgeActor->GetProperty()->SetColor(255.,255.,255.);
244
245   myPointsActor = SVTK_DeviceActor::New();
246   myPointsActor->SetRepresentation(SVTK::Representation::Points);
247   myPointsActor->SetProperty(aProperty);
248   myPointsActor->SetUserMatrix(aMatrix);
249
250   myPointSpriteActor = VISU_PointsDeviceActor::New();
251   myPointSpriteActor->SetProperty(aProperty);
252   myPointSpriteActor->SetUserMatrix(aMatrix);
253
254   aMatrix->Delete();
255
256   myIsPointSpriteMode = false;
257
258   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
259   //Quadratic 2D elements representation
260   if(aResourceMgr) {
261     //----------------------------------------------------------------------------
262     int aQuadraticAngle = aResourceMgr->integerValue( "VISU", "max_angle", 2);
263     mySurfaceActor->SetQuadraticArcAngle(aQuadraticAngle);
264     myEdgeActor->SetQuadraticArcAngle(aQuadraticAngle);
265
266     int anElem0DSize = aResourceMgr->integerValue( "VISU", "elem0d_size", 5);
267     mySurfaceActor->GetProperty()->SetPointSize(anElem0DSize);
268   }
269 }
270
271 //----------------------------------------------------------------------------
272 VISU_ScalarMapAct
273 ::~VISU_ScalarMapAct()
274 {
275   myScalarBar->Delete();
276
277   myPointsActor->Delete();
278   myPointSpriteActor->Delete();
279
280   mySurfaceActor->Delete();
281   myEdgeActor->Delete();
282 }
283
284 void
285 VISU_ScalarMapAct
286 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
287 {
288   VISU_DataSetActor::ShallowCopyPL( thePipeLine );
289
290   myEdgeActor->GetMapper()->ScalarVisibilityOff();
291
292   myPointSpriteActor->DoMapperShallowCopy( thePipeLine->GetMapper(), false );
293
294   VISU::CopyMapper( myPointsActor->GetMapper(), thePipeLine->GetMapper(), false );
295   VISU::CopyMapper( mySurfaceActor->GetMapper(), thePipeLine->GetMapper(), false );
296 }
297
298 //----------------------------------------------------------------------------
299 void
300 VISU_ScalarMapAct
301 ::SetMapperInput(vtkDataSet* theDataSet)
302 {
303   Superclass::SetMapperInput( theDataSet );
304
305 //    myPointsActor->SetInput( theDataSet );
306 //    mySurfaceActor->SetInput( theDataSet );
307 //    myEdgeActor->SetInput( theDataSet );
308
309   if (theDataSet->IsA("vtkPolyData")) {
310     myPointSpriteActor->SetInput( myPolyDataExtractor->GetOutput() );
311     myPointsActor->SetInput( myPolyDataExtractor->GetOutput() );
312     mySurfaceActor->SetInput( myPolyDataExtractor->GetOutput() );
313     myEdgeActor->SetInput( myPolyDataExtractor->GetOutput() );
314   } else {
315     myPointSpriteActor->SetInput( myExtractor->GetOutput() );
316     myPointsActor->SetInput( myExtractor->GetOutput() );
317     mySurfaceActor->SetInput( myExtractor->GetOutput() );
318     myEdgeActor->SetInput( myExtractor->GetOutput() );
319   }
320 }
321
322 //----------------------------------------------------------------------------
323 void
324 VISU_ScalarMapAct
325 ::SetTransform(VTKViewer_Transform* theTransform)
326 {
327   Superclass::SetTransform(theTransform);
328
329   myPointsActor->SetTransform(theTransform);
330   myPointSpriteActor->SetTransform(theTransform);
331
332   mySurfaceActor->SetTransform(theTransform);
333   myEdgeActor->SetTransform(theTransform);
334 }
335
336 //----------------------------------------------------------------------------
337 vtkProperty* 
338 VISU_ScalarMapAct
339 ::GetEdgeProperty()
340 {
341   return myEdgeActor->GetProperty();
342 }
343
344 //----------------------------------------------------------------------------
345 void
346 VISU_ScalarMapAct
347 ::SetShrinkable(bool theIsShrinkable)
348 {
349   Superclass::SetShrinkable(theIsShrinkable);
350
351   mySurfaceActor->SetShrinkable(theIsShrinkable);
352 }
353
354 void
355 VISU_ScalarMapAct
356 ::SetShrinkFactor(vtkFloatingPointType theValue)
357 {
358   Superclass::SetShrinkFactor(theValue);
359
360   mySurfaceActor->SetShrinkFactor(theValue);
361 }
362
363 //----------------------------------------------------------------------------
364 void
365 VISU_ScalarMapAct
366 ::SetShrink()
367 {
368   if(myRepresentation == VTK_POINTS)
369     return;
370
371   Superclass::SetShrink();
372
373   mySurfaceActor->SetShrink();
374 }
375
376 void
377 VISU_ScalarMapAct
378 ::UnShrink()
379 {
380   Superclass::UnShrink();
381
382   mySurfaceActor->UnShrink();
383 }
384
385 //----------------------------------------------------------------------------
386 void
387 VISU_ScalarMapAct
388 ::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
389 {
390   Superclass::SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
391
392   mySurfaceActor->SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed);
393 }
394
395 void
396 VISU_ScalarMapAct
397 ::SetFeatureEdgesAngle(vtkFloatingPointType theValue)
398 {
399   Superclass::SetFeatureEdgesAngle(theValue);
400
401   mySurfaceActor->SetFeatureEdgesAngle(theValue);
402 }
403
404 void
405 VISU_ScalarMapAct
406 ::SetFeatureEdgesFlags(bool theIsFeatureEdges,
407                        bool theIsBoundaryEdges,
408                        bool theIsManifoldEdges,
409                        bool theIsNonManifoldEdges)
410 {
411   Superclass::SetFeatureEdgesFlags(theIsFeatureEdges,
412                                    theIsBoundaryEdges,
413                                    theIsManifoldEdges,
414                                    theIsNonManifoldEdges);
415
416   mySurfaceActor->SetFeatureEdgesFlags(theIsFeatureEdges,
417                                        theIsBoundaryEdges,
418                                        theIsManifoldEdges,
419                                        theIsNonManifoldEdges);
420 }
421
422 void
423 VISU_ScalarMapAct
424 ::SetFeatureEdgesColoring(bool theIsColoring)
425 {
426   Superclass::SetFeatureEdgesColoring(theIsColoring);
427
428   mySurfaceActor->SetFeatureEdgesColoring(theIsColoring);
429 }
430
431 //----------------------------------------------------------------------------
432 void
433 VISU_ScalarMapAct
434 ::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
435 {
436   if(theIsFeatureEdgesEnabled && myRepresentation == VTK_POINTS)
437     return;
438
439   Superclass::SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
440
441   mySurfaceActor->SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled);
442 }
443
444 //----------------------------------------------------------------------------
445 void
446 VISU_ScalarMapAct
447 ::SetOpacity(vtkFloatingPointType theValue)
448 {
449   mySurfaceActor->GetProperty()->SetOpacity(theValue);
450
451   vtkFloatingPointType aPointSpriteOpacity = theValue > 0.0 ? 1.0 : 0.0;
452   myPointSpriteActor->GetPointSpriteMapper()->SetPointSpriteOpacity(aPointSpriteOpacity);
453 }
454
455 vtkFloatingPointType
456 VISU_ScalarMapAct
457 ::GetOpacity()
458 {
459   return mySurfaceActor->GetProperty()->GetOpacity();
460 }
461
462 //----------------------------------------------------------------------------
463 void
464 VISU_ScalarMapAct
465 ::SetLineWidth(vtkFloatingPointType theLineWidth)
466 {
467   mySurfaceActor->GetProperty()->SetLineWidth(theLineWidth);
468 }
469
470 vtkFloatingPointType
471 VISU_ScalarMapAct::GetLineWidth()
472 {
473   return mySurfaceActor->GetProperty()->GetLineWidth();
474 }
475
476 //----------------------------------------------------------------------------
477 void
478 VISU_ScalarMapAct
479 ::DeepCopy(VISU_Actor *theActor)
480 {
481   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
482     Superclass::DeepCopy(theActor);
483     SetBarVisibility(anActor->GetBarVisibility());
484     myPointSpriteActor->DeepCopy( anActor->myPointSpriteActor );
485     SetShading(anActor->IsShading());
486   }
487 }
488
489
490 //----------------------------------------------------------------------------
491 void
492 VISU_ScalarMapAct
493 ::AddToRender(vtkRenderer* theRenderer)
494 {
495   Superclass::AddToRender(theRenderer);
496
497   myPointSpriteActor->SetInteractor( myInteractor );
498
499   if(myScalarBar)
500     theRenderer->AddActor2D(myScalarBar);
501 }
502
503 //----------------------------------------------------------------------------
504 void
505 VISU_ScalarMapAct
506 ::RemoveFromRender(vtkRenderer* theRenderer)
507 {
508   if(myScalarBar)
509     theRenderer->RemoveActor(myScalarBar);
510
511   if ( vtkWindow* aWindow = theRenderer->GetRenderWindow() ) {
512     myPointSpriteActor->ReleaseGraphicsResources( aWindow );
513     myPointsActor->ReleaseGraphicsResources( aWindow );
514     mySurfaceActor->ReleaseGraphicsResources( aWindow );
515     myEdgeActor->ReleaseGraphicsResources( aWindow );
516   }
517
518   Superclass::RemoveFromRender(theRenderer);
519 }
520
521 //----------------------------------------------------------------------------
522 void
523 VISU_ScalarMapAct
524 ::SetVisibility(int theMode)
525 {
526   Superclass::SetVisibility( theMode );
527
528   myPointSpriteActor->SetVisibility( theMode );
529   myPointsActor->SetVisibility( theMode );
530
531   if(myScalarBar) 
532     myScalarBar->SetVisibility(myBarVisibility && theMode);
533 }
534
535 //----------------------------------------------------------------------------
536 int 
537 VISU_ScalarMapAct
538 ::GetBarVisibility()
539 {
540   return myBarVisibility;
541 }
542
543 //----------------------------------------------------------------------------
544 VISU_ScalarBarActor*
545 VISU_ScalarMapAct
546 ::GetScalarBar()
547 {
548   return myScalarBar;
549 }
550
551 //----------------------------------------------------------------------------
552 void
553 VISU_ScalarMapAct
554 ::SetBarVisibility(bool theMode)
555 {
556   myBarVisibility = theMode;
557   if(myScalarBar) 
558     myScalarBar->SetVisibility(myBarVisibility && GetVisibility());
559 }
560
561
562 //----------------------------------------------------------------------------
563 void
564 VISU_ScalarMapAct
565 ::SetRepresentation(int theMode) 
566
567   bool anIsShanding = IsShading();
568
569   Superclass::SetRepresentation(theMode);
570
571   if(theMode == SVTK::Representation::Surfaceframe)
572     mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
573   else
574     mySurfaceActor->SetRepresentation(theMode);
575
576   myPointSpriteActor->SetProperty( mySurfaceActor->GetProperty() );
577   myPointsActor->SetProperty( mySurfaceActor->GetProperty() );
578
579   SetShading(anIsShanding);
580 }
581
582
583 //----------------------------------------------------------------------------
584 void
585 VISU_ScalarMapAct
586 ::SetShading(bool theOn)
587 {
588   vtkProperty* aProperty = mySurfaceActor->GetProperty();
589
590   if (theOn) {
591     aProperty->SetAmbient(0.0); 
592     aProperty->SetDiffuse(1.0);
593   } else {
594     aProperty->SetAmbient(1.0); 
595     aProperty->SetDiffuse(0.0);
596   }
597 }
598
599 //----------------------------------------------------------------------------
600 bool
601 VISU_ScalarMapAct
602 ::IsShading()
603 {
604   vtkProperty* aProperty = mySurfaceActor->GetProperty();
605   
606   return (fabs(aProperty->GetAmbient()) < EPS && fabs(aProperty->GetDiffuse() - 1.) < EPS);
607 }
608
609 int
610 VISU_ScalarMapAct
611 ::RenderOpaqueGeometry(vtkViewport *ren)
612 {
613   GetMatrix(myEdgeActor->GetUserMatrix());
614   GetMatrix(mySurfaceActor->GetUserMatrix());
615   GetMatrix(myPointsActor->GetUserMatrix());
616   GetMatrix(myPointSpriteActor->GetUserMatrix());
617
618   using namespace SVTK::Representation;
619   switch ( GetRepresentation() ) {
620
621   case Surfaceframe:
622     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
623     mySurfaceActor->RenderOpaqueGeometry(ren);
624
625     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
626     myEdgeActor->RenderOpaqueGeometry(ren);
627     break;
628
629   case Points:
630     if( myIsPointSpriteMode ) {
631       myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
632       myPointSpriteActor->RenderOpaqueGeometry(ren);
633     } else {
634       myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
635       myPointsActor->RenderOpaqueGeometry(ren);
636     }
637     break;
638
639   default:
640     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
641     mySurfaceActor->RenderOpaqueGeometry(ren);
642   }
643
644   return 1;
645 }
646
647 int
648 VISU_ScalarMapAct
649 #if (VTK_XVERSION < 0x050100)
650 ::RenderTranslucentGeometry(vtkViewport *ren)
651 #else
652 ::RenderTranslucentPolygonalGeometry(vtkViewport *ren)
653 #endif
654 {
655   GetMatrix(myEdgeActor->GetUserMatrix());
656   GetMatrix(mySurfaceActor->GetUserMatrix());
657
658   using namespace SVTK::Representation;
659   switch ( GetRepresentation() ) {
660
661   case Surfaceframe:
662     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
663 #if (VTK_XVERSION < 0x050100)
664     mySurfaceActor->RenderTranslucentGeometry(ren);
665 #else
666     mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
667 #endif
668
669     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
670 #if (VTK_XVERSION < 0x050100)
671     myEdgeActor->RenderTranslucentGeometry(ren);
672 #else
673     myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
674 #endif
675     break;
676
677   case Points:
678     if( myIsPointSpriteMode ) {
679       myPointSpriteActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
680 #if (VTK_XVERSION < 0x050100)
681       myPointSpriteActor->RenderTranslucentGeometry(ren);
682 #else
683       myPointSpriteActor->RenderTranslucentPolygonalGeometry(ren);
684 #endif
685     } else {
686       myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
687 #if (VTK_XVERSION < 0x050100)
688       myPointsActor->RenderTranslucentGeometry(ren);
689 #else
690       myPointsActor->RenderTranslucentPolygonalGeometry(ren);
691 #endif
692     }
693     break;
694
695   default:
696     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
697 #if (VTK_XVERSION < 0x050100)
698     mySurfaceActor->RenderTranslucentGeometry(ren);
699 #else
700     mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
701 #endif
702   }
703
704   return 1;
705 }
706
707 //----------------------------------------------------------------------------
708 #if (VTK_XVERSION >= 0x050100)
709 int
710 VISU_ScalarMapAct
711 ::HasTranslucentPolygonalGeometry()
712 {
713   int result = 0; 
714
715   using namespace SVTK::Representation;
716   switch ( GetRepresentation() ) {
717   case Surfaceframe:
718     result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
719     result |= myEdgeActor->HasTranslucentPolygonalGeometry();
720     break;
721   case Points:
722     if( myIsPointSpriteMode )
723       result |= myPointSpriteActor->HasTranslucentPolygonalGeometry();
724     else
725       result |= myPointsActor->HasTranslucentPolygonalGeometry();
726     break;
727   default:
728     result |= mySurfaceActor->HasTranslucentPolygonalGeometry();
729   }
730
731   return result;
732 }
733 #endif
734
735 //----------------------------------------------------------------------------
736 unsigned long int
737 VISU_ScalarMapAct
738 ::GetMemorySize()
739 {
740   unsigned long int aSize = Superclass::GetMemorySize();
741
742   aSize += myPointSpriteActor->GetMemorySize();
743
744   return aSize;
745 }
746
747 //----------------------------------------------------------------------------
748
749 VISU_Actor::EQuadratic2DRepresentation 
750 VISU_ScalarMapAct
751 ::GetQuadratic2DRepresentation() const
752 {
753   bool mode = (mySurfaceActor->GetQuadraticArcMode() && myEdgeActor->GetQuadraticArcMode());
754   if(mode){
755     return VISU_Actor::eArcs;
756   }
757   else
758     return VISU_Actor::eLines;
759 }
760   
761 void VISU_ScalarMapAct::SetQuadratic2DRepresentation( VISU_Actor::EQuadratic2DRepresentation theMode )
762 {
763   Superclass::SetQuadratic2DRepresentation( theMode );
764   switch(theMode) {
765   case VISU_Actor::eArcs:
766     mySurfaceActor->SetQuadraticArcMode(true);
767     myEdgeActor->SetQuadraticArcMode(true);
768     break;
769   case VISU_Actor::eLines:
770     mySurfaceActor->SetQuadraticArcMode(false);
771     myEdgeActor->SetQuadraticArcMode(false);
772     break;
773   default:
774     break;
775   }
776 }
777
778 void VISU_ScalarMapAct::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
779 {
780   Superclass::SetMarkerStd( theMarkerType, theMarkerScale );
781   myPointsActor->SetMarkerStd( theMarkerType, theMarkerScale );
782
783   myIsPointSpriteMode = theMarkerType == VTK::MT_POINT_SPRITE;
784 }
785
786 void VISU_ScalarMapAct::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
787 {
788   Superclass::SetMarkerTexture( theMarkerId, theMarkerTexture );
789   myPointsActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
790
791   myIsPointSpriteMode = false;
792 }
793
794 /**
795  * Set size of the 0D elements.
796  */
797 void VISU_ScalarMapAct::Set0DElemSize(vtkFloatingPointType theValue) {
798   mySurfaceActor->GetProperty()->SetPointSize(theValue);
799 }
800
801 /**
802  * Get size of the 0D elements.
803  */
804 vtkFloatingPointType VISU_ScalarMapAct::Get0DElemSize() {
805   return mySurfaceActor->GetProperty()->GetPointSize();
806 }
807