From: apo Date: Mon, 19 Dec 2005 06:37:57 +0000 (+0000) Subject: Fix for Bug GVIEW10649 X-Git-Tag: TG-D5-38-2003_D2005-20-12~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff5232d37ced7b915f406e502aeec39b002f434f;p=modules%2Fvisu.git Fix for Bug GVIEW10649 min / max marks shown on global scalal bar while still computing min / max --- diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 95b7cb1a..4a5ac993 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -200,7 +200,11 @@ namespace VISU TMinMax GetMinMax(vtkIdType theCompID) = 0; - TField(): myNbComp(0) + bool myIsMinMaxInitilized; //!< Is the min / max values are calculated + + TField(): + myNbComp(0), + myIsMinMaxInitilized(false) {} }; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 4cb7050c..cc379d7d 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1173,6 +1173,7 @@ VISU_MedConvertor aNbComp2 = 3; TMinMaxArr& aMinMaxArr = aField->myMinMaxArr; + TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized); for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()"); INITMSG(MYDEBUG,"- iTimeStamp = "<SetRepresentation(VTK_WIREFRAME); myCellActor->SetSource(myCellSource.GetPointer()); - //vtkDataSetMapper* aCellMapper = vtkDataSetMapper::New(); - //aCellMapper->SetInput(myCellSource.GetPointer()); - //myCellActor->SetMapper(aCellMapper); - myCellActor->SetVisibility(0); myCellActor->SetPickable(0); myCellActor->GetProperty()->SetAmbient(1.0); myCellActor->GetProperty()->SetDiffuse(0.0); - //myCellActor->GetProperty()->SetRepresentationToWireframe(); myScalarBarCtrl->Delete(); - myScalarBarCtrl->SetMode(0); - myScalarBarCtrl->SetRangeGlobal(0.,10.); - myScalarBarCtrl->SetOrientationToHorizontal(); - myScalarBarCtrl->GetScalarBarActor(0)->SetTitle("GLB"); - myScalarBarCtrl->GetScalarBarActor(1)->SetTitle("LOC"); } VISU_GaussPtsAct @@ -251,7 +241,6 @@ VISU_GaussPtsAct myDeviceActor->AddToRender(theRenderer); theRenderer->AddActor(myTextActor.GetPointer()); - //theRenderer->AddActor(myCellActor.GetPointer()); myCellActor->AddToRender(theRenderer); myCursorPyramid->AddToRender(theRenderer); @@ -270,7 +259,6 @@ VISU_GaussPtsAct myDeviceActor->RemoveFromRender(theRenderer); theRenderer->RemoveActor(myTextActor.GetPointer()); - //theRenderer->RemoveActor(myCellActor.GetPointer()); myCellActor->RemoveFromRender(theRenderer); myCursorPyramid->RemoveFromRender(theRenderer); @@ -485,7 +473,8 @@ VISU_GaussPtsAct ::SetBarVisibility(bool theMode) { myBarVisibility = theMode; - myScalarBarCtrl->SetCtrlVisibility((int)theMode); + myScalarBarCtrl->SetCtrlVisibility(theMode); + myScalarBarCtrl->SetVisibility(GetVisibility()); } bool @@ -944,7 +933,6 @@ VISU_GaussPtsAct vtkIdType aCellID = aGaussPointID.first; vtkCell* aCell = aParent->GetElemCell(aCellID); myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); - //myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug myCellActor->SetVisibility(anIsVisible && theIsHighlight); myCellActor->SetRepresentation(VTK_WIREFRAME); } @@ -1467,7 +1455,7 @@ VISU_GaussPtsAct2 if(theWidgetCtrl){ myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction()); - myDeviceActor->SetVisibility(Superclass::GetVisibility() && theWidgetCtrl->GetEnabled()); + myDeviceActor->SetVisibility(Superclass::GetVisibility()); } Superclass::SetWidgetCtrl(theWidgetCtrl); @@ -1483,14 +1471,14 @@ VISU_GaussPtsAct2 Superclass::SetVisibility(theMode); - myDeviceActor->SetVisibility(Superclass::GetVisibility() && myWidgetCtrl->GetEnabled()); + myDeviceActor->SetVisibility(GetVisibility()); } int VISU_GaussPtsAct2 ::GetVisibility() { - return Superclass::GetVisibility() && myWidgetCtrl->GetEnabled(); + return Superclass::GetVisibility(); } void @@ -1500,10 +1488,9 @@ VISU_GaussPtsAct2 switch(theEvent){ case vtkCommand::EnableEvent: case vtkCommand::DisableEvent: - myDeviceActor->SetVisibility(Superclass::GetVisibility() && myWidgetCtrl->GetEnabled()); - if (theEvent==vtkCommand::EnableEvent){ + myDeviceActor->SetVisibility(GetVisibility()); + if(theEvent == vtkCommand::EnableEvent) Update(); - } break; case vtkCommand::EndInteractionEvent: Update(); diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.cxx b/src/PIPELINE/VISU_ScalarBarCtrl.cxx index 4554d1fb..561b2432 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.cxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.cxx @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_ScalarBarCtrl.hxx" + #include #include #include @@ -34,603 +35,486 @@ #include #include #include + #include -// -static - void MarkValueByColor(vtkLookupTable* theTable, - float theValue, - unsigned char* theColor); -// + + +//---------------------------------------------------------------------------- +namespace +{ + inline + void + MarkValueByColor(vtkLookupTable* theTable, + float theValue, + unsigned char* theColor) + { + vtkIdType anIndex = theTable->GetIndex(theValue); + unsigned char *aTablePtr = theTable->GetPointer(anIndex); + aTablePtr[0] = theColor[0]; + aTablePtr[1] = theColor[1]; + aTablePtr[2] = theColor[2]; + } + + inline + void + CopyColor(unsigned char* theTaget, const unsigned char* theSource) + { + theTaget[0] = theSource[0]; + theTaget[1] = theSource[1]; + theTaget[2] = theSource[2]; + } + + void + FillByColor(vtkLookupTable* theTable, + unsigned char* theColor) + { + vtkIdType aNbColors = theTable->GetNumberOfColors(); + for(int i = 0; i < aNbColors; i++){ + unsigned char *aTablePtr = theTable->GetPointer(i); + CopyColor(aTablePtr,theColor); + } + } + + void + MakeBiColor(vtkLookupTable* theTable) + { + unsigned char aRedPtr[3] = {255, 0, 0}; + unsigned char aBluePtr[3] = {0, 0, 255}; + + float aRange[2]; + theTable->GetTableRange(aRange); + vtkIdType aNbColors = theTable->GetNumberOfColors(); + + float aDelta = (aRange[1]-aRange[0])/aNbColors; + float aValue = aRange[0]+0.5*aDelta; + for(int i = 0; i < aNbColors; i++){ + vtkIdType anIndex = theTable->GetIndex(aValue); + unsigned char* aTablePtr = theTable->GetPointer(anIndex); + if(aValue > 0.0){ + CopyColor(aTablePtr,aRedPtr); + }else{ + CopyColor(aTablePtr,aBluePtr); + } + aValue += aDelta; + } + } +} + + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_ScalarBarCtrl); -//================================================================== -// function : Ctor -// purpose : -//================================================================== -VISU_ScalarBarCtrl::VISU_ScalarBarCtrl() + +//---------------------------------------------------------------------------- +VISU_ScalarBarCtrl +::VISU_ScalarBarCtrl(): + myGlobalRangeIsDefined(false) { myDistance=0.02; - myL=0.8; - myB=0.15; myPosition[0]=0.15; myPosition[1]=0.01; myBicolor=false; - myMaximumNumberOfColors=256; myMarked=false; myMarkedValue=99.; // - int i; - // - for (i=0; i<2; ++i){ - float aX; - - aX=(float)i; - myRangeLocal[i]=aX; - myRangeGlobal[i]=aX; - } - // - //myMode=0; //0-simple ; 1-global; 2-local - SetMode(0); - // - myScalarBarNumberMax=2; - for (i=0; iSetHueRange(0.667,0.0); - myXLT[i]->SetNumberOfColors((vtkIdType)myMaximumNumberOfColors); - // - mySBA[i]=vtkScalarBarActor::New(); - mySBA[i]->SetMaximumNumberOfColors(myMaximumNumberOfColors); - } - // - SetOrientation(1);//VERTICAL - // - for (i=0; i<4; ++i){ - myBlack[i]=0; - myGrey[i]=192; - } + SetMode(eSimple); + + // Initilize global scalar bar + myGlobalLookupTable = vtkLookupTable::New(); + myGlobalLookupTable->SetHueRange(0.667,0.0); + + myGlobalScalarBar = vtkScalarBarActor::New(); + myGlobalScalarBar->SetLookupTable(myGlobalLookupTable); + myGlobalLookupTable->Delete(); + + // Initilize local scalar bar + myLocalLookupTable = vtkLookupTable::New(); + myLocalLookupTable->SetHueRange(0.667,0.0); + + myLocalScalarBar = vtkScalarBarActor::New(); + myLocalScalarBar->SetLookupTable(myLocalLookupTable); + myLocalLookupTable->Delete(); + + myBlack[0] = myBlack[1] = myBlack[2] = 0; + myGrey[0] = myGrey[1] = myGrey[2] = 192; // - myCtrlVisibility=1; + myCtrlVisibility = 1; SetVisibility(1); } -//================================================================== -// function : ~ -// purpose : -//================================================================== -VISU_ScalarBarCtrl::~VISU_ScalarBarCtrl() + + +//---------------------------------------------------------------------------- +VISU_ScalarBarCtrl +::~VISU_ScalarBarCtrl() { + myGlobalScalarBar->Delete(); } -//================================================================== -// function : SetMode -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetMode(const int theMode) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetMode(VISU_ScalarBarCtrl::EMode theMode) { - myMode=theMode; - //myScalarBarNumber=myScalarBarNumberMax; - //if(!myMode){ - // myScalarBarNumber=1; - //} + myMode = theMode; } -//================================================================== -// function : GetMode -// purpose : -//================================================================== -int VISU_ScalarBarCtrl::GetMode()const + +VISU_ScalarBarCtrl::EMode +VISU_ScalarBarCtrl +::GetMode() const { return myMode; } -//================================================================== -// function : SetVisibility -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetVisibility(const int theFlag) -{ - int iVisibility=(myCtrlVisibility && theFlag); - for (int i=0; i<2; ++i){ - mySBA[i]->SetVisibility(iVisibility); + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetVisibility(int theVisibility) +{ + myGlobalScalarBar->SetVisibility(false); + myLocalScalarBar->SetVisibility(false); + int aVisibility = (myCtrlVisibility && theVisibility); + if(aVisibility){ + if(myMode != eSimple) + myGlobalScalarBar->SetVisibility(aVisibility); + myLocalScalarBar->SetVisibility(aVisibility); } } -//================================================================== -// function : GetVisibility -// purpose : -//================================================================== -int VISU_ScalarBarCtrl::GetVisibility()const + +int +VISU_ScalarBarCtrl +::GetVisibility() const { - return mySBA[0]->GetVisibility(); + return myGlobalScalarBar->GetVisibility() || myLocalScalarBar->GetVisibility(); } -//================================================================== -// function : SetCtrlVisibility -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetCtrlVisibility(const int theFlag) + +void +VISU_ScalarBarCtrl +::SetCtrlVisibility(int theVisibility) { - myCtrlVisibility=theFlag; - SetVisibility(1); + myCtrlVisibility = theVisibility; } -//================================================================== -// function : GetCtrlVisibility -// purpose : -//================================================================== -int VISU_ScalarBarCtrl::GetCtrlVisibility()const + +int +VISU_ScalarBarCtrl +::GetCtrlVisibility() const { return myCtrlVisibility; } -//================================================================== -// function : SetRangeLocal -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetRangeLocal(const float *theX) -{ - SetRangeLocal(theX[0], theX[1]); -} -//================================================================== -// function : SetRangeLocal -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetRangeLocal(const float theX1, - const float theX2) -{ - myRangeLocal[0]=theX1; - myRangeLocal[1]=theX2; -} -//================================================================== -// function : GetRangeLocal -// purpose : -//================================================================== -const float* VISU_ScalarBarCtrl::GetRangeLocal()const -{ - return myRangeLocal; -} -//================================================================== -// function : SetRangeGlobal -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetRangeGlobal(const float *theX) -{ - SetRangeGlobal(theX[0], theX[1]); -} -//================================================================== -// function : SetRangeGlobal -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetRangeGlobal(const float theX1, - const float theX2) -{ - myRangeGlobal[0]=theX1; - myRangeGlobal[1]=theX2; -} -//================================================================== -// function : GetRangeGlobal -// purpose : -//================================================================== -const float* VISU_ScalarBarCtrl::GetRangeGlobal()const -{ - return myRangeGlobal; -} -//================================================================== -// function : SetOrientation -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetOrientation(const int theOrientation) -{ - for (int i=0; iSetOrientation(theOrientation); - } + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetRangeLocal(float *theRange) +{ + myLocalLookupTable->SetTableRange(theRange); } -//================================================================== -// function : GetOrientation -// purpose : -//================================================================== -int VISU_ScalarBarCtrl::GetOrientation()const + +void +VISU_ScalarBarCtrl +::SetRangeLocal(float theMin, + float theMax) { - return mySBA[0]->GetOrientation(); + myLocalLookupTable->SetTableRange(theMin,theMax); } -//================================================================== -// function : GetScalarBarActor -// purpose : -//================================================================== -vtkScalarBarActor* VISU_ScalarBarCtrl::GetScalarBarActor(const int theIndex) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetRangeGlobal(float *theRange) { - if (theIndex>-1 && theIndexSetTableRange(theRange); } -//================================================================== -// function : GetLookupTable -// purpose : -//================================================================== -vtkLookupTable* VISU_ScalarBarCtrl::GetLookupTable(const int theIndex) + +void +VISU_ScalarBarCtrl +::SetRangeGlobal(float theMin, + float theMax) { - if (theIndex>-1 && theIndexSetTableRange(theMin,theMax); } -//================================================================== -// function : AddToRender -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::AddToRender(vtkRenderer* theRenderer) +void +VISU_ScalarBarCtrl +::SetGlobalRangeIsDefined(bool theIsDefined) { - int i; - // - Update(); - for (i=0; iAddActor2D(mySBA[i]); - } + myGlobalRangeIsDefined = theIsDefined; } -//================================================================== -// function : RemoveFromRender -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::RemoveFromRender(vtkRenderer* theRenderer) + + +//---------------------------------------------------------------------------- +vtkScalarBarActor* +VISU_ScalarBarCtrl +::GetLocalBar() { - for (int i=0; iRemoveActor2D(mySBA[i]); - } + return myLocalScalarBar; } -//================================================================== -// function : SetWidth -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetWidth(const float theWidth) + +vtkScalarBarActor* +VISU_ScalarBarCtrl +::GetGlobalBar() { - myL=theWidth; + return myGlobalScalarBar; } -//================================================================== -// function : GetWidth -// purpose : -//================================================================== -float VISU_ScalarBarCtrl::GetWidth()const + + +//---------------------------------------------------------------------------- +vtkLookupTable* +VISU_ScalarBarCtrl +::GetLocalTable() { - return myL; + return myLocalLookupTable; } -//================================================================== -// function : SetHeight -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetHeight(const float theHeight) + +vtkLookupTable* +VISU_ScalarBarCtrl +::GetGlobalTable() { - myB=theHeight; + return myGlobalLookupTable; } -//================================================================== -// function : GetHeight -// purpose : -//================================================================== -float VISU_ScalarBarCtrl::GetHeight()const + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::AddToRender(vtkRenderer* theRenderer) { - return myB; + theRenderer->AddActor2D(myGlobalScalarBar); + theRenderer->AddActor2D(myLocalScalarBar); + Update(); } -//================================================================== -// function : SetPosition -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetPosition(const float* thePosition) + +void +VISU_ScalarBarCtrl +::RemoveFromRender(vtkRenderer* theRenderer) { - myPosition[0]=thePosition[0]; - myPosition[1]=thePosition[1]; + theRenderer->RemoveActor2D(myGlobalScalarBar); + theRenderer->RemoveActor2D(myLocalScalarBar); } -//================================================================== -// function : GetPosition -// purpose : -//================================================================== -const float* VISU_ScalarBarCtrl::GetPosition()const + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetWidth(float theWidth) { - return myPosition; + myGlobalScalarBar->SetWidth(theWidth); + myLocalScalarBar->SetWidth(theWidth); } -//================================================================== -// function : SetSpacing -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetSpacing(const float theSpacing) + +float +VISU_ScalarBarCtrl +::GetWidth() const { - myDistance=theSpacing; + return myGlobalScalarBar->GetWidth(); } -//================================================================== -// function : GetSpacing -// purpose : -//================================================================== -float VISU_ScalarBarCtrl::GetSpacing()const + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetHeight(float theHeight) { - return myDistance; + myGlobalScalarBar->SetHeight(theHeight); + myLocalScalarBar->SetHeight(theHeight); +} + + +float +VISU_ScalarBarCtrl +::GetHeight() const +{ + return myGlobalScalarBar->GetHeight(); } -//================================================================== -// function : SetBicolor -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetBicolor(const bool theBicolor) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetPosition(const float* thePosition) { - myBicolor=theBicolor; + myPosition[0] = thePosition[0]; + myPosition[1] = thePosition[1]; } -//================================================================== -// function : GetBicolor -// purpose : -//================================================================== -bool VISU_ScalarBarCtrl::GetBicolor()const + +const float* +VISU_ScalarBarCtrl::GetPosition() const { - return myBicolor; + return myPosition; +} + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetSpacing(const float theSpacing) +{ + myDistance = theSpacing; +} + +float +VISU_ScalarBarCtrl +::GetSpacing() const +{ + return myDistance; } -//================================================================== -// function : SetMaximumNumberOfColors -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetMaximumNumberOfColors(const int theNumber) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetBicolor(const bool theBicolor) { - myMaximumNumberOfColors=theNumber; + myBicolor = theBicolor; } -//================================================================== -// function : GetMaximumNumberOfColors -// purpose : -//================================================================== -int VISU_ScalarBarCtrl::GetMaximumNumberOfColors()const + +bool +VISU_ScalarBarCtrl +::GetBicolor() const { - return myMaximumNumberOfColors; + return myBicolor; } -//================================================================== -// function : SetMarkValue -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetMarkValue(const float theValue) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetMarkValue(const float theValue) { - myMarkedValue=theValue; + myMarkedValue = theValue; } -//================================================================== -// function : GetMarkValue -// purpose : -//================================================================== -float VISU_ScalarBarCtrl::GetMarkValue()const + +float +VISU_ScalarBarCtrl +::GetMarkValue() const { return myMarkedValue; } -//================================================================== -// function : SetIsMarked -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::SetIsMarked(const bool theFlag) + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::SetIsMarked(const bool theFlag) { - myMarked=theFlag; + myMarked = theFlag; } -//================================================================== -// function : GetIsMarked -// purpose : -//================================================================== -bool VISU_ScalarBarCtrl::GetIsMarked()const + +bool +VISU_ScalarBarCtrl +::GetIsMarked() const { return myMarked; } -//================================================================== -// function : Update -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::Update() + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::Update() { - if (!myCtrlVisibility) { - SetVisibility(0); - return; - } + SetVisibility(GetVisibility()); // PrepareTables(); // - if (myBicolor) { + if(myBicolor) UpdateForBicolor(); - } - else { + else UpdateForColor(); - } // UpdateMarkValue(); } -//================================================================== -// function : UpdateMarkValue -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::UpdateMarkValue() -{ - if (myMarked){ - if (myMode==0 || myMode==1) { - MarkValueByColor(myXLT[0], myMarkedValue, myBlack); - } - else { - MarkValueByColor(myXLT[1], myMarkedValue, myBlack); + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::UpdateMarkValue() +{ + if(myMarked){ + if(myMode == eGlobal){ + MarkValueByColor(myGlobalLookupTable, myMarkedValue, myBlack); + }else{ + MarkValueByColor(myLocalLookupTable, myMarkedValue, myBlack); } } + if(myGlobalRangeIsDefined){ + float aLocalRange[2]; + myLocalLookupTable->GetTableRange(aLocalRange); + MarkValueByColor(myGlobalLookupTable, aLocalRange[0], myBlack); + MarkValueByColor(myGlobalLookupTable, aLocalRange[1], myBlack); + } } -//================================================================== -// function : PrepareTables -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::PrepareTables() -{ - int i, aOrientation; - // - // Apply Orientation - aOrientation=GetOrientation(); - // - for (i=0; iGetPositionCoordinate(); - pCoordinate->SetCoordinateSystemToNormalizedViewport(); - // - if (aOrientation) {// VERTICAL - pCoordinate->SetValue(myPosition[0]+i*(myL+myDistance), myPosition[1]); - mySBA[i]->SetWidth(myL); - mySBA[i]->SetHeight(myB); - } - else { - pCoordinate->SetValue(myPosition[0], myPosition[1]+i*(myB+myDistance)); - mySBA[i]->SetWidth(myL); - mySBA[i]->SetHeight(myB); - } + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::PrepareTables(vtkScalarBarActor* theScalarBarActor, + vtkLookupTable *theLookupTable, + vtkIdType theId) +{ + vtkCoordinate * aCoordinate = theScalarBarActor->GetPositionCoordinate(); + aCoordinate->SetCoordinateSystemToNormalizedViewport(); + if(theScalarBarActor->GetOrientation() == VTK_ORIENT_VERTICAL){ + float aWidth = theScalarBarActor->GetWidth(); + aCoordinate->SetValue(myPosition[0]+theId*(aWidth+myDistance), myPosition[1]); + }else{ + float aHeight = theScalarBarActor->GetHeight(); + aCoordinate->SetValue(myPosition[0], myPosition[1]+theId*(aHeight+myDistance)); } - // // Initialize Lookup Tables and Scalar Bars - for (i=0; iSetNumberOfColors((vtkIdType)myMaximumNumberOfColors); - myXLT[i]->SetRange(myRangeGlobal[0], myRangeGlobal[1]); - myXLT[i]->Modified(); - myXLT[i]->Build(); - // - mySBA[i]->SetMaximumNumberOfColors(myMaximumNumberOfColors); - mySBA[i]->SetLookupTable(myXLT[i]); - mySBA[i]->Modified(); - } -} -//================================================================== -// function : UpdateForColor -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::UpdateForColor() -{ - if (myMode==0){ - myXLT[0]->SetRange(myRangeLocal[0], myRangeLocal[1]); - myXLT[0]->Modified(); - myXLT[0]->Build(); - // - mySBA[1]->VisibilityOff(); - return ; - } - // - size_t aN4=4*sizeof(unsigned char); - unsigned char *pTL, *pTG; - vtkIdType j, aNbColors; - // - aNbColors=myXLT[0]->GetNumberOfColors(); - // - if (myMode==1){ - for (j=0; jGetPointer(j); - myGrey[3]=pTL[3]; - memcpy(pTL, myGrey, aN4); - } + theLookupTable->Modified(); + theLookupTable->Build(); +} + + +void +VISU_ScalarBarCtrl +::PrepareTables() +{ + if(myMode != eSimple){ + PrepareTables(myGlobalScalarBar,myGlobalLookupTable,0); + PrepareTables(myLocalScalarBar,myLocalLookupTable,1); + }else{ + PrepareTables(myLocalScalarBar,myLocalLookupTable,0); } - else if (myMode==2){ - for (j=0; jGetPointer(j); - myGrey[3]=pTG[3]; - memcpy(pTG, myGrey, aN4); - } - // - MarkValueByColor(myXLT[0], myRangeLocal[0], myBlack); - MarkValueByColor(myXLT[0], myRangeLocal[1], myBlack); +} + + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::UpdateForColor() +{ + if(myMode == eGlobal){ + FillByColor(myLocalLookupTable,myGrey); + }else if(myMode == eLocal){ + FillByColor(myGlobalLookupTable,myGrey); } - myXLT[1]->SetRange(myRangeLocal[0], myRangeLocal[1]); } -//================================================================== -// function : UpdateForBicolor -// purpose : -//================================================================== -void VISU_ScalarBarCtrl::UpdateForBicolor() + +//---------------------------------------------------------------------------- +void +VISU_ScalarBarCtrl +::UpdateForBicolor() { - size_t aN4=4*sizeof(unsigned char); - unsigned char *pTi, *pTRed, *pTBlue, *pTL, *pTG; - int i; - float aXi, aX0, dX, *pRange; - vtkIdType aIndex, aNbColors; - // - aNbColors=myXLT[0]->GetNumberOfColors(); - pTBlue=myXLT[0]->GetPointer(0); - pTRed =myXLT[0]->GetPointer(aNbColors-1); - // - if (myMode==0) { - myXLT[0]->SetRange(myRangeLocal[0], myRangeLocal[1]); - myXLT[0]->Modified(); - myXLT[0]->Build(); - // - mySBA[0]->SetLookupTable(myXLT[0]); - mySBA[0]->Modified(); - // - pRange=myRangeLocal; - dX=(pRange[1]-pRange[0])/aNbColors; - aX0=pRange[0]+0.5*dX; - for (i=0; iGetIndex(aXi); - pTi=myXLT[0]->GetPointer(aIndex); - if (aXi > 0.) { - memcpy(pTi, pTRed, aN4); - } - else { - memcpy(pTi, pTBlue, aN4); - } - } - mySBA[1]->VisibilityOff(); + myLocalLookupTable->Modified(); + myLocalLookupTable->Build(); + + if(myMode == eSimple){ + MakeBiColor(myLocalLookupTable); return; } - // - // mode: 1,2 - myXLT[1]->SetRange(myRangeLocal[0], myRangeLocal[1]); - myXLT[1]->Modified(); - myXLT[1]->Build(); - // - mySBA[1]->SetLookupTable(myXLT[1]); - mySBA[1]->Modified(); - // - if (myMode==1){ - pRange=myRangeGlobal; - dX=(pRange[1]-pRange[0])/aNbColors; - aX0=pRange[0]+0.5*dX; - for (i=0; iGetIndex(aXi); - pTi=myXLT[0]->GetPointer(aIndex); - if (aXi > 0.) { - memcpy(pTi, pTRed, aN4); - } - else { - memcpy(pTi, pTBlue, aN4); - } - } - // - for (i=0; iGetPointer(i); - myGrey[3]=pTL[3]; - memcpy(pTL, myGrey, aN4); - } - } - // - else if (myMode==2){ - pRange=myRangeLocal; - dX=(pRange[1]-pRange[0])/aNbColors; - aX0=pRange[0]+0.5*dX; - for (i=0; iGetIndex(aXi); - pTi=myXLT[1]->GetPointer(aIndex); - if (aXi > 0.) { - memcpy(pTi, pTRed, aN4); - } - else { - memcpy(pTi, pTBlue, aN4); - } - } - // - for (i=0; iGetPointer(i); - myGrey[3]=pTG[3]; - memcpy(pTG, myGrey, aN4); - } - // - MarkValueByColor(myXLT[0], myRangeLocal[0], myBlack); - MarkValueByColor(myXLT[0], myRangeLocal[1], myBlack); + + if(myMode == eGlobal){ + MakeBiColor(myGlobalLookupTable); + FillByColor(myLocalLookupTable,myGrey); + }else if(myMode == eLocal){ + MakeBiColor(myLocalLookupTable); + FillByColor(myGlobalLookupTable,myGrey); } } -//================================================================== -// function : MarkValueByColor -// purpose : -//================================================================== -void MarkValueByColor(vtkLookupTable* theTable, - float theValue, - unsigned char* theColor) -{ - size_t aN4=4*sizeof(unsigned char); - unsigned char *pT, aC3; - vtkIdType aIndex; - // - aC3=theColor[3]; - aIndex=theTable->GetIndex(theValue); - pT=theTable->GetPointer(aIndex); - theColor[3]=pT[3]; - memcpy(pT, theColor, aN4); - theColor[3]=aC3; -} diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.hxx b/src/PIPELINE/VISU_ScalarBarCtrl.hxx index f55ae051..c1a2f958 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.hxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.hxx @@ -27,50 +27,53 @@ #ifndef VISU_ScalarBarCtrl_HeaderFile #define VISU_ScalarBarCtrl_HeaderFile -#include -#include +#include class vtkRenderer; -class VISU_ScalarBarCtrl : public vtkObject { +class vtkLookupTable; +class vtkScalarBarActor; +class VISU_ScalarBarCtrl : public vtkObject +{ public: vtkTypeMacro(VISU_ScalarBarCtrl, vtkObject); static VISU_ScalarBarCtrl* New(); - // + + enum EMode {eSimple, eGlobal, eLocal}; + // Mode - void SetMode(const int theNumber); - int GetMode()const; - // - // Ranges - void SetRangeGlobal(const float theX1, - const float theX2); - - void SetRangeGlobal(const float *theX); - - const float* GetRangeGlobal()const; + void SetMode(EMode theMode); + EMode GetMode() const; - void SetRangeLocal(const float theX1, - const float theX2); + // Ranges + void SetRangeGlobal(float theMin, + float theMax); + void SetRangeGlobal(float *theRange); - void SetRangeLocal(const float *theX); + void SetGlobalRangeIsDefined(bool theIsDefined); + + void SetRangeLocal(float theMin, + float theMax); + void SetRangeLocal(float *theRange); - const float* GetRangeLocal()const; - // // Selectors - vtkScalarBarActor* GetScalarBarActor(const int theIndex); - vtkLookupTable* GetLookupTable(const int theIndex); + vtkScalarBarActor* GetLocalBar(); + vtkLookupTable* GetLocalTable(); + + vtkScalarBarActor* GetGlobalBar(); + vtkLookupTable* GetGlobalTable(); // // Renderer void AddToRender(vtkRenderer* theRenderer); void RemoveFromRender(vtkRenderer* theRenderer); // // Visibility - void SetVisibility(const int theFlag); - int GetVisibility()const; + void SetVisibility(int theFlag); + int GetVisibility() const; // // Visibility - void SetCtrlVisibility(const int theFlag); - int GetCtrlVisibility()const; + void SetCtrlVisibility(int theFlag); + int GetCtrlVisibility() const; // // Build void Update(); @@ -91,20 +94,6 @@ public: bool GetBicolor() const; void SetBicolor(const bool theBicolor); // - //Orientation - void SetOrientationToHorizontal() { - SetOrientation(0); - } - void SetOrientationToVertical() { - SetOrientation(1); - } - void SetOrientation(const int theOrientation); - int GetOrientation()const; - // - // Maximum Number Of Colors - void SetMaximumNumberOfColors(const int theNumber); - int GetMaximumNumberOfColors ()const; - // // Misc void SetMarkValue (const float theValue); float GetMarkValue ()const; @@ -120,25 +109,30 @@ protected: void UpdateMarkValue(); void PrepareTables(); + void PrepareTables(vtkScalarBarActor* theScalarBarActor, + vtkLookupTable *theLookupTable, + vtkIdType theId); protected: - int myMode; - //int myScalarBarNumber; - int myScalarBarNumberMax; - float myDistance, myL, myB, myPosition[2]; - float myRangeLocal[2]; - float myRangeGlobal[2]; + EMode myMode; + bool myGlobalRangeIsDefined; + + float myDistance; + float myPosition[2]; bool myBicolor; int myCtrlVisibility; - int myMaximumNumberOfColors; - unsigned char myBlack[4]; - unsigned char myGrey[4]; + + unsigned char myBlack[3]; + unsigned char myGrey[3]; // bool myMarked; float myMarkedValue; // - vtkScalarBarActor *mySBA[2]; - vtkLookupTable *myXLT[2]; + vtkScalarBarActor *myGlobalScalarBar; + vtkLookupTable *myGlobalLookupTable; + + vtkScalarBarActor *myLocalScalarBar; + vtkLookupTable *myLocalLookupTable; }; #endif diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 2d33325f..b4d4778d 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -282,7 +282,10 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs) bool activeLocal = thePrs->GetIsActiveLocalScalarBar(); myRBLocal->setChecked( activeLocal ); + myRBGlobal->setChecked( !activeLocal ); + myRBGlobal->setEnabled( thePrs->IsGlobalRangeDefined() ); + myCBDisplayed->setEnabled( activeLocal ); myCBDisplayed->setChecked( thePrs->GetIsDispGlobalScalarBar() ); @@ -505,8 +508,6 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE")); setSizeGripEnabled(TRUE); - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - QVBoxLayout* TopLayout = new QVBoxLayout(this); TopLayout->setSpacing(6); TopLayout->setMargin(11); diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index b54e5ffa..7de16afc 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -520,6 +520,8 @@ VISU::GaussPoints_i myGaussPointsPL->SetGaussPtsIDMapper(aGaussPtsIDMapper); myGaussPointsPL->Init(); myGaussPointsPL->Build(); + + theResult->MinMaxConnect(this); } @@ -610,86 +612,103 @@ VISU::GaussPoints_i return NULL; } + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::UpdateScalarBar(vtkScalarBarActor *theScalarBar, + vtkLookupTable* theLookupTable) +{ + theScalarBar->SetTitle(myTitle.c_str()); + theScalarBar->SetOrientation(myOrientation); + theScalarBar->SetNumberOfLabels(myNumberOfLabels); + + vtkLookupTable* aLookupTable = myScalarMapPL->GetBarTable(); + + theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors()); + theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors()); + + vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty(); + aTitleProp->SetFontFamily(myTitFontType); + aTitleProp->SetColor(myTitleColor); + (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff(); + (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); + (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); + + vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty(); + aLabelProp->SetFontFamily(myLblFontType); + aLabelProp->SetColor(myLabelColor); + (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff(); + (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); + (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); + + theScalarBar->Modified(); +} + + //---------------------------------------------------------------------------- void VISU::GaussPoints_i ::UpdateActor(VISU_Actor* theActor) { if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)){ + VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl(); if(GetIsColored()){ anActor->SetBarVisibility(true); myPipeLine->GetMapper()->SetScalarVisibility(1); - if(VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl()){ - float aRange[2]; - myScalarMapPL->GetSourceRange(aRange); - aScalarBarCtrl->SetRangeLocal(aRange); - - vtkIdType aScalarMode = GetScalarMode(); - TMinMax aTMinMax = myField->GetMinMax(aScalarMode); - aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second); - aScalarBarCtrl->SetOrientation(myOrientation); - - int aScalarBarMode; - aScalarBarMode = 1; //global sb - if(myIsActiveLocalScalarBar){ - if (myIsDispGlobalScalarBar){ - aScalarBarMode = 2; - } - else{ - aScalarBarMode = 0; - } - } - - if (aScalarBarMode==1){ - float aRangeGlobal[2]; - // - aRangeGlobal[0]=aTMinMax.first; - aRangeGlobal[1]=aTMinMax.second; - - GetGaussPointsPL()->GetMapper()->SetScalarRange(aRangeGlobal); - } - - aScalarBarCtrl->SetMode(aScalarBarMode); - - // Position - aScalarBarCtrl->SetWidth(myWidth); - aScalarBarCtrl->SetHeight(myHeight); - aScalarBarCtrl->SetPosition(myPosition); - - aScalarBarCtrl->SetSpacing(mySpacing); - - // Bicolor - bool anIsBicolor = GetGaussPointsPL()->GetBicolor(); - aScalarBarCtrl->SetBicolor(anIsBicolor); + float aRange[2]; + myScalarMapPL->GetSourceRange(aRange); + aScalarBarCtrl->SetRangeLocal(aRange); - aScalarBarCtrl->Update(); + TMinMax aTMinMax(-VTK_LARGE_FLOAT,VTK_LARGE_FLOAT); + bool anIsMinMaxDone = IsGlobalRangeDefined(); + if(anIsMinMaxDone) + aTMinMax = myField->GetMinMax(GetScalarMode()); + aScalarBarCtrl->SetGlobalRangeIsDefined(anIsMinMaxDone); + aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second); - for(int i = 0; i < 2; ++i){ - vtkScalarBarActor *aScalarBar = aScalarBarCtrl->GetScalarBarActor(i); - aScalarBar->SetTitle(myTitle.c_str()); - aScalarBar->SetNumberOfLabels(myNumberOfLabels); - - vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty(); - aTitleProp->SetFontFamily(myTitFontType); - aTitleProp->SetColor(myTitleColor); - (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff(); - (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); - (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); - - vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty(); - aLabelProp->SetFontFamily(myLblFontType); - aLabelProp->SetColor(myLabelColor); - (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff(); - (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); - (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); - - aScalarBar->Modified(); + VISU_ScalarBarCtrl::EMode aScalarBarMode = VISU_ScalarBarCtrl::eGlobal; + if(myIsActiveLocalScalarBar){ + if(myIsDispGlobalScalarBar){ + aScalarBarMode = VISU_ScalarBarCtrl::eLocal; + }else{ + aScalarBarMode = VISU_ScalarBarCtrl::eSimple; } } - } - else{ + + if(aScalarBarMode == VISU_ScalarBarCtrl::eGlobal){ + float aRangeGlobal[2]; + // + aRangeGlobal[0] = aTMinMax.first; + aRangeGlobal[1] = aTMinMax.second; + + GetGaussPointsPL()->GetMapper()->SetScalarRange(aRangeGlobal); + } + + aScalarBarCtrl->SetMode(aScalarBarMode); + + // Position + aScalarBarCtrl->SetWidth(myWidth); + aScalarBarCtrl->SetHeight(myHeight); + aScalarBarCtrl->SetPosition(myPosition); + + aScalarBarCtrl->SetSpacing(mySpacing); + + // Bicolor + bool anIsBicolor = GetGaussPointsPL()->GetBicolor(); + aScalarBarCtrl->SetBicolor(anIsBicolor); + + UpdateScalarBar(aScalarBarCtrl->GetLocalBar(), + aScalarBarCtrl->GetLocalTable()); + + UpdateScalarBar(aScalarBarCtrl->GetGlobalBar(), + aScalarBarCtrl->GetGlobalTable()); + + aScalarBarCtrl->Update(); + }else{ anActor->SetBarVisibility(false); + myPipeLine->GetMapper()->SetScalarVisibility(0); anActor->GetProperty()->SetColor(myColor.red() / 255.0, @@ -755,6 +774,13 @@ VISU::GaussPoints_i myIsDispGlobalScalarBar=theFlag; } +bool +VISU::GaussPoints_i +::IsGlobalRangeDefined() const +{ + return myResult->IsMinMaxDone(); +} + bool VISU::GaussPoints_i ::GetIsDispGlobalScalarBar() const @@ -789,3 +815,12 @@ VISU::GaussPoints_i { return mySpacing; } + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::UpdateMinMax() +{ + MinMaxCunsomer::UpdateMinMax(); + UpdateActors(); +} diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 14b0d10a..60def88d 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -27,9 +27,13 @@ #ifndef VISU_GaussPoints_i_HeaderFile #define VISU_GaussPoints_i_HeaderFile +#include "VISU_Result_i.hh" #include "VISU_ColoredPrs3d_i.hh" #include "VISU_GaussPtsActorFactory.h" +class vtkLookupTable; +class vtkScalarBarActor; + class VISU_GaussPointsPL; namespace VISU @@ -37,6 +41,7 @@ namespace VISU //! Class of the Gauss Points presentation. class GaussPoints_i : public virtual POA_VISU::GaussPoints, public virtual VISU::TGaussPtsActorFactory, + public virtual MinMaxCunsomer, public virtual ColoredPrs3d_i { static int myNbPresent; @@ -226,6 +231,15 @@ namespace VISU float GetSpacing() const; + //! Let know is the global range is already calculated + bool + IsGlobalRangeDefined() const; + + //! To update the min / max automatically + virtual + void + UpdateMinMax(); + protected: virtual void @@ -249,12 +263,13 @@ namespace VISU VISU_GaussPtsAct2* OnCreateActor2(const Handle(SALOME_InteractiveObject)& theIO = NULL); + void + UpdateScalarBar(vtkScalarBarActor *theScalarBar, + vtkLookupTable* theLookupTable); + VISU_GaussPointsPL *myGaussPointsPL; - //bool myIsDeformed; - //float myScaleFactor; - bool myIsColored; bool myIsDispGlobalScalarBar; bool myIsActiveLocalScalarBar; diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index f51e1f09..fa77bb87 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -634,7 +634,8 @@ namespace VISU BuildMinMax(Result_i* theResult, VISU_Convertor* theInput, CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild) + CORBA::Boolean theIsBuild, + Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal) { if(!theIsBuild || *theIsDone) return; @@ -643,7 +644,10 @@ namespace VISU TResultManager aResultManager(theResult); theInput->BuildMinMax(); + *theIsDone = true; + + (*theUpdateMinMaxSignal)(); } @@ -655,6 +659,7 @@ namespace VISU CORBA::Boolean theIsBuildFields, CORBA::Boolean* theIsMinMaxDone, CORBA::Boolean theIsBuildMinMax, + Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, _PTR(Study) theStudy) { BuildFields(theResult, @@ -666,7 +671,8 @@ namespace VISU BuildMinMax(theResult, theInput, theIsMinMaxDone, - theIsBuildMinMax); + theIsBuildMinMax, + theUpdateMinMaxSignal); } @@ -681,6 +687,7 @@ namespace VISU CORBA::Boolean myIsBuildFields; CORBA::Boolean* myIsMinMaxDone; CORBA::Boolean myIsBuildMinMax; + Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal; CORBA::Boolean* myIsGroupsDone; CORBA::Boolean myIsBuildGroups; _PTR(Study) myStudy; @@ -693,6 +700,7 @@ namespace VISU CORBA::Boolean theIsBuildFields, CORBA::Boolean* theIsMinMaxDone, CORBA::Boolean theIsBuildMinMax, + Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, CORBA::Boolean* theIsGroupsDone, CORBA::Boolean theIsBuildGroups, _PTR(Study) theStudy): @@ -704,6 +712,7 @@ namespace VISU myIsBuildFields(theIsBuildFields), myIsMinMaxDone(theIsMinMaxDone), myIsBuildMinMax(theIsBuildMinMax), + myUpdateMinMaxSignal(theUpdateMinMaxSignal), myIsGroupsDone(theIsGroupsDone), myIsBuildGroups(theIsBuildGroups), myStudy(theStudy) @@ -736,6 +745,7 @@ namespace VISU theBuildArgs.myIsBuildFields, theBuildArgs.myIsMinMaxDone, theBuildArgs.myIsBuildMinMax, + theBuildArgs.myUpdateMinMaxSignal, theBuildArgs.myStudy)); } } @@ -743,6 +753,27 @@ namespace VISU } +//--------------------------------------------------------------- +VISU::MinMaxCunsomer +::MinMaxCunsomer(): + myMinMaxIsInitilized(false) +{} + +bool +VISU::MinMaxCunsomer +::IsMinMaxInitilized() +{ + return myMinMaxIsInitilized; +} + +void +VISU::MinMaxCunsomer +::UpdateMinMax() +{ + myMinMaxIsInitilized = true; +} + + //--------------------------------------------------------------- const string VISU::Result_i::myComment = "RESULT"; const char* VISU::Result_i::GetComment() const { return myComment.c_str();} @@ -782,6 +813,15 @@ VISU::Result_i } +//--------------------------------------------------------------- +void +VISU::Result_i +::MinMaxConnect(VISU::MinMaxCunsomer* theMinMaxCunsomer) +{ + myUpdateMinMaxSignal.connect(boost::bind(&MinMaxCunsomer::UpdateMinMax,theMinMaxCunsomer)); +} + + //--------------------------------------------------------------- int VISU::Result_i @@ -961,7 +1001,8 @@ VISU::Result_i BuildMinMax(this, myInput, &myIsMinMaxDone, - myIsBuildMinMax); + myIsBuildMinMax, + &myUpdateMinMaxSignal); }else{ TBuildArgs aBuildArgs(this, @@ -972,6 +1013,7 @@ VISU::Result_i myIsBuildFields, &myIsMinMaxDone, myIsBuildMinMax, + &myUpdateMinMaxSignal, &myIsGroupsDone, myIsBuildGroups, myStudy); diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index e56cc0f6..ee903de6 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -30,13 +30,35 @@ #include "VISUConfig.hh" #include "SALOME_GenericObj_i.hh" -#include +#include +#include +#include #include class VISU_Convertor; -namespace VISU{ +namespace VISU +{ + //---------------------------------------------------------------------------- + class MinMaxCunsomer: public virtual boost::bsignals::trackable + { + protected: + bool myMinMaxIsInitilized; + MinMaxCunsomer(); + + public: + virtual + bool + IsMinMaxInitilized(); + + virtual + void + UpdateMinMax(); + }; + + + //---------------------------------------------------------------------------- class Result_i : public virtual POA_VISU::Result, public virtual RemovableObject_i, public virtual SALOME::GenericObj_i @@ -74,6 +96,12 @@ namespace VISU{ virtual CORBA::Boolean IsMinMaxDone(); + virtual + void + MinMaxConnect(MinMaxCunsomer* theMinMaxCunsomer); + + typedef boost::signal0 TUpdateMinMaxSignal; + typedef VISU_Convertor TInput; private: @@ -99,7 +127,9 @@ namespace VISU{ CORBA::Boolean myIsBuildFields; CORBA::Boolean myIsBuildGroups; + CORBA::Boolean myIsBuildMinMax; + TUpdateMinMaxSignal myUpdateMinMaxSignal; CORBA::Boolean myIsAllDone;