#include "VISU_GaussPtsDeviceActor.h"
#include "VISU_ImplicitFunctionWidget.h"
#include "VISU_OpenGLPointSpriteMapper.hxx"
+#include "VISU_ScalarBarCtrl.hxx"
+#include "VISU_ScalarBarActor.hxx"
#include "SVTK_Actor.h"
#include <vtkRenderer.h>
#include <vtkPointPicker.h>
#include <vtkScalarBarWidget.h>
-
+#include <vtkScalarBarActor.h>
#include <vtkTextMapper.h>
#include <vtkTextProperty.h>
myCellActor(vtkActor::New())
{
if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
+
myEventCallbackCommand->Delete();
myDeviceActor->Delete();
myCellActor->GetProperty()->SetAmbient(1.0);
myCellActor->GetProperty()->SetDiffuse(0.0);
myCellActor->GetProperty()->SetRepresentationToWireframe();
+ mySBCtrl=VISU_ScalarBarCtrl::New();
+ mySBCtrl->Delete();
+ mySBCtrl->SetMode(0);
+ mySBCtrl->SetRangeGlobal(0.,10.);
+ mySBCtrl->SetOrientationToHorizontal();
+ mySBCtrl->GetScalarBarActor(0)->SetTitle("GLB");
+ mySBCtrl->GetScalarBarActor(1)->SetTitle("LOC");
+
+ myScalarBar->SetVisibility(0);
}
VISU_GaussPtsAct
theRenderer->AddActor(myCellActor.GetPointer());
myCursorPyramid->AddToRender(theRenderer);
+ mySBCtrl->AddToRender(theRenderer);
}
void
theRenderer->RemoveActor(myCellActor.GetPointer());
myCursorPyramid->RemoveFromRender(theRenderer);
+ mySBCtrl->RemoveFromRender(theRenderer);
}
void
return bRet;
}
+//==================================================================
+// function : SetBarVisibility
+// purpose :
+//==================================================================
+void VISU_GaussPtsAct::SetBarVisibility(bool theMode)
+{
+ myBarVisibility = theMode;
+ mySBCtrl->SetBarVisibility(myBarVisibility);
+ //VISU_ScalarMapAct::SetBarVisibility(theMode);
+}
+//==================================================================
+// function : GetScalarBarCtrl
+// purpose :
+//==================================================================
+VISU_ScalarBarCtrl* VISU_GaussPtsAct::GetScalarBarCtrl()
+{
+ return mySBCtrl.GetPointer();
+}
//==============================================================================
vtkStandardNewMacro(VISU_GaussPtsAct1);
class vtkInteractorObserver;
class vtkCallbackCommand;
+class VISU_ScalarBarCtrl;
class VTKOCC_EXPORT VISU_OutsideCursorSettings : public vtkObject
{
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
+ virtual void SetBarVisibility(bool theMode);
+ VISU_ScalarBarCtrl* GetScalarBarCtrl();
+
protected:
//----------------------------------------------------------------------------
VISU_GaussPtsAct();
vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
vtkSmartPointer<vtkActor> myCellActor;
+ vtkSmartPointer<VISU_ScalarBarCtrl> mySBCtrl;
vtkSmartPointer<VISU_OutsideCursorSettings> myOutsideCursorSettings;
};
//==================================================================
VISU_ScalarBarCtrl::VISU_ScalarBarCtrl()
{
- myDistance=0.15;
+ myBarVisibility=true;
+ myDistance=0.02;
myL=0.8;
myB=0.15;
- myX0=0.05;
- myY0=0.1;
+ myPosition[0]=0.05;
+ myPosition[1]=0.1;
+ myBicolor=false;
//
int i;
//
myScalarBarNumberMax=2;
for (i=0; i<myScalarBarNumberMax; ++i){
myXLT[i]=vtkLookupTable::New();
+ myXLT[i]->SetHueRange(0.667,0.0);
mySBA[i]=vtkScalarBarActor::New();
}
//
return myMode;
}
//==================================================================
+// function : SetBarVisibility
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::SetBarVisibility(const bool theFlag)
+{
+ myBarVisibility=theFlag;
+}
+//==================================================================
+// function : GetBarVisibility
+// purpose :
+//==================================================================
+bool VISU_ScalarBarCtrl::GetBarVisibility()const
+{
+ return myBarVisibility;
+}
+//==================================================================
// function : SetRangeLocal
// purpose :
//==================================================================
}
return NULL;
}
+
+//==================================================================
+// function : AddToRender
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::AddToRender(vtkRenderer* theRenderer)
+{
+ int i;
+ //
+ Update();
+ for (i=0; i<myScalarBarNumber; ++i){
+ theRenderer->AddActor2D(mySBA[i]);
+ }
+}
+//==================================================================
+// function : RemoveFromRender
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::RemoveFromRender(vtkRenderer* theRenderer)
+{
+ for (int i=0; i<myScalarBarNumber; ++i){
+ theRenderer->RemoveActor2D(mySBA[i]);
+ }
+}
+//==================================================================
+// function : SetWidth
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::SetWidth(const float theWidth)
+{
+ myL=theWidth;
+}
+//==================================================================
+// function : GetWidth
+// purpose :
+//==================================================================
+float VISU_ScalarBarCtrl::GetWidth()const
+{
+ return myL;
+}
+//==================================================================
+// function : SetHeight
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::SetHeight(const float theHeight)
+{
+ myB=theHeight;
+}
+//==================================================================
+// function : GetHeight
+// purpose :
+//==================================================================
+float VISU_ScalarBarCtrl::GetHeight()const
+{
+ return myB;
+}
//==================================================================
-// function : PrepareData
+// function : SetPosition
// purpose :
//==================================================================
-int VISU_ScalarBarCtrl::PrepareData()
+void VISU_ScalarBarCtrl::SetPosition(const float* thePosition)
+{
+ myPosition[0]=thePosition[0];
+ myPosition[1]=thePosition[1];
+}
+//==================================================================
+// function : GetPosition
+// purpose :
+//==================================================================
+const float* VISU_ScalarBarCtrl::GetPosition()const
+{
+ return myPosition;
+}
+//==================================================================
+// function : SetBicolor
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::SetBicolor(const bool theBicolor)
+{
+ myBicolor=theBicolor;
+}
+//==================================================================
+// function : GetBicolor
+// purpose :
+//==================================================================
+bool VISU_ScalarBarCtrl::GetBicolor()const
+{
+ return myBicolor;
+}
+//==================================================================
+// function : Update
+// purpose :
+//==================================================================
+int VISU_ScalarBarCtrl::Update()
+{
+ if (!myBarVisibility) {
+ for (int i=0; i<myScalarBarNumberMax; ++i){
+ mySBA[i]->SetVisibility(myBarVisibility);
+ }
+ return 0;
+ }
+ //
+ PrepareTables();
+ //
+ if (myBicolor) {
+ UpdateForBicolor();
+ }
+ else {
+ UpdateForColor();
+ }
+ return 0;
+}
+//==================================================================
+// function : PrepareTables
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::PrepareTables()
{
int i, aOrientation;
//
pCoordinate->SetCoordinateSystemToNormalizedViewport();
//
if (aOrientation) {// VERTICAL
- pCoordinate->SetValue(myX0+i*myDistance, myY0);
- mySBA[i]->SetWidth(myB);
- mySBA[i]->SetHeight(myL);
+ pCoordinate->SetValue(myPosition[0]+i*0.5*(myL+myDistance), myPosition[1]);
+ mySBA[i]->SetWidth(0.5*(myL-myDistance));
+ mySBA[i]->SetHeight(myB);
}
else {
- pCoordinate->SetValue(myX0, myY0+i*myDistance);
+ pCoordinate->SetValue(myPosition[0], myPosition[1]+i*0.5*(myB+myDistance));
mySBA[i]->SetWidth(myL);
- mySBA[i]->SetHeight(myB);
+ mySBA[i]->SetHeight(0.5*(myB-myDistance));
}
}
//
// Initialize Lookup Tables and Scalar Bars
for (i=0; i<myScalarBarNumberMax; ++i){
myXLT[i]->SetRange(myRangeGlobal[0], myRangeGlobal[1]);
- myXLT[i]->Build();
+ myXLT[i]->Modified();
+ myXLT[i]->Build();
+ //
mySBA[i]->SetLookupTable(myXLT[i]);
+ mySBA[i]->SetVisibility(myBarVisibility);
+ mySBA[i]->Modified();
}
+}
+//==================================================================
+// function : UpdateForColor
+// purpose :
+//==================================================================
+void VISU_ScalarBarCtrl::UpdateForColor()
+{
+ int i;
//
if (!myMode){
- return 0; //nothing to do
+ mySBA[1]->VisibilityOff();
+ return ;
}
//
// Fill Lookup Tables
}
}
myXLT[1]->SetRange(myRangeLocal[0], myRangeLocal[1]);
- return 0;
}
+
//==================================================================
-// function : AddToRender
+// function : UpdateForBicolor
// purpose :
//==================================================================
-void VISU_ScalarBarCtrl::AddToRender(vtkRenderer* theRenderer)
+void VISU_ScalarBarCtrl::UpdateForBicolor()
{
- int i, iErr;
+ size_t aN4=4*sizeof(unsigned char);
+ unsigned char *pTi, *pTRed, *pTBlue;
+ int i, j, aNb;
+ float aXi, aX0, dX;
+ vtkIdType aIndex, aNbColors;
//
- iErr=PrepareData();
- if (!iErr){
- for (i=0; i<myScalarBarNumber; ++i){
- theRenderer->AddActor2D(mySBA[i]);
- }
+ aNbColors=myXLT[0]->GetNumberOfColors();
+ //
+ pTBlue=myXLT[0]->GetPointer(0);
+ pTRed=myXLT[0]->GetPointer(aNbColors-1);
+ //
+ if (myMode){
+ aNb=2;
+ myXLT[1]->SetRange(myRangeLocal[0], myRangeLocal[1]);
+ myXLT[1]->Modified();
+ myXLT[1]->Build();
+ //
+ mySBA[1]->SetLookupTable(myXLT[1]);
+ mySBA[1]->Modified();
}
-}
-//==================================================================
-// function : RemoveFromRender
-// purpose :
-//==================================================================
-void VISU_ScalarBarCtrl::RemoveFromRender(vtkRenderer* theRenderer)
-{
- for (int i=0; i<myScalarBarNumber; ++i){
- theRenderer->RemoveActor2D(mySBA[i]);
+ else {
+ aNb=1;
+ mySBA[1]->VisibilityOff();
+ }
+ //
+ for (j=0; j<aNb; ++j){
+ float *pRange=(!j) ? myRangeGlobal : myRangeLocal;
+ dX=(pRange[1]-pRange[0])/aNbColors;
+ aX0=pRange[0]+0.5*dX;
+ for (i=0; i<aNbColors; ++i){
+ aXi=aX0+i*dX;
+ aIndex=myXLT[j]->GetIndex(aXi);
+ pTi=myXLT[j]->GetPointer(aIndex);
+ if (aXi > 0.) {
+ memcpy(pTi, pTRed, aN4);
+ }
+ else {
+ memcpy(pTi, pTBlue, aN4);
+ }
+ }
}
}
void AddToRender(vtkRenderer* theRenderer);
void RemoveFromRender(vtkRenderer* theRenderer);
//
+ // Visibility
+ void SetBarVisibility(const bool theFlag);
+ bool GetBarVisibility()const;
+ //
+ int Update();
+ //
+ void SetWidth(const float theWidth);
+ float GetWidth()const;
+ void SetHeight(const float theHeight);
+ float GetHeight()const;
+ void SetPosition(const float* thePosition);
+ const float* GetPosition()const;
+
+ bool GetBicolor() const;
+ void SetBicolor(const bool theBicolor);
+
protected:
VISU_ScalarBarCtrl();
virtual ~VISU_ScalarBarCtrl();
- int PrepareData();
-
+ void UpdateForBicolor();
+ void UpdateForColor();
+ void PrepareTables();
+
protected:
int myMode;
int myScalarBarNumber;
int myScalarBarNumberMax;
- float myDistance, myX0, myY0, myL, myB;
+ float myDistance, myL, myB, myPosition[2];
float myRangeLocal[2];
float myRangeGlobal[2];
+ bool myBicolor;
+ bool myBarVisibility;
//
vtkScalarBarActor *mySBA[2];
vtkLookupTable *myXLT[2];
BarTypeGroup->setFrameStyle( QFrame::NoFrame );
BarTypeGroup->layout()->setMargin( 0 );
- QRadioButton* LocalButton = new QRadioButton( tr( "LOCAL" ), BarTypeGroup );
- LocalButton->setChecked( true );
+ myRBLocal = new QRadioButton( tr( "LOCAL" ), BarTypeGroup );
+ myRBLocal->setChecked( true );
QRadioButton* GlobalButton = new QRadioButton( tr( "GLOBAL" ), BarTypeGroup );
- QCheckBox* DisplayedBox = new QCheckBox( tr( "DISPLAYED" ), ActiveBarGroup );
- DisplayedBox->setChecked( true );
- DisplayedBox->setEnabled( false );
+ myCBDisplayed = new QCheckBox( tr( "DISPLAYED" ), ActiveBarGroup );
+ myCBDisplayed->setChecked( true );
+ myCBDisplayed->setEnabled( false );
ActiveBarGroupLayout->addMultiCellWidget( BarTypeGroup, 0, 1, 0, 0);
- ActiveBarGroupLayout->addWidget( DisplayedBox, 1, 1);
+ ActiveBarGroupLayout->addWidget( myCBDisplayed, 1, 1);
// Range ============================================================
RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
myTextDlg->setTitleVisible(!SetPref);
// signals and slots connections ===========================================
- connect( GlobalButton, SIGNAL( toggled( bool ) ), DisplayedBox, SLOT( setEnabled( bool ) ) );
+ connect( GlobalButton, SIGNAL( toggled( bool ) ), myCBDisplayed, SLOT( setEnabled( bool ) ) );
connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorLabel, SLOT( setEnabled( bool ) ) );
connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorSpin, SLOT( setEnabled( bool ) ) );
connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelLabel, SLOT( setEnabled( bool ) ) );
thePrs->SetPosition(XSpin->value(), YSpin->value());
thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
-
+ thePrs->SetIsActiveLocalScalarBar(myRBLocal->isChecked());
+ thePrs->SetIsDispGlobalScalarBar(myCBDisplayed->isChecked());
thePrs->SetSourceRange();
thePrs->SetNbColors(ColorSpin->value());
thePrs->SetLabels(LabelSpin->value());
QComboBox* myModeCombo;
QPushButton* myTextBtn;
VisuGUI_TextPrefDlg* myTextDlg;
+ QRadioButton* myRBLocal;
+ QCheckBox* myCBDisplayed;
double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax;
double myHorX, myHorY, myHorW, myHorH;
#include "VISU_GaussPointsPL.hxx"
#include "VISU_OpenGLPointSpriteMapper.hxx"
+#include "VISU_ScalarBarCtrl.hxx"
#include <vtkImageData.h>
#include <vtkXMLImageDataReader.h>
+#include <vtkScalarBarActor.h>
+#include <vtkTextProperty.h>
+
using namespace VISU;
using namespace std;
ScalarMap_i(theResult,theAddToStudy),
myGaussPointsPL(NULL),
myIsColored(true),
+ myIsActiveLocalScalarBar(true),
+ myIsDispGlobalScalarBar(true),
myColor(Qt::blue)
{
if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
PrsObject_i(theResult->GetStudyDocument()),
Prs3d_i(theResult,theSObject),
ScalarMap_i(theResult,theSObject),
- myGaussPointsPL(NULL)
+ myGaussPointsPL(NULL),
+ myIsActiveLocalScalarBar(true),
+ myIsDispGlobalScalarBar(true)
{
if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
}
}
//----------------------------------------------------------------------------
-void
-VISU::GaussPoints_i
-::UpdateActor(VISU_Actor* theActor)
+void VISU::GaussPoints_i::UpdateActor(VISU_Actor* theActor)
{
if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
if(IsColored()){
anActor->SetBarVisibility(true);
myPipeLine->GetMapper()->SetScalarVisibility(1);
- }else{
+ }
+ else{
anActor->SetBarVisibility(false);
myPipeLine->GetMapper()->SetScalarVisibility(0);
myColor.green() / 255.0,
myColor.blue() / 255.0);
}
+ //
+ VISU_ScalarBarCtrl *aSBCtrl = anActor->GetScalarBarCtrl();
+ //
+ // Ranges
+ float *pRange=myScalarMapPL->GetBarTable()->GetRange();
+ //
+
+ VISU::TField *pField=myField.get();
+ vtkIdType aIndexOfComponent=(vtkIdType)GetScalarMode();
+ TMinMax aTMinMax=pField->GetMinMax(aIndexOfComponent);
+ aSBCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second);
+
+ /* Stub for testing
+ {
+ float dR;
+ //
+ dR=0.5*(pRange[1]-pRange[0]);
+ aSBCtrl->SetRangeGlobal (pRange[0]-dR, pRange[1]+dR);
+ }
+ */
+ aSBCtrl->SetRangeLocal (pRange);
+ aSBCtrl->SetOrientation(myOrientation);
+ //
+ // Mode
+ int iSBMode;
+ //
+ if (myIsActiveLocalScalarBar) {
+ iSBMode=1;
+ }
+ else {
+ if (myIsDispGlobalScalarBar) {
+ iSBMode=2;
+ }
+ else {
+ iSBMode=0;
+ aSBCtrl->SetRangeGlobal(pRange);
+ }
+ }
+ aSBCtrl->SetMode(iSBMode);
+ //
+ // Position
+ aSBCtrl->SetWidth(myWidth);
+ aSBCtrl->SetHeight(myHeight);
+ aSBCtrl->SetPosition(myPosition);
+ //
+ // Bicolor
+ bool bBicolor=GetGaussPointsPL()->GetBicolor();
+ aSBCtrl->SetBicolor(bBicolor);
+ //
+ aSBCtrl->Update();
+ //
+ for (int i=0; i<2; ++i) {
+ vtkScalarBarActor *aScalarBar = aSBCtrl->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::ScalarMap_i::UpdateActor(theActor);
}
}
anImageData->Delete();
}
}
-
+//----------------------------------------------------------------------------
+void VISU::GaussPoints_i::SetIsActiveLocalScalarBar(const bool theFlag){
+ myIsActiveLocalScalarBar=theFlag;
+}
+//----------------------------------------------------------------------------
+bool VISU::GaussPoints_i::GetIsActiveLocalScalarBar()const {
+ return myIsActiveLocalScalarBar;
+}
+//----------------------------------------------------------------------------
+void VISU::GaussPoints_i::SetIsDispGlobalScalarBar(const bool theFlag){
+ myIsDispGlobalScalarBar=theFlag;
+}
+//----------------------------------------------------------------------------
+bool VISU::GaussPoints_i::GetIsDispGlobalScalarBar()const {
+ return myIsDispGlobalScalarBar;
+}
SetTextures( const QString& theMainTexture,
const QString& theAlphaTexture );
+ void SetIsActiveLocalScalarBar(const bool theFlag);
+ bool GetIsActiveLocalScalarBar()const;
+ void SetIsDispGlobalScalarBar(const bool theFlag);
+ bool GetIsDispGlobalScalarBar()const;
+
protected:
virtual
void
VISU_GaussPointsPL *myGaussPointsPL;
bool myIsColored;
+ bool myIsDispGlobalScalarBar;
+ bool myIsActiveLocalScalarBar;
QColor myColor;
QString myMainTexture;