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