Salome HOME
Merge from PortingMED3 07Apr11
[modules/visu.git] / src / VISU_I / VISU_ScalarMap_i.cc
1 //  Copyright (C) 2007-2010  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_PrsObject_i.cxx
25 //  Author : Alexey PETROV
26 //  Module : VISU
27 //
28 #include "VISU_ScalarMap_i.hh"
29 #include "VISU_Prs3dUtils.hh"
30
31 #include "VISU_Result_i.hh"
32 #include "VISU_ResultUtils.hh"
33
34 #include "VISU_ScalarMapAct.h"
35 #include "VISU_ScalarMapPL.hxx"
36 #include "VISU_LookupTable.hxx"
37 #include "VISU_PipeLineUtils.hxx"
38 #include "VISU_ScalarBarActor.hxx"
39 #include "VISU_Convertor.hxx"
40
41 #include "SUIT_ResourceMgr.h"
42
43 #include "SUIT_Session.h"
44 #include "SALOME_Event.h"
45 #include "SalomeApp_Study.h"
46 #include "SalomeApp_Application.h"
47
48 #include <vtkDataSetMapper.h>
49 #include <vtkTextProperty.h>
50
51 #ifdef _DEBUG_
52 static int MYDEBUG = 0;
53 #else
54 static int MYDEBUG = 0;
55 #endif
56
57 static int INCMEMORY = 4;
58
59 using namespace std;
60
61 //----------------------------------------------------------------------------
62 size_t
63 VISU::ScalarMap_i
64 ::IsPossible(Result_i* theResult, 
65              const std::string& theMeshName, 
66              VISU::Entity theEntity, 
67              const std::string& theFieldName, 
68              CORBA::Long theTimeStampNumber, 
69              bool theIsMemoryCheck)
70 {
71   size_t aResult = 0;
72   try{
73     if(theResult){
74       bool anIsEstimated = true;
75       VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
76                                                            theEntity,
77                                                            theFieldName,
78                                                            theTimeStampNumber);
79       size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
80                                                      (VISU::TEntity)theEntity,
81                                                      theFieldName,
82                                                      theTimeStampNumber,
83                                                      anIsEstimated);
84       aResult = 1;
85       if(theIsMemoryCheck){
86         if(anIsEstimated)
87           aSize *= INCMEMORY;
88         aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
89         if(MYDEBUG) 
90           MESSAGE("ScalarMap_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
91       }
92     }
93   }catch(std::exception& exc){
94     INFOS("Follow exception was occured :\n"<<exc.what());
95   }catch(...){
96     INFOS("Unknown exception was occured!");
97   }
98   return aResult;
99 }
100
101 //----------------------------------------------------------------------------
102 namespace
103 {
104   bool
105   IsSameColor(const SALOMEDS::Color& theLeft,
106               const SALOMEDS::Color& theRight)
107   {
108     return 
109       VISU::CheckIsSameValue(theLeft.R, theRight.R) &&
110       VISU::CheckIsSameValue(theLeft.G, theRight.G) &&
111       VISU::CheckIsSameValue(theLeft.B, theRight.B);
112   }
113 }
114
115 //----------------------------------------------------------------------------
116 int VISU::ScalarMap_i::myNbPresent = 0;
117
118 //----------------------------------------------------------------------------
119 QString
120 VISU::ScalarMap_i
121 ::GenerateName() 
122
123   return VISU::GenerateName("ScalarMap",myNbPresent++);
124 }
125
126 //----------------------------------------------------------------------------
127 const string VISU::ScalarMap_i::myComment = "SCALARMAP";
128
129 //----------------------------------------------------------------------------
130 const char* 
131 VISU::ScalarMap_i
132 ::GetComment() const 
133
134   return myComment.c_str();
135 }
136
137 //----------------------------------------------------------------------------
138 const char*
139 VISU::ScalarMap_i
140 ::GetIconName()
141 {
142   if (!IsGroupsUsed())
143     return "ICON_TREE_SCALAR_MAP";
144   else
145     return "ICON_TREE_SCALAR_MAP_GROUPS";
146 }
147
148 //----------------------------------------------------------------------------
149 void
150 VISU::ScalarMap_i
151 ::UpdateIcon()
152 {
153   SALOMEDS::SObject_var aSObject = GetSObject();
154   if(CORBA::is_nil(aSObject))
155     return;
156
157   SALOMEDS::Study_var aStudyDocument = GetStudyDocument();
158   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
159
160   // Check if the icon needs to be updated, update if necessary
161   SALOMEDS::GenericAttribute_var anAttr = 
162     aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributePixMap");
163   SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
164
165   CORBA::String_var aPixMapName = aPixmap->GetPixMap();
166   if(strcmp(GetIconName(), aPixMapName.in()) != 0)
167     aPixmap->SetPixMap(GetIconName());
168
169   // Update Object Browser
170   //rnv: to fix issue 0020167 (crash then AddMeshOnGroup called from 
171   //python script). Solution: update object browser using UpdateObjBrowser event.
172   /*
173   SUIT_Session* aSession = SUIT_Session::session();
174   QList<SUIT_Application*> anApplications = aSession->applications();
175   QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
176   while( anIter != anApplications.end() ){
177     SUIT_Application* aSApp = *anIter;
178     if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
179       if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())){
180         if(_PTR(Study) aCStudy = aStudy->studyDS()){
181           if(aStudyDocument->StudyId() == aCStudy->StudyId()){
182             anApp->updateObjectBrowser();
183             break;
184           }
185         }
186       }
187     }
188     anIter++;
189   }
190   */
191   bool done = true;
192   ProcessVoidEvent(new TUpdateObjBrowser(aStudyDocument->StudyId(),&done));
193 }
194
195 //----------------------------------------------------------------------------
196 VISU::ScalarMap_i::
197 ScalarMap_i(EPublishInStudyMode thePublishInStudyMode) :
198   ColoredPrs3d_i(thePublishInStudyMode),
199   myShowBar(true)
200 {}
201
202 //----------------------------------------------------------------------------
203 VISU::ScalarMap_i
204 ::~ScalarMap_i()
205 {}
206
207
208 //----------------------------------------------------------------------------
209 void
210 VISU::ScalarMap_i
211 ::SameAs(const Prs3d_i* theOrigin)
212 {
213   TSuperClass::SameAs(theOrigin);
214
215   if(const ScalarMap_i* aPrs3d = dynamic_cast<const ScalarMap_i*>(theOrigin)){
216     ScalarMap_i* anOrigin = const_cast<ScalarMap_i*>(aPrs3d);
217  
218     SetScaling(anOrigin->GetScaling());
219     SetGaussMetric(anOrigin->GetGaussMetric());
220     SetBarVisible(anOrigin->IsBarVisible());
221     Update();
222   }
223 }
224
225
226 //----------------------------------------------------------------------------
227 /**
228  * Creates Scalar Map and initialises it from resources
229  */
230 VISU::Storable* 
231 VISU::ScalarMap_i
232 ::Create(const std::string& theMeshName, 
233          VISU::Entity theEntity,
234          const std::string& theFieldName, 
235          CORBA::Long theTimeStampNumber)
236 {
237   TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
238
239   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
240
241   if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) )
242     SetScaling(VISU::LOGARITHMIC);
243   else
244     SetScaling(VISU::LINEAR);
245
246   QColor aColor = aResourceMgr->colorValue( "VISU", "edge_color", QColor( 255, 255, 255 ) );
247   SALOMEDS::Color aLinkColor;
248   aLinkColor.R = aColor.red()/255.;
249   aLinkColor.G = aColor.green()/255.;
250   aLinkColor.B = aColor.blue()/255.;
251   SetLinkColor(aLinkColor);
252
253   int aGaussMetric = aResourceMgr->integerValue("VISU", "scalar_gauss_metric", 0);
254   SetGaussMetric((VISU::GaussMetric)aGaussMetric);
255
256   myShowBar = true;
257   return this;
258 }
259
260 //----------------------------------------------------------------------------
261 CORBA::Float
262 VISU::ScalarMap_i
263 ::GetMemorySize()
264 {
265   return TSuperClass::GetMemorySize();
266 }
267
268 //----------------------------------------------------------------------------
269 VISU::Storable* 
270 VISU::ScalarMap_i
271 ::Restore(SALOMEDS::SObject_ptr theSObject,
272           const Storable::TRestoringMap& theMap)
273 {
274   if(!TSuperClass::Restore(theSObject, theMap))
275     return NULL;
276
277   SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt()));
278
279   QString aVal = VISU::Storable::FindValue(theMap,"myShowBar", "1");
280   SetBarVisible((aVal.toInt() == 1)? true : false);
281
282   SetGaussMetric(VISU::GaussMetric(VISU::Storable::FindValue(theMap,"myGaussMetric").toInt()));
283
284   SALOMEDS::Color aLinkColor;
285   aLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble();
286   aLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble();
287   aLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble();
288   SetLinkColor(aLinkColor);
289
290   // Check if the icon needs to be updated, update if necessary
291   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
292   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
293   SALOMEDS::GenericAttribute_var anAttr = 
294     aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributePixMap");
295   SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
296
297   CORBA::String_var aPixMapName = aPixmap->GetPixMap();
298   if(strcmp(GetIconName(), aPixMapName.in()) != 0)
299     aPixmap->SetPixMap(GetIconName());
300
301   return this;
302 }
303
304 //----------------------------------------------------------------------------
305 void 
306 VISU::ScalarMap_i
307 ::ToStream(std::ostringstream& theStr)
308 {
309   TSuperClass::ToStream(theStr);
310
311   Storable::DataToStream( theStr, "myScaling",        GetScaling() );
312   Storable::DataToStream( theStr, "myShowBar",        (IsBarVisible()? 1:0) );
313   Storable::DataToStream( theStr, "myGaussMetric",    int(GetGaussMetric()) );
314
315   SALOMEDS::Color aLinkColor = GetLinkColor();
316   Storable::DataToStream( theStr, "myLinkColor.R",    aLinkColor.R );
317   Storable::DataToStream( theStr, "myLinkColor.G",    aLinkColor.G );
318   Storable::DataToStream( theStr, "myLinkColor.B",    aLinkColor.B );
319 }
320
321
322 //----------------------------------------------------------------------------
323 VISU::Scaling 
324 VISU::ScalarMap_i
325 ::GetScaling()
326 {
327   return VISU::Scaling(GetSpecificPL()->GetScaling());
328 }
329
330 //----------------------------------------------------------------------------
331 void
332 VISU::ScalarMap_i
333 ::SetScaling(VISU::Scaling theScaling)
334 {
335   VISU::TSetModified aModified(this);
336   
337   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ScalarMapPL, int>
338                    (GetSpecificPL(), &VISU_ColoredPL::SetScaling, theScaling));
339 }
340
341 //----------------------------------------------------------------------------
342 void 
343 VISU::ScalarMap_i
344 ::SetLinkColor(const SALOMEDS::Color& theColor) 
345
346   if(IsSameColor(myLinkColor, theColor))
347     return;
348
349   VISU::TSetModified aModified(this);
350   
351   myLinkColor = theColor;
352   myParamsTime.Modified();
353 }
354
355 //----------------------------------------------------------------------------
356 SALOMEDS::Color 
357 VISU::ScalarMap_i
358 ::GetLinkColor() 
359
360   return myLinkColor;
361 }
362
363 //----------------------------------------------------------------------------
364 VISU::GaussMetric 
365 VISU::ScalarMap_i
366 ::GetGaussMetric()
367 {
368   return VISU::GaussMetric(GetSpecificPL()->GetGaussMetric());
369 }
370
371 //----------------------------------------------------------------------------
372 void
373 VISU::ScalarMap_i
374 ::SetGaussMetric(VISU::GaussMetric theGaussMetric)
375 {
376   VISU::TSetModified aModified(this);
377   
378   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ScalarMapPL, VISU::TGaussMetric>
379                    (GetSpecificPL(), &VISU_ScalarMapPL::SetGaussMetric, (VISU::TGaussMetric)theGaussMetric));
380 }
381
382 //----------------------------------------------------------------------------
383 void
384 VISU::ScalarMap_i
385 ::SetSourceGeometry()
386 {
387   int aNbGroups = myGroupNames.size();
388   if(aNbGroups != 0){
389     GetSpecificPL()->SetSourceGeometry();
390     myGroupNames.clear();
391     UpdateIcon();
392   }
393 }
394
395 //----------------------------------------------------------------------------
396 void
397 VISU::ScalarMap_i
398 ::AddMeshOnGroup(const char* theGroupName)
399 {
400   VISU::Result_i::PInput anInput = GetCResult()->GetInput();
401   VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName);
402   if(anIDMapper){
403     int aNbGroups  = myGroupNames.size();
404     if(myGroupNames.find(theGroupName) == myGroupNames.end()){
405       GetSpecificPL()->AddGeometry(anIDMapper->GetOutput(), theGroupName);
406       myGroupNames.insert(theGroupName);
407       if(aNbGroups == 0)
408         UpdateIcon();
409       // To update scalar range according to the new input (IPAL21305)
410       if(!IsRangeFixed())
411         SetSourceRange();
412     }
413   }
414 }
415
416
417 //----------------------------------------------------------------------------
418 void
419 VISU::ScalarMap_i
420 ::RemoveAllGeom()
421 {
422   int aNbGroups  = myGroupNames.size();
423   GetSpecificPL()->ClearGeometry();
424   myGroupNames.clear();
425   if(aNbGroups != 0)
426     UpdateIcon();
427 }
428
429
430 //----------------------------------------------------------------------------
431 void 
432 VISU::ScalarMap_i
433 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
434 {
435   VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
436                                                           GetEntity(),
437                                                           GetCFieldName(),
438                                                           GetTimeStampNumber());
439   if(!anInput)
440     throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!");
441
442   SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName()));
443   if(!GetField())
444     throw std::runtime_error("There is no Field with the parameters !!!");
445
446   VISU::PUnstructuredGridIDMapper anIDMapper =
447     anInput->GetTimeStampOnMesh(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber());
448
449   if(!anIDMapper) 
450     throw std::runtime_error("There is no TimeStamp with the parameters !!!");
451
452   GetSpecificPL()->SetUnstructuredGridIDMapper(anIDMapper);
453 }
454
455
456 //----------------------------------------------------------------------------
457 bool
458 VISU::ScalarMap_i
459 ::CheckIsPossible() 
460 {
461   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
462 }
463
464 void VISU::ScalarMap_i::SetBarVisible(CORBA::Boolean theVisible) 
465
466   if (myShowBar == theVisible)
467     return;
468   VISU::TSetModified aModified(this);
469   myShowBar = theVisible; 
470   myParamsTime.Modified();
471 }
472
473 //----------------------------------------------------------------------------
474 void
475 VISU::ScalarMap_i
476 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
477 {
478   if(MYDEBUG) MESSAGE("ScalarMap_i::CreatePipeLine() - "<<thePipeLine);
479   if(!thePipeLine){
480     myScalarMapPL = VISU_ScalarMapPL::New();
481     myScalarMapPL->GetMapper()->SetScalarVisibility(1);
482   }else
483     myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine);
484
485   TSuperClass::CreatePipeLine(myScalarMapPL);
486 }
487
488 //----------------------------------------------------------------------------
489 VISU_Actor* 
490 VISU::ScalarMap_i
491 ::CreateActor(bool toSupressShrinking)
492 {
493   VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New();
494   try{
495     TSuperClass::CreateActor(anActor);
496     anActor->SetBarVisibility(myShowBar); 
497     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
498     int  aDispMode = aResourceMgr->integerValue("VISU", "scalar_map_represent", 2);
499     bool toShrink  = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false);
500     bool toUseShading = aResourceMgr->booleanValue("VISU", "represent_shading", false);
501     anActor->SetRepresentation(aDispMode);
502     if (toShrink && !toSupressShrinking) anActor->SetShrink();
503     anActor->SetShading(toUseShading);
504
505     anActor->SetFeatureEdgesAngle( aResourceMgr->doubleValue("VISU", "feature_edges_angle", 0.0) );
506     anActor->SetFeatureEdgesFlags( aResourceMgr->booleanValue("VISU", "show_feature_edges", false),
507                                    aResourceMgr->booleanValue("VISU", "show_boundary_edges", false),
508                                    aResourceMgr->booleanValue("VISU", "show_manifold_edges", false),
509                                    aResourceMgr->booleanValue("VISU", "show_non_manifold_edges", false) );
510     anActor->SetFeatureEdgesColoring( aResourceMgr->booleanValue("VISU", "feature_edges_coloring", false) );
511
512     anActor->SetQuadratic2DRepresentation(VISU_Actor::EQuadratic2DRepresentation(aResourceMgr->integerValue( "VISU", 
513                                                                                                              "quadratic_mode", 
514                                                                                                              0)));
515
516     UpdateActor(anActor);
517   }catch(...){
518     anActor->Delete();
519     throw;
520   }
521   return anActor;
522 }
523
524 //----------------------------------------------------------------------------
525 VISU_Actor* 
526 VISU::ScalarMap_i
527 ::CreateActor()
528 {
529   return CreateActor(false);
530 }
531
532 //----------------------------------------------------------------------------
533 void
534 VISU::ScalarMap_i
535 ::UpdateActor(VISU_ActorBase* theActor) 
536 {
537   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
538     VISU_LookupTable * aLookupTable = GetSpecificPL()->GetBarTable();
539
540     bool anIsScalarFilterUsed = IsScalarFilterUsed();
541     if ( anIsScalarFilterUsed || aLookupTable->HasMarkedValues() )
542       aLookupTable->ForceBuild();
543
544     if ( anIsScalarFilterUsed ) {
545       static unsigned char MARK_COLOR[] = { 255, 255, 255 };
546       aLookupTable->MarkValueByColor( GetScalarFilterMin(), MARK_COLOR );
547       aLookupTable->MarkValueByColor( GetScalarFilterMax(), MARK_COLOR );
548     }
549
550     VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
551     aScalarBar->SetLookupTable( aLookupTable );
552
553     aScalarBar->SetDistribution( GetSpecificPL()->GetDistribution() );
554     aScalarBar->SetDistributionVisibility( GetIsDistributionVisible() );
555
556     aScalarBar->SetTitle(GetScalarBarTitle().c_str());
557     aScalarBar->SetOrientation(GetBarOrientation());
558     aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
559     aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
560     aScalarBar->SetWidth(GetWidth());
561     aScalarBar->SetHeight(GetHeight());
562     aScalarBar->SetRatios(GetTitleSize(), GetLabelSize(), 
563                           GetBarWidth(), GetBarHeight());
564     aScalarBar->SetNumberOfLabels(GetLabels());
565     aScalarBar->SetLabelFormat(GetLabelsFormat());
566
567     vtkFloatingPointType anRGB[3];
568
569     vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
570     aTitleProp->SetFontFamily(GetTitFontType());
571
572     GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
573     aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
574
575     IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
576     IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
577     IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
578
579     vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
580     aLabelProp->SetFontFamily(GetLblFontType());
581
582     GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
583     aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
584
585     IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
586     IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
587     IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
588
589     anActor->SetBarVisibility(myShowBar); 
590
591     aScalarBar->Modified();
592     
593     // Update values labels
594
595     vtkTextProperty* aProp = anActor->GetsValLabelsProps();
596     if ( aProp )
597     {
598       aProp->SetFontFamily( GetValLblFontType() );
599       aProp->SetFontSize( GetValLblFontSize() );
600       aProp->SetBold( IsBoldValLbl() );
601       aProp->SetItalic( IsItalicValLbl() );
602       aProp->SetShadow( IsShadowValLbl() );
603
604       vtkFloatingPointType anRGB[ 3 ];
605       GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
606       aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
607     }
608
609     // Update edge property
610     SALOMEDS::Color aLinkColor = GetLinkColor();
611     anActor->GetEdgeProperty()->SetColor(aLinkColor.R, aLinkColor.G, aLinkColor.B);
612   }
613   TSuperClass::UpdateActor(theActor);
614 }
615
616 //----------------------------------------------------------------------------
617 struct TGetComponentMin: public SALOME_Event
618 {
619   VISU::ColoredPrs3d_i* myColoredPrs3d;
620   vtkIdType myCompID;
621   
622   typedef CORBA::Double TResult;
623   TResult myResult;
624   
625   TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
626                     vtkIdType theCompID ):
627     myColoredPrs3d( theColoredPrs3d ),
628     myCompID( theCompID )
629   {}
630     
631   virtual
632   void
633   Execute()
634   {
635     VISU::TNames aGroupNames;
636     VISU::GaussMetric aGaussMetric = VISU::AVERAGE;
637     if(VISU::ScalarMap_i* aPrs3d = dynamic_cast<VISU::ScalarMap_i*>(myColoredPrs3d)) {
638       aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
639       aGaussMetric = aPrs3d->GetGaussMetric();
640     }
641
642     VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
643     if ( aMinMaxController ) {
644       myResult = aMinMaxController->GetComponentMin( myCompID );
645     } else {
646       VISU::TMinMax aTMinMax;
647       if(myColoredPrs3d->GetScalarField()->myIsELNO)
648         aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames, (VISU::TGaussMetric)aGaussMetric );
649       else
650         aTMinMax = myColoredPrs3d->GetScalarField()->GetAverageMinMax( myCompID, aGroupNames, (VISU::TGaussMetric)aGaussMetric );
651       myResult = aTMinMax.first;
652     }
653   }
654 };
655
656
657 //----------------------------------------------------------------------------
658 vtkFloatingPointType 
659 VISU::ScalarMap_i
660 ::GetComponentMin(vtkIdType theCompID)
661 {
662   return ProcessEvent( new TGetComponentMin( this, theCompID ) );
663 }
664
665 //----------------------------------------------------------------------------
666 struct TGetComponentMax: public SALOME_Event
667 {
668   VISU::ColoredPrs3d_i* myColoredPrs3d;
669   vtkIdType myCompID;
670
671   typedef CORBA::Double TResult;
672   TResult myResult;
673   
674   TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
675                     vtkIdType theCompID ):
676     myColoredPrs3d( theColoredPrs3d ),
677     myCompID( theCompID )
678   {}
679     
680   virtual
681   void
682   Execute()
683   {
684     VISU::TNames aGroupNames;
685     VISU::GaussMetric aGaussMetric = VISU::AVERAGE;
686     if(VISU::ScalarMap_i* aPrs3d = dynamic_cast<VISU::ScalarMap_i*>(myColoredPrs3d)) {
687       aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
688       aGaussMetric = aPrs3d->GetGaussMetric();
689     }
690
691     VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
692     if ( aMinMaxController ) {
693       myResult = aMinMaxController->GetComponentMax( myCompID );
694     } else {
695       VISU::TMinMax aTMinMax;
696       if(myColoredPrs3d->GetScalarField()->myIsELNO)
697         aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames, (VISU::TGaussMetric)aGaussMetric );
698       else
699         aTMinMax = myColoredPrs3d->GetScalarField()->GetAverageMinMax( myCompID, aGroupNames, (VISU::TGaussMetric)aGaussMetric );
700       myResult = aTMinMax.second;
701     }
702   }
703 };
704
705
706 //----------------------------------------------------------------------------
707 vtkFloatingPointType 
708 VISU::ScalarMap_i
709 ::GetComponentMax(vtkIdType theCompID)
710 {
711   return ProcessEvent( new TGetComponentMax( this, theCompID ) );
712 }