]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_GaussPoints_i.cc
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISU_I / VISU_GaussPoints_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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //  File   :
24 //  Author :
25 //  Module :
26
27 #include "VISU_GaussPoints_i.hh"
28 #include "VISU_ScalarMap_i.hh"
29 #include "VISU_Prs3dUtils.hh"
30
31 #include "VISU_Result_i.hh"
32 #include "VISU_GaussPtsAct.h"
33 #include "VISU_GaussPointsPL.hxx"
34 #include "VISU_GaussPtsDeviceActor.h"
35
36 #include "VISU_OpenGLPointSpriteMapper.hxx"
37 #include "VISU_ScalarBarCtrl.hxx"
38 #include <VISU_ScalarBarActor.hxx>
39 #include "VISU_LookupTable.hxx"
40 #include "VISU_Convertor.hxx"
41
42 #include "SUIT_ResourceMgr.h"
43
44 #include "VISU_PipeLineUtils.hxx"
45
46 #include <vtkImageData.h>
47 #include <vtkXMLImageDataReader.h>
48 #include <vtkTextProperty.h>
49 #include <vtkProperty.h>
50
51 #ifdef _DEBUG_
52 static int MYDEBUG = 0;
53 #else
54 static int MYDEBUG = 0;
55 #endif
56
57 static int INCMEMORY = 10;
58
59 //----------------------------------------------------------------------------
60 size_t
61 VISU::GaussPoints_i
62 ::IsPossible(Result_i* theResult, 
63              const std::string& theMeshName, 
64              VISU::Entity theEntity,
65              const std::string& theFieldName, 
66              CORBA::Long theTimeStampNumber,
67              bool theIsMemoryCheck)
68 {
69   size_t aResult = 0;
70   if(theEntity == VISU::NODE)
71     return aResult;
72   try{
73     bool anIsEstimated = true;
74     VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
75                                                          theEntity,
76                                                          theFieldName,
77                                                          theTimeStampNumber);
78     size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
79                                                        VISU::TEntity(theEntity),
80                                                        theFieldName,
81                                                        theTimeStampNumber,
82                                                        anIsEstimated);
83       aResult = 1;
84     if(theIsMemoryCheck){
85       if(anIsEstimated)
86         aSize *= INCMEMORY;
87       aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
88       if(MYDEBUG) 
89         MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
90     }
91   }catch(std::exception& exc){
92     INFOS("Follow exception was occured :\n"<<exc.what());
93   }catch(...){
94     INFOS("Unknown exception was occured!");
95   }
96   return aResult;
97 }
98
99 //----------------------------------------------------------------------------
100 int VISU::GaussPoints_i::myNbPresent = 0;
101
102 QString 
103 VISU::GaussPoints_i
104 ::GenerateName()
105 {
106   return VISU::GenerateName("Gauss Points",myNbPresent++);
107 }
108
109 //----------------------------------------------------------------------------
110 const string VISU::GaussPoints_i::myComment = "GAUSSPOINTS";
111
112 const char* 
113 VISU::GaussPoints_i
114 ::GetComment() const 
115
116   return myComment.c_str();
117 }
118
119
120 //---------------------------------------------------------------
121 const char*
122 VISU::GaussPoints_i
123 ::GetIconName()
124 {
125   return "ICON_TREE_GAUSS_POINTS";
126 }  
127
128
129 //----------------------------------------------------------------------------
130 VISU::GaussPoints_i
131 ::GaussPoints_i(EPublishInStudyMode thePublishInStudyMode) : 
132   ColoredPrs3d_i(thePublishInStudyMode),
133   myGaussPointsPL(NULL),
134   myColor(Qt::blue),
135   myIsActiveLocalScalarBar(true),
136   myIsDispGlobalScalarBar(true),
137   mySpacing(0.01),
138   myFaceLimit(50000)
139 {
140   if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
141 }
142
143
144 //----------------------------------------------------------------------------
145 VISU::Storable* 
146 VISU::GaussPoints_i
147 ::Create(const std::string& theMeshName, 
148            VISU::Entity theEntity,
149            const std::string& theFieldName, 
150            CORBA::Long theTimeStampNumber)
151 {
152   TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
153
154   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
155
156   int anActiveLocal = aResourceMgr->integerValue( "VISU", "scalar_bar_active_local", GetIsActiveLocalScalarBar() );
157   SetIsActiveLocalScalarBar( anActiveLocal == 0 );
158
159   bool aDisplayGlobal = aResourceMgr->booleanValue( "VISU", "scalar_bar_diplay_global", GetIsDispGlobalScalarBar() );
160   SetIsDispGlobalScalarBar( aDisplayGlobal );
161
162   int aBicolor = aResourceMgr->integerValue( "VISU", "scalar_bar_bicolor", GetBiColor() );
163   SetBiColor( aBicolor == 0 );
164
165   vtkFloatingPointType aSpacing = aResourceMgr->doubleValue( "VISU", "scalar_bar_spacing", GetSpacing() );
166   SetSpacing( aSpacing );
167
168   vtkFloatingPointType aScaleFactor = aResourceMgr->doubleValue( "VISU", "deformed_shape_scale_factor", GetScaleFactor() );
169   SetScaleFactor( aScaleFactor );
170
171   int aPrimitiveType = aResourceMgr->integerValue( "VISU", "point_sprite_primitive_type", GetPrimitiveType() );
172   SetPrimitiveType( VISU::GaussPoints::PrimitiveType(aPrimitiveType) );
173
174   vtkFloatingPointType aClamp = aResourceMgr->doubleValue( "VISU", "point_sprite_clamp", GetClamp() );
175   SetClamp( aClamp );
176
177   int aMinSize = aResourceMgr->integerValue( "VISU", "point_sprite_min_size", ( int )( GetMinSize() * 100.0 ) );
178   SetMinSize( aMinSize / 100.0 );
179
180   int aMaxSize = aResourceMgr->integerValue( "VISU", "point_sprite_max_size", ( int )( GetMaxSize() * 100.0 ) );
181   SetMaxSize( aMaxSize / 100.0 );
182
183   int aGeomSize = aResourceMgr->integerValue( "VISU", "point_sprite_size", ( int )( GetGeomSize() * 100.0 ) );
184   SetGeomSize( aGeomSize / 100.0 );
185
186   int aMagnification = aResourceMgr->integerValue( "VISU", "point_sprite_magnification", ( int )( GetMagnification() * 100.0 ) );
187   SetMagnification( aMagnification / 100.0 );
188
189   vtkFloatingPointType anIncrement = aResourceMgr->doubleValue( "VISU", "point_sprite_increment", GetMagnificationIncrement() );
190   SetMagnificationIncrement( anIncrement );
191
192   bool isColored = aResourceMgr->booleanValue( "VISU", "point_sprite_results", GetIsColored() );
193   SetIsColored( isColored );
194
195   QColor aColor = aResourceMgr->colorValue( "VISU", "point_sprite_color", GetQColor() );
196   SetQColor( aColor );
197
198   vtkFloatingPointType anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "point_sprite_alpha_threshold", GetAlphaThreshold() );
199   SetAlphaThreshold( anAlphaThreshold );
200
201   int aResolution = aResourceMgr->integerValue( "VISU", "geom_sphere_resolution", GetResolution() );
202   SetResolution( aResolution );
203
204   int aFaceLimit = aResourceMgr->integerValue( "VISU", "geom_sphere_face_limit", GetFaceLimit() );
205   SetFaceLimit( aFaceLimit );
206
207   QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_texture.bmp";
208   aMainTexture = aResourceMgr->stringValue( "VISU", "point_sprite_main_texture", aMainTexture );
209
210   QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_alpha.bmp";
211   anAlphaTexture = aResourceMgr->stringValue( "VISU", "point_sprite_alpha_texture", anAlphaTexture );
212
213   SetTextures( aMainTexture, anAlphaTexture );
214
215   return this;
216 }
217
218
219 //---------------------------------------------------------------
220 void 
221 VISU::GaussPoints_i
222 ::SameAs(const Prs3d_i* theOrigin)
223 {
224   TSuperClass::SameAs(theOrigin);
225
226   if(const GaussPoints_i* aPrs3d = dynamic_cast<const GaussPoints_i*>(theOrigin)){
227     GaussPoints_i* anOrigin = const_cast<GaussPoints_i*>(aPrs3d);
228
229     SetIsActiveLocalScalarBar(anOrigin->GetIsActiveLocalScalarBar());
230     SetIsDispGlobalScalarBar(anOrigin->GetIsDispGlobalScalarBar());
231
232     SetSpacing(anOrigin->GetSpacing());
233
234     SetFaceLimit(anOrigin->GetFaceLimit());
235
236     SetColor(anOrigin->GetColor());
237
238     SetTextures(anOrigin->GetMainTexture(), anOrigin->GetAlphaTexture());
239   }
240 }
241
242 //----------------------------------------------------------------------------
243 CORBA::Float
244 VISU::GaussPoints_i
245 ::GetMemorySize()
246 {
247   return TSuperClass::GetMemorySize();
248 }
249
250 //----------------------------------------------------------------------------
251 VISU::Storable* 
252 VISU::GaussPoints_i
253 ::Restore(SALOMEDS::SObject_ptr theSObject,
254           const Storable::TRestoringMap& theMap)
255 {
256   if(!TSuperClass::Restore(theSObject, theMap))
257     return NULL;
258
259   // Check if the icon needs to be updated, update if necessary
260   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
261   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
262   SALOMEDS::GenericAttribute_var anAttr = 
263     aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributePixMap");
264   SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
265
266   CORBA::String_var aPixMapName = aPixmap->GetPixMap();
267   if(strcmp(GetIconName(), aPixMapName.in()) != 0)
268     aPixmap->SetPixMap(GetIconName());
269
270   SetIsActiveLocalScalarBar(Storable::FindValue(theMap,"myIsActiveLocalScalarBar").toInt());
271   SetIsDispGlobalScalarBar(Storable::FindValue(theMap,"myIsDispGlobalScalarBar").toInt());
272   SetBiColor(Storable::FindValue(theMap,"myIsBiColor").toInt());
273   SetSpacing(Storable::FindValue(theMap,"mySpacing").toDouble());
274
275   int aPrimitiveType = Storable::FindValue(theMap,"myPrimitiveType").toInt();
276   SetPrimitiveType(VISU::GaussPoints::PrimitiveType(aPrimitiveType));
277   SetClamp(Storable::FindValue(theMap,"myClamp").toDouble());
278   SetMinSize(Storable::FindValue(theMap,"myMinSize").toDouble());
279   SetMaxSize(Storable::FindValue(theMap,"myMaxSize").toDouble());
280   SetGeomSize(Storable::FindValue(theMap,"myGeomSize").toDouble());
281
282   SetMagnification(Storable::FindValue(theMap,"myMagnification").toDouble());
283   SetMagnificationIncrement(Storable::FindValue(theMap,"myMagnificationIncrement").toDouble());
284
285   SetIsDeformed(Storable::FindValue(theMap,"myIsDeformed").toInt());
286   SetScaleFactor(Storable::FindValue(theMap,"myScaleFactor").toDouble());
287
288   SetFaceLimit(Storable::FindValue(theMap,"myFaceLimit").toInt());
289
290   SetIsColored(Storable::FindValue(theMap,"myIsColored").toInt());
291   int aRed = Storable::FindValue(theMap,"myColor.R").toInt();
292   int aGreen = Storable::FindValue(theMap,"myColor.G").toInt();
293   int aBlue = Storable::FindValue(theMap,"myColor.B").toInt();
294   SetQColor( QColor(aRed, aGreen, aBlue) );
295
296   SetAlphaThreshold(Storable::FindValue(theMap,"myAlphaThreshold").toDouble());
297
298   SetTextures( Storable::FindValue(theMap,"myMainTexture"),
299                Storable::FindValue(theMap,"myAlphaTexture") );
300
301   SetResolution(Storable::FindValue(theMap,"myResolution").toInt());
302
303   return this;
304 }
305
306
307 //----------------------------------------------------------------------------
308 void
309 VISU::GaussPoints_i
310 ::ToStream(std::ostringstream& theStr)
311 {
312   TSuperClass::ToStream(theStr);
313
314   Storable::DataToStream( theStr, "myIsActiveLocalScalarBar", myIsActiveLocalScalarBar );
315   Storable::DataToStream( theStr, "myIsDispGlobalScalarBar", myIsDispGlobalScalarBar );
316   Storable::DataToStream( theStr, "myIsBiColor", GetBiColor() );
317   Storable::DataToStream( theStr, "mySpacing", GetSpacing() );
318
319   Storable::DataToStream( theStr, "myPrimitiveType", GetPrimitiveType() );
320   Storable::DataToStream( theStr, "myClamp", GetClamp() );
321   Storable::DataToStream( theStr, "myMinSize", GetMinSize() );
322   Storable::DataToStream( theStr, "myMaxSize", GetMaxSize() );
323   Storable::DataToStream( theStr, "myGeomSize", GetGeomSize() );
324
325   Storable::DataToStream( theStr, "myMagnification", GetMagnification() );
326   Storable::DataToStream( theStr, "myMagnificationIncrement", GetMagnificationIncrement() );
327
328   Storable::DataToStream( theStr, "myIsDeformed", GetIsDeformed() );
329   Storable::DataToStream( theStr, "myScaleFactor", GetScaleFactor() );
330
331   Storable::DataToStream( theStr, "myFaceLimit", GetFaceLimit() );
332
333   Storable::DataToStream( theStr, "myIsColored", GetIsColored() );
334   QColor aColor = GetQColor();
335   Storable::DataToStream( theStr, "myColor.R", aColor.red() );
336   Storable::DataToStream( theStr, "myColor.G", aColor.green() );
337   Storable::DataToStream( theStr, "myColor.B", aColor.blue() );
338
339   Storable::DataToStream( theStr, "myAlphaThreshold", GetAlphaThreshold() );
340   Storable::DataToStream( theStr, "myMainTexture", GetQMainTexture() );
341   Storable::DataToStream( theStr, "myAlphaTexture", GetQAlphaTexture() );
342
343   Storable::DataToStream( theStr, "myResolution", GetResolution() );
344 }
345
346
347 VISU::GaussPoints_i
348 ::~GaussPoints_i()
349 {
350   if(MYDEBUG) MESSAGE("GaussPoints_i::~GaussPoints_i() - this = "<<this);
351 }
352
353
354 //----------------------------------------------------------------------------
355 CORBA::Long
356 VISU::GaussPoints_i
357 ::GetFaceLimit()
358 {
359   return myFaceLimit;
360 }
361
362 //----------------------------------------------------------------------------
363 void
364 VISU::GaussPoints_i
365 ::SetFaceLimit( CORBA::Long theFaceLimit )
366 {
367   if( myFaceLimit == theFaceLimit )
368     return;
369
370   VISU::TSetModified aModified(this);
371   
372   myFaceLimit = theFaceLimit;
373   myParamsTime.Modified();
374 }
375
376 //----------------------------------------------------------------------------
377 void
378 VISU::GaussPoints_i
379 ::SetIsDeformed( CORBA::Boolean theIsDeformed )
380 {
381   VISU::TSetModified aModified(this);
382   
383   myGaussPointsPL->SetIsDeformed( theIsDeformed );
384 }
385
386 CORBA::Boolean
387 VISU::GaussPoints_i
388 ::GetIsDeformed()
389 {
390   return myGaussPointsPL->GetIsDeformed();
391 }
392
393 //----------------------------------------------------------------------------
394 void
395 VISU::GaussPoints_i
396 ::SetScaleFactor( CORBA::Double theScaleFactor )
397 {
398   VISU::TSetModified aModified(this);
399   
400   myGaussPointsPL->SetScale( theScaleFactor );
401 }
402
403 CORBA::Double
404 VISU::GaussPoints_i
405 ::GetScaleFactor()
406 {
407   return myGaussPointsPL->GetScale();
408 }
409
410 //----------------------------------------------------------------------------
411 QColor
412 VISU::GaussPoints_i
413 ::GetQColor()
414 {
415   return myColor;
416 }
417
418 SALOMEDS::Color
419 VISU::GaussPoints_i
420 ::GetColor()
421 {
422   SALOMEDS::Color aColor;
423   aColor.R = myColor.red();
424   aColor.G = myColor.green();
425   aColor.B = myColor.blue();
426   return aColor;
427 }
428
429
430 //----------------------------------------------------------------------------
431 void
432 VISU::GaussPoints_i
433 ::SetQColor( const QColor& theColor )
434 {
435   if(myColor == theColor)
436     return;
437
438   VISU::TSetModified aModified(this);
439   
440   myColor = theColor;
441   myParamsTime.Modified();
442 }
443
444 void
445 VISU::GaussPoints_i
446 ::SetColor( const SALOMEDS::Color& theColor )
447 {
448   SetQColor(QColor(int(theColor.R), int(theColor.G), int(theColor.B)));
449 }
450
451
452 //----------------------------------------------------------------------------
453 void
454 VISU::GaussPoints_i
455 ::SetIsColored( bool theIsColored )
456 {
457   VISU::TSetModified aModified(this);
458   
459   myGaussPointsPL->SetIsColored( theIsColored );
460 }
461
462 bool
463 VISU::GaussPoints_i
464 ::GetIsColored()
465 {
466   return myGaussPointsPL->GetIsColored();
467 }
468
469 //----------------------------------------------------------------------------
470 bool
471 VISU::GaussPoints_i
472 ::SetMainTexture( const QString& theMainTexture ) 
473 {
474   if(myMainTexture != theMainTexture){
475     VISU::TSetModified aModified(this);
476   
477     myMainTexture = theMainTexture;
478     myParamsTime.Modified();
479     return true;
480   }
481
482   return false;
483 }
484
485 QString
486 VISU::GaussPoints_i
487 ::GetQMainTexture() 
488
489   return myMainTexture; 
490 }
491
492 char*
493 VISU::GaussPoints_i
494 ::GetMainTexture() 
495
496   return CORBA::string_dup(myMainTexture.latin1());
497 }
498
499
500 //----------------------------------------------------------------------------
501 bool
502 VISU::GaussPoints_i
503 ::SetAlphaTexture( const QString& theAlphaTexture ) 
504 {
505   if(myAlphaTexture != theAlphaTexture){
506     VISU::TSetModified aModified(this);
507   
508     myAlphaTexture = theAlphaTexture;
509     myParamsTime.Modified();
510     return true;
511   }
512
513   return false;
514 }
515
516 QString
517 VISU::GaussPoints_i
518 ::GetQAlphaTexture() 
519
520   return myAlphaTexture; 
521 }
522
523 char*
524 VISU::GaussPoints_i
525 ::GetAlphaTexture() 
526
527   return CORBA::string_dup(myAlphaTexture.latin1());
528 }
529
530
531 //----------------------------------------------------------------------------
532 void
533 VISU::GaussPoints_i
534 ::SetAlphaThreshold( CORBA::Double theAlphaThreshold )
535 {
536   VISU::TSetModified aModified(this);
537   
538   myGaussPointsPL->SetAlphaThreshold( theAlphaThreshold );
539 }
540
541 CORBA::Double
542 VISU::GaussPoints_i
543 ::GetAlphaThreshold()
544 {
545   return myGaussPointsPL->GetAlphaThreshold();
546 }
547
548 //----------------------------------------------------------------------------
549 void
550 VISU::GaussPoints_i
551 ::SetResolution( CORBA::Long theResolution )
552 {
553   VISU::TSetModified aModified(this);
554   
555   myGaussPointsPL->SetResolution( theResolution );
556 }
557
558 CORBA::Long
559 VISU::GaussPoints_i
560 ::GetResolution()
561 {
562   return myGaussPointsPL->GetResolution();
563 }
564
565 //----------------------------------------------------------------------------
566 void
567 VISU::GaussPoints_i
568 ::SetPrimitiveType(VISU::GaussPoints::PrimitiveType thePrimitiveType)
569 {
570   VISU::TSetModified aModified(this);
571   
572   myGaussPointsPL->SetPrimitiveType( thePrimitiveType );
573 }
574
575 VISU::GaussPoints::PrimitiveType
576 VISU::GaussPoints_i
577 ::GetPrimitiveType()
578 {
579   int aPrimitiveType = myGaussPointsPL->GetPrimitiveType();
580
581   if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint)
582     return VISU::GaussPoints::POINT;
583
584   if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere)
585     return VISU::GaussPoints::SPHERE;
586
587   return VISU::GaussPoints::SPRITE;
588 }
589
590 //----------------------------------------------------------------------------
591 vtkFloatingPointType
592 VISU::GaussPoints_i
593 ::GetMaximumSupportedSize()
594 {
595   return myGaussPointsPL->GetMaximumSupportedSize();
596 }
597
598 //----------------------------------------------------------------------------
599 void
600 VISU::GaussPoints_i
601 ::SetClamp(CORBA::Double theClamp)
602 {
603   VISU::TSetModified aModified(this);
604   
605   myGaussPointsPL->SetClamp( theClamp );
606 }
607
608 CORBA::Double
609 VISU::GaussPoints_i
610 ::GetClamp()
611 {
612   return myGaussPointsPL->GetClamp();
613 }
614
615 //----------------------------------------------------------------------------
616 void
617 VISU::GaussPoints_i
618 ::SetGeomSize( CORBA::Double theGeomSize )
619 {
620   VISU::TSetModified aModified(this);
621   
622   myGaussPointsPL->SetSize( theGeomSize );
623 }
624
625 CORBA::Double
626 VISU::GaussPoints_i
627 ::GetGeomSize()
628 {
629   return myGaussPointsPL->GetSize();
630 }
631
632 //----------------------------------------------------------------------------
633 void
634 VISU::GaussPoints_i
635 ::SetMinSize( CORBA::Double theMinSize )
636 {
637   VISU::TSetModified aModified(this);
638   
639   myGaussPointsPL->SetMinSize( theMinSize );
640 }
641
642 CORBA::Double
643 VISU::GaussPoints_i
644 ::GetMinSize()
645 {
646   return myGaussPointsPL->GetMinSize();
647 }
648
649 //----------------------------------------------------------------------------
650 void
651 VISU::GaussPoints_i
652 ::SetMaxSize( CORBA::Double theMaxSize )
653 {
654   VISU::TSetModified aModified(this);
655   
656   myGaussPointsPL->SetMaxSize( theMaxSize );
657 }
658
659 CORBA::Double
660 VISU::GaussPoints_i
661 ::GetMaxSize()
662 {
663   return myGaussPointsPL->GetMaxSize();
664 }
665
666 //----------------------------------------------------------------------------
667 void
668 VISU::GaussPoints_i
669 ::SetMagnification( CORBA::Double theMagnification )
670 {
671   VISU::TSetModified aModified(this);
672   
673   myGaussPointsPL->SetMagnification( theMagnification );
674 }
675
676 CORBA::Double
677 VISU::GaussPoints_i
678 ::GetMagnification()
679 {
680   return myGaussPointsPL->GetMagnification();
681 }
682
683 //----------------------------------------------------------------------------
684 void
685 VISU::GaussPoints_i
686 ::SetMagnificationIncrement( CORBA::Double theIncrement )
687 {
688   VISU::TSetModified aModified(this);
689   
690   myGaussPointsPL->SetMagnificationIncrement( theIncrement );
691 }
692
693 CORBA::Double
694 VISU::GaussPoints_i
695 ::GetMagnificationIncrement()
696 {
697   return myGaussPointsPL->GetMagnificationIncrement();
698 }
699
700 //----------------------------------------------------------------------------
701 void
702 VISU::GaussPoints_i
703 ::SetSourceGeometry()
704 {
705   int aNbGroups = myGroupNames.size();
706   if(aNbGroups != 0){
707     GetSpecificPL()->SetSourceGeometry();
708     myGroupNames.clear();
709     /*UpdateIcon();*/
710   }
711 }
712
713 //----------------------------------------------------------------------------
714 void
715 VISU::GaussPoints_i
716 ::AddMeshOnGroup(const char* theGroupName)
717 {
718   VISU::Result_i::PInput anInput = GetCResult()->GetInput();
719   VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName);
720   if(anIDMapper){
721     int aNbGroups  = myGroupNames.size();
722     if(myGroupNames.find(theGroupName) == myGroupNames.end()){
723       GetSpecificPL()->AddGeometry(anIDMapper->GetOutput());
724       myGroupNames.insert(theGroupName);
725       /*
726       if(aNbGroups == 0)
727         UpdateIcon();
728       */
729     }
730   }
731 }
732
733
734 //----------------------------------------------------------------------------
735 void
736 VISU::GaussPoints_i
737 ::RemoveAllGeom()
738 {
739   int aNbGroups  = myGroupNames.size();
740   GetSpecificPL()->ClearGeometry();
741   myGroupNames.clear();
742   /*
743   if(aNbGroups != 0)
744     UpdateIcon();
745   */
746 }
747
748 //----------------------------------------------------------------------------
749 void
750 VISU::GaussPoints_i
751 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
752 {
753   VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
754                                                           GetEntity(),
755                                                           GetCFieldName(),
756                                                           GetTimeStampNumber());
757   if(!anInput)
758     throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
759
760   SetField(anInput->GetField(GetCMeshName(),
761                              GetTEntity(),
762                              GetCFieldName()));
763   if(!GetField()) 
764     throw std::runtime_error("There is no Field with the parameters !!!");
765
766   VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
767     anInput->GetTimeStampOnGaussPts(GetCMeshName(),
768                                     GetTEntity(),
769                                     GetCFieldName(),
770                                     GetTimeStampNumber());
771   if(!aGaussPtsIDMapper) 
772     throw std::runtime_error("There is no TimeStamp with the parameters !!!");
773
774   GetSpecificPL()->SetGaussPtsIDMapper(aGaussPtsIDMapper);
775 }
776
777
778 //----------------------------------------------------------------------------
779 bool
780 VISU::GaussPoints_i
781 ::CheckIsPossible() 
782 {
783   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
784 }
785
786
787 //----------------------------------------------------------------------------
788 void
789 VISU::GaussPoints_i
790 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
791 {
792   if(!thePipeLine){
793     myGaussPointsPL = VISU_GaussPointsPL::New();
794   }else
795     myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
796
797   TSuperClass::CreatePipeLine(myGaussPointsPL);
798 }
799
800
801 //----------------------------------------------------------------------------
802 VISU_PipeLine* 
803 VISU::GaussPoints_i
804 ::GetActorPipeLine()
805 {
806   // We create a new PipeLine instance in order to provide
807   //   different representations for different actors (basic and segmented)
808   VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
809   aPipeLine->ShallowCopy(GetPipeLine(), true);
810   return aPipeLine;
811 }
812
813
814 //----------------------------------------------------------------------------
815 bool 
816 VISU::GaussPoints_i
817 ::OnCreateActor(VISU_GaussPtsAct* theActor)
818 {
819   try{
820     TSuperClass::CreateActor(theActor);
821     UpdateActor(theActor);
822     return true;
823   }catch(...){
824     theActor->Delete();
825     throw ;
826   }
827   return false;
828 }
829
830 VISU_GaussPtsAct1* 
831 VISU::GaussPoints_i
832 ::OnCreateActor1()
833 {
834   VISU_GaussPtsAct1* anActor = VISU_GaussPtsAct1::New();
835   if(OnCreateActor(anActor))
836     return anActor;
837   return NULL;
838 }
839
840 VISU_GaussPtsAct2* 
841 VISU::GaussPoints_i
842 ::OnCreateActor2()
843 {
844   VISU_GaussPtsAct2* anActor = VISU_GaussPtsAct2::New();
845   if(OnCreateActor(anActor))
846     return anActor;
847   return NULL;
848 }
849
850 VISU_Actor* 
851 VISU::GaussPoints_i
852 ::CreateActor() 
853 {
854   return OnCreateActor1();
855 }
856
857 //----------------------------------------------------------------------------
858 VISU_GaussPtsAct2* 
859 VISU::GaussPoints_i
860 ::CloneActor(VISU_GaussPtsAct1* theActor) 
861 {
862   if(MYDEBUG) MESSAGE("GaussPoints_i::CloneActor - this = "<<this);
863   if(VISU_GaussPtsAct2* anActor = OnCreateActor2()){
864     theActor->Connect(anActor);
865     return anActor;
866   }
867   return NULL;
868 }
869
870
871 //----------------------------------------------------------------------------
872 void
873 VISU::GaussPoints_i
874 ::UpdateScalarBar(VISU_ScalarBarActor *theScalarBar,
875                   VISU_LookupTable* theLookupTable)
876 {
877   theScalarBar->SetTitle(GetScalarBarTitle().c_str());
878   theScalarBar->SetOrientation(GetBarOrientation());
879   theScalarBar->SetNumberOfLabels(GetLabels());
880   theScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(),
881                           GetLabelWidth(), GetLabelHeight(),
882                           GetBarWidth(), GetBarHeight());
883   theScalarBar->SetLabelFormat(GetLabelsFormat());
884
885   VISU_LookupTable* aLookupTable = GetSpecificPL()->GetBarTable();
886   
887   theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors());
888   theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors());
889
890   vtkFloatingPointType anRGB[3];
891
892   vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty();
893   aTitleProp->SetFontFamily(GetTitFontType());
894
895   GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]);
896   aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
897
898   IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
899   IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
900   IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
901   
902   vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty();
903   aLabelProp->SetFontFamily(GetLblFontType());
904
905   GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]);
906   aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
907
908   IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
909   IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
910   IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
911   
912   theScalarBar->Modified();
913 }
914
915
916 //----------------------------------------------------------------------------
917 void 
918 VISU::GaussPoints_i
919 ::UpdateActor(VISU_Actor* theActor) 
920 {
921   if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
922     VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl();
923     if(GetIsColored()){
924       anActor->SetBarVisibility(true);
925       GetPipeLine()->GetMapper()->SetScalarVisibility(1);
926
927       if(IsRangeFixed()){
928         vtkFloatingPointType* aRange = GetSpecificPL()->GetScalarRange();
929         aScalarBarCtrl->SetRangeLocal(aRange);
930       }else{
931         vtkFloatingPointType aRange[2];
932         GetSpecificPL()->GetSourceRange(aRange);
933         aScalarBarCtrl->SetRangeLocal(aRange);
934       }
935
936       bool anIsMinMaxDone = IsGlobalRangeDefined();
937       aScalarBarCtrl->SetGlobalRangeIsDefined(anIsMinMaxDone);
938
939       TMinMax aTMinMax( GetComponentMin( GetScalarMode() ),
940                         GetComponentMax( GetScalarMode() ));
941       aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second);
942       
943       VISU_ScalarBarCtrl::EMode aScalarBarMode = VISU_ScalarBarCtrl::eGlobal;
944       if(myIsActiveLocalScalarBar){
945         if(myIsDispGlobalScalarBar){
946           aScalarBarMode = VISU_ScalarBarCtrl::eLocal; 
947         }else{
948           aScalarBarMode = VISU_ScalarBarCtrl::eSimple; 
949         }
950       }
951       
952       if(aScalarBarMode == VISU_ScalarBarCtrl::eGlobal){
953         vtkFloatingPointType aRangeGlobal[2];
954         //
955         aRangeGlobal[0] = aTMinMax.first;
956         aRangeGlobal[1] = aTMinMax.second;
957         
958         GetSpecificPL()->GetMapper()->SetScalarRange(aRangeGlobal);
959       }
960       
961       aScalarBarCtrl->SetMode(aScalarBarMode);
962       
963       // Position
964       aScalarBarCtrl->SetWidth(GetWidth());
965       aScalarBarCtrl->SetHeight(GetHeight());
966
967       vtkFloatingPointType aPosition[] = {GetPosX(), GetPosY()};
968       aScalarBarCtrl->SetPosition(aPosition);
969       
970       aScalarBarCtrl->SetSpacing(mySpacing);
971       
972       // Bicolor
973       bool anIsBicolor = GetSpecificPL()->GetBicolor();
974       aScalarBarCtrl->SetBicolor(anIsBicolor);
975       
976       UpdateScalarBar(aScalarBarCtrl->GetLocalBar(),
977                       aScalarBarCtrl->GetLocalTable());
978       
979       UpdateScalarBar(aScalarBarCtrl->GetGlobalBar(),
980                       aScalarBarCtrl->GetGlobalTable());
981
982       aScalarBarCtrl->Update();
983     }else{
984       anActor->SetBarVisibility(false);
985
986       GetPipeLine()->GetMapper()->SetScalarVisibility(0);
987
988       anActor->GetProperty()->SetColor(myColor.red() / 255.0,
989                                        myColor.green() / 255.0,
990                                        myColor.blue() / 255.0);
991     }
992
993     if( GetSpecificPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
994       theActor->SetRepresentation( VTK_POINTS );
995     else
996       theActor->SetRepresentation( VTK_SURFACE );
997   }
998   TSuperClass::UpdateActor(theActor);
999 }
1000
1001 //----------------------------------------------------------------------------
1002 void
1003 VISU::GaussPoints_i
1004 ::UpdateFromActor(VISU_GaussPtsAct* theActor) 
1005 {
1006   if(MYDEBUG) MESSAGE("GaussPoints_i::UpdateFromActor - this = "<<this);
1007   myGaussPointsPL->ChangeMagnification(theActor->GetChangeMagnification());
1008   myParamsTime.Modified();
1009   UpdateActors();
1010 }
1011
1012
1013 //----------------------------------------------------------------------------
1014 void
1015 VISU::GaussPoints_i
1016 ::SetQTextures( const QString& theMainTexture, 
1017                 const QString& theAlphaTexture )
1018 {
1019   bool updateMainTexture = SetMainTexture( theMainTexture );
1020   bool updateAlphaTexture = SetAlphaTexture( theAlphaTexture );
1021   if( !updateMainTexture && !updateAlphaTexture )
1022     return;
1023
1024   VISU::TSetModified aModified(this);
1025   
1026   using namespace VISU;
1027   TTextureValue aTextureValue = GetTexture(theMainTexture, theAlphaTexture);
1028   myGaussPointsPL->SetImageData( aTextureValue.GetPointer() );
1029 }
1030
1031 void
1032 VISU::GaussPoints_i
1033 ::SetTextures( const char* theMainTexture, 
1034                const char* theAlphaTexture )
1035 {
1036   SetQTextures(theMainTexture, theAlphaTexture);
1037 }
1038
1039
1040 //----------------------------------------------------------------------------
1041 void
1042 VISU::GaussPoints_i
1043 ::SetIsActiveLocalScalarBar(CORBA::Boolean theIsActiveLocalScalarBar)
1044 {
1045   if(myIsActiveLocalScalarBar == theIsActiveLocalScalarBar)
1046     return;
1047
1048   VISU::TSetModified aModified(this);
1049   
1050   myIsActiveLocalScalarBar = theIsActiveLocalScalarBar;
1051
1052   if ( !theIsActiveLocalScalarBar || !IsRangeFixed() )
1053     SetSourceRange();
1054
1055   myParamsTime.Modified();
1056 }
1057
1058 CORBA::Boolean
1059 VISU::GaussPoints_i
1060 ::GetIsActiveLocalScalarBar() 
1061 {
1062   return myIsActiveLocalScalarBar;
1063 }
1064
1065 void
1066 VISU::GaussPoints_i
1067 ::SetIsDispGlobalScalarBar(CORBA::Boolean theIsDispGlobalScalarBar)
1068 {
1069   if(myIsDispGlobalScalarBar == theIsDispGlobalScalarBar)
1070     return;
1071
1072   VISU::TSetModified aModified(this);
1073   
1074   myIsDispGlobalScalarBar = theIsDispGlobalScalarBar;
1075   myParamsTime.Modified();
1076 }
1077
1078 bool
1079 VISU::GaussPoints_i
1080 ::IsGlobalRangeDefined() const 
1081 {
1082   return GetCResult()->IsMinMaxDone();
1083 }
1084
1085 //----------------------------------------------------------------------------
1086 void
1087 VISU::GaussPoints_i
1088 ::SetSourceRange()
1089 {
1090   VISU::TSetModified aModified(this);
1091
1092   vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()};
1093   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
1094                    (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
1095
1096   UseFixedRange(false);
1097 }
1098
1099
1100 //----------------------------------------------------------------------------
1101 struct TGetSourceMin: public SALOME_Event
1102 {
1103   VISU::GaussPoints_i* myColoredPrs3d;
1104
1105   typedef CORBA::Double TResult;
1106   TResult myResult;
1107   
1108   TGetSourceMin( VISU::GaussPoints_i* theColoredPrs3d ):
1109     myColoredPrs3d( theColoredPrs3d )
1110   {}
1111     
1112   virtual
1113   void
1114   Execute()
1115   {
1116     if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1117       vtkFloatingPointType aRange[2];
1118       myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1119       myResult = aRange[0];
1120     }else{
1121       VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode() );
1122       myResult = aTMinMax.first;
1123     }
1124   }
1125 };
1126
1127
1128 //----------------------------------------------------------------------------
1129 CORBA::Double 
1130 VISU::GaussPoints_i
1131 ::GetSourceMin()
1132 {
1133   return ProcessEvent( new TGetSourceMin( this ) );
1134 }
1135
1136
1137 //----------------------------------------------------------------------------
1138 struct TGetSourceMax: public SALOME_Event
1139 {
1140   VISU::GaussPoints_i* myColoredPrs3d;
1141
1142   typedef CORBA::Double TResult;
1143   TResult myResult;
1144   
1145   TGetSourceMax( VISU::GaussPoints_i* theColoredPrs3d ):
1146     myColoredPrs3d( theColoredPrs3d )
1147   {}
1148     
1149   virtual
1150   void
1151   Execute()
1152   {
1153     if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1154       vtkFloatingPointType aRange[2];
1155       myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1156       myResult = aRange[1];
1157     }else{
1158       VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode() );
1159       myResult = aTMinMax.second;
1160     }
1161   }
1162 };
1163
1164
1165 //----------------------------------------------------------------------------
1166 CORBA::Double 
1167 VISU::GaussPoints_i
1168 ::GetSourceMax()
1169 {
1170   return ProcessEvent( new TGetSourceMax( this ) );
1171 }
1172
1173
1174 //----------------------------------------------------------------------------
1175 CORBA::Boolean
1176 VISU::GaussPoints_i
1177 ::GetIsDispGlobalScalarBar()
1178 {
1179   return myIsDispGlobalScalarBar;
1180 }
1181
1182
1183 void
1184 VISU::GaussPoints_i
1185 ::SetBiColor(CORBA::Boolean theIsBiColor)
1186 {
1187   VISU::TSetModified aModified(this);
1188
1189   GetSpecificPL()->SetBicolor(theIsBiColor);
1190 }
1191
1192 CORBA::Boolean
1193 VISU::GaussPoints_i
1194 ::GetBiColor() 
1195 {
1196   return GetSpecificPL()->GetBicolor();
1197 }
1198
1199 void
1200 VISU::GaussPoints_i
1201 ::SetSpacing(CORBA::Double theSpacing)
1202 {
1203   if(VISU::CheckIsSameValue(mySpacing, theSpacing))
1204     return;
1205
1206   VISU::TSetModified aModified(this);
1207
1208   mySpacing = theSpacing;
1209   myParamsTime.Modified();
1210 }
1211
1212 CORBA::Double
1213 VISU::GaussPoints_i
1214 ::GetSpacing()
1215 {
1216   return mySpacing;
1217 }