1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
27 #include "VISU_GaussPoints_i.hh"
28 #include "VISU_ScalarMap_i.hh"
29 #include "VISU_Prs3dUtils.hh"
31 #include "VISU_Result_i.hh"
32 #include "VISU_GaussPtsAct.h"
33 #include "VISU_GaussPointsPL.hxx"
34 #include "VISU_GaussPtsDeviceActor.h"
36 #include "VISU_OpenGLPointSpriteMapper.hxx"
37 #include "VISU_ScalarBarCtrl.hxx"
38 #include <VISU_ScalarBarActor.hxx>
39 #include "VISU_LookupTable.hxx"
40 #include "VISU_MedConvertor.hxx"
42 #include "SUIT_ResourceMgr.h"
44 #include "VISU_PipeLineUtils.hxx"
46 #include <vtkImageData.h>
47 #include <vtkXMLImageDataReader.h>
48 #include <vtkTextProperty.h>
49 #include <vtkProperty.h>
52 static int MYDEBUG = 0;
54 static int MYDEBUG = 0;
57 static int INCMEMORY = 10;
61 //----------------------------------------------------------------------------
64 ::IsPossible(Result_i* theResult,
65 const std::string& theMeshName,
66 VISU::Entity theEntity,
67 const std::string& theFieldName,
68 CORBA::Long theTimeStampNumber,
69 bool theIsMemoryCheck)
72 if(theEntity == VISU::NODE)
75 bool anIsEstimated = true;
76 VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
80 if(!dynamic_cast<const VISU_MedConvertor*>(anInput.get()))
82 size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
83 VISU::TEntity(theEntity),
91 aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
93 MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
95 }catch(std::exception& exc){
96 INFOS("Follow exception was occured :\n"<<exc.what());
98 INFOS("Unknown exception was occured!");
103 //----------------------------------------------------------------------------
104 int VISU::GaussPoints_i::myNbPresent = 0;
110 return VISU::GenerateName("Gauss Points",myNbPresent++);
113 //----------------------------------------------------------------------------
114 const string VISU::GaussPoints_i::myComment = "GAUSSPOINTS";
120 return myComment.c_str();
124 //---------------------------------------------------------------
129 return "ICON_TREE_GAUSS_POINTS";
133 //----------------------------------------------------------------------------
135 ::GaussPoints_i(EPublishInStudyMode thePublishInStudyMode) :
136 ColoredPrs3d_i(thePublishInStudyMode),
137 myGaussPointsPL(NULL),
139 myIsActiveLocalScalarBar(true),
140 myIsDispGlobalScalarBar(true),
145 if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
149 //----------------------------------------------------------------------------
152 ::Create(const std::string& theMeshName,
153 VISU::Entity theEntity,
154 const std::string& theFieldName,
155 CORBA::Long theTimeStampNumber)
157 TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
159 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
161 int anActiveLocal = aResourceMgr->integerValue( "VISU", "scalar_bar_active_local", GetIsActiveLocalScalarBar() );
162 SetIsActiveLocalScalarBar( anActiveLocal == 0 );
164 bool aDisplayGlobal = aResourceMgr->booleanValue( "VISU", "scalar_bar_diplay_global", GetIsDispGlobalScalarBar() );
165 SetIsDispGlobalScalarBar( aDisplayGlobal );
167 int aBicolor = aResourceMgr->integerValue( "VISU", "scalar_bar_bicolor", GetBiColor() );
168 SetBiColor( aBicolor == 0 );
170 vtkFloatingPointType aSpacing = aResourceMgr->doubleValue( "VISU", "scalar_bar_spacing", GetSpacing() );
171 SetSpacing( aSpacing );
173 vtkFloatingPointType aScaleFactor = aResourceMgr->doubleValue( "VISU", "deformed_shape_scale_factor", GetScaleFactor() );
174 SetScaleFactor( aScaleFactor );
176 int aPrimitiveType = aResourceMgr->integerValue( "VISU", "point_sprite_primitive_type", GetPrimitiveType() );
177 SetPrimitiveType( VISU::GaussPoints::PrimitiveType(aPrimitiveType) );
179 vtkFloatingPointType aClamp = aResourceMgr->doubleValue( "VISU", "point_sprite_clamp", GetClamp() );
182 int aMinSize = aResourceMgr->integerValue( "VISU", "point_sprite_min_size", ( int )( GetMinSize() * 100.0 ) );
183 SetMinSize( aMinSize / 100.0 );
185 int aMaxSize = aResourceMgr->integerValue( "VISU", "point_sprite_max_size", ( int )( GetMaxSize() * 100.0 ) );
186 SetMaxSize( aMaxSize / 100.0 );
188 int aGeomSize = aResourceMgr->integerValue( "VISU", "point_sprite_size", ( int )( GetGeomSize() * 100.0 ) );
189 SetGeomSize( aGeomSize / 100.0 );
191 int aMagnification = aResourceMgr->integerValue( "VISU", "point_sprite_magnification", ( int )( GetMagnification() * 100.0 ) );
192 SetMagnification( aMagnification / 100.0 );
194 vtkFloatingPointType anIncrement = aResourceMgr->doubleValue( "VISU", "point_sprite_increment", GetMagnificationIncrement() );
195 SetMagnificationIncrement( anIncrement );
197 bool isColored = aResourceMgr->booleanValue( "VISU", "point_sprite_results", GetIsColored() );
198 SetIsColored( isColored );
200 QColor aColor = aResourceMgr->colorValue( "VISU", "point_sprite_color", GetQColor() );
203 vtkFloatingPointType anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "point_sprite_alpha_threshold", GetAlphaThreshold() );
204 SetAlphaThreshold( anAlphaThreshold );
206 int aResolution = aResourceMgr->integerValue( "VISU", "geom_sphere_resolution", GetResolution() );
207 SetResolution( aResolution );
209 int aFaceLimit = aResourceMgr->integerValue( "VISU", "geom_sphere_face_limit", GetFaceLimit() );
210 SetFaceLimit( aFaceLimit );
212 QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_texture.bmp";
213 aMainTexture = aResourceMgr->stringValue( "VISU", "point_sprite_main_texture", aMainTexture );
215 QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_alpha.bmp";
216 anAlphaTexture = aResourceMgr->stringValue( "VISU", "point_sprite_alpha_texture", anAlphaTexture );
218 SetTextures( aMainTexture.toLatin1().data(), anAlphaTexture.toLatin1().data() );
226 //---------------------------------------------------------------
229 ::SameAs(const Prs3d_i* theOrigin)
231 TSuperClass::SameAs(theOrigin);
233 if(const GaussPoints_i* aPrs3d = dynamic_cast<const GaussPoints_i*>(theOrigin)){
234 GaussPoints_i* anOrigin = const_cast<GaussPoints_i*>(aPrs3d);
236 SetIsActiveLocalScalarBar(anOrigin->GetIsActiveLocalScalarBar());
237 SetIsDispGlobalScalarBar(anOrigin->GetIsDispGlobalScalarBar());
239 SetSpacing(anOrigin->GetSpacing());
241 SetFaceLimit(anOrigin->GetFaceLimit());
243 SetColor(anOrigin->GetColor());
245 SetBarVisible(anOrigin->IsBarVisible());
247 SetTextures(anOrigin->GetMainTexture(), anOrigin->GetAlphaTexture());
251 //----------------------------------------------------------------------------
256 return TSuperClass::GetMemorySize();
259 //----------------------------------------------------------------------------
262 ::Restore(SALOMEDS::SObject_ptr theSObject,
263 const Storable::TRestoringMap& theMap)
265 if(!TSuperClass::Restore(theSObject, theMap))
268 // Check if the icon needs to be updated, update if necessary
269 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
270 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
271 SALOMEDS::GenericAttribute_var anAttr =
272 aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributePixMap");
273 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
275 CORBA::String_var aPixMapName = aPixmap->GetPixMap();
276 if(strcmp(GetIconName(), aPixMapName.in()) != 0)
277 aPixmap->SetPixMap(GetIconName());
279 QString aVal = VISU::Storable::FindValue(theMap,"myShowBar", "1");
280 SetBarVisible((aVal.toInt() == 1)? true : false);
282 SetIsActiveLocalScalarBar(Storable::FindValue(theMap,"myIsActiveLocalScalarBar").toInt());
283 SetIsDispGlobalScalarBar(Storable::FindValue(theMap,"myIsDispGlobalScalarBar").toInt());
284 SetBiColor(Storable::FindValue(theMap,"myIsBiColor").toInt());
285 SetSpacing(Storable::FindValue(theMap,"mySpacing").toDouble());
287 int aPrimitiveType = Storable::FindValue(theMap,"myPrimitiveType").toInt();
288 SetPrimitiveType(VISU::GaussPoints::PrimitiveType(aPrimitiveType));
289 SetClamp(Storable::FindValue(theMap,"myClamp").toDouble());
290 SetMinSize(Storable::FindValue(theMap,"myMinSize").toDouble());
291 SetMaxSize(Storable::FindValue(theMap,"myMaxSize").toDouble());
292 SetGeomSize(Storable::FindValue(theMap,"myGeomSize").toDouble());
294 SetMagnification(Storable::FindValue(theMap,"myMagnification").toDouble());
295 SetMagnificationIncrement(Storable::FindValue(theMap,"myMagnificationIncrement").toDouble());
297 SetIsDeformed(Storable::FindValue(theMap,"myIsDeformed").toInt());
298 SetScaleFactor(Storable::FindValue(theMap,"myScaleFactor").toDouble());
300 SetFaceLimit(Storable::FindValue(theMap,"myFaceLimit").toInt());
302 SetIsColored(Storable::FindValue(theMap,"myIsColored").toInt());
303 int aRed = Storable::FindValue(theMap,"myColor.R").toInt();
304 int aGreen = Storable::FindValue(theMap,"myColor.G").toInt();
305 int aBlue = Storable::FindValue(theMap,"myColor.B").toInt();
306 SetQColor( QColor(aRed, aGreen, aBlue) );
308 SetAlphaThreshold(Storable::FindValue(theMap,"myAlphaThreshold").toDouble());
310 SetTextures( Storable::FindValue(theMap,"myMainTexture").toLatin1().data(),
311 Storable::FindValue(theMap,"myAlphaTexture").toLatin1().data() );
313 SetResolution(Storable::FindValue(theMap,"myResolution").toInt());
319 //----------------------------------------------------------------------------
322 ::ToStream(std::ostringstream& theStr)
324 TSuperClass::ToStream(theStr);
326 Storable::DataToStream( theStr, "myIsActiveLocalScalarBar", myIsActiveLocalScalarBar );
327 Storable::DataToStream( theStr, "myIsDispGlobalScalarBar", myIsDispGlobalScalarBar );
328 Storable::DataToStream( theStr, "myIsBiColor", GetBiColor() );
329 Storable::DataToStream( theStr, "mySpacing", GetSpacing() );
331 Storable::DataToStream( theStr, "myPrimitiveType", GetPrimitiveType() );
332 Storable::DataToStream( theStr, "myClamp", GetClamp() );
333 Storable::DataToStream( theStr, "myMinSize", GetMinSize() );
334 Storable::DataToStream( theStr, "myMaxSize", GetMaxSize() );
335 Storable::DataToStream( theStr, "myGeomSize", GetGeomSize() );
337 Storable::DataToStream( theStr, "myMagnification", GetMagnification() );
338 Storable::DataToStream( theStr, "myMagnificationIncrement", GetMagnificationIncrement() );
340 Storable::DataToStream( theStr, "myIsDeformed", GetIsDeformed() );
341 Storable::DataToStream( theStr, "myScaleFactor", GetScaleFactor() );
343 Storable::DataToStream( theStr, "myFaceLimit", GetFaceLimit() );
345 Storable::DataToStream( theStr, "myIsColored", GetIsColored() );
346 QColor aColor = GetQColor();
347 Storable::DataToStream( theStr, "myColor.R", aColor.red() );
348 Storable::DataToStream( theStr, "myColor.G", aColor.green() );
349 Storable::DataToStream( theStr, "myColor.B", aColor.blue() );
351 Storable::DataToStream( theStr, "myAlphaThreshold", GetAlphaThreshold() );
352 Storable::DataToStream( theStr, "myMainTexture", GetQMainTexture() );
353 Storable::DataToStream( theStr, "myAlphaTexture", GetQAlphaTexture() );
355 Storable::DataToStream( theStr, "myResolution", GetResolution() );
356 Storable::DataToStream( theStr, "myShowBar", (IsBarVisible()? 1:0) );
363 if(MYDEBUG) MESSAGE("GaussPoints_i::~GaussPoints_i() - this = "<<this);
367 //----------------------------------------------------------------------------
375 //----------------------------------------------------------------------------
378 ::SetFaceLimit( CORBA::Long theFaceLimit )
380 if( myFaceLimit == theFaceLimit )
383 VISU::TSetModified aModified(this);
385 myFaceLimit = theFaceLimit;
386 myParamsTime.Modified();
389 //----------------------------------------------------------------------------
392 ::SetIsDeformed( CORBA::Boolean theIsDeformed )
394 VISU::TSetModified aModified(this);
396 myGaussPointsPL->SetIsDeformed( theIsDeformed );
403 return myGaussPointsPL->GetIsDeformed();
406 //----------------------------------------------------------------------------
409 ::SetScaleFactor( CORBA::Double theScaleFactor )
411 VISU::TSetModified aModified(this);
413 myGaussPointsPL->SetScale( theScaleFactor );
420 return myGaussPointsPL->GetScale();
423 //----------------------------------------------------------------------------
435 SALOMEDS::Color aColor;
436 aColor.R = myColor.red();
437 aColor.G = myColor.green();
438 aColor.B = myColor.blue();
443 //----------------------------------------------------------------------------
446 ::SetQColor( const QColor& theColor )
448 if(myColor == theColor)
451 VISU::TSetModified aModified(this);
454 myParamsTime.Modified();
459 ::SetColor( const SALOMEDS::Color& theColor )
461 SetQColor(QColor(int(theColor.R), int(theColor.G), int(theColor.B)));
465 //----------------------------------------------------------------------------
468 ::SetIsColored( bool theIsColored )
470 VISU::TSetModified aModified(this);
472 myGaussPointsPL->SetIsColored( theIsColored );
479 return myGaussPointsPL->GetIsColored();
482 //----------------------------------------------------------------------------
485 ::SetMainTexture( const QString& theMainTexture )
487 if(myMainTexture != theMainTexture){
488 VISU::TSetModified aModified(this);
490 myMainTexture = theMainTexture;
491 myParamsTime.Modified();
502 return myMainTexture;
509 return CORBA::string_dup(myMainTexture.toLatin1().data());
513 //----------------------------------------------------------------------------
516 ::SetAlphaTexture( const QString& theAlphaTexture )
518 if(myAlphaTexture != theAlphaTexture){
519 VISU::TSetModified aModified(this);
521 myAlphaTexture = theAlphaTexture;
522 myParamsTime.Modified();
533 return myAlphaTexture;
540 return CORBA::string_dup(myAlphaTexture.toLatin1().data());
544 //----------------------------------------------------------------------------
547 ::SetAlphaThreshold( CORBA::Double theAlphaThreshold )
549 VISU::TSetModified aModified(this);
551 myGaussPointsPL->SetAlphaThreshold( theAlphaThreshold );
556 ::GetAlphaThreshold()
558 return myGaussPointsPL->GetAlphaThreshold();
561 //----------------------------------------------------------------------------
564 ::SetResolution( CORBA::Long theResolution )
566 VISU::TSetModified aModified(this);
568 myGaussPointsPL->SetResolution( theResolution );
575 return myGaussPointsPL->GetResolution();
578 //----------------------------------------------------------------------------
581 ::SetPrimitiveType(VISU::GaussPoints::PrimitiveType thePrimitiveType)
583 VISU::TSetModified aModified(this);
585 myGaussPointsPL->SetPrimitiveType( thePrimitiveType );
588 VISU::GaussPoints::PrimitiveType
592 int aPrimitiveType = myGaussPointsPL->GetPrimitiveType();
594 if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint)
595 return VISU::GaussPoints::POINT;
597 if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere)
598 return VISU::GaussPoints::SPHERE;
600 return VISU::GaussPoints::SPRITE;
603 //----------------------------------------------------------------------------
606 ::GetMaximumSupportedSize()
608 return myGaussPointsPL->GetMaximumSupportedSize();
611 //----------------------------------------------------------------------------
614 ::SetClamp(CORBA::Double theClamp)
616 VISU::TSetModified aModified(this);
618 myGaussPointsPL->SetClamp( theClamp );
625 return myGaussPointsPL->GetClamp();
628 //----------------------------------------------------------------------------
631 ::SetGeomSize( CORBA::Double theGeomSize )
633 VISU::TSetModified aModified(this);
635 myGaussPointsPL->SetSize( theGeomSize );
642 return myGaussPointsPL->GetSize();
645 //----------------------------------------------------------------------------
648 ::SetMinSize( CORBA::Double theMinSize )
650 VISU::TSetModified aModified(this);
652 myGaussPointsPL->SetMinSize( theMinSize );
659 return myGaussPointsPL->GetMinSize();
662 //----------------------------------------------------------------------------
665 ::SetMaxSize( CORBA::Double theMaxSize )
667 VISU::TSetModified aModified(this);
669 myGaussPointsPL->SetMaxSize( theMaxSize );
676 return myGaussPointsPL->GetMaxSize();
679 //----------------------------------------------------------------------------
682 ::SetMagnification( CORBA::Double theMagnification )
684 VISU::TSetModified aModified(this);
686 myGaussPointsPL->SetMagnification( theMagnification );
693 return myGaussPointsPL->GetMagnification();
696 //----------------------------------------------------------------------------
699 ::SetMagnificationIncrement( CORBA::Double theIncrement )
701 VISU::TSetModified aModified(this);
703 myGaussPointsPL->SetMagnificationIncrement( theIncrement );
708 ::GetMagnificationIncrement()
710 return myGaussPointsPL->GetMagnificationIncrement();
713 //----------------------------------------------------------------------------
716 ::SetSourceGeometry()
718 int aNbGroups = myGroupNames.size();
720 GetSpecificPL()->SetSourceGeometry();
721 myGroupNames.clear();
726 //----------------------------------------------------------------------------
729 ::AddMeshOnGroup(const char* theGroupName)
731 VISU::Result_i::PInput anInput = GetCResult()->GetInput();
732 VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName);
734 int aNbGroups = myGroupNames.size();
735 if(myGroupNames.find(theGroupName) == myGroupNames.end()){
736 GetSpecificPL()->AddGeometry(anIDMapper->GetOutput(), theGroupName);
737 myGroupNames.insert(theGroupName);
742 // To update scalar range according to the new input (IPAL21305)
750 //----------------------------------------------------------------------------
755 int aNbGroups = myGroupNames.size();
756 GetSpecificPL()->ClearGeometry();
757 myGroupNames.clear();
764 //----------------------------------------------------------------------------
767 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
769 VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
772 GetTimeStampNumber());
774 throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
776 SetField(anInput->GetField(GetCMeshName(),
780 throw std::runtime_error("There is no Field with the parameters !!!");
782 VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
783 anInput->GetTimeStampOnGaussPts(GetCMeshName(),
786 GetTimeStampNumber());
787 if(!aGaussPtsIDMapper)
788 throw std::runtime_error("There is no TimeStamp with the parameters !!!");
790 GetSpecificPL()->SetGaussPtsIDMapper(aGaussPtsIDMapper);
794 //----------------------------------------------------------------------------
799 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
802 void VISU::GaussPoints_i::SetBarVisible(CORBA::Boolean theVisible)
804 if (myShowBar == theVisible)
806 VISU::TSetModified aModified(this);
807 myShowBar = theVisible;
808 myParamsTime.Modified();
811 //----------------------------------------------------------------------------
814 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
817 myGaussPointsPL = VISU_GaussPointsPL::New();
819 myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
821 TSuperClass::CreatePipeLine(myGaussPointsPL);
825 //----------------------------------------------------------------------------
830 // We create a new PipeLine instance in order to provide
831 // different representations for different actors (basic and segmented)
832 VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
833 aPipeLine->ShallowCopy(GetPipeLine(), true);
838 //----------------------------------------------------------------------------
841 ::OnCreateActor(VISU_GaussPtsAct* theActor)
844 TSuperClass::CreateActor(theActor);
845 UpdateActor(theActor);
858 VISU_GaussPtsAct1* anActor = VISU_GaussPtsAct1::New();
859 if(OnCreateActor(anActor))
868 VISU_GaussPtsAct2* anActor = VISU_GaussPtsAct2::New();
869 if(OnCreateActor(anActor))
878 VISU_GaussPtsAct* anActor = VISU_GaussPtsAct::New();
879 anActor->SetBarVisibility(myShowBar);
880 if(OnCreateActor(anActor))
883 // return OnCreateActor1();
886 //----------------------------------------------------------------------------
889 ::CloneActor(VISU_GaussPtsAct1* theActor)
891 if(MYDEBUG) MESSAGE("GaussPoints_i::CloneActor - this = "<<this);
892 if(VISU_GaussPtsAct2* anActor = OnCreateActor2()){
893 theActor->Connect(anActor);
900 //----------------------------------------------------------------------------
903 ::UpdateScalarBar(VISU_ScalarBarActor *theScalarBar,
904 VISU_LookupTable* theLookupTable)
906 theScalarBar->SetTitle(GetScalarBarTitle().c_str());
907 theScalarBar->SetOrientation(GetBarOrientation());
908 theScalarBar->SetNumberOfLabels(GetLabels());
909 theScalarBar->SetRatios(GetTitleSize(), GetLabelSize(),
910 GetBarWidth(), GetBarHeight());
911 theScalarBar->SetLabelFormat(GetLabelsFormat());
913 VISU_LookupTable* aLookupTable = GetSpecificPL()->GetBarTable();
915 theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors());
916 theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors());
918 vtkFloatingPointType anRGB[3];
920 vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty();
921 aTitleProp->SetFontFamily(GetTitFontType());
923 GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
924 aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
926 IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
927 IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
928 IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
930 vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty();
931 aLabelProp->SetFontFamily(GetLblFontType());
933 GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
934 aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
936 IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
937 IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
938 IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
940 theScalarBar->Modified();
944 //----------------------------------------------------------------------------
947 ::UpdateActor(VISU_ActorBase* theActor)
949 if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
950 VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl();
952 GetPipeLine()->GetMapper()->SetScalarVisibility(1);
955 vtkFloatingPointType* aRange = GetSpecificPL()->GetScalarRange();
956 aScalarBarCtrl->SetRangeLocal(aRange);
958 vtkFloatingPointType aRange[2];
959 GetSpecificPL()->GetSourceRange(aRange);
960 aScalarBarCtrl->SetRangeLocal(aRange);
963 bool anIsMinMaxDone = IsGlobalRangeDefined();
964 aScalarBarCtrl->SetGlobalRangeIsDefined(anIsMinMaxDone);
966 TMinMax aTMinMax( GetComponentMin( GetScalarMode() ),
967 GetComponentMax( GetScalarMode() ));
968 aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second);
970 VISU_ScalarBarCtrl::EMode aScalarBarMode = VISU_ScalarBarCtrl::eGlobal;
971 if(myIsActiveLocalScalarBar){
972 if(myIsDispGlobalScalarBar){
973 aScalarBarMode = VISU_ScalarBarCtrl::eLocal;
975 aScalarBarMode = VISU_ScalarBarCtrl::eSimple;
979 if(aScalarBarMode == VISU_ScalarBarCtrl::eGlobal){
980 vtkFloatingPointType aRangeGlobal[2];
982 aRangeGlobal[0] = aTMinMax.first;
983 aRangeGlobal[1] = aTMinMax.second;
985 GetSpecificPL()->GetMapper()->SetScalarRange(aRangeGlobal);
988 aScalarBarCtrl->SetMode(aScalarBarMode);
991 aScalarBarCtrl->SetWidth(GetWidth());
992 aScalarBarCtrl->SetHeight(GetHeight());
994 vtkFloatingPointType aPosition[] = {GetPosX(), GetPosY()};
995 aScalarBarCtrl->SetPosition(aPosition);
997 aScalarBarCtrl->SetSpacing(mySpacing);
1000 bool anIsBicolor = GetSpecificPL()->GetBicolor();
1001 aScalarBarCtrl->SetBicolor(anIsBicolor);
1003 UpdateScalarBar(aScalarBarCtrl->GetLocalBar(),
1004 aScalarBarCtrl->GetLocalTable());
1006 UpdateScalarBar(aScalarBarCtrl->GetGlobalBar(),
1007 aScalarBarCtrl->GetGlobalTable());
1009 aScalarBarCtrl->Update();
1011 GetPipeLine()->GetMapper()->SetScalarVisibility(0);
1013 anActor->GetProperty()->SetColor(myColor.red() / 255.0,
1014 myColor.green() / 255.0,
1015 myColor.blue() / 255.0);
1018 anActor->SetBarVisibility(myShowBar && GetIsColored());
1020 if( GetSpecificPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1021 theActor->SetRepresentation( VTK_POINTS );
1023 theActor->SetRepresentation( VTK_SURFACE );
1025 // Update values labels
1027 vtkTextProperty* aProp = anActor->GetsValLabelsProps();
1030 aProp->SetFontFamily( GetValLblFontType() );
1031 aProp->SetFontSize( GetValLblFontSize() );
1032 aProp->SetBold( IsBoldValLbl() );
1033 aProp->SetItalic( IsItalicValLbl() );
1034 aProp->SetShadow( IsShadowValLbl() );
1036 vtkFloatingPointType anRGB[ 3 ];
1037 GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
1038 aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
1042 TSuperClass::UpdateActor(theActor);
1045 //----------------------------------------------------------------------------
1048 ::UpdateFromActor(VISU_GaussPtsAct* theActor)
1050 if(MYDEBUG) MESSAGE("GaussPoints_i::UpdateFromActor - this = "<<this);
1051 myGaussPointsPL->ChangeMagnification(theActor->GetChangeMagnification());
1052 myParamsTime.Modified();
1057 //----------------------------------------------------------------------------
1060 ::SetQTextures( const QString& theMainTexture,
1061 const QString& theAlphaTexture )
1063 bool updateMainTexture = SetMainTexture( theMainTexture );
1064 bool updateAlphaTexture = SetAlphaTexture( theAlphaTexture );
1065 if( !updateMainTexture && !updateAlphaTexture )
1068 VISU::TSetModified aModified(this);
1070 using namespace VISU;
1071 TTextureValue aTextureValue = GetTexture(theMainTexture.toLatin1().data(),
1072 theAlphaTexture.toLatin1().data());
1073 myGaussPointsPL->SetImageData( aTextureValue.GetPointer() );
1078 ::SetTextures( const char* theMainTexture,
1079 const char* theAlphaTexture )
1081 SetQTextures(theMainTexture, theAlphaTexture);
1085 //----------------------------------------------------------------------------
1088 ::SetIsActiveLocalScalarBar(CORBA::Boolean theIsActiveLocalScalarBar)
1090 if(myIsActiveLocalScalarBar == theIsActiveLocalScalarBar)
1093 VISU::TSetModified aModified(this);
1095 myIsActiveLocalScalarBar = theIsActiveLocalScalarBar;
1097 if ( !theIsActiveLocalScalarBar || !IsRangeFixed() )
1100 myParamsTime.Modified();
1105 ::GetIsActiveLocalScalarBar()
1107 return myIsActiveLocalScalarBar;
1112 ::SetIsDispGlobalScalarBar(CORBA::Boolean theIsDispGlobalScalarBar)
1114 if(myIsDispGlobalScalarBar == theIsDispGlobalScalarBar)
1117 VISU::TSetModified aModified(this);
1119 myIsDispGlobalScalarBar = theIsDispGlobalScalarBar;
1120 myParamsTime.Modified();
1125 ::IsGlobalRangeDefined() const
1127 return GetCResult()->IsMinMaxDone();
1130 //----------------------------------------------------------------------------
1135 VISU::TSetModified aModified(this);
1137 vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()};
1138 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
1139 (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
1141 UseFixedRange(false);
1145 //----------------------------------------------------------------------------
1146 struct TGetSourceMin: public SALOME_Event
1148 VISU::GaussPoints_i* myColoredPrs3d;
1150 typedef CORBA::Double TResult;
1153 TGetSourceMin( VISU::GaussPoints_i* theColoredPrs3d ):
1154 myColoredPrs3d( theColoredPrs3d )
1161 if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1162 vtkFloatingPointType aRange[2];
1163 myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1164 myResult = aRange[0];
1166 VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
1167 VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
1168 myResult = aTMinMax.first;
1174 //----------------------------------------------------------------------------
1179 return ProcessEvent( new TGetSourceMin( this ) );
1183 //----------------------------------------------------------------------------
1184 struct TGetSourceMax: public SALOME_Event
1186 VISU::GaussPoints_i* myColoredPrs3d;
1188 typedef CORBA::Double TResult;
1191 TGetSourceMax( VISU::GaussPoints_i* theColoredPrs3d ):
1192 myColoredPrs3d( theColoredPrs3d )
1199 if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1200 vtkFloatingPointType aRange[2];
1201 myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1202 myResult = aRange[1];
1204 VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
1205 VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
1206 myResult = aTMinMax.second;
1212 //----------------------------------------------------------------------------
1217 return ProcessEvent( new TGetSourceMax( this ) );
1221 //----------------------------------------------------------------------------
1224 ::GetIsDispGlobalScalarBar()
1226 return myIsDispGlobalScalarBar;
1232 ::SetBiColor(CORBA::Boolean theIsBiColor)
1234 VISU::TSetModified aModified(this);
1236 GetSpecificPL()->SetBicolor(theIsBiColor);
1243 return GetSpecificPL()->GetBicolor();
1248 ::SetSpacing(CORBA::Double theSpacing)
1250 if(VISU::CheckIsSameValue(mySpacing, theSpacing))
1253 VISU::TSetModified aModified(this);
1255 mySpacing = theSpacing;
1256 myParamsTime.Modified();
1266 //----------------------------------------------------------------------------
1267 struct TGaussGetComponentMin: public SALOME_Event
1269 VISU::ColoredPrs3d_i* myColoredPrs3d;
1272 typedef CORBA::Double TResult;
1275 TGaussGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
1276 vtkIdType theCompID ):
1277 myColoredPrs3d( theColoredPrs3d ),
1278 myCompID( theCompID )
1285 VISU::TNames aGroupNames;
1286 if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
1287 aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
1289 VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
1290 if ( aMinMaxController ) {
1291 myResult = aMinMaxController->GetComponentMin( myCompID );
1293 VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
1294 myResult = aTMinMax.first;
1300 //----------------------------------------------------------------------------
1301 vtkFloatingPointType
1303 ::GetComponentMin(vtkIdType theCompID)
1305 return ProcessEvent( new TGaussGetComponentMin( this, theCompID ) );
1308 //----------------------------------------------------------------------------
1309 struct TGaussGetComponentMax: public SALOME_Event
1311 VISU::ColoredPrs3d_i* myColoredPrs3d;
1314 typedef CORBA::Double TResult;
1317 TGaussGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
1318 vtkIdType theCompID ):
1319 myColoredPrs3d( theColoredPrs3d ),
1320 myCompID( theCompID )
1327 VISU::TNames aGroupNames;
1328 if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
1329 aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
1331 VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
1332 if ( aMinMaxController ) {
1333 myResult = aMinMaxController->GetComponentMax( myCompID );
1335 VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
1336 myResult = aTMinMax.second;
1342 //----------------------------------------------------------------------------
1343 vtkFloatingPointType
1345 ::GetComponentMax(vtkIdType theCompID)
1347 return ProcessEvent( new TGaussGetComponentMax( this, theCompID ) );