1 // Copyright (C) 2007-2012 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
23 // VISU OBJECT : interactive object for VISU entities implementation
28 #include "VISU_GaussPoints_i.hh"
29 #include "VISU_ScalarMap_i.hh"
30 #include "VISU_Prs3dUtils.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_GaussPtsAct.h"
34 #include "VISU_GaussPointsPL.hxx"
35 #include "VISU_GaussPtsDeviceActor.h"
37 #include "VISU_OpenGLPointSpriteMapper.hxx"
38 #include "VISU_ScalarBarCtrl.hxx"
39 #include <VISU_ScalarBarActor.hxx>
40 #include "VISU_LookupTable.hxx"
41 #include "VISU_MedConvertor.hxx"
43 #include "SUIT_ResourceMgr.h"
45 #include "VISU_PipeLineUtils.hxx"
47 #include <vtkImageData.h>
48 #include <vtkXMLImageDataReader.h>
49 #include <vtkTextProperty.h>
50 #include <vtkProperty.h>
53 static int MYDEBUG = 0;
55 static int MYDEBUG = 0;
58 static int INCMEMORY = 10;
62 //----------------------------------------------------------------------------
65 ::IsPossible(Result_i* theResult,
66 const std::string& theMeshName,
67 VISU::Entity theEntity,
68 const std::string& theFieldName,
69 CORBA::Long theTimeStampNumber,
70 bool theIsMemoryCheck)
73 if(theEntity == VISU::NODE)
76 bool anIsEstimated = true;
77 VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
81 if(!dynamic_cast<const VISU_MedConvertor*>(anInput.get()))
83 size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
84 VISU::TEntity(theEntity),
92 aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
94 MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
96 }catch(std::exception& exc){
97 INFOS("Follow exception was occured :\n"<<exc.what());
99 INFOS("Unknown exception was occured!");
104 //----------------------------------------------------------------------------
105 int VISU::GaussPoints_i::myNbPresent = 0;
111 return VISU::GenerateName("Gauss Points",myNbPresent++);
114 //----------------------------------------------------------------------------
115 const string VISU::GaussPoints_i::myComment = "GAUSSPOINTS";
121 return myComment.c_str();
125 //---------------------------------------------------------------
130 return "ICON_TREE_GAUSS_POINTS";
134 //----------------------------------------------------------------------------
136 ::GaussPoints_i(EPublishInStudyMode thePublishInStudyMode) :
137 ColoredPrs3d_i(thePublishInStudyMode),
138 myGaussPointsPL(NULL),
140 myIsActiveLocalScalarBar(true),
141 myIsDispGlobalScalarBar(true),
146 if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
150 //----------------------------------------------------------------------------
153 ::Create(const std::string& theMeshName,
154 VISU::Entity theEntity,
155 const std::string& theFieldName,
156 CORBA::Long theTimeStampNumber)
158 TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
160 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
162 int anActiveLocal = aResourceMgr->integerValue( "VISU", "scalar_bar_active_local", GetIsActiveLocalScalarBar() );
163 SetIsActiveLocalScalarBar( anActiveLocal == 0 );
165 bool aDisplayGlobal = aResourceMgr->booleanValue( "VISU", "scalar_bar_diplay_global", GetIsDispGlobalScalarBar() );
166 SetIsDispGlobalScalarBar( aDisplayGlobal );
168 int aBicolor = aResourceMgr->integerValue( "VISU", "scalar_bar_bicolor", GetBiColor() );
169 SetBiColor( aBicolor == 0 );
171 double aSpacing = aResourceMgr->doubleValue( "VISU", "scalar_bar_spacing", GetSpacing() );
172 SetSpacing( aSpacing );
174 double aScaleFactor = aResourceMgr->doubleValue( "VISU", "deformed_shape_scale_factor", GetScaleFactor() );
175 SetScaleFactor( aScaleFactor );
177 int aPrimitiveType = aResourceMgr->integerValue( "VISU", "point_sprite_primitive_type", GetPrimitiveType() );
178 SetPrimitiveType( VISU::GaussPoints::PrimitiveType(aPrimitiveType) );
180 double aClamp = aResourceMgr->doubleValue( "VISU", "point_sprite_clamp", GetClamp() );
183 int aMinSize = aResourceMgr->integerValue( "VISU", "point_sprite_min_size", ( int )( GetMinSize() * 100.0 ) );
184 SetMinSize( aMinSize / 100.0 );
186 int aMaxSize = aResourceMgr->integerValue( "VISU", "point_sprite_max_size", ( int )( GetMaxSize() * 100.0 ) );
187 SetMaxSize( aMaxSize / 100.0 );
189 int aGeomSize = aResourceMgr->integerValue( "VISU", "point_sprite_size", ( int )( GetGeomSize() * 100.0 ) );
190 SetGeomSize( aGeomSize / 100.0 );
192 int aMagnification = aResourceMgr->integerValue( "VISU", "point_sprite_magnification", ( int )( GetMagnification() * 100.0 ) );
193 SetMagnification( aMagnification / 100.0 );
195 double anIncrement = aResourceMgr->doubleValue( "VISU", "point_sprite_increment", GetMagnificationIncrement() );
196 SetMagnificationIncrement( anIncrement );
198 bool isColored = aResourceMgr->booleanValue( "VISU", "point_sprite_results", GetIsColored() );
199 SetIsColored( isColored );
201 QColor aColor = aResourceMgr->colorValue( "VISU", "point_sprite_color", GetQColor() );
204 double anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "point_sprite_alpha_threshold", GetAlphaThreshold() );
205 SetAlphaThreshold( anAlphaThreshold );
207 int aResolution = aResourceMgr->integerValue( "VISU", "geom_sphere_resolution", GetResolution() );
208 SetResolution( aResolution );
210 int aFaceLimit = aResourceMgr->integerValue( "VISU", "geom_sphere_face_limit", GetFaceLimit() );
211 SetFaceLimit( aFaceLimit );
213 QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_texture.bmp";
214 aMainTexture = aResourceMgr->stringValue( "VISU", "point_sprite_main_texture", aMainTexture );
216 QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_alpha.bmp";
217 anAlphaTexture = aResourceMgr->stringValue( "VISU", "point_sprite_alpha_texture", anAlphaTexture );
219 SetTextures( aMainTexture.toLatin1().data(), anAlphaTexture.toLatin1().data() );
227 //---------------------------------------------------------------
230 ::SameAs(const Prs3d_i* theOrigin)
232 TSuperClass::SameAs(theOrigin);
234 if(const GaussPoints_i* aPrs3d = dynamic_cast<const GaussPoints_i*>(theOrigin)){
235 GaussPoints_i* anOrigin = const_cast<GaussPoints_i*>(aPrs3d);
237 SetIsActiveLocalScalarBar(anOrigin->GetIsActiveLocalScalarBar());
238 SetIsDispGlobalScalarBar(anOrigin->GetIsDispGlobalScalarBar());
240 SetSpacing(anOrigin->GetSpacing());
242 SetFaceLimit(anOrigin->GetFaceLimit());
244 SetColor(anOrigin->GetColor());
246 SetBarVisible(anOrigin->IsBarVisible());
248 SetTextures(anOrigin->GetMainTexture(), anOrigin->GetAlphaTexture());
252 //----------------------------------------------------------------------------
257 return TSuperClass::GetMemorySize();
260 //----------------------------------------------------------------------------
263 ::Restore(SALOMEDS::SObject_ptr theSObject,
264 const Storable::TRestoringMap& theMap)
266 if(!TSuperClass::Restore(theSObject, theMap))
269 // Check if the icon needs to be updated, update if necessary
270 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
271 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
272 SALOMEDS::GenericAttribute_var anAttr =
273 aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributePixMap");
274 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
276 CORBA::String_var aPixMapName = aPixmap->GetPixMap();
277 if(strcmp(GetIconName(), aPixMapName.in()) != 0)
278 aPixmap->SetPixMap(GetIconName());
280 QString aVal = VISU::Storable::FindValue(theMap,"myShowBar", "1");
281 SetBarVisible((aVal.toInt() == 1)? true : false);
283 SetIsActiveLocalScalarBar(Storable::FindValue(theMap,"myIsActiveLocalScalarBar").toInt());
284 SetIsDispGlobalScalarBar(Storable::FindValue(theMap,"myIsDispGlobalScalarBar").toInt());
285 SetBiColor(Storable::FindValue(theMap,"myIsBiColor").toInt());
286 SetSpacing(Storable::FindValue(theMap,"mySpacing").toDouble());
288 int aPrimitiveType = Storable::FindValue(theMap,"myPrimitiveType").toInt();
289 SetPrimitiveType(VISU::GaussPoints::PrimitiveType(aPrimitiveType));
290 SetClamp(Storable::FindValue(theMap,"myClamp").toDouble());
291 SetMinSize(Storable::FindValue(theMap,"myMinSize").toDouble());
292 SetMaxSize(Storable::FindValue(theMap,"myMaxSize").toDouble());
293 SetGeomSize(Storable::FindValue(theMap,"myGeomSize").toDouble());
295 SetMagnification(Storable::FindValue(theMap,"myMagnification").toDouble());
296 SetMagnificationIncrement(Storable::FindValue(theMap,"myMagnificationIncrement").toDouble());
298 SetIsDeformed(Storable::FindValue(theMap,"myIsDeformed").toInt());
299 SetScaleFactor(Storable::FindValue(theMap,"myScaleFactor").toDouble());
301 SetFaceLimit(Storable::FindValue(theMap,"myFaceLimit").toInt());
303 SetIsColored(Storable::FindValue(theMap,"myIsColored").toInt());
304 int aRed = Storable::FindValue(theMap,"myColor.R").toInt();
305 int aGreen = Storable::FindValue(theMap,"myColor.G").toInt();
306 int aBlue = Storable::FindValue(theMap,"myColor.B").toInt();
307 SetQColor( QColor(aRed, aGreen, aBlue) );
309 SetAlphaThreshold(Storable::FindValue(theMap,"myAlphaThreshold").toDouble());
311 SetTextures( Storable::FindValue(theMap,"myMainTexture").toLatin1().data(),
312 Storable::FindValue(theMap,"myAlphaTexture").toLatin1().data() );
314 SetResolution(Storable::FindValue(theMap,"myResolution").toInt());
320 //----------------------------------------------------------------------------
323 ::ToStream(std::ostringstream& theStr)
325 TSuperClass::ToStream(theStr);
327 Storable::DataToStream( theStr, "myIsActiveLocalScalarBar", myIsActiveLocalScalarBar );
328 Storable::DataToStream( theStr, "myIsDispGlobalScalarBar", myIsDispGlobalScalarBar );
329 Storable::DataToStream( theStr, "myIsBiColor", GetBiColor() );
330 Storable::DataToStream( theStr, "mySpacing", GetSpacing() );
332 Storable::DataToStream( theStr, "myPrimitiveType", GetPrimitiveType() );
333 Storable::DataToStream( theStr, "myClamp", GetClamp() );
334 Storable::DataToStream( theStr, "myMinSize", GetMinSize() );
335 Storable::DataToStream( theStr, "myMaxSize", GetMaxSize() );
336 Storable::DataToStream( theStr, "myGeomSize", GetGeomSize() );
338 Storable::DataToStream( theStr, "myMagnification", GetMagnification() );
339 Storable::DataToStream( theStr, "myMagnificationIncrement", GetMagnificationIncrement() );
341 Storable::DataToStream( theStr, "myIsDeformed", GetIsDeformed() );
342 Storable::DataToStream( theStr, "myScaleFactor", GetScaleFactor() );
344 Storable::DataToStream( theStr, "myFaceLimit", GetFaceLimit() );
346 Storable::DataToStream( theStr, "myIsColored", GetIsColored() );
347 QColor aColor = GetQColor();
348 Storable::DataToStream( theStr, "myColor.R", aColor.red() );
349 Storable::DataToStream( theStr, "myColor.G", aColor.green() );
350 Storable::DataToStream( theStr, "myColor.B", aColor.blue() );
352 Storable::DataToStream( theStr, "myAlphaThreshold", GetAlphaThreshold() );
353 Storable::DataToStream( theStr, "myMainTexture", GetQMainTexture() );
354 Storable::DataToStream( theStr, "myAlphaTexture", GetQAlphaTexture() );
356 Storable::DataToStream( theStr, "myResolution", GetResolution() );
357 Storable::DataToStream( theStr, "myShowBar", (IsBarVisible()? 1:0) );
364 if(MYDEBUG) MESSAGE("GaussPoints_i::~GaussPoints_i() - this = "<<this);
368 //----------------------------------------------------------------------------
376 //----------------------------------------------------------------------------
379 ::SetFaceLimit( CORBA::Long theFaceLimit )
381 if( myFaceLimit == theFaceLimit )
384 VISU::TSetModified aModified(this);
386 myFaceLimit = theFaceLimit;
387 myParamsTime.Modified();
390 //----------------------------------------------------------------------------
393 ::SetIsDeformed( CORBA::Boolean theIsDeformed )
395 VISU::TSetModified aModified(this);
397 myGaussPointsPL->SetIsDeformed( theIsDeformed );
404 return myGaussPointsPL->GetIsDeformed();
407 //----------------------------------------------------------------------------
410 ::SetScaleFactor( CORBA::Double theScaleFactor )
412 VISU::TSetModified aModified(this);
414 myGaussPointsPL->SetScale( theScaleFactor );
421 return myGaussPointsPL->GetScale();
424 //----------------------------------------------------------------------------
436 SALOMEDS::Color aColor;
437 aColor.R = myColor.red();
438 aColor.G = myColor.green();
439 aColor.B = myColor.blue();
444 //----------------------------------------------------------------------------
447 ::SetQColor( const QColor& theColor )
449 if(myColor == theColor)
452 VISU::TSetModified aModified(this);
455 myParamsTime.Modified();
460 ::SetColor( const SALOMEDS::Color& theColor )
462 SetQColor(QColor(int(theColor.R), int(theColor.G), int(theColor.B)));
466 //----------------------------------------------------------------------------
469 ::SetIsColored( bool theIsColored )
471 VISU::TSetModified aModified(this);
473 myGaussPointsPL->SetIsColored( theIsColored );
480 return myGaussPointsPL->GetIsColored();
483 //----------------------------------------------------------------------------
486 ::SetMainTexture( const QString& theMainTexture )
488 if(myMainTexture != theMainTexture){
489 VISU::TSetModified aModified(this);
491 myMainTexture = theMainTexture;
492 myParamsTime.Modified();
503 return myMainTexture;
510 return CORBA::string_dup(myMainTexture.toLatin1().data());
514 //----------------------------------------------------------------------------
517 ::SetAlphaTexture( const QString& theAlphaTexture )
519 if(myAlphaTexture != theAlphaTexture){
520 VISU::TSetModified aModified(this);
522 myAlphaTexture = theAlphaTexture;
523 myParamsTime.Modified();
534 return myAlphaTexture;
541 return CORBA::string_dup(myAlphaTexture.toLatin1().data());
545 //----------------------------------------------------------------------------
548 ::SetAlphaThreshold( CORBA::Double theAlphaThreshold )
550 VISU::TSetModified aModified(this);
552 myGaussPointsPL->SetAlphaThreshold( theAlphaThreshold );
557 ::GetAlphaThreshold()
559 return myGaussPointsPL->GetAlphaThreshold();
562 //----------------------------------------------------------------------------
565 ::SetResolution( CORBA::Long theResolution )
567 VISU::TSetModified aModified(this);
569 myGaussPointsPL->SetResolution( theResolution );
576 return myGaussPointsPL->GetResolution();
579 //----------------------------------------------------------------------------
582 ::SetPrimitiveType(VISU::GaussPoints::PrimitiveType thePrimitiveType)
584 VISU::TSetModified aModified(this);
586 myGaussPointsPL->SetPrimitiveType( thePrimitiveType );
589 VISU::GaussPoints::PrimitiveType
593 int aPrimitiveType = myGaussPointsPL->GetPrimitiveType();
595 if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::OpenGLPoint)
596 return VISU::GaussPoints::POINT;
598 if(aPrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere)
599 return VISU::GaussPoints::SPHERE;
601 return VISU::GaussPoints::SPRITE;
604 //----------------------------------------------------------------------------
607 ::GetMaximumSupportedSize()
609 return myGaussPointsPL->GetMaximumSupportedSize();
612 //----------------------------------------------------------------------------
615 ::SetClamp(CORBA::Double theClamp)
617 VISU::TSetModified aModified(this);
619 myGaussPointsPL->SetClamp( theClamp );
626 return myGaussPointsPL->GetClamp();
629 //----------------------------------------------------------------------------
632 ::SetGeomSize( CORBA::Double theGeomSize )
634 VISU::TSetModified aModified(this);
636 myGaussPointsPL->SetSize( theGeomSize );
643 return myGaussPointsPL->GetSize();
646 //----------------------------------------------------------------------------
649 ::SetMinSize( CORBA::Double theMinSize )
651 VISU::TSetModified aModified(this);
653 myGaussPointsPL->SetMinSize( theMinSize );
660 return myGaussPointsPL->GetMinSize();
663 //----------------------------------------------------------------------------
666 ::SetMaxSize( CORBA::Double theMaxSize )
668 VISU::TSetModified aModified(this);
670 myGaussPointsPL->SetMaxSize( theMaxSize );
677 return myGaussPointsPL->GetMaxSize();
680 //----------------------------------------------------------------------------
683 ::SetMagnification( CORBA::Double theMagnification )
685 VISU::TSetModified aModified(this);
687 myGaussPointsPL->SetMagnification( theMagnification );
694 return myGaussPointsPL->GetMagnification();
697 //----------------------------------------------------------------------------
700 ::SetMagnificationIncrement( CORBA::Double theIncrement )
702 VISU::TSetModified aModified(this);
704 myGaussPointsPL->SetMagnificationIncrement( theIncrement );
709 ::GetMagnificationIncrement()
711 return myGaussPointsPL->GetMagnificationIncrement();
714 //----------------------------------------------------------------------------
717 ::SetSourceGeometry()
719 int aNbGroups = myGroupNames.size();
721 GetSpecificPL()->SetSourceGeometry();
722 myGroupNames.clear();
727 //----------------------------------------------------------------------------
730 ::AddMeshOnGroup(const char* theGroupName)
732 VISU::Result_i::PInput anInput = GetCResult()->GetInput();
733 VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName);
735 int aNbGroups = myGroupNames.size();
736 if(myGroupNames.find(theGroupName) == myGroupNames.end()){
737 GetSpecificPL()->AddGeometry(anIDMapper->GetOutput(), theGroupName);
738 myGroupNames.insert(theGroupName);
743 // To update scalar range according to the new input (IPAL21305)
751 //----------------------------------------------------------------------------
756 int aNbGroups = myGroupNames.size();
757 GetSpecificPL()->ClearGeometry();
758 myGroupNames.clear();
765 //----------------------------------------------------------------------------
768 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
770 VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
773 GetTimeStampNumber());
775 throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
777 SetField(anInput->GetField(GetCMeshName(),
781 throw std::runtime_error("There is no Field with the parameters !!!");
783 VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
784 anInput->GetTimeStampOnGaussPts(GetCMeshName(),
787 GetTimeStampNumber());
788 if(!aGaussPtsIDMapper)
789 throw std::runtime_error("There is no TimeStamp with the parameters !!!");
791 GetSpecificPL()->SetGaussPtsIDMapper(aGaussPtsIDMapper);
795 //----------------------------------------------------------------------------
800 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
803 void VISU::GaussPoints_i::SetBarVisible(CORBA::Boolean theVisible)
805 if (myShowBar == theVisible)
807 VISU::TSetModified aModified(this);
808 myShowBar = theVisible;
809 myParamsTime.Modified();
812 //----------------------------------------------------------------------------
815 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
818 myGaussPointsPL = VISU_GaussPointsPL::New();
820 myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
822 TSuperClass::CreatePipeLine(myGaussPointsPL);
826 //----------------------------------------------------------------------------
831 // We create a new PipeLine instance in order to provide
832 // different representations for different actors (basic and segmented)
833 VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
834 aPipeLine->ShallowCopy(GetPipeLine(), true);
839 //----------------------------------------------------------------------------
842 ::OnCreateActor(VISU_GaussPtsAct* theActor)
845 TSuperClass::CreateActor(theActor);
846 UpdateActor(theActor);
859 VISU_GaussPtsAct1* anActor = VISU_GaussPtsAct1::New();
860 if(OnCreateActor(anActor))
869 VISU_GaussPtsAct2* anActor = VISU_GaussPtsAct2::New();
870 if(OnCreateActor(anActor))
879 VISU_GaussPtsAct* anActor = VISU_GaussPtsAct::New();
880 anActor->SetBarVisibility(myShowBar);
881 if(OnCreateActor(anActor))
884 // return OnCreateActor1();
887 //----------------------------------------------------------------------------
890 ::CloneActor(VISU_GaussPtsAct1* theActor)
892 if(MYDEBUG) MESSAGE("GaussPoints_i::CloneActor - this = "<<this);
893 if(VISU_GaussPtsAct2* anActor = OnCreateActor2()){
894 theActor->Connect(anActor);
901 //----------------------------------------------------------------------------
904 ::UpdateScalarBar(VISU_ScalarBarActor *theScalarBar,
905 VISU_LookupTable* theLookupTable)
907 theScalarBar->SetTitle(GetScalarBarTitle().c_str());
908 theScalarBar->SetOrientation(GetBarOrientation());
909 theScalarBar->SetNumberOfLabels(GetLabels());
910 theScalarBar->SetRatios(GetTitleSize(), GetLabelSize(),
911 GetBarWidth(), GetBarHeight());
912 theScalarBar->SetLabelFormat(GetLabelsFormat());
914 VISU_LookupTable* aLookupTable = GetSpecificPL()->GetBarTable();
916 theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors());
917 theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors());
921 vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty();
922 aTitleProp->SetFontFamily(GetTitFontType());
924 GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
925 aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
927 IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
928 IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
929 IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
931 vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty();
932 aLabelProp->SetFontFamily(GetLblFontType());
934 GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
935 aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
937 IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
938 IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
939 IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
941 theScalarBar->Modified();
945 //----------------------------------------------------------------------------
948 ::UpdateActor(VISU_ActorBase* theActor)
950 if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
951 VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl();
953 GetPipeLine()->GetMapper()->SetScalarVisibility(1);
956 double* aRange = GetSpecificPL()->GetScalarRange();
957 aScalarBarCtrl->SetRangeLocal(aRange);
960 GetSpecificPL()->GetSourceRange(aRange);
961 aScalarBarCtrl->SetRangeLocal(aRange);
964 bool anIsMinMaxDone = IsGlobalRangeDefined();
965 aScalarBarCtrl->SetGlobalRangeIsDefined(anIsMinMaxDone);
967 TMinMax aTMinMax( GetComponentMin( GetScalarMode() ),
968 GetComponentMax( GetScalarMode() ));
969 aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second);
971 VISU_ScalarBarCtrl::EMode aScalarBarMode = VISU_ScalarBarCtrl::eGlobal;
972 if(myIsActiveLocalScalarBar){
973 if(myIsDispGlobalScalarBar){
974 aScalarBarMode = VISU_ScalarBarCtrl::eLocal;
976 aScalarBarMode = VISU_ScalarBarCtrl::eSimple;
980 if(aScalarBarMode == VISU_ScalarBarCtrl::eGlobal){
981 double aRangeGlobal[2];
983 aRangeGlobal[0] = aTMinMax.first;
984 aRangeGlobal[1] = aTMinMax.second;
986 GetSpecificPL()->GetMapper()->SetScalarRange(aRangeGlobal);
989 aScalarBarCtrl->SetMode(aScalarBarMode);
992 aScalarBarCtrl->SetWidth(GetWidth());
993 aScalarBarCtrl->SetHeight(GetHeight());
995 double aPosition[] = {GetPosX(), GetPosY()};
996 aScalarBarCtrl->SetPosition(aPosition);
998 aScalarBarCtrl->SetSpacing(mySpacing);
1001 bool anIsBicolor = GetSpecificPL()->GetBicolor();
1002 aScalarBarCtrl->SetBicolor(anIsBicolor);
1004 UpdateScalarBar(aScalarBarCtrl->GetLocalBar(),
1005 aScalarBarCtrl->GetLocalTable());
1007 UpdateScalarBar(aScalarBarCtrl->GetGlobalBar(),
1008 aScalarBarCtrl->GetGlobalTable());
1010 aScalarBarCtrl->Update();
1012 GetPipeLine()->GetMapper()->SetScalarVisibility(0);
1014 anActor->GetProperty()->SetColor(myColor.red() / 255.0,
1015 myColor.green() / 255.0,
1016 myColor.blue() / 255.0);
1019 anActor->SetBarVisibility(myShowBar && GetIsColored());
1021 if( GetSpecificPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1022 theActor->SetRepresentation( VTK_POINTS );
1024 theActor->SetRepresentation( VTK_SURFACE );
1026 // Update values labels
1028 vtkTextProperty* aProp = anActor->GetsValLabelsProps();
1031 aProp->SetFontFamily( GetValLblFontType() );
1032 aProp->SetFontSize( GetValLblFontSize() );
1033 aProp->SetBold( IsBoldValLbl() );
1034 aProp->SetItalic( IsItalicValLbl() );
1035 aProp->SetShadow( IsShadowValLbl() );
1038 GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
1039 aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
1043 TSuperClass::UpdateActor(theActor);
1046 //----------------------------------------------------------------------------
1049 ::UpdateFromActor(VISU_GaussPtsAct* theActor)
1051 if(MYDEBUG) MESSAGE("GaussPoints_i::UpdateFromActor - this = "<<this);
1052 myGaussPointsPL->ChangeMagnification(theActor->GetChangeMagnification());
1053 myParamsTime.Modified();
1058 //----------------------------------------------------------------------------
1061 ::SetQTextures( const QString& theMainTexture,
1062 const QString& theAlphaTexture )
1064 bool updateMainTexture = SetMainTexture( theMainTexture );
1065 bool updateAlphaTexture = SetAlphaTexture( theAlphaTexture );
1066 if( !updateMainTexture && !updateAlphaTexture )
1069 VISU::TSetModified aModified(this);
1071 using namespace VISU;
1072 TTextureValue aTextureValue = GetTexture(theMainTexture.toLatin1().data(),
1073 theAlphaTexture.toLatin1().data());
1074 myGaussPointsPL->SetImageData( aTextureValue.GetPointer() );
1079 ::SetTextures( const char* theMainTexture,
1080 const char* theAlphaTexture )
1082 SetQTextures(theMainTexture, theAlphaTexture);
1086 //----------------------------------------------------------------------------
1089 ::SetIsActiveLocalScalarBar(CORBA::Boolean theIsActiveLocalScalarBar)
1091 if(myIsActiveLocalScalarBar == theIsActiveLocalScalarBar)
1094 VISU::TSetModified aModified(this);
1096 myIsActiveLocalScalarBar = theIsActiveLocalScalarBar;
1098 if ( !theIsActiveLocalScalarBar || !IsRangeFixed() )
1101 myParamsTime.Modified();
1106 ::GetIsActiveLocalScalarBar()
1108 return myIsActiveLocalScalarBar;
1113 ::SetIsDispGlobalScalarBar(CORBA::Boolean theIsDispGlobalScalarBar)
1115 if(myIsDispGlobalScalarBar == theIsDispGlobalScalarBar)
1118 VISU::TSetModified aModified(this);
1120 myIsDispGlobalScalarBar = theIsDispGlobalScalarBar;
1121 myParamsTime.Modified();
1126 ::IsGlobalRangeDefined() const
1128 return GetCResult()->IsMinMaxDone();
1131 //----------------------------------------------------------------------------
1136 VISU::TSetModified aModified(this);
1138 double aScalarRange[2] = {GetSourceMin(), GetSourceMax()};
1139 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, double*>
1140 (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
1142 UseFixedRange(false);
1146 //----------------------------------------------------------------------------
1147 struct TGetSourceMin: public SALOME_Event
1149 VISU::GaussPoints_i* myColoredPrs3d;
1151 typedef CORBA::Double TResult;
1154 TGetSourceMin( VISU::GaussPoints_i* theColoredPrs3d ):
1155 myColoredPrs3d( theColoredPrs3d )
1162 if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1164 myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1165 myResult = aRange[0];
1167 VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
1168 VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
1169 myResult = aTMinMax.first;
1175 //----------------------------------------------------------------------------
1180 return ProcessEvent( new TGetSourceMin( this ) );
1184 //----------------------------------------------------------------------------
1185 struct TGetSourceMax: public SALOME_Event
1187 VISU::GaussPoints_i* myColoredPrs3d;
1189 typedef CORBA::Double TResult;
1192 TGetSourceMax( VISU::GaussPoints_i* theColoredPrs3d ):
1193 myColoredPrs3d( theColoredPrs3d )
1200 if ( myColoredPrs3d->IsTimeStampFixed() || myColoredPrs3d->GetIsActiveLocalScalarBar() ) {
1202 myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
1203 myResult = aRange[1];
1205 VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
1206 VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
1207 myResult = aTMinMax.second;
1213 //----------------------------------------------------------------------------
1218 return ProcessEvent( new TGetSourceMax( this ) );
1222 //----------------------------------------------------------------------------
1225 ::GetIsDispGlobalScalarBar()
1227 return myIsDispGlobalScalarBar;
1233 ::SetBiColor(CORBA::Boolean theIsBiColor)
1235 VISU::TSetModified aModified(this);
1237 GetSpecificPL()->SetBicolor(theIsBiColor);
1244 return GetSpecificPL()->GetBicolor();
1249 ::SetSpacing(CORBA::Double theSpacing)
1251 if(VISU::CheckIsSameValue(mySpacing, theSpacing))
1254 VISU::TSetModified aModified(this);
1256 mySpacing = theSpacing;
1257 myParamsTime.Modified();
1267 //----------------------------------------------------------------------------
1268 struct TGaussGetComponentMin: public SALOME_Event
1270 VISU::ColoredPrs3d_i* myColoredPrs3d;
1273 typedef CORBA::Double TResult;
1276 TGaussGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
1277 vtkIdType theCompID ):
1278 myColoredPrs3d( theColoredPrs3d ),
1279 myCompID( theCompID )
1286 VISU::TNames aGroupNames;
1287 if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
1288 aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
1290 VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
1291 if ( aMinMaxController ) {
1292 myResult = aMinMaxController->GetComponentMin( myCompID );
1294 VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
1295 myResult = aTMinMax.first;
1301 //----------------------------------------------------------------------------
1304 ::GetComponentMin(vtkIdType theCompID)
1306 return ProcessEvent( new TGaussGetComponentMin( this, theCompID ) );
1309 //----------------------------------------------------------------------------
1310 struct TGaussGetComponentMax: public SALOME_Event
1312 VISU::ColoredPrs3d_i* myColoredPrs3d;
1315 typedef CORBA::Double TResult;
1318 TGaussGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
1319 vtkIdType theCompID ):
1320 myColoredPrs3d( theColoredPrs3d ),
1321 myCompID( theCompID )
1328 VISU::TNames aGroupNames;
1329 if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
1330 aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
1332 VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
1333 if ( aMinMaxController ) {
1334 myResult = aMinMaxController->GetComponentMax( myCompID );
1336 VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
1337 myResult = aTMinMax.second;
1343 //----------------------------------------------------------------------------
1346 ::GetComponentMax(vtkIdType theCompID)
1348 return ProcessEvent( new TGaussGetComponentMax( this, theCompID ) );