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
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_ColoredPrs3d_i.hh"
28 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_Result_i.hh"
31 #include "VISU_ColoredPL.hxx"
32 #include "VISU_PipeLineUtils.hxx"
33 #include "VISU_Convertor.hxx"
35 #include "SUIT_ResourceMgr.h"
36 #include "SALOME_Event.h"
39 #include <vtkMapper.h>
40 #include <vtkDataSet.h>
43 static int MYDEBUG = 0;
46 static int MYDEBUG = 0;
51 //---------------------------------------------------------------
55 FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy)
57 static char aFolderName[] = "3D Presentations";
58 CORBA::String_var anEntry;
59 SALOMEDS::SObject_var aSObject = theStudy->FindObject(aFolderName);
60 if(!CORBA::is_nil(aSObject) && aSObject->Depth() == 3){
61 anEntry = aSObject->GetID();
64 SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
65 CORBA::String_var aFatherEntry = aSComponent->GetID();
66 anEntry = VISU::CreateAttributes(theStudy,
78 //---------------------------------------------------------------
81 //---------------------------------------------------------------
84 GetMinMax(VISU::Result_i* theResult,
85 VISU::PField theField,
88 if(!theResult->IsMinMaxDone())
89 theResult->GetInput()->BuildMinMax();
90 if(theField->myIsELNO)
91 return theField->GetMinMax(theCompID);
93 return theField->GetAverageMinMax(theCompID);
96 //---------------------------------------------------------------
99 ::UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d)
103 //---------------------------------------------------------------
106 ::GetComponentMin(vtkIdType theCompID)
108 return VTK_LARGE_FLOAT;
112 //---------------------------------------------------------------
115 ::GetComponentMax(vtkIdType theCompID)
117 return -VTK_LARGE_FLOAT;
121 //---------------------------------------------------------------
122 struct TSimpleMinMaxController: virtual TVTKMinMaxController
124 VISU::Result_i* myResult;
125 VISU::ColoredPrs3d_i* myColoredPrs3d;
127 TSimpleMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d):
128 myResult(theColoredPrs3d->GetCResult()),
129 myColoredPrs3d(theColoredPrs3d)
132 ~TSimpleMinMaxController()
137 GetComponentMin(vtkIdType theCompID)
139 if ( VISU::PField aField = myColoredPrs3d->GetScalarField() ) {
140 TMinMax aMinMax = GetMinMax(myResult, aField, theCompID);
141 return aMinMax.first;
143 return TMinMaxController::GetComponentMin(theCompID);
148 GetComponentMax(vtkIdType theCompID)
150 if ( VISU::PField aField = myColoredPrs3d->GetScalarField() ) {
151 TMinMax aMinMax = GetMinMax(myResult, aField, theCompID);
152 return aMinMax.second;
154 return TMinMaxController::GetComponentMax(theCompID);
159 //---------------------------------------------------------------
161 CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d)
163 return PMinMaxController(new TSimpleMinMaxController(theColoredPrs3d));
167 //---------------------------------------------------------------
171 //---------------------------------------------------------------
172 VISU::ColoredPrs3d_i::
173 ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) :
175 myRestoringSObject( SALOMEDS::SObject::_nil() ),
176 myEntity( VISU::Entity( -1 ) ),
177 myPreviousEntity( VISU::Entity( -1 ) ),
178 myTimeStampNumber( -1 ),
179 myPreviousTimeStampNumber( -1 ),
180 myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp),
181 myPublishInStudyMode(thePublishInStudyMode),
183 myNumberOfLabels( -1 ),
184 myOrientation( VISU::ColoredPrs3dBase::HORIZONTAL ),
185 //myPosition[2], myWidth, myHeight, myTitleWidth, myTitleHeight,
186 //myLabelWidth, myLabelHeight, myBarWidth, myBarHeight,
187 //myIsBoldTitle, myIsItalicTitle, myIsShadowTitle, myTitFontType, myTitleColor[3],
188 //myIsBoldLabel, myIsItalicLabel, myIsShadowLabel, myLblFontType, myLabelColor[3],
190 myIsFixedRange(false),
191 myIsDistributionVisible(false)
194 //---------------------------------------------------------------
199 //---------------------------------------------------------------
204 TSuperClass::Register();
207 //---------------------------------------------------------------
212 TSuperClass::Destroy();
215 //---------------------------------------------------------------
220 struct TEvent: public SALOME_Event
222 VISU::ColoredPrs3d_i* myRemovable;
224 TEvent(VISU::ColoredPrs3d_i* theRemovable):
225 myRemovable(theRemovable)
232 SALOMEDS::SObject_var aSObject = myRemovable->GetSObject();
234 if(!CORBA::is_nil(aSObject.in()))
235 VISU::RemoveFromStudy(aSObject,false);
237 myRemovable->TSuperClass::RemoveFromStudy();
241 ProcessVoidEvent(new TEvent(this));
245 //----------------------------------------------------------------------------
248 ::UpdateFromResult(Result_i* theResult)
250 struct TEvent: public SALOME_Event
252 VISU::ColoredPrs3d_i* myColoredPrs3d;
254 TEvent(VISU::ColoredPrs3d_i* theColoredPrs3d):
255 myColoredPrs3d(theColoredPrs3d)
263 myColoredPrs3d->DoSetInput(false, false);
264 myColoredPrs3d->UpdateActors();
265 }catch(std::exception& exc){
266 INFOS("Follow exception was occured :\n"<<exc.what());
268 INFOS("Unknown exception was occured!");
273 if ( theResult == GetCResult() )
274 ProcessVoidEvent(new TEvent(this));
278 //---------------------------------------------------------------
281 ::SetInput(bool theReInit)
284 if(TSuperClass::SetInput(theReInit)){
285 if(CheckIsPossible()){
286 if(OnSetInput(theReInit)){
287 if(Create(GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber()))
300 //----------------------------------------------------------------------------
305 TSuperClass::OnRestoreInput();
306 myEntity = myPreviousEntity;
307 myFieldName = myPreviousFieldName;
308 myTimeStampNumber = myPreviousTimeStampNumber;
312 //---------------------------------------------------------------
315 ::OnSetInput(bool theReInit)
317 bool anIsCreatNew = !IsPipeLineExists();
319 CreatePipeLine(NULL); // to create proper pipeline
322 DoSetInput(anIsCreatNew, theReInit);
325 GetSpecificPL()->Init();
327 // To update scalar range according to the new input
328 if(!IsRangeFixed() && theReInit)
331 if(GetPublishInStudyMode() != EDoNotPublish)
332 GetCResult()->ConnectObserver(this, myResultConnection);
334 myPreviousEntity = myEntity;
335 myPreviousFieldName = myFieldName;
336 myPreviousTimeStampNumber = myTimeStampNumber;
337 }catch(std::exception& exc){
338 INFOS("Follow exception was occured :\n"<<exc.what());
342 INFOS("Unknown exception was occured!");
347 // To update title according to the new input
349 SetTitle(GetCFieldName().c_str());
355 //---------------------------------------------------------------
358 ::SetEntity(VISU::Entity theEntity)
360 if ( myEntity == theEntity )
363 VISU::TSetModified aModified(this);
365 myEntity = theEntity;
366 myParamsTime.Modified();
370 //---------------------------------------------------------------
379 //----------------------------------------------------------------------------
384 return VISU::TEntity(int(myEntity));
388 //----------------------------------------------------------------------------
391 ::SetFieldName(const char* theFieldName)
393 if(myFieldName == theFieldName)
396 VISU::TSetModified aModified(this);
398 myFieldName = theFieldName;
399 myParamsTime.Modified();
403 //----------------------------------------------------------------------------
408 return CORBA::string_dup(myFieldName.c_str());
412 //----------------------------------------------------------------------------
415 ::GetCFieldName() const
421 //----------------------------------------------------------------------------
430 //---------------------------------------------------------------
433 ::SetField(VISU::PField theField)
439 //----------------------------------------------------------------------------
442 ::SetTimeStampNumber(CORBA::Long theTimeStampNumber)
444 if ( myTimeStampNumber == theTimeStampNumber )
447 VISU::TSetModified aModified(this);
449 myTimeStampNumber = theTimeStampNumber;
450 myParamsTime.Modified();
454 //----------------------------------------------------------------------------
457 ::GetTimeStampNumber()
459 return myTimeStampNumber;
463 //----------------------------------------------------------------------------
466 ::GetTimeStampNumberByIndex( CORBA::Long theIndex )
468 VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
469 CORBA::Long aLength = aTimeStampsRange->length();
471 if( theIndex >= 0 && theIndex < aLength )
473 VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ theIndex ];
474 return anInfo.myNumber;
481 //----------------------------------------------------------------------------
484 ::GetTimeStampIndexByNumber( CORBA::Long theNumber )
486 VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
487 CORBA::Long aLength = aTimeStampsRange->length();
489 for( int index = 0; index < aLength; index++ )
491 VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ index ];
493 if( anInfo.myNumber == theNumber )
501 //----------------------------------------------------------------------------
510 //----------------------------------------------------------------------------
511 VISU::PMinMaxController
513 ::GetMinMaxController()
515 return myMinMaxController;
519 //----------------------------------------------------------------------------
522 ::SetMinMaxController( const VISU::PMinMaxController& theController )
524 myMinMaxController = theController;
531 //----------------------------------------------------------------------------
534 ::SetMinMaxController( VISU::ColoredPrs3d_i* theOrigin )
536 VISU::PMinMaxController aController = theOrigin->GetMinMaxController();
539 aController->UpdateReference( theOrigin, this );
541 SetMinMaxController( aController );
545 //----------------------------------------------------------------------------
548 ::GetScalarTimeStampNumber() const
550 return myTimeStampNumber;
554 //----------------------------------------------------------------------------
555 VISU::ColoredPrs3dHolder::TimeStampsRange*
557 ::GetTimeStampsRange()
559 VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange =
560 new VISU::ColoredPrs3dHolder::TimeStampsRange();
561 VISU::TValField& aValField = GetField()->myValField;
562 if(IsTimeStampFixed()){
563 aTimeStampsRange->length(1);
564 PValForTime& aValForTime = aValField[GetTimeStampNumber()];
565 std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
566 VISU::ColoredPrs3dHolder::TimeStampInfo anInfo;
567 anInfo.myNumber = GetTimeStampNumber();
568 anInfo.myTime = aTime.c_str();
569 aTimeStampsRange[0] = anInfo;
570 return aTimeStampsRange._retn();
573 // To exclude timstamps with repeated time
574 typedef std::map<std::string, long> TTimeStampsRange;
575 TTimeStampsRange aRange;
577 VISU::TValField::const_iterator anIter = aValField.begin();
578 for(; anIter != aValField.end(); anIter++){
579 vtkIdType aTimeStampNumber = anIter->first;
580 const PValForTime& aValForTime = anIter->second;
581 std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
582 aRange[aTime] = aTimeStampNumber;
586 // To sort timestamps according to their timestamp number
587 typedef std::map<long, std::string> TTimeStampsSortedRange;
588 TTimeStampsSortedRange aSortedRange;
590 TTimeStampsRange::const_iterator anIter = aRange.begin();
591 for(size_t aCounter = 0; anIter != aRange.end(); anIter++, aCounter++){
592 vtkIdType aTimeStampNumber = anIter->second;
593 const std::string& aTime = anIter->first;
594 aSortedRange[aTimeStampNumber] = aTime;
598 // To map the C++ data structures to the corresponding CORBA ones
600 aTimeStampsRange->length(aRange.size());
601 TTimeStampsSortedRange::const_iterator anIter = aSortedRange.begin();
602 for(size_t aCounter = 0; anIter != aSortedRange.end(); anIter++, aCounter++){
603 vtkIdType aTimeStampNumber = anIter->first;
604 const std::string& aTime = anIter->second;
605 VISU::ColoredPrs3dHolder::TimeStampInfo anInfo;
606 anInfo.myNumber = aTimeStampNumber;
607 anInfo.myTime = aTime.c_str();
608 aTimeStampsRange[aCounter] = anInfo;
611 return aTimeStampsRange._retn();
618 return TSuperClass::GetMemorySize();
621 VISU::ColoredPrs3dHolder::BasicInput*
625 VISU::ColoredPrs3dHolder::BasicInput* aBasicInput = new VISU::ColoredPrs3dHolder::BasicInput();
626 aBasicInput->myResult = GetResultObject();
627 aBasicInput->myMeshName = GetMeshName();
628 aBasicInput->myEntity = GetEntity();
629 aBasicInput->myFieldName = GetFieldName();
630 aBasicInput->myTimeStampNumber = GetTimeStampNumber();
636 //----------------------------------------------------------------------------
639 ::SetHolderEntry(const std::string& theEntry)
641 myHolderEntry = theEntry;
645 //----------------------------------------------------------------------------
650 return myHolderEntry;
654 //----------------------------------------------------------------------------
659 if(myHolderEntry != "")
660 return myHolderEntry;
661 return TSuperClass::GetActorEntry();
665 //----------------------------------------------------------------------------
670 return myIsTimeStampFixed;
673 //----------------------------------------------------------------------------
674 VISU::ColoredPrs3d_i::EPublishInStudyMode
676 ::GetPublishInStudyMode()
678 return myPublishInStudyMode;
681 //---------------------------------------------------------------
684 ::SameAs(const Prs3d_i* theOrigin)
686 if(const ColoredPrs3d_i* aPrs3d = dynamic_cast<const ColoredPrs3d_i*>(theOrigin)){
687 ColoredPrs3d_i* anOrigin = const_cast<ColoredPrs3d_i*>(aPrs3d);
689 bool anIsCreatNew = OnSetInput(false);
693 TSuperClass::SameAs(theOrigin);
695 CORBA::Long aNbComp = GetScalarField()->myNbComp;
696 CORBA::Long anOriginNbComp = anOrigin->GetScalarField()->myNbComp;
697 if(anOriginNbComp < aNbComp)
700 SetScalarMode(anOrigin->GetScalarMode());
702 SetNbColors(anOrigin->GetNbColors());
704 SetUnitsVisible(anOrigin->IsUnitsVisible());
705 SetIsDistributionVisible(anOrigin->GetIsDistributionVisible());
706 SetLabelsFormat( anOrigin->GetLabelsFormat() );
708 SetBarOrientation(anOrigin->GetBarOrientation());
710 SetMinMaxController( anOrigin );
712 if ( anOrigin->IsRangeFixed() )
713 SetRange( anOrigin->GetMin(), anOrigin->GetMax() );
717 SetScalarFilterRange( anOrigin->GetScalarFilterMin(), anOrigin->GetScalarFilterMax() );
718 UseScalarFiltering( anOrigin->IsScalarFilterUsed() );
720 SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY());
721 SetSize(anOrigin->GetWidth(), anOrigin->GetHeight());
722 SetRatios(anOrigin->GetTitleSize(), anOrigin->GetLabelSize(),
723 anOrigin->GetBarWidth(), anOrigin->GetBarHeight());
724 SetLabels(anOrigin->GetLabels());
726 SetTitle(anOrigin->GetTitle());
727 SetBoldTitle(anOrigin->IsBoldTitle());
728 SetItalicTitle(anOrigin->IsItalicTitle());
729 SetShadowTitle(anOrigin->IsShadowTitle());
730 SetTitFontType(anOrigin->GetTitFontType());
731 vtkFloatingPointType r,g,b;
732 anOrigin->GetTitleColor(r,g,b);
733 SetTitleColor(r,g,b);
735 SetBoldLabel(anOrigin->IsBoldLabel());
736 SetItalicLabel(anOrigin->IsItalicLabel());
737 SetShadowLabel(anOrigin->IsShadowLabel());
738 SetLblFontType(anOrigin->GetLblFontType());
739 anOrigin->GetLabelColor(r,g,b);
740 SetLabelColor(r,g,b);
742 myIsTimeStampFixed = anOrigin->IsTimeStampFixed();
744 SetHolderEntry( anOrigin->GetHolderEntry() );
746 myGroupNames = anOrigin->GetGroupNames();
750 //----------------------------------------------------------------------------
753 ::UpdateActor(VISU_ActorBase* theActor)
755 bool isOnGroups = myGroupNames.size() > 0;
759 TGroupNames::const_iterator anIter = myGroupNames.begin();
760 for ( ; anIter != myGroupNames.end(); anIter++ )
762 const std::string aGroupName = *anIter;
763 aList << QString( aGroupName.c_str() );
765 theActor->SetNameActorText( aList.join( "\n" ).toLatin1().constData() );
767 theActor->SetIsDisplayNameActor( isOnGroups );
769 TSuperClass::UpdateActor(theActor);
772 //----------------------------------------------------------------------------
777 return myColoredPL->GetScalarMode();
781 //----------------------------------------------------------------------------
784 ::SetScalarMode(CORBA::Long theScalarMode)
786 CORBA::Long aNbComp = GetScalarField()->myNbComp;
789 else if(theScalarMode > aNbComp)
792 VISU::TSetModified aModified(this);
794 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, int>
795 (GetSpecificPL(), &VISU_ColoredPL::SetScalarMode, theScalarMode));
798 //----------------------------------------------------------------------------
803 return myColoredPL->GetScalarRange()[0];
806 //----------------------------------------------------------------------------
811 return myColoredPL->GetScalarRange()[1];
815 //----------------------------------------------------------------------------
818 ::SetRange( CORBA::Double theMin, CORBA::Double theMax )
820 VISU::TSetModified aModified(this);
822 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
823 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
824 (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
829 //----------------------------------------------------------------------------
832 ::SetScalarFilterRange( CORBA::Double theMin, CORBA::Double theMax )
834 VISU::TSetModified aModified(this);
836 vtkFloatingPointType aScalarRange[ 2 ] = { theMin, theMax };
837 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
838 (GetSpecificPL(), &VISU_ColoredPL::SetScalarFilterRange, aScalarRange) );
842 //----------------------------------------------------------------------------
845 ::GetScalarFilterMin()
847 vtkFloatingPointType aScalarRange[ 2 ];
848 GetSpecificPL()->GetScalarFilterRange( aScalarRange );
850 return aScalarRange[ 0 ];
854 //----------------------------------------------------------------------------
857 ::GetScalarFilterMax()
859 vtkFloatingPointType aScalarRange[ 2 ];
860 GetSpecificPL()->GetScalarFilterRange( aScalarRange );
862 return aScalarRange[ 1 ];
866 //----------------------------------------------------------------------------
869 ::IsScalarFilterUsed()
871 return myColoredPL->IsScalarFilterUsed();
874 //----------------------------------------------------------------------------
877 ::UseScalarFiltering( CORBA::Boolean theUseScalarFilter )
879 return myColoredPL->UseScalarFiltering( theUseScalarFilter );
882 //----------------------------------------------------------------------------
887 VISU::TSetModified aModified(this);
889 if(IsTimeStampFixed()){
890 GetSpecificPL()->SetSourceRange();
891 ProcessVoidEvent(new TVoidMemFunEvent<VISU_ColoredPL>
892 (GetSpecificPL(), &VISU_ColoredPL::SetSourceRange));
894 vtkFloatingPointType aScalarRange[ 2 ] = {GetSourceMin(), GetSourceMax()};
895 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
896 (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
898 UseFixedRange(false);
901 //----------------------------------------------------------------------------
906 if(IsTimeStampFixed()){
907 vtkFloatingPointType aRange[2];
908 GetSpecificPL()->GetSourceRange(aRange);
911 return GetComponentMin(GetScalarMode());
914 //----------------------------------------------------------------------------
919 if(IsTimeStampFixed()){
920 vtkFloatingPointType aRange[2];
921 GetSpecificPL()->GetSourceRange(aRange);
924 return GetComponentMax(GetScalarMode());
928 //----------------------------------------------------------------------------
931 ::SetNbColors(CORBA::Long theNbColors)
933 VISU::TSetModified aModified(this);
935 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, int>
936 (GetSpecificPL(), &VISU_ColoredPL::SetNbColors, theNbColors));
939 //----------------------------------------------------------------------------
944 return GetSpecificPL()->GetNbColors();
947 //----------------------------------------------------------------------------
950 ::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation)
952 if ( myOrientation == theOrientation )
955 VISU::TSetModified aModified(this);
957 myOrientation = theOrientation;
958 myParamsTime.Modified();
961 //----------------------------------------------------------------------------
962 VISU::ColoredPrs3dBase::Orientation
964 ::GetBarOrientation()
966 return myOrientation;
969 //----------------------------------------------------------------------------
972 ::SetPosition(CORBA::Double theX, CORBA::Double theY)
974 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
975 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
979 VISU::TSetModified aModified(this);
981 myPosition[0] = theX;
982 myPosition[1] = theY;
983 myParamsTime.Modified();
986 //----------------------------------------------------------------------------
991 return myPosition[0];
994 //----------------------------------------------------------------------------
999 return myPosition[1];
1002 //----------------------------------------------------------------------------
1004 VISU::ColoredPrs3d_i
1005 ::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
1007 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
1008 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
1012 VISU::TSetModified aModified(this);
1015 myHeight = theHeight;
1016 myParamsTime.Modified();
1019 //----------------------------------------------------------------------------
1021 VISU::ColoredPrs3d_i
1027 //----------------------------------------------------------------------------
1029 VISU::ColoredPrs3d_i
1035 //----------------------------------------------------------------------------
1037 VISU::ColoredPrs3d_i
1038 ::SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
1039 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1041 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1042 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1043 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1044 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1048 VISU::TSetModified aModified(this);
1050 myTitleSize = theTitleSize;
1051 myLabelSize = theLabelSize;
1052 myBarWidth = theBarWidth;
1053 myBarHeight = theBarHeight;
1054 myParamsTime.Modified();
1057 //----------------------------------------------------------------------------
1059 VISU::ColoredPrs3d_i
1065 //----------------------------------------------------------------------------
1067 VISU::ColoredPrs3d_i
1073 //----------------------------------------------------------------------------
1075 VISU::ColoredPrs3d_i
1081 //----------------------------------------------------------------------------
1083 VISU::ColoredPrs3d_i
1089 //----------------------------------------------------------------------------
1091 VISU::ColoredPrs3d_i
1092 ::SetLabels(CORBA::Long theNbLabels)
1094 if(myNumberOfLabels == theNbLabels)
1097 VISU::TSetModified aModified(this);
1099 myNumberOfLabels = theNbLabels;
1100 myParamsTime.Modified();
1103 //----------------------------------------------------------------------------
1105 VISU::ColoredPrs3d_i
1108 return myNumberOfLabels;
1111 //----------------------------------------------------------------------------
1113 //----------------------------------------------------------------------------
1115 VISU::ColoredPrs3d_i
1116 ::SetLabelsFormat(const char* theFormat)
1118 if( myLabelsFormat != theFormat ){
1119 VISU::TSetModified aModified(this);
1120 myLabelsFormat = theFormat;
1121 myParamsTime.Modified();
1126 //----------------------------------------------------------------------------
1128 VISU::ColoredPrs3d_i
1131 return CORBA::string_dup(myLabelsFormat.c_str());
1134 //----------------------------------------------------------------------------
1136 VISU::ColoredPrs3d_i
1137 ::SetTitle(const char* theTitle)
1139 VISU::PValForTime aValForTime;
1140 VISU::TValField& aValField = GetScalarField()->myValField;
1141 VISU::TValField::iterator anIter = aValField.find(GetScalarTimeStampNumber());
1142 if (anIter != aValField.end())
1143 aValForTime = anIter->second;
1146 std::strstream aStream;
1147 const VISU::TTime& aTime = aValForTime->myTime;
1148 aStream<<theTitle<<" ";
1149 if(IsUnitsVisible()) {
1150 aStream << VISU_Convertor::GenerateName(aTime);
1153 aName.sprintf("%g", aTime.first);
1154 aStream << aName.toLatin1().data();
1156 aStream <<std::ends;
1157 std::string aScalarBarTitle = aStream.str();
1158 if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
1159 VISU::TSetModified aModified(this);
1161 myScalarBarTitle = aScalarBarTitle;
1163 myParamsTime.Modified();
1168 //----------------------------------------------------------------------------
1170 VISU::ColoredPrs3d_i
1173 return CORBA::string_dup(myTitle.c_str());
1176 //----------------------------------------------------------------------------
1178 VISU::ColoredPrs3d_i
1179 ::SetUnitsVisible(CORBA::Boolean theIsVisible)
1181 if ( myIsUnits == theIsVisible )
1184 VISU::TSetModified aModified( this );
1186 myIsUnits = theIsVisible;
1187 myParamsTime.Modified();
1190 //----------------------------------------------------------------------------
1192 VISU::ColoredPrs3d_i
1198 //----------------------------------------------------------------------------
1200 VISU::ColoredPrs3d_i
1206 //----------------------------------------------------------------------------
1208 VISU::ColoredPrs3d_i
1211 return myIsBoldTitle;
1214 //----------------------------------------------------------------------------
1216 VISU::ColoredPrs3d_i
1217 ::SetBoldTitle(bool theIsBoldTitle)
1219 if(myIsBoldTitle == theIsBoldTitle)
1222 VISU::TSetModified aModified(this);
1224 myIsBoldTitle = theIsBoldTitle;
1225 myParamsTime.Modified();
1228 //----------------------------------------------------------------------------
1230 VISU::ColoredPrs3d_i
1233 return myIsItalicTitle;
1236 //----------------------------------------------------------------------------
1238 VISU::ColoredPrs3d_i
1239 ::SetItalicTitle(bool theIsItalicTitle)
1241 if(myIsItalicTitle == theIsItalicTitle)
1244 VISU::TSetModified aModified(this);
1246 myIsItalicTitle = theIsItalicTitle;
1247 myParamsTime.Modified();
1250 //----------------------------------------------------------------------------
1252 VISU::ColoredPrs3d_i
1255 return myIsShadowTitle;
1258 //----------------------------------------------------------------------------
1260 VISU::ColoredPrs3d_i
1261 ::SetShadowTitle(bool theIsShadowTitle)
1263 if(myIsShadowTitle == theIsShadowTitle)
1266 VISU::TSetModified aModified(this);
1268 myIsShadowTitle = theIsShadowTitle;
1269 myParamsTime.Modified();
1272 //----------------------------------------------------------------------------
1274 VISU::ColoredPrs3d_i
1277 return myTitFontType;
1280 //----------------------------------------------------------------------------
1282 VISU::ColoredPrs3d_i
1283 ::SetTitFontType(int theTitFontType)
1285 if(myTitFontType == theTitFontType)
1288 VISU::TSetModified aModified(this);
1290 myTitFontType = theTitFontType;
1291 myParamsTime.Modified();
1294 //----------------------------------------------------------------------------
1296 VISU::ColoredPrs3d_i
1297 ::GetTitleColor(vtkFloatingPointType& theR,
1298 vtkFloatingPointType& theG,
1299 vtkFloatingPointType& theB)
1301 theR = myTitleColor[0];
1302 theG = myTitleColor[1];
1303 theB = myTitleColor[2];
1306 //----------------------------------------------------------------------------
1308 VISU::ColoredPrs3d_i
1309 ::SetTitleColor(vtkFloatingPointType theR,
1310 vtkFloatingPointType theG,
1311 vtkFloatingPointType theB)
1313 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1314 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1315 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1319 VISU::TSetModified aModified(this);
1321 myTitleColor[0] = theR;
1322 myTitleColor[1] = theG;
1323 myTitleColor[2] = theB;
1324 myParamsTime.Modified();
1327 //----------------------------------------------------------------------------
1329 VISU::ColoredPrs3d_i
1332 return myIsBoldLabel;
1335 //----------------------------------------------------------------------------
1337 VISU::ColoredPrs3d_i
1338 ::SetBoldLabel(bool theIsBoldLabel)
1340 if(myIsBoldLabel == theIsBoldLabel)
1343 VISU::TSetModified aModified(this);
1345 myIsBoldLabel = theIsBoldLabel;
1346 myParamsTime.Modified();
1349 //----------------------------------------------------------------------------
1351 VISU::ColoredPrs3d_i
1354 return myIsItalicLabel;
1357 //----------------------------------------------------------------------------
1359 VISU::ColoredPrs3d_i
1360 ::SetItalicLabel(bool theIsItalicLabel)
1362 if(myIsItalicLabel == theIsItalicLabel)
1365 VISU::TSetModified aModified(this);
1367 myIsItalicLabel = theIsItalicLabel;
1368 myParamsTime.Modified();
1371 //----------------------------------------------------------------------------
1373 VISU::ColoredPrs3d_i
1376 return myIsShadowLabel;
1379 //----------------------------------------------------------------------------
1381 VISU::ColoredPrs3d_i
1382 ::SetShadowLabel(bool theIsShadowLabel)
1384 if(myIsShadowLabel == theIsShadowLabel)
1387 VISU::TSetModified aModified(this);
1389 myIsShadowLabel = theIsShadowLabel;
1390 myParamsTime.Modified();
1393 //----------------------------------------------------------------------------
1395 VISU::ColoredPrs3d_i
1398 return myLblFontType;
1401 //----------------------------------------------------------------------------
1403 VISU::ColoredPrs3d_i
1404 ::SetLblFontType(int theLblFontType)
1406 if(myLblFontType == theLblFontType)
1409 VISU::TSetModified aModified(this);
1411 myLblFontType = theLblFontType;
1412 myParamsTime.Modified();
1415 //----------------------------------------------------------------------------
1417 VISU::ColoredPrs3d_i
1418 ::GetLabelColor(vtkFloatingPointType& theR,
1419 vtkFloatingPointType& theG,
1420 vtkFloatingPointType& theB)
1422 theR = myLabelColor[0];
1423 theG = myLabelColor[1];
1424 theB = myLabelColor[2];
1427 //----------------------------------------------------------------------------
1429 VISU::ColoredPrs3d_i
1430 ::SetLabelColor(vtkFloatingPointType theR,
1431 vtkFloatingPointType theG,
1432 vtkFloatingPointType theB)
1434 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1435 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1436 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1440 VISU::TSetModified aModified(this);
1442 myLabelColor[0] = theR;
1443 myLabelColor[1] = theG;
1444 myLabelColor[2] = theB;
1445 myParamsTime.Modified();
1449 //----------------------------------------------------------------------------
1451 VISU::ColoredPrs3d_i
1454 return myIsFixedRange;
1457 //----------------------------------------------------------------------------
1459 VISU::ColoredPrs3d_i
1460 ::UseFixedRange(bool theUseFixedRange)
1462 if(myIsFixedRange == theUseFixedRange)
1465 myIsFixedRange = theUseFixedRange;
1466 myParamsTime.Modified();
1469 //----------------------------------------------------------------------------
1471 VISU::ColoredPrs3d_i
1472 ::GetScalarBarTitle()
1474 return myScalarBarTitle;
1477 //----------------------------------------------------------------------------
1479 * Creates ColoredPrs3d and initialises it from resources
1482 VISU::ColoredPrs3d_i
1483 ::Create(const std::string& theMeshName,
1484 VISU::Entity theEntity,
1485 const std::string& theFieldName,
1486 CORBA::Long theTimeStampNumber)
1488 SetMeshName(theMeshName.c_str());
1489 SetEntity(theEntity);
1490 SetFieldName(theFieldName.c_str());
1491 SetTimeStampNumber(theTimeStampNumber);
1494 Build(ECreateNew); // to get corresponding input from result and initilize the pipeline
1496 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1498 int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
1499 SetScalarMode(aScalarMode);
1502 int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
1503 if ( aRangeType == 1 ) {
1504 float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
1505 float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
1506 SetRange( aMin, aMax );
1508 UseFixedRange( aRangeType == 1 );
1510 bool isFiltered = aResourceMgr->booleanValue("VISU", "scalar_bar_filter_by_scalars", false);
1511 UseScalarFiltering( isFiltered );
1513 int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
1514 SetNbColors(aNumberOfColors);
1516 bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true );
1517 SetUnitsVisible(isUnits);
1519 SetIsDistributionVisible( aResourceMgr->booleanValue("VISU", "scalar_bar_show_distribution", false) ); // RKV
1521 int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
1522 SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
1525 int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
1526 if(anOrientation == 1)
1527 SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL);
1529 SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL);
1531 // Scalar Bar origin
1532 QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
1534 vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.1;
1535 aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
1536 myPosition[0] = aXorigin;
1538 vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.01;
1539 aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
1540 myPosition[1] = aYorigin;
1543 myWidth = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.08 : 0.8;
1544 myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
1546 myHeight = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.08;
1547 myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
1550 myTitleSize = aResourceMgr->integerValue("VISU", propertyName + "title_size", myTitleSize);
1553 myLabelSize = aResourceMgr->integerValue("VISU", propertyName + "label_size", myLabelSize);
1556 myBarWidth = aResourceMgr->integerValue("VISU", propertyName + "bar_width", myBarWidth);
1559 myBarHeight = aResourceMgr->integerValue("VISU", propertyName + "bar_height", myBarHeight);
1561 // scalar bar default position
1562 bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
1564 if (anIsArrangeBar){
1565 aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
1567 if(myOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){
1568 myPosition[1] += myHeight*(aPlace-1);
1570 myPosition[0] += myWidth*(aPlace-1);
1574 myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
1576 // Fonts properties definition
1577 myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
1578 myTitFontType = VTK_ARIAL;
1580 if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){
1581 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
1582 if ( f.family() == "Arial" )
1583 myTitFontType = VTK_ARIAL;
1584 else if ( f.family() == "Courier" )
1585 myTitFontType = VTK_COURIER;
1586 else if ( f.family() == "Times" )
1587 myTitFontType = VTK_TIMES;
1589 myIsBoldTitle = f.bold();
1590 myIsItalicTitle = f.italic();
1591 myIsShadowTitle = f.overline();
1594 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1596 SetTitleColor(aTextColor.red()/255., aTextColor.green()/255., aTextColor.blue()/255.);
1598 myTitleColor[0] = aTextColor.red() / 255.;
1599 myTitleColor[1] = aTextColor.green() / 255.;
1600 myTitleColor[2] = aTextColor.blue() / 255.;
1602 myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
1603 myLblFontType = VTK_ARIAL;
1605 if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){
1606 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
1607 if ( f.family() == "Arial" )
1608 myLblFontType = VTK_ARIAL;
1609 else if ( f.family() == "Courier" )
1610 myLblFontType = VTK_COURIER;
1611 else if ( f.family() == "Times" )
1612 myLblFontType = VTK_TIMES;
1614 myIsBoldLabel = f.bold();
1615 myIsItalicLabel = f.italic();
1616 myIsShadowLabel = f.overline();
1619 QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1621 SetLabelColor(aLabelColor.red()/255., aLabelColor.green()/255., aLabelColor.blue()/255.);
1623 myLabelColor[0] = aLabelColor.red() / 255.;
1624 myLabelColor[1] = aLabelColor.green() / 255.;
1625 myLabelColor[2] = aLabelColor.blue() / 255.;
1627 // Parameters of labels displaed field values
1629 myValLblFontType = VTK_ARIAL;
1630 myIsBoldValLbl = true;
1631 myIsItalicValLbl = myIsShadowValLbl = false;
1632 myValLblFontSize = 12;
1633 if( aResourceMgr->hasValue( "VISU", "values_labeling_font" ) )
1636 QFont f = aResourceMgr->fontValue( "VISU", "values_labeling_font" );
1637 if ( f.family() == "Arial" )
1638 myValLblFontType = VTK_ARIAL;
1639 else if ( f.family() == "Courier" )
1640 myValLblFontType = VTK_COURIER;
1641 else if ( f.family() == "Times" )
1642 myValLblFontType = VTK_TIMES;
1645 if ( f.pointSize() > -1 )
1646 myValLblFontSize = f.pointSize();
1649 QColor aColor = aResourceMgr->colorValue(
1650 "VISU", "values_labeling_color", QColor( 255, 255, 255 ) );
1651 myValLblFontColor[ 0 ] = aColor.red() / 255.;
1652 myValLblFontColor[ 1 ] = aColor.green() / 255.;
1653 myValLblFontColor[ 2 ] = aColor.blue()/ 255.;
1655 // bold, italic, shadow
1656 myIsBoldValLbl = f.bold();
1657 myIsItalicValLbl = f.italic();
1658 myIsShadowValLbl = f.overline();
1665 //----------------------------------------------------------------------------
1667 VISU::ColoredPrs3d_i
1668 ::SaveRestoringState(SALOMEDS::SObject_ptr theSObject,
1669 const Storable::TRestoringMap& theMap)
1671 myRestoringSObject = SALOMEDS::SObject::_duplicate(theSObject);
1672 myRestoringMap = theMap;
1673 myIsRestored = false;
1677 //----------------------------------------------------------------------------
1679 VISU::ColoredPrs3d_i
1680 ::InitFromRestoringState()
1683 Restore(myRestoringSObject, myRestoringMap);
1684 myIsRestored = true;
1689 //----------------------------------------------------------------------------
1691 VISU::ColoredPrs3d_i
1692 ::Restore(SALOMEDS::SObject_ptr theSObject,
1693 const Storable::TRestoringMap& theMap)
1695 if(!TSuperClass::Restore(theSObject, theMap))
1698 SetEntity((VISU::Entity)VISU::Storable::FindValue(theMap,"myEntity").toInt());
1699 SetFieldName(VISU::Storable::FindValue(theMap,"myFieldName").toLatin1().data());
1700 SetTimeStampNumber(VISU::Storable::FindValue(theMap,"myIteration").toInt());
1701 myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed", "1").toInt();
1706 SetScalarMode(VISU::Storable::FindValue( theMap,"myScalarMode" ).toInt() );
1708 float aMin = VISU::Storable::FindValue( theMap, "myScalarRange[0]" ).toDouble();
1709 float aMax = VISU::Storable::FindValue( theMap, "myScalarRange[1]" ).toDouble();
1710 SetRange( aMin, aMax );
1713 bool isFiltered = VISU::Storable::FindValue( theMap, "myIsFilteredByScalars", "0" ).toInt();
1714 float aMin = VISU::Storable::FindValue( theMap, "myScalarFilterRange[0]" ).toDouble();
1715 float aMax = VISU::Storable::FindValue( theMap, "myScalarFilterRange[1]" ).toDouble();
1716 SetScalarFilterRange( aMin, aMax );
1717 UseScalarFiltering( isFiltered );
1719 SetIsDistributionVisible(VISU::Storable::FindValue(theMap,"myIsDistributionVisible", "0").toInt());
1721 UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
1723 SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
1724 SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
1725 SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g").toLatin1().data());
1726 SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt());
1728 SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().data());
1729 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
1730 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1731 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1732 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
1733 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
1734 myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
1735 myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
1736 myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
1737 myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
1739 myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
1740 myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
1741 myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
1742 myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
1743 myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
1744 myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
1745 myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
1747 myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
1748 myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
1749 myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
1750 myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
1751 myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
1752 myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
1753 myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
1756 QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList", &anIsExists);
1758 QStringList aGeomNameList = aGeomNames.split("|", QString::SkipEmptyParts);
1759 int aNbOfGroups = aGeomNameList.count();
1760 if(aNbOfGroups > 0){
1762 for(int aGroupNum = 0; aGroupNum < aNbOfGroups; aGroupNum++){
1763 QString aGroupName = aGeomNameList[aGroupNum];
1764 AddMeshOnGroup(aGroupName.toLatin1().data());
1769 // Parameters of labels displayed field values
1771 myValLblFontType = VISU::Storable::FindValue( theMap, "myValLblFontType", "0" ).toInt();
1772 myIsBoldValLbl = VISU::Storable::FindValue( theMap, "myIsBoldValLbl", "1" ).toInt();
1773 myIsItalicValLbl = VISU::Storable::FindValue( theMap, "myIsItalicValLbl", "0" ).toInt();
1774 myIsShadowValLbl = VISU::Storable::FindValue( theMap, "myIsShadowValLbl", "0" ).toInt();
1775 myValLblFontSize = VISU::Storable::FindValue( theMap, "myValLblFontSize", "12" ).toDouble();
1776 myValLblFontColor[ 0 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[0]", "1" ).toFloat();
1777 myValLblFontColor[ 1 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[1]", "1" ).toFloat();
1778 myValLblFontColor[ 2 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[2]", "1" ).toFloat();
1783 //----------------------------------------------------------------------------
1785 VISU::ColoredPrs3d_i
1786 ::ToStream(std::ostringstream& theStr)
1788 TSuperClass::ToStream(theStr);
1790 Storable::DataToStream( theStr, "myEntity", GetEntity() );
1791 Storable::DataToStream( theStr, "myFieldName", GetCFieldName().c_str() );
1792 Storable::DataToStream( theStr, "myIteration", int(GetTimeStampNumber()) );
1793 Storable::DataToStream( theStr, "myIsTimeStampFixed", int(myIsTimeStampFixed) );
1795 Storable::DataToStream( theStr, "myScalarMode", int(GetScalarMode()) );
1796 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
1797 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
1798 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
1800 Storable::DataToStream( theStr, "myIsFilteredByScalars", IsScalarFilterUsed() );
1801 Storable::DataToStream( theStr, "myScalarFilterRange[0]", GetScalarFilterMin() );
1802 Storable::DataToStream( theStr, "myScalarFilterRange[1]", GetScalarFilterMax() );
1804 Storable::DataToStream( theStr, "myIsDistributionVisible", GetIsDistributionVisible() ); // RKV
1806 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
1807 Storable::DataToStream( theStr, "myOrientation", myOrientation );
1809 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
1810 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
1811 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
1813 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
1815 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
1816 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
1817 Storable::DataToStream( theStr, "myWidth", myWidth );
1818 Storable::DataToStream( theStr, "myHeight", myHeight );
1819 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
1820 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
1821 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
1822 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
1824 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
1825 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
1826 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
1827 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
1828 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
1829 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
1830 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
1832 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
1833 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
1834 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
1835 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
1836 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
1837 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
1838 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
1840 // Parameters of labels displayed field values
1842 Storable::DataToStream( theStr, "myValLblFontType", myValLblFontType );
1843 Storable::DataToStream( theStr, "myIsBoldValLbl", myIsBoldValLbl );
1844 Storable::DataToStream( theStr, "myIsItalicValLbl", myIsItalicValLbl );
1845 Storable::DataToStream( theStr, "myIsShadowValLbl", myIsShadowValLbl );
1846 Storable::DataToStream( theStr, "myValLblFontSize", myValLblFontSize );
1847 Storable::DataToStream( theStr, "myValLblFontColor[0]", myValLblFontColor[ 0 ] );
1848 Storable::DataToStream( theStr, "myValLblFontColor[1]", myValLblFontColor[ 1 ] );
1849 Storable::DataToStream( theStr, "myValLblFontColor[2]", myValLblFontColor[ 2 ] );
1852 std::ostringstream aGeomNameList;
1853 std::string aMeshName = GetCMeshName();
1854 const TGroupNames& aGroupNames = GetGroupNames();
1855 TGroupNames::const_iterator anIter = aGroupNames.begin();
1856 for(; anIter != aGroupNames.end(); anIter++){
1857 const std::string& aGroupName = *anIter;
1858 aGeomNameList<<aGroupName<<"|";
1860 Storable::DataToStream(theStr, "myGeomNameList", aGeomNameList.str().c_str());
1863 //----------------------------------------------------------------------------
1864 const VISU::ColoredPrs3d_i
1866 VISU::ColoredPrs3d_i
1869 return myGroupNames;
1872 //----------------------------------------------------------------------------
1874 VISU::ColoredPrs3d_i
1877 return !myGroupNames.empty();
1881 //----------------------------------------------------------------------------
1883 VISU::ColoredPrs3d_i
1884 ::SetMapScale(double theMapScale)
1886 GetSpecificPL()->SetMapScale(theMapScale);
1890 //----------------------------------------------------------------------------
1892 VISU::ColoredPrs3d_i
1893 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
1895 if(MYDEBUG) MESSAGE("ColoredPrs3d_i::CreatePipeLine() - "<<thePipeLine);
1896 myColoredPL = dynamic_cast<VISU_ColoredPL*>(thePipeLine);
1898 SetPipeLine(myColoredPL);
1901 //----------------------------------------------------------------------------
1905 VISU::ColoredPrs3d_i
1906 ::Build(EBuildMode theBuildMode)
1909 MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theBuildMode = "<<theBuildMode);
1910 SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
1911 bool anIsPublishInStudy = (myPublishInStudyMode == EPublishUnderTimeStamp || myPublishInStudyMode == EPublishIndependently);
1912 if(anIsPublishInStudy)
1913 aStudyBuilder->NewCommand(); // There is a transaction
1918 SetName("NoName", false);
1919 if(theBuildMode == ECreateNew || theBuildMode == ESameAs){
1922 if(theBuildMode == ECreateNew)
1923 SetTitle(GetCFieldName().c_str());
1925 if(myPublishInStudyMode == EPublishUnderTimeStamp){
1926 SetName(GenerateName().toLatin1().data(), false);
1927 VISU::Storable::TRestoringMap aRestoringMap;
1928 aRestoringMap["myComment"] = "TIMESTAMP";
1929 aRestoringMap["myMeshName"] = GetCMeshName().c_str();
1930 aRestoringMap["myEntityId"] = QString::number(GetEntity());
1931 aRestoringMap["myFieldName"] = GetCFieldName().c_str();
1932 aRestoringMap["myTimeStampId"] = QString::number(GetTimeStampNumber());
1933 aRestoringMap["myNumComponent"] = QString::number(GetScalarField()->myNbComp);
1934 std::string anEntry = GetCResult()->GetEntry(aRestoringMap);
1936 throw std::runtime_error("There is no Entry for binding the presentation !!!");
1937 aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
1939 GetCMeshName().c_str(),
1941 GetCFieldName().c_str(),
1942 GetTimeStampNumber(),
1943 GetScalarField()->myNbComp);
1944 CORBA::String_var anIOR = GetID();
1945 CreateAttributes(GetStudyDocument(),
1951 aComment.toLatin1().data(),
1953 }else if(myPublishInStudyMode == EPublishIndependently){
1954 SetName(GenerateName().toLatin1().data(), false);
1955 CORBA::String_var anIOR = GetID();
1956 std::string aFatherEntry = ::FindOrCreate3DPresentationsFolder(GetStudyDocument());
1957 aComment.sprintf("myComment=%s",
1959 CreateAttributes(GetStudyDocument(),
1965 aComment.toLatin1().data(),
1969 }catch(std::exception& exc){
1970 INFOS("Follow exception was occured :\n"<<exc.what());
1973 INFOS("Unknown exception was occured!");
1978 if(anIsPublishInStudy)
1979 aStudyBuilder->CommitCommand();
1983 //----------------------------------------------------------------------------
1985 VISU::ColoredPrs3d_i
1986 ::SetIsDistributionVisible(CORBA::Boolean isVisible)
1988 if( myIsDistributionVisible != isVisible ){
1989 VISU::TSetModified aModified(this);
1990 myIsDistributionVisible = isVisible;
1991 myParamsTime.Modified();
1995 //----------------------------------------------------------------------------
1997 VISU::ColoredPrs3d_i
1998 ::GetIsDistributionVisible()
2000 return myIsDistributionVisible;
2003 //----------------------------------------------------------------------------
2007 VISU::ColoredPrs3d_i
2008 ::GetValLblFontType() const
2010 return myValLblFontType;
2013 //----------------------------------------------------------------------------
2016 VISU::ColoredPrs3d_i
2017 ::SetValLblFontType( const int theType )
2019 if ( myValLblFontType == theType )
2022 VISU::TSetModified aModified( this );
2024 myValLblFontType = theType;
2025 myParamsTime.Modified();
2028 //----------------------------------------------------------------------------
2031 VISU::ColoredPrs3d_i
2032 ::GetValLblFontSize() const
2034 return myValLblFontSize;
2037 //----------------------------------------------------------------------------
2040 VISU::ColoredPrs3d_i
2041 ::SetValLblFontSize( const double theSize )
2043 if ( VISU::CheckIsSameValue( myValLblFontSize, theSize ) )
2046 VISU::TSetModified aModified( this );
2048 myValLblFontSize = theSize;
2049 myParamsTime.Modified();
2052 //----------------------------------------------------------------------------
2055 VISU::ColoredPrs3d_i
2056 ::GetValLblFontColor( vtkFloatingPointType& theR,
2057 vtkFloatingPointType& theG,
2058 vtkFloatingPointType& theB ) const
2060 theR = myValLblFontColor[ 0 ];
2061 theG = myValLblFontColor[ 1 ];
2062 theB = myValLblFontColor[ 2 ];
2065 //----------------------------------------------------------------------------
2068 VISU::ColoredPrs3d_i
2069 ::SetValLblFontColor( const vtkFloatingPointType theR,
2070 const vtkFloatingPointType theG,
2071 const vtkFloatingPointType theB )
2073 if ( VISU::CheckIsSameValue( myValLblFontColor[ 0 ], theR ) &&
2074 VISU::CheckIsSameValue( myValLblFontColor[ 1 ], theG ) &&
2075 VISU::CheckIsSameValue (myValLblFontColor[ 2 ], theB ) )
2078 VISU::TSetModified aModified(this);
2080 myValLblFontColor[ 0 ] = theR;
2081 myValLblFontColor[ 1 ] = theG;
2082 myValLblFontColor[ 2 ] = theB;
2083 myParamsTime.Modified();
2086 //----------------------------------------------------------------------------
2089 VISU::ColoredPrs3d_i
2090 ::IsBoldValLbl() const
2092 return myIsBoldValLbl;
2095 //----------------------------------------------------------------------------
2098 VISU::ColoredPrs3d_i
2099 ::SetBoldValLbl( const bool theVal )
2101 if ( myIsBoldValLbl == theVal )
2104 VISU::TSetModified aModified( this );
2106 myIsBoldValLbl = theVal;
2107 myParamsTime.Modified();
2110 //----------------------------------------------------------------------------
2113 VISU::ColoredPrs3d_i
2114 ::IsItalicValLbl() const
2116 return myIsItalicValLbl;
2119 //----------------------------------------------------------------------------
2122 VISU::ColoredPrs3d_i
2123 ::SetItalicValLbl( const bool theVal )
2125 if ( myIsItalicValLbl == theVal )
2128 VISU::TSetModified aModified( this );
2130 myIsItalicValLbl = theVal;
2131 myParamsTime.Modified();
2134 //----------------------------------------------------------------------------
2137 VISU::ColoredPrs3d_i
2138 ::IsShadowValLbl() const
2140 return myIsShadowValLbl;
2143 //----------------------------------------------------------------------------
2146 VISU::ColoredPrs3d_i
2147 ::SetShadowValLbl( const bool theVal )
2149 if ( myIsShadowValLbl == theVal )
2152 VISU::TSetModified aModified( this );
2154 myIsShadowValLbl = theVal;
2155 myParamsTime.Modified();
2158 //----------------------------------------------------------------------------