#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
-#include "VisuGUI_FontWg.h"
+
+#include "SVTK_FontWidget.h"
+
+#include "SVTK_ViewWindow.h"
#include "SVTK_ViewWindow.h"
myModeLbl = new QLabel("Scalar Mode", RangeGroup);
myModeCombo = new QComboBox(RangeGroup);
- myModeCombo->insertItem("Modulus");
- myModeCombo->insertItem("Component 1");
- myModeCombo->insertItem("Component 2");
- myModeCombo->insertItem("Component 3");
CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
// signals and slots connections ===========================================
connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
+ connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
initFromResources();
myScalarMap = thePrs;
- myModeCombo->setCurrentItem(thePrs->GetScalarMode());
setPosAndSize( thePrs->GetPosX(),
thePrs->GetPosY(),
thePrs->GetWidth(),
setRange( thePrs->GetMin(), thePrs->GetMax(),
/*0.0, 0.0,*/ thePrs->IsRangeFixed() );
setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
- bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
+
+ // Update myModeCombo
+ int aNbComp = thePrs->GetField()->myNbComp;
+ bool isScalarMode = (aNbComp > 1);
+ myModeCombo->clear();
+ myModeCombo->insertItem("<Modulus>");
+ const VISU::PField& aField = thePrs->GetField();
+ const VISU::TNames& aCompNames = aField->myCompNames;
+ const VISU::TNames& aUnitNames = aField->myUnitNames;
+ for(int i = 0; i < aNbComp; i++){
+ QString aComponent = QString(aCompNames[i]).simplifyWhiteSpace();
+ if(aComponent.isNull() || aComponent == "")
+ aComponent = "Component " + QString::number(i+1);
+ else
+ aComponent = "[" + QString::number(i+1) + "] " + aComponent;
+
+ QString anUnit = QString(aUnitNames[i]).simplifyWhiteSpace();
+ if(anUnit.isNull() || anUnit == "")
+ anUnit = "-";
+
+ aComponent = aComponent + ", " + anUnit;
+
+ myModeCombo->insertItem(aComponent);
+ }
+ //
+ myModeCombo->setCurrentItem(thePrs->GetScalarMode());
+ if (aNbComp==1){
+ myModeCombo->setCurrentItem(1);
+ }
+ //
myModeLbl->setEnabled(isScalarMode);
myModeCombo->setEnabled(isScalarMode);
if (myPreviewActor != 0) return;
if (myScalarMap == NULL) return;
- if (!check()) return;
+ if(!check()) return;
if ( myBusy ) return;
void VisuGUI_ScalarBarPane::deleteScalarBar()
{
if ( myBusy ) return;
-
+
if (myPreviewActor == 0) return;
- if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()){
vf->RemoveActor(myPreviewActor);
myPreviewActor->GetScalarBar()->VisibilityOff();
}
/**
* Store values to presentation object
*/
-int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs)
-{
+int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
thePrs->SetScalarMode(myModeCombo->currentItem());
thePrs->SetPosition(XSpin->value(), YSpin->value());
thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
updatePreview();
}
+/*!
+ Called when scalar mode is changed
+*/
+void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
+{
+ if ( myScalarMap ) {
+ if ( RBFrange->isChecked() ) {
+ float aRange[2];
+ myScalarMap->SetScalarMode(theMode);
+ myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
+ MinEdit->setText( QString::number( aRange[0] ) );
+ MaxEdit->setText( QString::number( aRange[1] ) );
+ }
+ }
+}
+
/*!
Sets default values and range mode
*/
changeRange( 0 );
}
+/*!
+ Sets default values and range mode
+*/
+void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
+ Rmin = imin;
+ Rmax = imax;
+}
+
/*!
Sets size and position
*/
// font
QHBox* aHBox = new QHBox (aTitleGrp);
aHBox->setSpacing(5);
- myTitleFont = new VisuGUI_FontWg (aHBox);
+ myTitleFont = new SVTK_FontWidget (aHBox);
TopLayout->addWidget(aTitleGrp);
// font
aHBox = new QHBox (aLabelsGrp);
aHBox->setSpacing(5);
- myLabelFont = new VisuGUI_FontWg (aHBox);
+ myLabelFont = new SVTK_FontWidget (aHBox);
TopLayout->addWidget(aLabelsGrp);