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