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