Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / VISU_I / VISU_ScalarMap_i.cc
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //  File   : VISU_PrsObject_i.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_ScalarMap_i.hh"
28
29 #include "VISU_Result_i.hh"
30 #include "VISU_ViewManager_i.hh"
31
32 #include "VISU_ScalarMapPL.hxx"
33 #include "VISU_ScalarMapAct.h"
34
35 #include "SUIT_ResourceMgr.h"
36
37 #include <vtkDataSetMapper.h>
38 #include <vtkTextProperty.h>
39
40 using namespace VISU;
41 using namespace std;
42
43 #ifdef _DEBUG_
44 static int MYDEBUG = 0;
45 #else
46 static int MYDEBUG = 0;
47 #endif
48
49 static int INCMEMORY = 4;
50
51 int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
52                                   const char* theFieldName, int theIteration, int isMemoryCheck)
53 {
54   try{
55     float aSize = INCMEMORY*
56       theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration);
57     bool aResult = true;
58     if(isMemoryCheck){
59       aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
60       MESSAGE("ScalarMap_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
61     }
62     return aResult;
63   }catch(std::exception& exc){
64     INFOS("Follow exception was occured :\n"<<exc.what());
65   }catch(...){
66     INFOS("Unknown exception was occured!");
67   }
68   return 0;
69 }
70
71 int VISU::ScalarMap_i::myNbPresent = 0;
72 QString VISU::ScalarMap_i::GenerateName() { return VISU::GenerateName("ScalarMap",myNbPresent++);}
73
74 const string VISU::ScalarMap_i::myComment = "SCALARMAP";
75 const char* VISU::ScalarMap_i::GetComment() const { return myComment.c_str();}
76 VISU::ScalarMap_i::
77 ScalarMap_i(Result_i* theResult,
78             bool theAddToStudy) :
79   PrsObject_i(theResult->GetStudyDocument()),
80   Prs3d_i(theResult,theAddToStudy),
81   myScalarMapPL(NULL)
82 {
83 }
84
85
86 VISU::ScalarMap_i::
87 ScalarMap_i(Result_i* theResult,
88             SALOMEDS::SObject_ptr theSObject) :
89   PrsObject_i(theResult->GetStudyDocument()),
90   Prs3d_i(theResult,theSObject),
91   myScalarMapPL(NULL)
92 {
93 }
94
95
96 void VISU::ScalarMap_i::RemoveFromStudy()
97 {
98   VISU::DeleteActors(this);
99   VISU::RemoveFromStudy(mySObject,false);
100 }
101
102
103 void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin)
104 {
105   ScalarMap_i* aScalarMap = const_cast<ScalarMap_i*>(theOrigin);
106   DoHook();
107   VISU::Prs3d_i::SameAs(aScalarMap);
108   myField = aScalarMap->GetField();
109   myMeshName = myField->myMeshName;
110   myEntity = myField->myEntity;
111   myIteration = aScalarMap->GetIteration();
112   myFieldName = aScalarMap->GetFieldName();
113
114   SetScalarMode(aScalarMap->GetScalarMode());
115
116   SetRange(aScalarMap->GetMin(), aScalarMap->GetMax());
117   myIsFixedRange = aScalarMap->IsRangeFixed();
118
119   SetScaling(aScalarMap->GetScaling());
120
121   SetBarOrientation(aScalarMap->GetBarOrientation());
122   SetPosition(aScalarMap->GetPosX(), aScalarMap->GetPosY());
123   SetSize(aScalarMap->GetWidth(), aScalarMap->GetHeight());
124   SetNbColors(aScalarMap->GetNbColors());
125   SetLabels(aScalarMap->GetLabels());
126   SetTitle(aScalarMap->GetTitle());
127
128   SetBoldTitle(aScalarMap->IsBoldTitle());
129   SetItalicTitle(aScalarMap->IsItalicTitle());
130   SetShadowTitle(aScalarMap->IsShadowTitle());
131   SetTitFontType(aScalarMap->GetTitFontType());
132   float r,g,b;
133   aScalarMap->GetTitleColor(&r,&g,&b);
134   SetTitleColor(r,g,b);
135
136   SetBoldLabel(aScalarMap->IsBoldLabel());
137   SetItalicLabel(aScalarMap->IsItalicLabel());
138   SetShadowLabel(aScalarMap->IsShadowLabel());
139   SetLblFontType(aScalarMap->GetLblFontType());
140   aScalarMap->GetLabelColor(&r,&g,&b);
141   SetLabelColor(r,g,b);
142
143   Build(-1);
144   Update();
145 }
146
147 void VISU::ScalarMap_i::SameAsParams (const ScalarMap_i* theOrigin)
148 {
149   int time = GetIteration();
150   SameAs(theOrigin);
151   myIteration = time;
152
153   //??Build(true);
154   Build(-1);
155   Update();
156 }
157
158
159 /**
160  * Creates Scalar Map and initialises it from resources
161  */
162 VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity theEntity,
163                                           const char* theFieldName, int theIteration)
164 {
165   DoHook();
166
167   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
168
169   int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
170   SetScalarMode(aScalarMode);
171
172   // Orientation
173   int orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
174   if (orient == 1)
175     myOrientation = VISU::ScalarMap::HORIZONTAL;
176   else
177     myOrientation = VISU::ScalarMap::VERTICAL;
178
179   // Scalar Bar origin
180   QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
181
182   float aXorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.01 : 0.2;
183   aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
184   myPosition[0] = aXorigin;
185
186   float aYorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.1 : 0.012;
187   aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
188   myPosition[1] = aYorigin;
189
190   // Scalar Bar size
191   myWidth = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.1 : 0.6;
192   myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
193
194   myHeight = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
195   myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
196
197   // Nb of Colors
198   int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
199   SetNbColors(aNumberOfColors);
200
201   // Nb of Labels
202   myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
203
204   // Scalar Range
205   int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
206   myIsFixedRange = (rangeType == 1) ? true : false;
207
208   if (myIsFixedRange)
209     {
210       float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
211       float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
212       SetRange(aMin,aMax);
213     }
214
215   bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
216
217   if( isLog )
218     SetScaling(VISU::LOGARITHMIC);
219   else
220     SetScaling(VISU::LINEAR);
221
222   // Fonts properties definition
223   myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
224   myTitFontType = VTK_ARIAL;
225
226   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
227     {
228       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
229
230       if ( f.family() == "Arial" )
231         myTitFontType = VTK_ARIAL;
232       else if ( f.family() == "Courier" )
233         myTitFontType = VTK_COURIER;
234       else if ( f.family() == "Times" )
235         myTitFontType = VTK_TIMES;
236
237       myIsBoldTitle   = f.bold();
238       myIsItalicTitle = f.italic();
239       myIsShadowTitle =  f.underline();
240     }
241
242   QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
243
244   myTitleColor[0] = aTextColor.red()   / 255;
245   myTitleColor[1] = aTextColor.green() / 255;
246   myTitleColor[2] = aTextColor.blue()  / 255;
247
248   ///
249
250   myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
251   myLblFontType = VTK_ARIAL;
252
253   if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
254     {
255       QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
256
257       if ( f.family() == "Arial" )
258         myLblFontType = VTK_ARIAL;
259       else if ( f.family() == "Courier" )
260         myLblFontType = VTK_COURIER;
261       else if ( f.family() == "Times" )
262         myLblFontType = VTK_TIMES;
263
264       myIsBoldLabel   = f.bold();
265       myIsItalicLabel = f.italic();
266       myIsShadowLabel =  f.underline();
267     }
268
269   QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
270
271   myLabelColor[0] = aLabelColor.red()   / 255;
272   myLabelColor[1] = aLabelColor.green() / 255;
273   myLabelColor[2] = aLabelColor.blue()  / 255;
274
275
276   myMeshName = theMeshName;
277   myEntity = (VISU::TEntity)theEntity;
278   myFieldName =theFieldName;
279   myIteration = theIteration;
280
281   return Build(false);
282 }
283
284
285 VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap)
286 {
287   DoHook();
288   myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
289   myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
290   myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
291   myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
292
293   SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
294   SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt()));
295   float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
296   float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
297   SetRange(aMin,aMax);
298   myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt();
299
300   myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
301   myOrientation = (VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt();
302   SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
303   myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
304   myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
305   myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
306   myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
307   myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
308
309   myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
310   myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
311   myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
312   myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
313   myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
314   myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
315   myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
316
317   myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
318   myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
319   myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
320   myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
321   myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
322   myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
323   myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
324
325   Prs3d_i::Restore(theMap);
326   myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
327   return Build(true);
328 }
329
330
331 void VISU::ScalarMap_i::ToStream(std::ostringstream& theStr){
332   Prs3d_i::ToStream(theStr);
333
334   Storable::DataToStream( theStr, "myMeshName",       myMeshName.c_str() );
335   Storable::DataToStream( theStr, "myEntity",         myEntity );
336   Storable::DataToStream( theStr, "myFieldName",      myFieldName.c_str() );
337   Storable::DataToStream( theStr, "myIteration",      myIteration );
338
339   Storable::DataToStream( theStr, "myScalarMode",     int(GetScalarMode()) );
340   Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
341   Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
342   Storable::DataToStream( theStr, "myIsFixedRange",   myIsFixedRange );
343   Storable::DataToStream( theStr, "myScaling",        GetScaling() );
344
345   Storable::DataToStream( theStr, "myTitle",          myTitle.c_str() );
346   Storable::DataToStream( theStr, "myOrientation",    myOrientation );
347   Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
348   Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
349   Storable::DataToStream( theStr, "myPosition[0]",    myPosition[0] );
350   Storable::DataToStream( theStr, "myPosition[1]",    myPosition[1] );
351   Storable::DataToStream( theStr, "myWidth",          myWidth );
352   Storable::DataToStream( theStr, "myHeight",         myHeight );
353
354   Storable::DataToStream( theStr, "myTitFontType",    myTitFontType );
355   Storable::DataToStream( theStr, "myIsBoldTitle",    myIsBoldTitle );
356   Storable::DataToStream( theStr, "myIsItalicTitle",  myIsItalicTitle );
357   Storable::DataToStream( theStr, "myIsShadowTitle",  myIsShadowTitle );
358   Storable::DataToStream( theStr, "myTitleColor[0]",  myTitleColor[0] );
359   Storable::DataToStream( theStr, "myTitleColor[1]",  myTitleColor[1] );
360   Storable::DataToStream( theStr, "myTitleColor[2]",  myTitleColor[2] );
361
362   Storable::DataToStream( theStr, "myLblFontType",    myLblFontType );
363   Storable::DataToStream( theStr, "myIsBoldLabel",    myIsBoldLabel );
364   Storable::DataToStream( theStr, "myIsItalicLabel",  myIsItalicLabel );
365   Storable::DataToStream( theStr, "myIsShadowLabel",  myIsShadowLabel );
366   Storable::DataToStream( theStr, "myLabelColor[0]",  myLabelColor[0] );
367   Storable::DataToStream( theStr, "myLabelColor[1]",  myLabelColor[1] );
368   Storable::DataToStream( theStr, "myLabelColor[2]",  myLabelColor[2] );
369 }
370
371
372 CORBA::Long VISU::ScalarMap_i::GetScalarMode(){
373   return myScalarMapPL->GetScalarMode();
374 }
375 void VISU::ScalarMap_i::SetScalarMode(CORBA::Long theScalarMode) {
376   myScalarMapPL->SetScalarMode(theScalarMode);
377 }
378
379
380 VISU::Scaling VISU::ScalarMap_i::GetScaling(){
381   return VISU::Scaling(myScalarMapPL->GetScaling());
382 }
383 void VISU::ScalarMap_i::SetScaling(VISU::Scaling theScaling){
384   myScalarMapPL->SetScaling(theScaling);
385 }
386
387
388 void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax){
389   if(theMin > theMax) return;
390   float aScalarRange[2] = {theMin, theMax};
391   myScalarMapPL->SetScalarRange(aScalarRange);
392   myIsFixedRange = true;
393 }
394
395 CORBA::Double VISU::ScalarMap_i::GetMin(){
396   return myScalarMapPL->GetScalarRange()[0];
397 }
398
399 CORBA::Double VISU::ScalarMap_i::GetMax(){
400   return myScalarMapPL->GetScalarRange()[1];
401 }
402
403
404 void VISU::ScalarMap_i::SetNbColors(CORBA::Long theNbColors){
405   myScalarMapPL->SetNbColors(theNbColors);
406 }
407
408 CORBA::Long VISU::ScalarMap_i::GetNbColors(){
409   return myScalarMapPL->GetNbColors();
410 }
411
412
413 VISU::ScalarMap_i::~ScalarMap_i(){}
414
415
416 VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){
417   if(MYDEBUG)
418     MESSAGE("ScalarMap_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
419   SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
420   if(myAddToStudy) aStudyBuilder->NewCommand();  // There is a transaction
421   try{
422     DoSetInput(myResult);
423     QString aComment;
424     myName = "NoName";
425     if(theRestoring <= 0){
426       if(theRestoring == 0) myScalarMapPL->Init();
427       if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
428       const VISU::TValField& aValField = myField->myValField;
429       const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
430       aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
431       if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1();
432     }
433     if(myAddToStudy){
434       myName = GenerateName().latin1();
435       aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
436                        VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
437       string aResultEntry = myResult->GetEntry();
438       string aRefFatherEntry = myResult->GetRefFatherEntry();
439       string anEntry = myResult->GetEntry(aComment.latin1());
440       if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
441       aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
442                        GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
443       CORBA::String_var anIOR = GetID();
444       CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
445       mySObject = myStudy->FindObjectIOR(anIOR);
446     }
447   }catch(std::exception& exc){
448     INFOS("Follow exception was occured :\n"<<exc.what());
449     return NULL;
450   }catch(...){
451     INFOS("Unknown exception was occured!");
452     return NULL;
453   }
454   if(myAddToStudy) aStudyBuilder->CommitCommand();
455   return this;
456 }
457
458
459 void VISU::ScalarMap_i::DoSetInput(Result_i* theResult){
460   if(theResult->GetInput() == NULL)
461     throw std::runtime_error("Mesh_i::Build - theResult->GetInput() == NULL !!!");
462   myField = theResult->GetInput()->GetField(myMeshName,myEntity,myFieldName);
463   if(myField == NULL) 
464     throw std::runtime_error("There is no Field with the parameters !!!");
465   VISU_Convertor::TOutput *anOutput =
466     theResult->GetInput()->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration);
467   if(anOutput == NULL) 
468     throw std::runtime_error("There is no TimeStamp with the parameters !!!");
469   myScalarMapPL->SetInput(anOutput);
470   myScalarMapPL->Build();
471 }
472
473
474 void VISU::ScalarMap_i::DoHook(){
475   if(MYDEBUG)  MESSAGE("ScalarMap_i::DoHook() - "<<myPipeLine);
476   if(!myPipeLine) {
477     myPipeLine = VISU_ScalarMapPL::New();
478     myPipeLine->GetMapper()->SetScalarVisibility(1);
479   }
480   myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
481 }
482
483 void VISU::ScalarMap_i::Update() {
484   VISU::Prs3d_i::Update();
485 }
486
487 void VISU::ScalarMap_i::SetMapScale(double theMapScale){
488   myScalarMapPL->SetMapScale(theMapScale);
489 }
490
491 VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
492 {
493   VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New();
494   try{
495     VISU::Prs3d_i::CreateActor(anActor,theIO);
496     anActor->SetBarVisibility(true);
497     anActor->SetRepresentation(2);
498     UpdateActor(anActor);
499   }catch(...){
500     anActor->Delete();
501     throw;
502   }
503   return anActor;
504 }
505
506 void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) {
507   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
508     VISU::Prs3d_i::UpdateActor(theActor);
509     VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
510     aScalarBar->SetLookupTable(myScalarMapPL->GetBarTable());
511     aScalarBar->SetTitle(myTitle.c_str());
512     aScalarBar->SetOrientation(myOrientation);
513     aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
514     aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]);
515     aScalarBar->SetWidth(myWidth);
516     aScalarBar->SetHeight(myHeight);
517     aScalarBar->SetNumberOfLabels(myNumberOfLabels);
518
519     vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
520     aTitleProp->SetFontFamily(myTitFontType);
521     aTitleProp->SetColor(myTitleColor);
522     (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
523     (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
524     (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
525
526     vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
527     aLabelProp->SetFontFamily(myLblFontType);
528     aLabelProp->SetColor(myLabelColor);
529     (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
530     (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
531     (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
532
533     aScalarBar->Modified();
534   }
535 }
536
537
538 void VISU::ScalarMap_i::SetSourceRange(){
539   myScalarMapPL->SetSourceRange();
540   myIsFixedRange = false;
541 }