Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISU_I / VISU_ColoredPrs3d_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_ColoredPrs3d_i.hh"
28
29 #include "VISU_ScalarMapPL.hxx"
30 #include "VISU_Result_i.hh"
31 #include "VISU_Convertor.hxx"
32
33 #include "SUIT_ResourceMgr.h"
34 #include "SALOME_Event.hxx"
35
36 #include <vtkMapper.h>
37
38 using namespace VISU;
39 using namespace std;
40
41 #ifdef _DEBUG_
42 static int MYDEBUG = 0;
43 //#define _DEXCEPT_
44 #else
45 static int MYDEBUG = 0;
46 #endif
47
48
49 //============================================================================
50 VISU::ColoredPrs3d_i::
51 ColoredPrs3d_i(Result_i* theResult,
52                bool theAddToStudy) :
53   PrsObject_i(theResult->GetStudyDocument()),
54   Prs3d_i(theResult,theAddToStudy),
55   myScalarMapPL(NULL),
56   myIsFixedRange(false)
57 {}
58
59 VISU::ColoredPrs3d_i::
60 ColoredPrs3d_i(Result_i* theResult,
61                SALOMEDS::SObject_ptr theSObject) :
62   PrsObject_i(theResult->GetStudyDocument()),
63   Prs3d_i(theResult,theSObject),
64   myScalarMapPL(NULL),
65   myIsFixedRange(false)
66 {}
67
68 VISU::ColoredPrs3d_i
69 ::~ColoredPrs3d_i()
70 {}
71
72 //---------------------------------------------------------------
73 void 
74 VISU::ColoredPrs3d_i
75 ::RemoveFromStudy()
76 {
77   struct TRemoveFromStudy: public SALOME_Event
78   {
79     VISU::ColoredPrs3d_i* myRemovable;
80     TRemoveFromStudy(VISU::ColoredPrs3d_i* theRemovable):
81       myRemovable(theRemovable)
82     {}
83     
84     virtual
85     void
86     Execute()
87     {
88       SALOMEDS::SObject_var aSObject = myRemovable->GetSObject();
89       if(!CORBA::is_nil(aSObject.in()))
90         VISU::RemoveFromStudy(aSObject,false);
91       myRemovable->TSuperClass::RemoveFromStudy();
92     }
93   };
94
95   ProcessVoidEvent(new TRemoveFromStudy(this));
96 }
97
98 //---------------------------------------------------------------
99 void
100 VISU::ColoredPrs3d_i
101 ::SameAs(const Prs3d_i* theOrigin)
102 {
103   if(const ColoredPrs3d_i* aPrs3d = dynamic_cast<const ColoredPrs3d_i*>(theOrigin)){
104     DoHook();
105
106     ColoredPrs3d_i* anOrigin = const_cast<ColoredPrs3d_i*>(aPrs3d);
107  
108     myField = anOrigin->GetField();
109     myMeshName = myField->myMeshName;
110     myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
111     myIteration = anOrigin->GetIteration();
112     myFieldName = anOrigin->GetFieldName();
113     
114     Build(-1);
115     
116     TSuperClass::SameAs(theOrigin);
117     
118     SetScalarMode(anOrigin->GetScalarMode());
119     SetNbColors(anOrigin->GetNbColors());
120     SetBarOrientation(anOrigin->GetBarOrientation());
121     
122     SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY());
123     SetSize(anOrigin->GetWidth(), anOrigin->GetHeight());
124     SetLabels(anOrigin->GetLabels());
125     SetTitle(anOrigin->GetTitle());
126     
127     SetBoldTitle(anOrigin->IsBoldTitle());
128     SetItalicTitle(anOrigin->IsItalicTitle());
129     SetShadowTitle(anOrigin->IsShadowTitle());
130     SetTitFontType(anOrigin->GetTitFontType());
131     vtkFloatingPointType r,g,b;
132     anOrigin->GetTitleColor(&r,&g,&b);
133     SetTitleColor(r,g,b);
134     
135     SetBoldLabel(anOrigin->IsBoldLabel());
136     SetItalicLabel(anOrigin->IsItalicLabel());
137     SetShadowLabel(anOrigin->IsShadowLabel());
138     SetLblFontType(anOrigin->GetLblFontType());
139     anOrigin->GetLabelColor(&r,&g,&b);
140     SetLabelColor(r,g,b);
141   }
142 }
143   
144 void
145 VISU::ColoredPrs3d_i
146 ::SameAsParams(const ColoredPrs3d_i* theOrigin)
147 {
148   int anIteration = GetIteration();
149   SameAs(theOrigin);
150   myIteration = anIteration;
151
152   Build(-1);
153   Update();
154 }
155
156
157 //----------------------------------------------------------------------------
158 CORBA::Long 
159 VISU::ColoredPrs3d_i
160 ::GetScalarMode()
161 {
162   return myScalarMapPL->GetScalarMode();
163 }
164
165 void
166 VISU::ColoredPrs3d_i
167 ::SetScalarMode(CORBA::Long theScalarMode) 
168 {
169   myScalarMapPL->SetScalarMode(theScalarMode);
170 }
171
172 CORBA::Double 
173 VISU::ColoredPrs3d_i
174 ::GetMin()
175 {
176   return myScalarMapPL->GetScalarRange()[0];
177 }
178
179 CORBA::Double 
180 VISU::ColoredPrs3d_i
181 ::GetMax()
182 {
183   return myScalarMapPL->GetScalarRange()[1];
184 }
185
186 void
187 VISU::ColoredPrs3d_i
188 ::SetNbColors(CORBA::Long theNbColors)
189 {
190   myScalarMapPL->SetNbColors(theNbColors);
191 }
192
193 CORBA::Long 
194 VISU::ColoredPrs3d_i
195 ::GetNbColors()
196 {
197   return myScalarMapPL->GetNbColors();
198 }
199
200 void
201 VISU::ColoredPrs3d_i
202 ::SetBarOrientation(VISU::ScalarMap::Orientation theOrientation)
203 {
204   myOrientation = theOrientation;
205 }
206
207 VISU::ScalarMap::Orientation 
208 VISU::ColoredPrs3d_i
209 ::GetBarOrientation() 
210 {
211   return myOrientation;
212 }
213
214 void
215 VISU::ColoredPrs3d_i
216 ::SetPosition(CORBA::Double X, CORBA::Double Y) 
217
218   myPosition[0] = X; 
219   myPosition[1] = Y;
220 }
221
222 CORBA::Double
223 VISU::ColoredPrs3d_i
224 ::GetPosX() 
225 {
226   return myPosition[0];
227 }
228
229 CORBA::Double
230 VISU::ColoredPrs3d_i
231 ::GetPosY() 
232
233   return myPosition[1];
234 }
235
236 void
237 VISU::ColoredPrs3d_i
238 ::SetSize(CORBA::Double theWidth, CORBA::Double theHeight) 
239 {
240   myWidth = theWidth; 
241   myHeight = theHeight;
242 }
243
244 CORBA::Double
245 VISU::ColoredPrs3d_i
246 ::GetWidth() 
247 {
248   return myWidth;
249 }
250
251 CORBA::Double
252 VISU::ColoredPrs3d_i
253 ::GetHeight() 
254
255   return myHeight;
256 }
257
258 void
259 VISU::ColoredPrs3d_i
260 ::SetLabels(CORBA::Long theNbLabels)
261 {
262   myNumberOfLabels = theNbLabels;
263 }
264
265 CORBA::Long
266 VISU::ColoredPrs3d_i
267 ::GetLabels() 
268
269   return myNumberOfLabels;
270 }
271
272 void
273 VISU::ColoredPrs3d_i
274 ::SetTitle(const char* theName) 
275 {
276   myTitle = theName;
277 }
278
279 char* 
280 VISU::ColoredPrs3d_i
281 ::GetTitle() 
282
283   return CORBA::string_dup(myTitle.c_str());
284 }
285
286 bool
287 VISU::ColoredPrs3d_i
288 ::IsBoldTitle() 
289
290   return myIsBoldTitle;
291 }
292
293 void
294 VISU::ColoredPrs3d_i
295 ::SetBoldTitle(bool isBold)
296 {
297   myIsBoldTitle = isBold;
298 }
299
300 bool
301 VISU::ColoredPrs3d_i
302 ::IsItalicTitle() 
303
304   return myIsItalicTitle;
305 }
306
307 void
308 VISU::ColoredPrs3d_i
309 ::SetItalicTitle(bool isItalic)
310
311   myIsItalicTitle = isItalic;
312 }
313
314 bool
315 VISU::ColoredPrs3d_i
316 ::IsShadowTitle() 
317
318   return myIsShadowTitle;
319 }
320
321 void
322 VISU::ColoredPrs3d_i
323 ::SetShadowTitle(bool isShadow)
324
325   myIsShadowTitle = isShadow;
326 }
327
328 int
329 VISU::ColoredPrs3d_i
330 ::GetTitFontType()
331 {
332   return myTitFontType;
333 }
334
335 void
336 VISU::ColoredPrs3d_i
337 ::SetTitFontType(int theType)
338 {
339   myTitFontType = theType;
340 }
341
342 void
343 VISU::ColoredPrs3d_i
344 ::GetTitleColor(vtkFloatingPointType* theR, 
345                 vtkFloatingPointType* theG, 
346                 vtkFloatingPointType* theB)
347 {
348   *theR = myTitleColor[0]; 
349   *theG = myTitleColor[1]; 
350   *theB = myTitleColor[2];
351 }
352
353 void
354 VISU::ColoredPrs3d_i
355 ::SetTitleColor(vtkFloatingPointType theR, 
356                 vtkFloatingPointType theG, 
357                 vtkFloatingPointType theB)
358 {
359   myTitleColor[0] = theR; 
360   myTitleColor[1] = theG; 
361   myTitleColor[2] = theB; 
362 }
363
364 bool
365 VISU::ColoredPrs3d_i
366 ::IsBoldLabel()
367 {
368   return myIsBoldLabel;
369 }
370
371 void
372 VISU::ColoredPrs3d_i
373 ::SetBoldLabel(bool isBold) 
374 {
375   myIsBoldLabel = isBold;
376 }
377
378 bool
379 VISU::ColoredPrs3d_i
380 ::IsItalicLabel() 
381 {
382   return myIsItalicLabel;
383 }
384
385 void
386 VISU::ColoredPrs3d_i
387 ::SetItalicLabel(bool isItalic)
388 {
389   myIsItalicLabel = isItalic;
390 }
391
392 bool
393 VISU::ColoredPrs3d_i
394 ::IsShadowLabel() 
395 {
396   return myIsShadowLabel;
397 }
398
399 void
400 VISU::ColoredPrs3d_i
401 ::SetShadowLabel(bool isShadow)
402 {
403   myIsShadowLabel = isShadow;
404 }
405
406 int
407 VISU::ColoredPrs3d_i
408 ::GetLblFontType()
409 {
410   return myLblFontType;
411 }
412
413 void
414 VISU::ColoredPrs3d_i
415 ::SetLblFontType(int theType)
416 {
417   myLblFontType = theType;
418 }
419
420 void
421 VISU::ColoredPrs3d_i
422 ::GetLabelColor(vtkFloatingPointType* theR, 
423                 vtkFloatingPointType* theG, 
424                 vtkFloatingPointType* theB)
425 {
426   *theR = myLabelColor[0]; 
427   *theG = myLabelColor[1]; 
428   *theB = myLabelColor[2];
429 }
430
431 void
432 VISU::ColoredPrs3d_i
433 ::SetLabelColor(vtkFloatingPointType theR, 
434                 vtkFloatingPointType theG, 
435                 vtkFloatingPointType theB)
436 {
437   myLabelColor[0] = theR; 
438   myLabelColor[1] = theG; 
439   myLabelColor[2] = theB; 
440 }
441
442
443 //----------------------------------------------------------------------------
444 /**
445  * Creates ColoredPrs3d and initialises it from resources
446  */
447 VISU::Storable* 
448 VISU::ColoredPrs3d_i
449 ::Create(const char* theMeshName, 
450          VISU::Entity theEntity,
451          const char* theFieldName, 
452          int theIteration)
453 {
454   DoHook(); // to create proper pipeline
455
456   myMeshName = theMeshName;
457   myEntity = (VISU::TEntity)theEntity;
458   myFieldName =theFieldName;
459   myIteration = theIteration;
460
461   Build(false); // to get corresponding input from result and initilize the pipeline
462
463   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
464
465   int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
466   SetScalarMode(aScalarMode);
467
468   int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
469   SetNbColors(aNumberOfColors);
470
471   // Orientation
472   int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
473   if(anOrientation == 1)
474     myOrientation = VISU::ScalarMap::HORIZONTAL;
475   else
476     myOrientation = VISU::ScalarMap::VERTICAL;
477
478   // Scalar Bar origin
479   QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
480
481   vtkFloatingPointType aXorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.01 : 0.2;
482   aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
483   myPosition[0] = aXorigin;
484
485   vtkFloatingPointType aYorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.1 : 0.012;
486   aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
487   myPosition[1] = aYorigin;
488
489   // Scalar Bar size
490   myWidth = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.1 : 0.6;
491   myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
492
493   myHeight = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
494   myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
495
496   // scalar bar default position
497   bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
498   int aPlace = 1;
499   if (anIsArrangeBar){
500     aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
501   }
502   if(myOrientation == VISU::ScalarMap::HORIZONTAL){
503     myPosition[1] += myHeight*(aPlace-1);
504   } else {
505     myPosition[0] += myWidth*(aPlace-1);
506   }
507
508   // Nb of Labels
509   myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
510
511   // Fonts properties definition
512   myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
513   myTitFontType = VTK_ARIAL;
514
515   if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){
516     QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
517     if ( f.family() == "Arial" )
518       myTitFontType = VTK_ARIAL;
519     else if ( f.family() == "Courier" )
520       myTitFontType = VTK_COURIER;
521     else if ( f.family() == "Times" )
522       myTitFontType = VTK_TIMES;
523     
524     myIsBoldTitle   = f.bold();
525     myIsItalicTitle = f.italic();
526     myIsShadowTitle =  f.underline();
527   }
528
529   QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
530
531   myTitleColor[0] = aTextColor.red()   / 255;
532   myTitleColor[1] = aTextColor.green() / 255;
533   myTitleColor[2] = aTextColor.blue()  / 255;
534
535   myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
536   myLblFontType = VTK_ARIAL;
537
538   if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){
539     QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
540     if ( f.family() == "Arial" )
541       myLblFontType = VTK_ARIAL;
542     else if ( f.family() == "Courier" )
543       myLblFontType = VTK_COURIER;
544     else if ( f.family() == "Times" )
545       myLblFontType = VTK_TIMES;
546     
547     myIsBoldLabel   = f.bold();
548     myIsItalicLabel = f.italic();
549     myIsShadowLabel =  f.underline();
550   }
551
552   QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
553
554   myLabelColor[0] = aLabelColor.red()   / 255;
555   myLabelColor[1] = aLabelColor.green() / 255;
556   myLabelColor[2] = aLabelColor.blue()  / 255;
557
558   return this;
559 }
560
561 VISU::Storable* 
562 VISU::ColoredPrs3d_i
563 ::Restore(const Storable::TRestoringMap& theMap)
564 {
565   DoHook();
566
567   myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
568   myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
569   myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
570   myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
571
572   myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
573
574   Build(true);
575
576   TSuperClass::Restore(theMap);
577
578   SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
579   SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
580   SetBarOrientation((VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt());
581   
582   myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
583   myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
584   myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
585   myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
586   myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
587   myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
588
589   myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
590   myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
591   myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
592   myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
593   myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
594   myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
595   myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
596
597   myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
598   myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
599   myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
600   myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
601   myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
602   myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
603   myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
604
605   return this;
606 }
607
608 void 
609 VISU::ColoredPrs3d_i
610 ::ToStream(std::ostringstream& theStr)
611 {
612   TSuperClass::ToStream(theStr);
613
614   Storable::DataToStream( theStr, "myScalarMode",     int(GetScalarMode()) );
615   Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
616   Storable::DataToStream( theStr, "myOrientation",    myOrientation );
617
618   Storable::DataToStream( theStr, "myMeshName",       myMeshName.c_str() );
619   Storable::DataToStream( theStr, "myEntity",         myEntity );
620   Storable::DataToStream( theStr, "myFieldName",      myFieldName.c_str() );
621   Storable::DataToStream( theStr, "myIteration",      myIteration );
622
623   Storable::DataToStream( theStr, "myTitle",          myTitle.c_str() );
624   Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
625   Storable::DataToStream( theStr, "myPosition[0]",    myPosition[0] );
626   Storable::DataToStream( theStr, "myPosition[1]",    myPosition[1] );
627   Storable::DataToStream( theStr, "myWidth",          myWidth );
628   Storable::DataToStream( theStr, "myHeight",         myHeight );
629
630   Storable::DataToStream( theStr, "myTitFontType",    myTitFontType );
631   Storable::DataToStream( theStr, "myIsBoldTitle",    myIsBoldTitle );
632   Storable::DataToStream( theStr, "myIsItalicTitle",  myIsItalicTitle );
633   Storable::DataToStream( theStr, "myIsShadowTitle",  myIsShadowTitle );
634   Storable::DataToStream( theStr, "myTitleColor[0]",  myTitleColor[0] );
635   Storable::DataToStream( theStr, "myTitleColor[1]",  myTitleColor[1] );
636   Storable::DataToStream( theStr, "myTitleColor[2]",  myTitleColor[2] );
637
638   Storable::DataToStream( theStr, "myLblFontType",    myLblFontType );
639   Storable::DataToStream( theStr, "myIsBoldLabel",    myIsBoldLabel );
640   Storable::DataToStream( theStr, "myIsItalicLabel",  myIsItalicLabel );
641   Storable::DataToStream( theStr, "myIsShadowLabel",  myIsShadowLabel );
642   Storable::DataToStream( theStr, "myLabelColor[0]",  myLabelColor[0] );
643   Storable::DataToStream( theStr, "myLabelColor[1]",  myLabelColor[1] );
644   Storable::DataToStream( theStr, "myLabelColor[2]",  myLabelColor[2] );
645 }
646
647
648 //----------------------------------------------------------------------------
649 void
650 VISU::ColoredPrs3d_i
651 ::DoHook()
652 {
653   if(MYDEBUG) MESSAGE("ColoredPrs3d_i::DoHook() - "<<myPipeLine);
654   if(!myPipeLine){
655     myPipeLine = VISU_ScalarMapPL::New();
656     myPipeLine->GetMapper()->SetScalarVisibility(1);
657   }
658   myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
659 }
660
661 //----------------------------------------------------------------------------
662 VISU::Storable* 
663 VISU::ColoredPrs3d_i
664 ::Build(int theRestoring)
665 {
666   if(MYDEBUG)
667     MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
668   SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
669   if(myAddToStudy) 
670     aStudyBuilder->NewCommand();  // There is a transaction
671 #ifndef _DEXCEPT_
672   try{
673 #endif
674     DoSetInput(myResult);
675     QString aComment;
676     myName = "NoName";
677     if(theRestoring <= 0){
678       if(theRestoring == 0) myScalarMapPL->Init();
679       if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
680       const VISU::TValField& aValField = myField->myValField;
681       const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
682       aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
683       if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1();
684     }
685     if(myAddToStudy){
686       myName = GenerateName().latin1();
687       aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
688                        VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
689       string aResultEntry = myResult->GetEntry();
690       string aRefFatherEntry = myResult->GetRefFatherEntry();
691       string anEntry = myResult->GetEntry(aComment.latin1());
692       if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
693       aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
694                        GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
695       CORBA::String_var anIOR = GetID();
696       CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
697       mySObject = myStudy->FindObjectIOR(anIOR);
698     }
699 #ifndef _DEXCEPT_
700   }catch(std::exception& exc){
701     INFOS("Follow exception was occured :\n"<<exc.what());
702     throw;
703   }catch(...){
704     INFOS("Unknown exception was occured!");
705     throw;
706   }
707 #endif
708   if(myAddToStudy) 
709     aStudyBuilder->CommitCommand();
710   return this;
711 }
712
713
714 //----------------------------------------------------------------------------
715 const VISU::PField&
716 VISU::ColoredPrs3d_i
717 ::GetField() const 
718
719   return myField;
720 }
721
722 const std::string&
723 VISU::ColoredPrs3d_i
724 ::GetMeshName() const 
725
726   return myMeshName;
727 }
728
729 VISU::Entity
730 VISU::ColoredPrs3d_i
731 ::GetEntity() const 
732
733   return VISU::Entity(myEntity);
734 }
735
736 const std::string&
737 VISU::ColoredPrs3d_i
738 ::GetFieldName() const 
739
740   return myFieldName;
741 }
742
743 int
744 VISU::ColoredPrs3d_i
745 ::GetIteration() const 
746
747   return myIteration;
748 }
749
750 VISU_ScalarMapPL*
751 VISU::ColoredPrs3d_i
752 ::GetScalarMapPL()
753
754   return myScalarMapPL;
755 }