]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_ScalarMap_i.cc
Salome HOME
Merge with branch V2_2_0_VISU_improvement
[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
148 /**
149  * Creates Scalar Map and initialises it from resources
150  */
151 VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity theEntity,
152                                           const char* theFieldName, int theIteration)
153 {
154   DoHook();
155
156   // Orientation
157   QString aOrient = VISU::GetResourceMgr()->stringValue("Visu:SBOrientation");
158   if ( !aOrient.isEmpty() )
159     myOrientation = (VISU::ScalarMap::Orientation) aOrient.toInt();
160   else
161     myOrientation = VISU::ScalarMap::VERTICAL;
162
163   // Scalar Bar origin
164   QString aXorigin = VISU::GetResourceMgr()->stringValue("Visu:SBXorigin");
165   if ( !aXorigin.isEmpty() )
166     myPosition[0] = aXorigin.toFloat();
167   else {
168     if(myOrientation == VISU::ScalarMap::VERTICAL) {
169       myPosition[0] = 0.03;
170     } else {
171       myPosition[0] = 0.2;
172     }
173   }
174
175   QString aYorigin = VISU::GetResourceMgr()->stringValue("Visu:SBYorigin");
176   if ( !aYorigin.isEmpty() )
177     myPosition[1] = aYorigin.toFloat();
178   else {
179     if(myOrientation == VISU::ScalarMap::VERTICAL) {
180       myPosition[1] = 0.1;
181     } else {
182       myPosition[1] = 0.012;
183     }
184   }
185
186   // Scalar Bar size
187   QString aWidth = VISU::GetResourceMgr()->stringValue("Visu:SBWidth");
188   if ( !aWidth.isEmpty() )
189     myWidth = aWidth.toFloat();
190   else {
191     myWidth =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.17:0.6;
192   }
193   QString aHeight = VISU::GetResourceMgr()->stringValue("Visu:SBHeight");
194   if ( !aHeight.isEmpty() )
195     myHeight = aHeight.toFloat();
196   else {
197     myHeight =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
198   }
199
200   // Nb of Colors
201   QString aColors = VISU::GetResourceMgr()->stringValue("Visu:SBNumberOfColors");
202   int aNumberOfColors = (aColors.isEmpty())? 64 : aColors.toInt();
203   if (aNumberOfColors > 64)
204     aNumberOfColors = 64;
205   SetNbColors(aNumberOfColors);
206
207   // Nb of Labels
208   QString aLabels = VISU::GetResourceMgr()->stringValue("Visu:SBNumberOfLabels");
209   myNumberOfLabels = (aLabels.isEmpty())? 5 : aLabels.toInt();
210   if (myNumberOfLabels > 65)
211     myNumberOfLabels = 65;
212
213   // Scalar Range
214   QString aFixRange = VISU::GetResourceMgr()->stringValue("Visu:SBImposeRange");
215   myIsFixedRange = (aFixRange.compare("true") == 0);
216
217   if(myIsFixedRange){
218     QString aRangeMin = VISU::GetResourceMgr()->stringValue("Visu:SBMinimumValue");
219     float aMin = (aRangeMin.isEmpty())? 0 : aRangeMin.toFloat();
220     QString aRangeMax = VISU::GetResourceMgr()->stringValue("Visu:SBMaximumValue");
221     float aMax = (aRangeMax.isEmpty())? 0 : aRangeMax.toFloat();
222     SetRange(aMin,aMax);
223   }
224
225   QString aScaling = VISU::GetResourceMgr()->stringValue("Visu:SBScaling");
226   if(aScaling.compare("LOGARITHMIC") == 0)
227     SetScaling(VISU::LOGARITHMIC);
228   else
229     SetScaling(VISU::LINEAR);
230
231   // Fonts properties definition
232   QString aIsBoldTitle = VISU::GetResourceMgr()->stringValue("Visu:IsBoldTitle");
233   myIsBoldTitle = (aIsBoldTitle.isEmpty())? true : (aIsBoldTitle.compare("true") == 0);
234
235   QString aIsItalicTitle = VISU::GetResourceMgr()->stringValue("Visu:IsItalicTitle");
236   myIsItalicTitle = (aIsItalicTitle.isEmpty())? true : (aIsItalicTitle.compare("true") == 0);
237
238   QString aIsShadowTitle = VISU::GetResourceMgr()->stringValue("Visu:IsShadowTitle");
239   myIsShadowTitle = (aIsShadowTitle.isEmpty())? true : (aIsShadowTitle.compare("true") == 0);
240
241   QString aTitFontType = VISU::GetResourceMgr()->stringValue("Visu:TitFontType");
242   if (!aTitFontType.isEmpty()) {
243     switch (aTitFontType.toInt()) {
244     case 0: myTitFontType = VTK_ARIAL; break;
245     case 1: myTitFontType = VTK_COURIER; break;
246     case 2: myTitFontType = VTK_TIMES; break;
247     }
248   } else {
249     myTitFontType = VTK_ARIAL;
250   }
251   QString aRTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorR");
252   myTitleColor[0] = (aRTitColor.isEmpty())? 1 : aRTitColor.toFloat();
253   if (myTitleColor[0] > 1) myTitleColor[0] = 1;
254   if (myTitleColor[0] < 0) myTitleColor[0] = 0;
255
256   QString aGTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorG");
257   myTitleColor[1] = (aGTitColor.isEmpty())? 1 : aGTitColor.toFloat();
258   if (myTitleColor[1] > 1) myTitleColor[1] = 1;
259   if (myTitleColor[1] < 0) myTitleColor[1] = 0;
260
261   QString aBTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorB");
262   myTitleColor[2] = (aBTitColor.isEmpty())? 1 : aBTitColor.toFloat();
263   if (myTitleColor[2] > 1) myTitleColor[2] = 1;
264   if (myTitleColor[2] < 0) myTitleColor[2] = 0;
265
266   ///
267
268   QString aIsBoldLabel = VISU::GetResourceMgr()->stringValue("Visu:IsBoldLabel");
269   myIsBoldLabel = (aIsBoldLabel.isEmpty())? true : (aIsBoldLabel.compare("true") == 0);
270
271   QString aIsItalicLabel = VISU::GetResourceMgr()->stringValue("Visu:IsItalicLabel");
272   myIsItalicLabel = (aIsItalicLabel.isEmpty())? true : (aIsItalicLabel.compare("true") == 0);
273
274   QString aIsShadowLabel = VISU::GetResourceMgr()->stringValue("Visu:IsShadowLabel");
275   myIsShadowLabel = (aIsShadowLabel.isEmpty())? true : (aIsShadowLabel.compare("true") == 0);
276
277   QString aLblFontType = VISU::GetResourceMgr()->stringValue("Visu:LblFontType");
278   if (!aLblFontType.isEmpty()) {
279     switch (aLblFontType.toInt()) {
280     case 0: myLblFontType = VTK_ARIAL; break;
281     case 1: myLblFontType = VTK_COURIER; break;
282     case 2: myLblFontType = VTK_TIMES; break;
283     }
284   } else {
285     myLblFontType = VTK_ARIAL;
286   }
287   QString aRLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorR");
288   myLabelColor[0] = (aRLblColor.isEmpty())? 1 : aRLblColor.toFloat();
289   if (myLabelColor[0] > 1) myLabelColor[0] = 1;
290   if (myLabelColor[0] < 0) myLabelColor[0] = 0;
291
292   QString aGLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorG");
293   myLabelColor[1] = (aGLblColor.isEmpty())? 1 : aGLblColor.toFloat();
294   if (myLabelColor[1] > 1) myLabelColor[1] = 1;
295   if (myLabelColor[1] < 0) myLabelColor[1] = 0;
296
297   QString aBLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorB");
298   myLabelColor[2] = (aBLblColor.isEmpty())? 1 : aBLblColor.toFloat();
299   if (myLabelColor[2] > 1) myLabelColor[2] = 1;
300   if (myLabelColor[2] < 0) myLabelColor[2] = 0;
301
302
303   myMeshName = theMeshName;
304   myEntity = (VISU::TEntity)theEntity;
305   myFieldName =theFieldName;
306   myIteration = theIteration;
307
308   return Build(false);
309 }
310
311
312 VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap)
313 {
314   DoHook();
315   myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
316   myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
317   myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
318   myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
319
320   SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
321   SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt()));
322   float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
323   float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
324   SetRange(aMin,aMax);
325   myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt();
326
327   myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
328   myOrientation = (VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt();
329   SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
330   myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
331   myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
332   myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
333   myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
334   myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
335
336   myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
337   myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
338   myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
339   myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
340   myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
341   myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
342   myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
343
344   myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
345   myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
346   myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
347   myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
348   myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
349   myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
350   myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
351
352   Prs3d_i::Restore(theMap);
353   myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
354   return Build(true);
355 }
356
357
358 void VISU::ScalarMap_i::ToStream(std::ostringstream& theStr){
359   Prs3d_i::ToStream(theStr);
360
361   Storable::DataToStream( theStr, "myMeshName",       myMeshName.c_str() );
362   Storable::DataToStream( theStr, "myEntity",         myEntity );
363   Storable::DataToStream( theStr, "myFieldName",      myFieldName.c_str() );
364   Storable::DataToStream( theStr, "myIteration",      myIteration );
365
366   Storable::DataToStream( theStr, "myScalarMode",     int(GetScalarMode()) );
367   Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
368   Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
369   Storable::DataToStream( theStr, "myIsFixedRange",   myIsFixedRange );
370   Storable::DataToStream( theStr, "myScaling",        GetScaling() );
371
372   Storable::DataToStream( theStr, "myTitle",          myTitle.c_str() );
373   Storable::DataToStream( theStr, "myOrientation",    myOrientation );
374   Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
375   Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
376   Storable::DataToStream( theStr, "myPosition[0]",    myPosition[0] );
377   Storable::DataToStream( theStr, "myPosition[1]",    myPosition[1] );
378   Storable::DataToStream( theStr, "myWidth",          myWidth );
379   Storable::DataToStream( theStr, "myHeight",         myHeight );
380
381   Storable::DataToStream( theStr, "myTitFontType",    myTitFontType );
382   Storable::DataToStream( theStr, "myIsBoldTitle",    myIsBoldTitle );
383   Storable::DataToStream( theStr, "myIsItalicTitle",  myIsItalicTitle );
384   Storable::DataToStream( theStr, "myIsShadowTitle",  myIsShadowTitle );
385   Storable::DataToStream( theStr, "myTitleColor[0]",  myTitleColor[0] );
386   Storable::DataToStream( theStr, "myTitleColor[1]",  myTitleColor[1] );
387   Storable::DataToStream( theStr, "myTitleColor[2]",  myTitleColor[2] );
388
389   Storable::DataToStream( theStr, "myLblFontType",    myLblFontType );
390   Storable::DataToStream( theStr, "myIsBoldLabel",    myIsBoldLabel );
391   Storable::DataToStream( theStr, "myIsItalicLabel",  myIsItalicLabel );
392   Storable::DataToStream( theStr, "myIsShadowLabel",  myIsShadowLabel );
393   Storable::DataToStream( theStr, "myLabelColor[0]",  myLabelColor[0] );
394   Storable::DataToStream( theStr, "myLabelColor[1]",  myLabelColor[1] );
395   Storable::DataToStream( theStr, "myLabelColor[2]",  myLabelColor[2] );
396 }
397
398
399 CORBA::Long VISU::ScalarMap_i::GetScalarMode(){
400   return myScalarMapPL->GetScalarMode();
401 }
402 void VISU::ScalarMap_i::SetScalarMode(CORBA::Long theScalarMode) {
403   myScalarMapPL->SetScalarMode(theScalarMode);
404 }
405
406
407 VISU::Scaling VISU::ScalarMap_i::GetScaling(){
408   return VISU::Scaling(myScalarMapPL->GetScaling());
409 }
410 void VISU::ScalarMap_i::SetScaling(VISU::Scaling theScaling){
411   myScalarMapPL->SetScaling(theScaling);
412 }
413
414
415 void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax){
416   if(theMin > theMax) return;
417   float aScalarRange[2] = {theMin, theMax};
418   myScalarMapPL->SetScalarRange(aScalarRange);
419   myIsFixedRange = true;
420 }
421
422 CORBA::Double VISU::ScalarMap_i::GetMin(){
423   return myScalarMapPL->GetScalarRange()[0];
424 }
425
426 CORBA::Double VISU::ScalarMap_i::GetMax(){
427   return myScalarMapPL->GetScalarRange()[1];
428 }
429
430
431 void VISU::ScalarMap_i::SetNbColors(CORBA::Long theNbColors){
432   myScalarMapPL->SetNbColors(theNbColors);
433 }
434
435 CORBA::Long VISU::ScalarMap_i::GetNbColors(){
436   return myScalarMapPL->GetNbColors();
437 }
438
439
440 VISU::ScalarMap_i::~ScalarMap_i(){}
441
442
443 VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){
444   if(MYDEBUG)
445     MESSAGE("ScalarMap_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
446   SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
447   if(myAddToStudy) aStudyBuilder->NewCommand();  // There is a transaction
448   try{
449     if(myResult->GetInput() == NULL)
450       throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
451     myField = myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName);
452     if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!");
453     VISU_Convertor::TOutput *anOutput =
454       myResult->GetInput()->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration);
455     if(anOutput == NULL) throw std::runtime_error("There is no TimeStamp with the parameters !!!");
456     myScalarMapPL->SetInput(anOutput);
457     myScalarMapPL->Build();
458     QString aComment;
459     myName = "NoName";
460     if(theRestoring <= 0){
461       if(theRestoring == 0) myScalarMapPL->Init();
462       if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
463       const VISU::TValField& aValField = myField->myValField;
464       const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
465       aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
466       if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1();
467     }
468     if(myAddToStudy){
469       myName = GenerateName().latin1();
470       aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
471                        VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
472       string aResultEntry = myResult->GetEntry();
473       string aRefFatherEntry = myResult->GetRefFatherEntry();
474       string anEntry = myResult->GetEntry(aComment.latin1());
475       if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
476       aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
477                        GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
478       CORBA::String_var anIOR = GetID();
479       CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
480       mySObject = myStudy->FindObjectIOR(anIOR);
481     }
482   }catch(std::exception& exc){
483     INFOS("Follow exception was occured :\n"<<exc.what());
484     return NULL;
485   }catch(...){
486     INFOS("Unknown exception was occured!");
487     return NULL;
488   }
489   if(myAddToStudy) aStudyBuilder->CommitCommand();
490   return this;
491 }
492
493
494 void VISU::ScalarMap_i::DoHook(){
495   if(MYDEBUG)  MESSAGE("ScalarMap_i::DoHook() - "<<myPipeLine);
496   if(!myPipeLine) {
497     myPipeLine = VISU_ScalarMapPL::New();
498     myPipeLine->GetMapper()->SetScalarVisibility(1);
499   }
500   myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
501 }
502
503 void VISU::ScalarMap_i::Update() {
504   VISU::Prs3d_i::Update();
505 }
506
507 void VISU::ScalarMap_i::SetMapScale(double theMapScale){
508   myScalarMapPL->SetMapScale(theMapScale);
509 }
510
511 VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
512 {
513   VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New();
514   try{
515     VISU::Prs3d_i::CreateActor(anActor,theIO);
516     anActor->SetBarVisibility(true);
517     anActor->SetRepresentation(2);
518     UpdateActor(anActor);
519   }catch(...) {
520     anActor->Delete();
521     throw std::runtime_error("CreateActor error");
522   }
523   return anActor;
524 }
525
526 void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) {
527   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
528     VISU::Prs3d_i::UpdateActor(theActor);
529     VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
530     aScalarBar->SetLookupTable(myScalarMapPL->GetBarTable());
531     aScalarBar->SetTitle(myTitle.c_str());
532     aScalarBar->SetOrientation(myOrientation);
533     aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
534     aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]);
535     aScalarBar->SetWidth(myWidth);
536     aScalarBar->SetHeight(myHeight);
537     aScalarBar->SetNumberOfLabels(myNumberOfLabels);
538
539     vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
540     aTitleProp->SetFontFamily(myTitFontType);
541     aTitleProp->SetColor(myTitleColor);
542     (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
543     (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
544     (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
545
546     vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
547     aLabelProp->SetFontFamily(myLblFontType);
548     aLabelProp->SetColor(myLabelColor);
549     (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
550     (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
551     (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
552
553     aScalarBar->Modified();
554   }
555 }
556
557
558 void VISU::ScalarMap_i::SetSourceRange(){
559   myScalarMapPL->SetSourceRange();
560   myIsFixedRange = false;
561 }