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