// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
// File : VISU_PrsObject_i.cxx
// Module : VISU
#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_Prs3dUtils.hh"
-#include "VISU_ScalarMapPL.hxx"
#include "VISU_Result_i.hh"
+#include "VISU_ColoredPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
#include "VISU_Convertor.hxx"
#include "SUIT_ResourceMgr.h"
#include "SALOME_Event.hxx"
+#include <strstream>
#include <vtkMapper.h>
-
-using namespace VISU;
-using namespace std;
+#include <vtkDataSet.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
-//============================================================================
-VISU::ColoredPrs3d_i::
-ColoredPrs3d_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- myScalarMapPL(NULL),
- myIsFixedRange(false)
-{}
+//---------------------------------------------------------------
+namespace
+{
+ std::string
+ FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy)
+ {
+ static char aFolderName[] = "3D Presentations";
+ CORBA::String_var anEntry;
+ SALOMEDS::SObject_var aSObject = theStudy->FindObject(aFolderName);
+ if(!CORBA::is_nil(aSObject) && aSObject->Depth() == 3){
+ anEntry = aSObject->GetID();
+ return anEntry.in();
+ }
+ SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
+ CORBA::String_var aFatherEntry = aSComponent->GetID();
+ anEntry = VISU::CreateAttributes(theStudy,
+ aFatherEntry.in(),
+ "",
+ "",
+ aFolderName,
+ "",
+ "",
+ true).c_str();
+ return anEntry.in();
+ }
+}
+
+//---------------------------------------------------------------
+namespace VISU
+{
+ //---------------------------------------------------------------
+ inline
+ TMinMax
+ GetMinMax(VISU::Result_i* theResult,
+ VISU::PField theField,
+ vtkIdType theCompID)
+ {
+ if(!theResult->IsMinMaxDone())
+ theResult->GetInput()->BuildMinMax();
+
+ return theField->GetMinMax(theCompID);
+ }
+
+ //---------------------------------------------------------------
+ void
+ TMinMaxController
+ ::UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d)
+ {}
+
+
+ //---------------------------------------------------------------
+ vtkFloatingPointType
+ TMinMaxController
+ ::GetComponentMin(vtkIdType theCompID)
+ {
+ return VTK_LARGE_FLOAT;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkFloatingPointType
+ TMinMaxController
+ ::GetComponentMax(vtkIdType theCompID)
+ {
+ return -VTK_LARGE_FLOAT;
+ }
+
+ //---------------------------------------------------------------
+ struct TSimpleMinMaxController: virtual TVTKMinMaxController
+ {
+ VISU::Result_i* myResult;
+ VISU::ColoredPrs3d_i* myColoredPrs3d;
+
+ TSimpleMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d):
+ myResult(theColoredPrs3d->GetCResult()),
+ myColoredPrs3d(theColoredPrs3d)
+ {}
+
+ ~TSimpleMinMaxController()
+ {}
+
+ virtual
+ vtkFloatingPointType
+ GetComponentMin(vtkIdType theCompID)
+ {
+ if ( VISU::PField aField = myColoredPrs3d->GetScalarField() ) {
+ TMinMax aMinMax = GetMinMax(myResult, aField, theCompID);
+ return aMinMax.first;
+ }
+ return TMinMaxController::GetComponentMin(theCompID);
+ }
+
+ virtual
+ vtkFloatingPointType
+ GetComponentMax(vtkIdType theCompID)
+ {
+ if ( VISU::PField aField = myColoredPrs3d->GetScalarField() ) {
+ TMinMax aMinMax = GetMinMax(myResult, aField, theCompID);
+ return aMinMax.second;
+ }
+ return TMinMaxController::GetComponentMax(theCompID);
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ PMinMaxController
+ CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d)
+ {
+ return PMinMaxController(new TSimpleMinMaxController(theColoredPrs3d));
+ }
+
+
+ //---------------------------------------------------------------
+}
+
+
+//---------------------------------------------------------------
VISU::ColoredPrs3d_i::
-ColoredPrs3d_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- myScalarMapPL(NULL),
- myIsFixedRange(false)
+ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) :
+ myPublishInStudyMode(thePublishInStudyMode),
+ myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp),
+ myColoredPL(NULL),
+ myIsFixedRange(false),
+ myIsRestored(true)
{}
+//---------------------------------------------------------------
VISU::ColoredPrs3d_i
::~ColoredPrs3d_i()
{}
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::Register()
+{
+ TSuperClass::Register();
+}
+
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::Destroy()
+{
+ TSuperClass::Destroy();
+}
+
//---------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::RemoveFromStudy()
{
- struct TRemoveFromStudy: public SALOME_Event
+ struct TEvent: public SALOME_Event
{
VISU::ColoredPrs3d_i* myRemovable;
- TRemoveFromStudy(VISU::ColoredPrs3d_i* theRemovable):
+
+ TEvent(VISU::ColoredPrs3d_i* theRemovable):
myRemovable(theRemovable)
{}
Execute()
{
SALOMEDS::SObject_var aSObject = myRemovable->GetSObject();
+
if(!CORBA::is_nil(aSObject.in()))
VISU::RemoveFromStudy(aSObject,false);
+
myRemovable->TSuperClass::RemoveFromStudy();
}
};
- ProcessVoidEvent(new TRemoveFromStudy(this));
+ ProcessVoidEvent(new TEvent(this));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::UpdateFromResult(Result_i* theResult)
+{
+ struct TEvent: public SALOME_Event
+ {
+ VISU::ColoredPrs3d_i* myColoredPrs3d;
+
+ TEvent(VISU::ColoredPrs3d_i* theColoredPrs3d):
+ myColoredPrs3d(theColoredPrs3d)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ try{
+ myColoredPrs3d->DoSetInput(false, false);
+ myColoredPrs3d->UpdateActors();
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+ }
+ };
+
+ if ( theResult == GetCResult() )
+ ProcessVoidEvent(new TEvent(this));
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::SetInput(bool theReInit)
+{
+ try{
+ if(TSuperClass::SetInput(theReInit)){
+ if(CheckIsPossible()){
+ if(OnSetInput(theReInit)){
+ if(Create(GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber()))
+ return true;
+ }else
+ return true;
+ }
+ }
+ }catch(...){
+ }
+
+ return false;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::OnRestoreInput()
+{
+ TSuperClass::OnRestoreInput();
+ myEntity = myPreviousEntity;
+ myFieldName = myPreviousFieldName;
+ myTimeStampNumber = myPreviousTimeStampNumber;
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::OnSetInput(bool theReInit)
+{
+ bool anIsCreatNew = !IsPipeLineExists();
+ if(anIsCreatNew)
+ CreatePipeLine(NULL); // to create proper pipeline
+
+ try{
+ DoSetInput(anIsCreatNew, theReInit);
+
+ if(anIsCreatNew)
+ GetSpecificPL()->Init();
+
+ // To update scalar range according to the new input
+ if(!IsRangeFixed() && theReInit)
+ SetSourceRange();
+
+ if(GetPublishInStudyMode() != EDoNotPublish)
+ GetCResult()->ConnectObserver(this, myResultConnection);
+
+ myPreviousEntity = myEntity;
+ myPreviousFieldName = myFieldName;
+ myPreviousTimeStampNumber = myTimeStampNumber;
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ OnRestoreInput();
+ throw;
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ OnRestoreInput();
+ throw;
+ }
+
+ // To update title according to the new input
+ if(theReInit)
+ SetTitle(GetCFieldName().c_str());
+
+ return anIsCreatNew;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetEntity(VISU::Entity theEntity)
+{
+ if(myEntity == theEntity)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myEntity = theEntity;
+ myParamsTime.Modified();
+}
+
+
+//---------------------------------------------------------------
+VISU::Entity
+VISU::ColoredPrs3d_i
+::GetEntity()
+{
+ return myEntity;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TEntity
+VISU::ColoredPrs3d_i
+::GetTEntity() const
+{
+ return VISU::TEntity(int(myEntity));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetFieldName(const char* theFieldName)
+{
+ if(myFieldName == theFieldName)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myFieldName = theFieldName;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+char*
+VISU::ColoredPrs3d_i
+::GetFieldName()
+{
+ return CORBA::string_dup(myFieldName.c_str());
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetCFieldName() const
+{
+ return myFieldName;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PField
+VISU::ColoredPrs3d_i
+::GetField()
+{
+ return myField;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetField(VISU::PField theField)
+{
+ myField = theField;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetTimeStampNumber(CORBA::Long theTimeStampNumber)
+{
+ if(myTimeStampNumber == theTimeStampNumber)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myTimeStampNumber = theTimeStampNumber;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampNumber()
+{
+ return myTimeStampNumber;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampNumberByIndex( CORBA::Long theIndex )
+{
+ VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ if( theIndex >= 0 && theIndex < aLength )
+ {
+ VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ theIndex ];
+ return anInfo.myNumber;
+ }
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampIndexByNumber( CORBA::Long theNumber )
+{
+ VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ for( int index = 0; index < aLength; index++ )
+ {
+ VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ index ];
+
+ if( anInfo.myNumber == theNumber )
+ return index;
+ }
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PField
+VISU::ColoredPrs3d_i
+::GetScalarField()
+{
+ return myField;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PMinMaxController
+VISU::ColoredPrs3d_i
+::GetMinMaxController()
+{
+ return myMinMaxController;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetMinMaxController( const VISU::PMinMaxController& theController )
+{
+ myMinMaxController = theController;
+
+ if(!IsRangeFixed())
+ SetSourceRange();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetMinMaxController( VISU::ColoredPrs3d_i* theOrigin )
+{
+ VISU::PMinMaxController aController = theOrigin->GetMinMaxController();
+
+ if ( aController )
+ aController->UpdateReference( theOrigin, this );
+
+ SetMinMaxController( aController );
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetScalarTimeStampNumber() const
+{
+ return myTimeStampNumber;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder::TimeStampsRange*
+VISU::ColoredPrs3d_i
+::GetTimeStampsRange()
+{
+ VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange =
+ new VISU::ColoredPrs3dHolder::TimeStampsRange();
+ VISU::TValField& aValField = GetField()->myValField;
+ if(IsTimeStampFixed()){
+ aTimeStampsRange->length(1);
+ PValForTime& aValForTime = aValField[GetTimeStampNumber()];
+ std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
+ VISU::ColoredPrs3dHolder::TimeStampInfo anInfo;
+ anInfo.myNumber = GetTimeStampNumber();
+ anInfo.myTime = aTime.c_str();
+ aTimeStampsRange[0] = anInfo;
+ return aTimeStampsRange._retn();
+ }
+
+ // To exclude timstamps with repeated time
+ typedef std::map<std::string, long> TTimeStampsRange;
+ TTimeStampsRange aRange;
+ {
+ VISU::TValField::const_iterator anIter = aValField.begin();
+ for(; anIter != aValField.end(); anIter++){
+ vtkIdType aTimeStampNumber = anIter->first;
+ const PValForTime& aValForTime = anIter->second;
+ std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
+ aRange[aTime] = aTimeStampNumber;
+ }
+ }
+
+ // To sort timestamps according to their timestamp number
+ typedef std::map<long, std::string> TTimeStampsSortedRange;
+ TTimeStampsSortedRange aSortedRange;
+ {
+ TTimeStampsRange::const_iterator anIter = aRange.begin();
+ for(size_t aCounter = 0; anIter != aRange.end(); anIter++, aCounter++){
+ vtkIdType aTimeStampNumber = anIter->second;
+ const std::string& aTime = anIter->first;
+ aSortedRange[aTimeStampNumber] = aTime;
+ }
+ }
+
+ // To map the C++ data structures to the corresponding CORBA ones
+ {
+ aTimeStampsRange->length(aRange.size());
+ TTimeStampsSortedRange::const_iterator anIter = aSortedRange.begin();
+ for(size_t aCounter = 0; anIter != aSortedRange.end(); anIter++, aCounter++){
+ vtkIdType aTimeStampNumber = anIter->first;
+ const std::string& aTime = anIter->second;
+ VISU::ColoredPrs3dHolder::TimeStampInfo anInfo;
+ anInfo.myNumber = aTimeStampNumber;
+ anInfo.myTime = aTime.c_str();
+ aTimeStampsRange[aCounter] = anInfo;
+ }
+ }
+ return aTimeStampsRange._retn();
+}
+
+CORBA::Float
+VISU::ColoredPrs3d_i
+::GetMemorySize()
+{
+ return TSuperClass::GetMemorySize();
+}
+
+VISU::ColoredPrs3dHolder::BasicInput*
+VISU::ColoredPrs3d_i
+::GetBasicInput()
+{
+ VISU::ColoredPrs3dHolder::BasicInput* aBasicInput = new VISU::ColoredPrs3dHolder::BasicInput();
+ aBasicInput->myResult = GetResultObject();
+ aBasicInput->myMeshName = GetMeshName();
+ aBasicInput->myEntity = GetEntity();
+ aBasicInput->myFieldName = GetFieldName();
+ aBasicInput->myTimeStampNumber = GetTimeStampNumber();
+
+ return aBasicInput;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetHolderEntry(const std::string& theEntry)
+{
+ myHolderEntry = theEntry;
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetHolderEntry()
+{
+ return myHolderEntry;
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetActorEntry()
+{
+ if(myHolderEntry != "")
+ return myHolderEntry;
+ return TSuperClass::GetActorEntry();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3d_i
+::IsTimeStampFixed()
+{
+ return myIsTimeStampFixed;
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i::EPublishInStudyMode
+VISU::ColoredPrs3d_i
+::GetPublishInStudyMode()
+{
+ return myPublishInStudyMode;
}
//---------------------------------------------------------------
::SameAs(const Prs3d_i* theOrigin)
{
if(const ColoredPrs3d_i* aPrs3d = dynamic_cast<const ColoredPrs3d_i*>(theOrigin)){
- DoHook();
-
ColoredPrs3d_i* anOrigin = const_cast<ColoredPrs3d_i*>(aPrs3d);
-
- myField = anOrigin->GetField();
- myMeshName = myField->myMeshName;
- myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
- myIteration = anOrigin->GetIteration();
- myFieldName = anOrigin->GetFieldName();
-
- Build(-1);
+
+ bool anIsCreatNew = OnSetInput(false);
+ if(anIsCreatNew)
+ Build(ESameAs);
TSuperClass::SameAs(theOrigin);
- SetScalarMode(anOrigin->GetScalarMode());
+ CORBA::Long aNbComp = GetScalarField()->myNbComp;
+ CORBA::Long anOriginNbComp = anOrigin->GetScalarField()->myNbComp;
+ if(anOriginNbComp < aNbComp)
+ SetScalarMode(0);
+ else
+ SetScalarMode(anOrigin->GetScalarMode());
+
SetNbColors(anOrigin->GetNbColors());
+
+ SetUnitsVisible(anOrigin->IsUnitsVisible());
+ SetLabelsFormat(anOrigin->GetLabelsFormat());
+
SetBarOrientation(anOrigin->GetBarOrientation());
+ SetMinMaxController( anOrigin );
+
+ if(anOrigin->IsRangeFixed())
+ SetRange(anOrigin->GetMin(), anOrigin->GetMax());
+ else
+ SetSourceRange();
+
SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY());
SetSize(anOrigin->GetWidth(), anOrigin->GetHeight());
+ SetRatios(anOrigin->GetTitleWidth(), anOrigin->GetTitleHeight(),
+ anOrigin->GetLabelWidth(), anOrigin->GetLabelHeight(),
+ anOrigin->GetBarWidth(), anOrigin->GetBarHeight());
SetLabels(anOrigin->GetLabels());
- SetTitle(anOrigin->GetTitle());
-
+
+ SetTitle(anOrigin->GetTitle());
SetBoldTitle(anOrigin->IsBoldTitle());
SetItalicTitle(anOrigin->IsItalicTitle());
SetShadowTitle(anOrigin->IsShadowTitle());
SetTitFontType(anOrigin->GetTitFontType());
- float r,g,b;
+ vtkFloatingPointType r,g,b;
anOrigin->GetTitleColor(&r,&g,&b);
SetTitleColor(r,g,b);
SetLblFontType(anOrigin->GetLblFontType());
anOrigin->GetLabelColor(&r,&g,&b);
SetLabelColor(r,g,b);
+
+ myIsTimeStampFixed = anOrigin->IsTimeStampFixed();
+
+ SetHolderEntry( anOrigin->GetHolderEntry() );
+
+ myGroupNames = anOrigin->GetGroupNames();
}
}
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetScalarMode()
+{
+ return myColoredPL->GetScalarMode();
+}
+
+
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SameAsParams(const ColoredPrs3d_i* theOrigin)
+::SetScalarMode(CORBA::Long theScalarMode)
{
- int anIteration = GetIteration();
- SameAs(theOrigin);
- myIteration = anIteration;
+ CORBA::Long aNbComp = GetScalarField()->myNbComp;
+ if(aNbComp == 1)
+ theScalarMode = 1;
+ else if(theScalarMode > aNbComp)
+ theScalarMode = 0;
+
+ VISU::TSetModified aModified(this);
- Build(-1);
- Update();
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, int>
+ (GetSpecificPL(), &VISU_ColoredPL::SetScalarMode, theScalarMode));
}
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::ColoredPrs3d_i
+::GetMin()
+{
+ return myColoredPL->GetScalarRange()[0];
+}
//----------------------------------------------------------------------------
-CORBA::Long
+CORBA::Double
VISU::ColoredPrs3d_i
-::GetScalarMode()
+::GetMax()
{
- return myScalarMapPL->GetScalarMode();
+ return myColoredPL->GetScalarRange()[1];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetScalarMode(CORBA::Long theScalarMode)
+::SetRange(CORBA::Double theMin, CORBA::Double theMax)
+{
+ VISU::TSetModified aModified(this);
+
+ vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
+ (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
+
+ UseFixedRange(true);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetSourceRange()
+{
+ VISU::TSetModified aModified(this);
+
+ if(IsTimeStampFixed()){
+ GetSpecificPL()->SetSourceRange();
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_ColoredPL>
+ (GetSpecificPL(), &VISU_ColoredPL::SetSourceRange));
+ }else{
+ vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()};
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
+ (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange));
+ }
+ UseFixedRange(false);
+}
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::ColoredPrs3d_i
+::GetSourceMin()
+{
+ if(IsTimeStampFixed()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[0];
+ }
+ return GetComponentMin(GetScalarMode());
+}
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::ColoredPrs3d_i
+::GetSourceMax()
+{
+ if(IsTimeStampFixed()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[1];
+ }
+ return GetComponentMax(GetScalarMode());
+}
+
+
+//----------------------------------------------------------------------------
+struct TGetComponentMin: public SALOME_Event
+{
+ VISU::ColoredPrs3d_i* myColoredPrs3d;
+ vtkIdType myCompID;
+
+ typedef CORBA::Double TResult;
+ TResult myResult;
+
+ TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
+ vtkIdType theCompID ):
+ myColoredPrs3d( theColoredPrs3d ),
+ myCompID( theCompID )
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+ if ( aMinMaxController ) {
+ myResult = aMinMaxController->GetComponentMin( myCompID );
+ } else {
+ VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+ myResult = aTMinMax.first;
+ }
+ }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU::ColoredPrs3d_i
+::GetComponentMin(vtkIdType theCompID)
{
- myScalarMapPL->SetScalarMode(theScalarMode);
+ return ProcessEvent( new TGetComponentMin( this, theCompID ) );
}
-CORBA::Double
-VISU::ColoredPrs3d_i
-::GetMin()
+//----------------------------------------------------------------------------
+struct TGetComponentMax: public SALOME_Event
{
- return myScalarMapPL->GetScalarRange()[0];
-}
+ VISU::ColoredPrs3d_i* myColoredPrs3d;
+ vtkIdType myCompID;
-CORBA::Double
+ typedef CORBA::Double TResult;
+ TResult myResult;
+
+ TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
+ vtkIdType theCompID ):
+ myColoredPrs3d( theColoredPrs3d ),
+ myCompID( theCompID )
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+ if ( aMinMaxController ) {
+ myResult = aMinMaxController->GetComponentMax( myCompID );
+ } else {
+ VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+ myResult = aTMinMax.second;
+ }
+ }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType
VISU::ColoredPrs3d_i
-::GetMax()
+::GetComponentMax(vtkIdType theCompID)
{
- return myScalarMapPL->GetScalarRange()[1];
+ return ProcessEvent( new TGetComponentMax( this, theCompID ) );
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetNbColors(CORBA::Long theNbColors)
{
- myScalarMapPL->SetNbColors(theNbColors);
+ VISU::TSetModified aModified(this);
+
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, int>
+ (GetSpecificPL(), &VISU_ColoredPL::SetNbColors, theNbColors));
}
+//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
::GetNbColors()
{
- return myScalarMapPL->GetNbColors();
+ return GetSpecificPL()->GetNbColors();
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetBarOrientation(VISU::ScalarMap::Orientation theOrientation)
+::SetBarOrientation(VISU::ColoredPrs3d::Orientation theOrientation)
{
+ if(myOrientation == theOrientation)
+ return;
+
+ VISU::TSetModified aModified(this);
+
myOrientation = theOrientation;
+ myParamsTime.Modified();
}
-VISU::ScalarMap::Orientation
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d::Orientation
VISU::ColoredPrs3d_i
::GetBarOrientation()
{
return myOrientation;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetPosition(CORBA::Double X, CORBA::Double Y)
+::SetPosition(CORBA::Double theX, CORBA::Double theY)
{
- myPosition[0] = X;
- myPosition[1] = Y;
+ bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
+ anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
+ if(anIsSameValue)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myPosition[0] = theX;
+ myPosition[1] = theY;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetPosX()
return myPosition[0];
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetPosY()
return myPosition[1];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
{
+ bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
+ anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
+ if(anIsSameValue)
+ return;
+
+ VISU::TSetModified aModified(this);
+
myWidth = theWidth;
myHeight = theHeight;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetWidth()
return myWidth;
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetHeight()
return myHeight;
}
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight,
+ CORBA::Long theLabelWidth, CORBA::Long theLabelHeight,
+ CORBA::Long theBarWidth, CORBA::Long theBarHeight)
+{
+ bool anIsSameValue = VISU::CheckIsSameValue(myTitleWidth, theTitleWidth);
+ anIsSameValue &= VISU::CheckIsSameValue(myTitleHeight, theTitleHeight);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelWidth, theLabelWidth);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelHeight, theLabelHeight);
+ anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
+ anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
+ if(anIsSameValue)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myTitleWidth = theTitleWidth;
+ myTitleHeight = theTitleHeight;
+ myLabelWidth = theLabelWidth;
+ myLabelHeight = theLabelHeight;
+ myBarWidth = theBarWidth;
+ myBarHeight = theBarHeight;
+ myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTitleWidth()
+{
+ return myTitleWidth;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTitleHeight()
+{
+ return myTitleHeight;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetLabelWidth()
+{
+ return myLabelWidth;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetLabelHeight()
+{
+ return myLabelHeight;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetBarWidth()
+{
+ return myBarWidth;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetBarHeight()
+{
+ return myBarHeight;
+}
+
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetLabels(CORBA::Long theNbLabels)
{
+ if(myNumberOfLabels == theNbLabels)
+ return;
+
+ VISU::TSetModified aModified(this);
+
myNumberOfLabels = theNbLabels;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
::GetLabels()
return myNumberOfLabels;
}
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetLabelsFormat(const char* theFormat)
+{
+ if( myLabelsFormat != theFormat ){
+ VISU::TSetModified aModified(this);
+ myLabelsFormat = theFormat;
+ myParamsTime.Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+char*
+VISU::ColoredPrs3d_i
+::GetLabelsFormat()
+{
+ return CORBA::string_dup(myLabelsFormat.c_str());
+}
+
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetTitle(const char* theName)
+::SetTitle(const char* theTitle)
{
- myTitle = theName;
+ VISU::PValForTime aValForTime;
+ VISU::TValField& aValField = GetScalarField()->myValField;
+ VISU::TValField::iterator anIter = aValField.find(GetScalarTimeStampNumber());
+ if (anIter != aValField.end())
+ aValForTime = anIter->second;
+
+ if (aValForTime) {
+ std::strstream aStream;
+ const VISU::TTime& aTime = aValForTime->myTime;
+ aStream<<theTitle<<" ";
+ if(IsUnitsVisible()) {
+ aStream << VISU_Convertor::GenerateName(aTime);
+ } else {
+ QString aName;
+ aName.sprintf("%g", aTime.first);
+ aStream << aName;
+ }
+ aStream <<std::ends;
+ std::string aScalarBarTitle = aStream.str();
+ if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
+ VISU::TSetModified aModified(this);
+
+ myScalarBarTitle = aScalarBarTitle;
+ myTitle = theTitle;
+ myParamsTime.Modified();
+ }
+ }
}
+//----------------------------------------------------------------------------
char*
VISU::ColoredPrs3d_i
::GetTitle()
return CORBA::string_dup(myTitle.c_str());
}
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetUnitsVisible(CORBA::Boolean isVisible)
+{
+ if( myIsUnits != isVisible ){
+ VISU::TSetModified aModified(this);
+ myIsUnits = isVisible;
+ myParamsTime.Modified();
+ }
+}
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3d_i
+::IsUnitsVisible()
+{
+ return myIsUnits;
+}
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetCTitle()
+{
+ return myTitle;
+}
+
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsBoldTitle()
return myIsBoldTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetBoldTitle(bool isBold)
+::SetBoldTitle(bool theIsBoldTitle)
{
- myIsBoldTitle = isBold;
+ if(myIsBoldTitle == theIsBoldTitle)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsBoldTitle = theIsBoldTitle;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsItalicTitle()
return myIsItalicTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetItalicTitle(bool isItalic)
+::SetItalicTitle(bool theIsItalicTitle)
{
- myIsItalicTitle = isItalic;
+ if(myIsItalicTitle == theIsItalicTitle)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsItalicTitle = theIsItalicTitle;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsShadowTitle()
return myIsShadowTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetShadowTitle(bool isShadow)
+::SetShadowTitle(bool theIsShadowTitle)
{
- myIsShadowTitle = isShadow;
+ if(myIsShadowTitle == theIsShadowTitle)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsShadowTitle = theIsShadowTitle;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
int
VISU::ColoredPrs3d_i
::GetTitFontType()
return myTitFontType;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetTitFontType(int theType)
+::SetTitFontType(int theTitFontType)
{
- myTitFontType = theType;
+ if(myTitFontType == theTitFontType)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myTitFontType = theTitFontType;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::GetTitleColor(float* theR, float* theG, float* theB)
+::GetTitleColor(vtkFloatingPointType* theR,
+ vtkFloatingPointType* theG,
+ vtkFloatingPointType* theB)
{
*theR = myTitleColor[0];
*theG = myTitleColor[1];
*theB = myTitleColor[2];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetTitleColor(float theR, float theG, float theB)
+::SetTitleColor(vtkFloatingPointType theR,
+ vtkFloatingPointType theG,
+ vtkFloatingPointType theB)
{
+ bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
+ anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
+ anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
+ if(anIsSameValue)
+ return;
+
+ VISU::TSetModified aModified(this);
+
myTitleColor[0] = theR;
myTitleColor[1] = theG;
myTitleColor[2] = theB;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsBoldLabel()
return myIsBoldLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetBoldLabel(bool isBold)
+::SetBoldLabel(bool theIsBoldLabel)
{
- myIsBoldLabel = isBold;
+ if(myIsBoldLabel == theIsBoldLabel)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsBoldLabel = theIsBoldLabel;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsItalicLabel()
return myIsItalicLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetItalicLabel(bool isItalic)
+::SetItalicLabel(bool theIsItalicLabel)
{
- myIsItalicLabel = isItalic;
+ if(myIsItalicLabel == theIsItalicLabel)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsItalicLabel = theIsItalicLabel;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsShadowLabel()
return myIsShadowLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetShadowLabel(bool isShadow)
+::SetShadowLabel(bool theIsShadowLabel)
{
- myIsShadowLabel = isShadow;
+ if(myIsShadowLabel == theIsShadowLabel)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myIsShadowLabel = theIsShadowLabel;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
int
VISU::ColoredPrs3d_i
::GetLblFontType()
return myLblFontType;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetLblFontType(int theType)
+::SetLblFontType(int theLblFontType)
{
- myLblFontType = theType;
+ if(myLblFontType == theLblFontType)
+ return;
+
+ VISU::TSetModified aModified(this);
+
+ myLblFontType = theLblFontType;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::GetLabelColor(float* theR, float* theG, float* theB)
+::GetLabelColor(vtkFloatingPointType* theR,
+ vtkFloatingPointType* theG,
+ vtkFloatingPointType* theB)
{
*theR = myLabelColor[0];
*theG = myLabelColor[1];
*theB = myLabelColor[2];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetLabelColor(float theR, float theG, float theB)
+::SetLabelColor(vtkFloatingPointType theR,
+ vtkFloatingPointType theG,
+ vtkFloatingPointType theB)
{
+ bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
+ if(anIsSameValue)
+ return;
+
+ VISU::TSetModified aModified(this);
+
myLabelColor[0] = theR;
myLabelColor[1] = theG;
myLabelColor[2] = theB;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3d_i
+::IsRangeFixed()
+{
+ return myIsFixedRange;
}
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::UseFixedRange(bool theUseFixedRange)
+{
+ if(myIsFixedRange == theUseFixedRange)
+ return;
+
+ myIsFixedRange = theUseFixedRange;
+ myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetScalarBarTitle()
+{
+ return myScalarBarTitle;
+}
//----------------------------------------------------------------------------
/**
*/
VISU::Storable*
VISU::ColoredPrs3d_i
-::Create(const char* theMeshName,
+::Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration)
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- DoHook(); // to create proper pipeline
-
- myMeshName = theMeshName;
- myEntity = (VISU::TEntity)theEntity;
- myFieldName =theFieldName;
- myIteration = theIteration;
+ SetMeshName(theMeshName.c_str());
+ SetEntity(theEntity);
+ SetFieldName(theFieldName.c_str());
+ SetTimeStampNumber(theTimeStampNumber);
+ OnSetInput(false);
- Build(false); // to get corresponding input from result and initilize the pipeline
+ Build(ECreateNew); // to get corresponding input from result and initilize the pipeline
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
SetScalarMode(aScalarMode);
+ // Scalar Range
+ int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
+ if(aRangeType == 1){
+ float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
+ float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
+ SetRange(aMin, aMax);
+ }
+ UseFixedRange(aRangeType == 1);
+
int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
SetNbColors(aNumberOfColors);
+ bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true );
+ SetUnitsVisible(isUnits);
+
+ QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" );
+ const char *lf=aLabelsFormat.latin1();
+ SetLabelsFormat(lf);
+
// Orientation
int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
if(anOrientation == 1)
- myOrientation = VISU::ScalarMap::HORIZONTAL;
+ SetBarOrientation(VISU::ColoredPrs3d::HORIZONTAL);
else
- myOrientation = VISU::ScalarMap::VERTICAL;
+ SetBarOrientation(VISU::ColoredPrs3d::VERTICAL);
// Scalar Bar origin
QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
- float aXorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.01 : 0.2;
+ vtkFloatingPointType aXorigin = (myOrientation == VISU::ColoredPrs3d::VERTICAL) ? 0.01 : 0.2;
aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
myPosition[0] = aXorigin;
- float aYorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.1 : 0.012;
+ vtkFloatingPointType aYorigin = (myOrientation == VISU::ColoredPrs3d::VERTICAL) ? 0.1 : 0.012;
aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
myPosition[1] = aYorigin;
// Scalar Bar size
- myWidth = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.1 : 0.6;
+ myWidth = (myOrientation == VISU::ColoredPrs3d::VERTICAL)? 0.1 : 0.6;
myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
- myHeight = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12;
+ myHeight = (myOrientation == VISU::ColoredPrs3d::VERTICAL)? 0.8:0.12;
myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
+ myTitleWidth = 0;
+ myTitleWidth = aResourceMgr->integerValue("VISU", propertyName + "title_width", myTitleWidth);
+
+ myTitleHeight = 0;
+ myTitleHeight = aResourceMgr->integerValue("VISU", propertyName + "title_height", myTitleHeight);
+
+ myLabelWidth = 0;
+ myLabelWidth = aResourceMgr->integerValue("VISU", propertyName + "label_width", myLabelWidth);
+
+ myLabelHeight = 0;
+ myLabelHeight = aResourceMgr->integerValue("VISU", propertyName + "label_height", myLabelHeight);
+
+ myBarWidth = 0;
+ myBarWidth = aResourceMgr->integerValue("VISU", propertyName + "bar_width", myBarWidth);
+
+ myBarHeight = 0;
+ myBarHeight = aResourceMgr->integerValue("VISU", propertyName + "bar_height", myBarHeight);
+
// scalar bar default position
bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
int aPlace = 1;
if (anIsArrangeBar){
aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
}
- if(myOrientation == VISU::ScalarMap::HORIZONTAL){
+ if(myOrientation == VISU::ColoredPrs3d::HORIZONTAL){
myPosition[1] += myHeight*(aPlace-1);
} else {
myPosition[0] += myWidth*(aPlace-1);
return this;
}
-VISU::Storable*
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SaveRestoringState(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap)
+{
+ myRestoringSObject = SALOMEDS::SObject::_duplicate(theSObject);
+ myRestoringMap = theMap;
+ myIsRestored = false;
+}
+
+
+//----------------------------------------------------------------------------
+void
VISU::ColoredPrs3d_i
-::Restore(const Storable::TRestoringMap& theMap)
+::InitFromRestoringState()
{
- DoHook();
+ if(!myIsRestored){
+ Restore(myRestoringSObject, myRestoringMap);
+ myIsRestored = true;
+ }
+}
- myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
- myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
- myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
- myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
- myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3d_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap)
+{
+ if(!TSuperClass::Restore(theSObject, theMap))
+ return NULL;
- Build(true);
+ SetEntity((VISU::Entity)VISU::Storable::FindValue(theMap,"myEntity").toInt());
+ SetFieldName(VISU::Storable::FindValue(theMap,"myFieldName").latin1());
+ SetTimeStampNumber(VISU::Storable::FindValue(theMap,"myIteration").toInt());
+ myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed", "1").toInt();
+ OnSetInput(false);
- TSuperClass::Restore(theMap);
+ Build(ERestore);
SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
+ float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
+ float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
+ SetRange(aMin, aMax);
+
+ UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
+
SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
- SetBarOrientation((VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt());
+ SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
+ SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g"));
+ SetBarOrientation((VISU::ColoredPrs3d::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt());
- myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
+ SetTitle(VISU::Storable::FindValue(theMap,"myTitle").latin1());
myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
+ myTitleWidth = VISU::Storable::FindValue(theMap,"myTitleWidth").toInt();
+ myTitleHeight = VISU::Storable::FindValue(theMap,"myTitleHeight").toInt();
+ myLabelWidth = VISU::Storable::FindValue(theMap,"myLabelWidth").toInt();
+ myLabelHeight = VISU::Storable::FindValue(theMap,"myLabelHeight").toInt();
+ myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
+ myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
+ bool anIsExists;
+ QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList", &anIsExists);
+ if(anIsExists){
+ QStringList aGeomNameList = QStringList::split("|", aGeomNames);
+ int aNbOfGroups = aGeomNameList.count();
+ if(aNbOfGroups > 0){
+ RemoveAllGeom();
+ for(int aGroupNum = 0; aGroupNum < aNbOfGroups; aGroupNum++){
+ QString aGroupName = aGeomNameList[aGroupNum];
+ AddMeshOnGroup(aGroupName.latin1());
+ }
+ }
+ }
return this;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::ToStream(std::ostringstream& theStr)
{
TSuperClass::ToStream(theStr);
+ Storable::DataToStream( theStr, "myEntity", GetEntity() );
+ Storable::DataToStream( theStr, "myFieldName", GetCFieldName() );
+ Storable::DataToStream( theStr, "myIteration", int(GetTimeStampNumber()) );
+ Storable::DataToStream( theStr, "myIsTimeStampFixed", int(myIsTimeStampFixed) );
+
Storable::DataToStream( theStr, "myScalarMode", int(GetScalarMode()) );
+ Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
+ Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
+ Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
+
Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
Storable::DataToStream( theStr, "myOrientation", myOrientation );
- Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
- Storable::DataToStream( theStr, "myEntity", myEntity );
- Storable::DataToStream( theStr, "myFieldName", myFieldName.c_str() );
- Storable::DataToStream( theStr, "myIteration", myIteration );
-
Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
+ Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
+ Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
Storable::DataToStream( theStr, "myWidth", myWidth );
Storable::DataToStream( theStr, "myHeight", myHeight );
+ Storable::DataToStream( theStr, "myTitleWidth", myTitleWidth );
+ Storable::DataToStream( theStr, "myTitleHeight", myTitleHeight );
+ Storable::DataToStream( theStr, "myLabelWidth", myLabelWidth );
+ Storable::DataToStream( theStr, "myLabelHeight", myLabelHeight );
+ Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
+ Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
+
+ std::ostringstream aGeomNameList;
+ std::string aMeshName = GetCMeshName();
+ const TGroupNames& aGroupNames = GetGroupNames();
+ TGroupNames::const_iterator anIter = aGroupNames.begin();
+ for(; anIter != aGroupNames.end(); anIter++){
+ const std::string& aGroupName = *anIter;
+ aGeomNameList<<aGroupName<<"|";
+ }
+ Storable::DataToStream(theStr, "myGeomNameList", aGeomNameList.str());
+}
+
+//----------------------------------------------------------------------------
+const VISU::ColoredPrs3d_i
+::TGroupNames&
+VISU::ColoredPrs3d_i
+::GetGroupNames()
+{
+ return myGroupNames;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::IsGroupsUsed()
+{
+ return !myGroupNames.empty();
}
//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::DoHook()
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
{
- if(MYDEBUG) MESSAGE("ColoredPrs3d_i::DoHook() - "<<myPipeLine);
- if(!myPipeLine){
- myPipeLine = VISU_ScalarMapPL::New();
- myPipeLine->GetMapper()->SetScalarVisibility(1);
- }
- myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
+ if(MYDEBUG) MESSAGE("ColoredPrs3d_i::CreatePipeLine() - "<<thePipeLine);
+ myColoredPL = dynamic_cast<VISU_ColoredPL*>(thePipeLine);
+
+ SetPipeLine(myColoredPL);
}
//----------------------------------------------------------------------------
+
+
VISU::Storable*
VISU::ColoredPrs3d_i
-::Build(int theRestoring)
+::Build(EBuildMode theBuildMode)
{
if(MYDEBUG)
- MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
- if(myAddToStudy)
+ MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theBuildMode = "<<theBuildMode);
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
+ bool anIsPublishInStudy = (myPublishInStudyMode == EPublishUnderTimeStamp || myPublishInStudyMode == EPublishIndependently);
+ if(anIsPublishInStudy)
aStudyBuilder->NewCommand(); // There is a transaction
#ifndef _DEXCEPT_
try{
#endif
- DoSetInput(myResult);
QString aComment;
- myName = "NoName";
- if(theRestoring <= 0){
- if(theRestoring == 0) myScalarMapPL->Init();
- if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
- const VISU::TValField& aValField = myField->myValField;
- const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
- aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
- if (theRestoring == 0) myTitle = aComment.simplifyWhiteSpace().latin1();
+ SetName("NoName", false);
+ if(theBuildMode == ECreateNew || theBuildMode == ESameAs){
+ if(!IsRangeFixed())
+ SetSourceRange();
+ if(theBuildMode == ECreateNew)
+ SetTitle(GetCFieldName().c_str());
}
- if(myAddToStudy){
- myName = GenerateName().latin1();
- aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
- string aResultEntry = myResult->GetEntry();
- string aRefFatherEntry = myResult->GetRefFatherEntry();
- string anEntry = myResult->GetEntry(aComment.latin1());
- if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
+ if(myPublishInStudyMode == EPublishUnderTimeStamp){
+ SetName(GenerateName().latin1(), false);
+ VISU::Storable::TRestoringMap aRestoringMap;
+ aRestoringMap["myComment"] = "TIMESTAMP";
+ aRestoringMap["myMeshName"] = GetCMeshName();
+ aRestoringMap["myEntityId"] = QString::number(GetEntity());
+ aRestoringMap["myFieldName"] = GetCFieldName();
+ aRestoringMap["myTimeStampId"] = QString::number(GetTimeStampNumber());
+ aRestoringMap["myNumComponent"] = QString::number(GetScalarField()->myNbComp);
+ std::string anEntry = GetCResult()->GetEntry(aRestoringMap);
+ if(anEntry == "")
+ throw std::runtime_error("There is no Entry for binding the presentation !!!");
aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
+ GetComment(),
+ GetCMeshName().c_str(),
+ GetEntity(),
+ GetCFieldName().c_str(),
+ GetTimeStampNumber(),
+ GetScalarField()->myNbComp);
CORBA::String_var anIOR = GetID();
- CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
- mySObject = myStudy->FindObjectIOR(anIOR);
+ CreateAttributes(GetStudyDocument(),
+ anEntry,
+ GetIconName(),
+ anIOR.in(),
+ GetName(),
+ "",
+ aComment.latin1(),
+ true);
+ }else if(myPublishInStudyMode == EPublishIndependently){
+ SetName(GenerateName().latin1(), false);
+ CORBA::String_var anIOR = GetID();
+ std::string aFatherEntry = ::FindOrCreate3DPresentationsFolder(GetStudyDocument());
+ aComment.sprintf("myComment=%s",
+ GetComment());
+ CreateAttributes(GetStudyDocument(),
+ aFatherEntry,
+ GetIconName(),
+ anIOR.in(),
+ GetName(),
+ "",
+ aComment.latin1(),
+ true);
}
#ifndef _DEXCEPT_
}catch(std::exception& exc){
throw;
}
#endif
- if(myAddToStudy)
+
+ if(anIsPublishInStudy)
aStudyBuilder->CommitCommand();
return this;
}
-
-
-//----------------------------------------------------------------------------
-const VISU::PField&
-VISU::ColoredPrs3d_i
-::GetField() const
-{
- return myField;
-}
-
-const std::string&
-VISU::ColoredPrs3d_i
-::GetMeshName() const
-{
- return myMeshName;
-}
-
-VISU::Entity
-VISU::ColoredPrs3d_i
-::GetEntity() const
-{
- return VISU::Entity(myEntity);
-}
-
-const std::string&
-VISU::ColoredPrs3d_i
-::GetFieldName() const
-{
- return myFieldName;
-}
-
-int
-VISU::ColoredPrs3d_i
-::GetIteration() const
-{
- return myIteration;
-}
-
-VISU_ScalarMapPL*
-VISU::ColoredPrs3d_i
-::GetScalarMapPL()
-{
- return myScalarMapPL;
-}