]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_ScalarMap_i.cc
Salome HOME
Merge with OCC_development_01
[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 #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
73 VISU::ScalarMap_i::ScalarMap_i(Result_i* theResult, bool theAddToStudy, SALOMEDS::SObject_ptr theSObject) : 
74        PrsObject_i(theResult->GetStudyDocument()), 
75        Prs3d_i(theResult,theSObject)
76 {
77   myAddToStudy = theAddToStudy;
78   myScalarMapPL = NULL;
79 }
80
81
82 void VISU::ScalarMap_i::RemoveFromStudy(){
83   VISU::RemoveFromStudy(mySObject,false);
84 }
85
86
87 void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin)
88 {
89   ScalarMap_i* aScalarMap = const_cast<ScalarMap_i*>(theOrigin);
90   DoHook();
91   VISU::Prs3d_i::SameAs(aScalarMap);
92   myField = aScalarMap->GetField();
93   myMeshName = myField->myMeshName;
94   myEntity = myField->myEntity;
95   myIteration = aScalarMap->GetIteration();
96   myFieldName = aScalarMap->GetFieldName();
97
98   SetScalarMode(aScalarMap->GetScalarMode());
99
100   SetRange(aScalarMap->GetMin(), aScalarMap->GetMax());
101   myIsFixedRange = aScalarMap->IsRangeFixed();
102
103   SetScaling(aScalarMap->GetScaling());
104
105   SetBarOrientation(aScalarMap->GetBarOrientation());
106   SetPosition(aScalarMap->GetPosX(), aScalarMap->GetPosY());
107   SetSize(aScalarMap->GetWidth(), aScalarMap->GetHeight());
108   SetNbColors(aScalarMap->GetNbColors());
109   SetLabels(aScalarMap->GetLabels());
110   SetTitle(aScalarMap->GetTitle());
111
112   SetBoldTitle(aScalarMap->IsBoldTitle());
113   SetItalicTitle(aScalarMap->IsItalicTitle());
114   SetShadowTitle(aScalarMap->IsShadowTitle());
115   SetTitFontType(aScalarMap->GetTitFontType());
116   float r,g,b;
117   aScalarMap->GetTitleColor(&r,&g,&b);
118   SetTitleColor(r,g,b);
119
120   SetBoldLabel(aScalarMap->IsBoldLabel());
121   SetItalicLabel(aScalarMap->IsItalicLabel());
122   SetShadowLabel(aScalarMap->IsShadowLabel());
123   SetLblFontType(aScalarMap->GetLblFontType());
124   aScalarMap->GetLabelColor(&r,&g,&b);
125   SetLabelColor(r,g,b);
126
127   Build(-1);
128   Update();
129 }
130
131
132 /**
133  * Creates Scalar Map and initialises it from resources
134  */
135 VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity theEntity, 
136                                           const char* theFieldName, int theIteration)
137 {
138   DoHook();
139
140   // Orientation
141   QString aOrient = QAD_CONFIG->getSetting("Visu:SBOrientation");
142   if ( !aOrient.isEmpty() ) 
143     myOrientation = (VISU::ScalarMap::Orientation) aOrient.toInt();
144   else
145     myOrientation = VISU::ScalarMap::VERTICAL;
146
147   // Scalar Bar origin
148   QString aXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
149   if ( !aXorigin.isEmpty() )
150     myPosition[0] = aXorigin.toFloat();
151   else {
152     if(myOrientation == VISU::ScalarMap::VERTICAL) {
153       myPosition[0] = 0.03;
154     } else {
155       myPosition[0] = 0.2;
156     }
157   }
158   
159   QString aYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
160   if ( !aYorigin.isEmpty() )
161     myPosition[1] = aYorigin.toFloat();
162   else {
163     if(myOrientation == VISU::ScalarMap::VERTICAL) {
164       myPosition[1] = 0.1;
165     } else {
166       myPosition[1] = 0.012;
167     }
168   }
169
170   // Scalar Bar size
171   QString aWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
172   if ( !aWidth.isEmpty() )
173     myWidth = aWidth.toFloat();
174   else {
175     myWidth =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.17:0.6;
176   }
177   QString aHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
178   if ( !aHeight.isEmpty() )
179     myHeight = aHeight.toFloat();
180   else {
181     myHeight =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
182   }
183
184   // Nb of Colors
185   QString aColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
186   int aNumberOfColors = (aColors.isEmpty())? 64 : aColors.toInt();
187   if (aNumberOfColors > 64) 
188     aNumberOfColors = 64;
189   SetNbColors(aNumberOfColors);
190
191   // Nb of Labels
192   QString aLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
193   myNumberOfLabels = (aLabels.isEmpty())? 5 : aLabels.toInt();
194   if (myNumberOfLabels > 65) 
195     myNumberOfLabels = 65;
196   
197   // Scalar Range
198   QString aFixRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
199   myIsFixedRange = (aFixRange.compare("true") == 0);
200
201   if(myIsFixedRange){
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 {
298   DoHook();
299   myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
300   myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
301   myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
302   myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
303
304   SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
305   SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt()));
306   float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
307   float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
308   SetRange(aMin,aMax);
309   myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt();
310
311   myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
312   myOrientation = (VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt();
313   SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
314   myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
315   myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
316   myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
317   myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
318   myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
319
320   myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
321   myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
322   myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
323   myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
324   myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
325   myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
326   myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
327
328   myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
329   myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
330   myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
331   myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
332   myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
333   myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
334   myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
335
336   Prs3d_i::Restore(theMap);
337   myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
338   return Build(true);
339 }
340
341
342 void VISU::ScalarMap_i::ToStream(std::ostringstream& theStr){
343   Prs3d_i::ToStream(theStr);
344
345   Storable::DataToStream( theStr, "myMeshName",       myMeshName.c_str() );
346   Storable::DataToStream( theStr, "myEntity",         myEntity );
347   Storable::DataToStream( theStr, "myFieldName",      myFieldName.c_str() );
348   Storable::DataToStream( theStr, "myIteration",      myIteration );
349
350   Storable::DataToStream( theStr, "myScalarMode",     int(GetScalarMode()) );
351   Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
352   Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
353   Storable::DataToStream( theStr, "myIsFixedRange",   myIsFixedRange );
354   Storable::DataToStream( theStr, "myScaling",        GetScaling() );
355
356   Storable::DataToStream( theStr, "myTitle",          myTitle.c_str() );
357   Storable::DataToStream( theStr, "myOrientation",    myOrientation );
358   Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
359   Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
360   Storable::DataToStream( theStr, "myPosition[0]",    myPosition[0] );
361   Storable::DataToStream( theStr, "myPosition[1]",    myPosition[1] );
362   Storable::DataToStream( theStr, "myWidth",          myWidth );
363   Storable::DataToStream( theStr, "myHeight",         myHeight );
364
365   Storable::DataToStream( theStr, "myTitFontType",    myTitFontType );
366   Storable::DataToStream( theStr, "myIsBoldTitle",    myIsBoldTitle );
367   Storable::DataToStream( theStr, "myIsItalicTitle",  myIsItalicTitle );
368   Storable::DataToStream( theStr, "myIsShadowTitle",  myIsShadowTitle );
369   Storable::DataToStream( theStr, "myTitleColor[0]",  myTitleColor[0] );
370   Storable::DataToStream( theStr, "myTitleColor[1]",  myTitleColor[1] );
371   Storable::DataToStream( theStr, "myTitleColor[2]",  myTitleColor[2] );
372
373   Storable::DataToStream( theStr, "myLblFontType",    myLblFontType );
374   Storable::DataToStream( theStr, "myIsBoldLabel",    myIsBoldLabel );
375   Storable::DataToStream( theStr, "myIsItalicLabel",  myIsItalicLabel );
376   Storable::DataToStream( theStr, "myIsShadowLabel",  myIsShadowLabel );
377   Storable::DataToStream( theStr, "myLabelColor[0]",  myLabelColor[0] );
378   Storable::DataToStream( theStr, "myLabelColor[1]",  myLabelColor[1] );
379   Storable::DataToStream( theStr, "myLabelColor[2]",  myLabelColor[2] );
380 }
381
382
383 CORBA::Long VISU::ScalarMap_i::GetScalarMode(){ 
384   return myScalarMapPL->GetScalarMode();
385 }
386 void VISU::ScalarMap_i::SetScalarMode(CORBA::Long theScalarMode) { 
387   myScalarMapPL->SetScalarMode(theScalarMode);
388 }
389
390
391 VISU::Scaling VISU::ScalarMap_i::GetScaling(){
392   return VISU::Scaling(myScalarMapPL->GetScaling());
393 }
394 void VISU::ScalarMap_i::SetScaling(VISU::Scaling theScaling){
395   myScalarMapPL->SetScaling(theScaling);
396 }
397
398
399 void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax){ 
400   if(theMin > theMax) return;
401   float aScalarRange[2] = {theMin, theMax};
402   myScalarMapPL->SetScalarRange(aScalarRange);
403   myIsFixedRange = true;
404 }
405
406 CORBA::Double VISU::ScalarMap_i::GetMin(){
407   return myScalarMapPL->GetScalarRange()[0];
408 }
409
410 CORBA::Double VISU::ScalarMap_i::GetMax(){
411   return myScalarMapPL->GetScalarRange()[1];
412 }
413
414    
415 void VISU::ScalarMap_i::SetNbColors(CORBA::Long theNbColors){
416   myScalarMapPL->SetNbColors(theNbColors);
417 }
418
419 CORBA::Long VISU::ScalarMap_i::GetNbColors(){
420   return myScalarMapPL->GetNbColors();
421 }
422
423
424 VISU::ScalarMap_i::~ScalarMap_i(){}
425
426
427 VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){
428   if(MYDEBUG) 
429     MESSAGE("ScalarMap_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
430   SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
431   if(myAddToStudy) aStudyBuilder->NewCommand();  // There is a transaction
432   try{
433     if(myResult->GetInput() == NULL) 
434       throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
435     myField = myResult->GetInput()->GetField(myMeshName,myEntity,myFieldName);
436     if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!");
437     VISU_Convertor::TOutput *anOutput = 
438       myResult->GetInput()->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration);
439     if(anOutput == NULL) throw std::runtime_error("There is no TimeStamp with the parameters !!!");
440     myScalarMapPL->SetInput(anOutput);
441     myScalarMapPL->Build();
442     QString aComment;
443     myName = "NoName";
444     if(theRestoring <= 0){
445       if(theRestoring == 0) myScalarMapPL->Init();
446       if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
447       const VISU::TValField& aValField = myField->myValField;
448       const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
449       aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
450       if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1();
451     }
452     if(myAddToStudy){
453       myName = GenerateName().latin1();
454       aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
455                        VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
456       string aResultEntry = myResult->GetEntry();
457       string aRefFatherEntry = myResult->GetRefFatherEntry();
458       string anEntry = myResult->GetEntry(aComment.latin1());
459       if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
460       aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
461                        GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
462       CORBA::String_var anIOR = GetID();
463       CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
464       mySObject = myStudy->FindObjectIOR(anIOR);
465     }
466   }catch(std::exception& exc){
467     INFOS("Follow exception was occured :\n"<<exc.what());
468     return NULL;
469   }catch(...){
470     INFOS("Unknown exception was occured!");
471     return NULL;
472   }
473   if(myAddToStudy) aStudyBuilder->CommitCommand();
474   return this;
475 }
476
477
478 void VISU::ScalarMap_i::DoHook(){
479   if(MYDEBUG)  MESSAGE("ScalarMap_i::DoHook() - "<<myPipeLine);
480   if(!myPipeLine) {
481     myPipeLine = VISU_ScalarMapPL::New();
482     myPipeLine->GetMapper()->SetScalarVisibility(1);
483   }
484   myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
485 }
486
487 void VISU::ScalarMap_i::Update() {
488   VISU::Prs3d_i::Update();
489 }
490
491 void VISU::ScalarMap_i::SetMapScale(double theMapScale){
492   myScalarMapPL->SetMapScale(theMapScale);
493 }
494
495 VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
496 {
497   VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New();
498   try{
499     VISU::Prs3d_i::CreateActor(anActor,theIO);
500     anActor->SetBarVisibility(true);
501     anActor->SetRepresentation(2);
502     UpdateActor(anActor);
503   }catch(...) {
504     anActor->Delete();
505     throw std::runtime_error("CreateActor error"); 
506   }
507   return anActor;
508 }
509
510 void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) {
511   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
512     VISU::Prs3d_i::UpdateActor(theActor);
513     VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
514     aScalarBar->SetLookupTable(myScalarMapPL->GetBarTable());
515     aScalarBar->SetTitle(myTitle.c_str());
516     aScalarBar->SetOrientation(myOrientation);
517     aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
518     aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]);
519     aScalarBar->SetWidth(myWidth);
520     aScalarBar->SetHeight(myHeight);
521     aScalarBar->SetNumberOfLabels(myNumberOfLabels);
522     
523     vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
524     aTitleProp->SetFontFamily(myTitFontType);
525     aTitleProp->SetColor(myTitleColor);
526     (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
527     (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
528     (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
529     
530     vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
531     aLabelProp->SetFontFamily(myLblFontType);
532     aLabelProp->SetColor(myLabelColor);
533     (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
534     (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
535     (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
536     
537     aScalarBar->Modified();
538   }
539 }
540
541
542 void VISU::ScalarMap_i::SetSourceRange(){
543   myScalarMapPL->SetSourceRange();
544   myIsFixedRange = false;
545 }