#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
-#include "VisuGUI_FontWg.h"
+#include "VisuGUI_ViewTools.h"
#include "SVTK_ViewWindow.h"
+#include "SVTK_FontWidget.h"
#include "VISUConfig.hh"
#include "VISU_Convertor.hxx"
VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
QVBox(parent), myPreviewActor(0)
{
- myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
- myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ QString propertyName;
+ propertyName = QString("scalar_bar_vertical_");
+ myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", myVerX);
+ myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", myVerY);
+ myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", myVerW);
+ myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",myVerH);
+
+ propertyName = QString("scalar_bar_horizontal_");
+ myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", myHorX);
+ myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", myHorY);
+ myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", myHorW);
+ myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",myHorH);
+
Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
myRangeMode = -1;
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 ) ) );
changeRange( 0 );
changeDefaults( 0 );
myIsStoreTextProp = false;
+ myBusy = false;
}
-
/**
* Initializes dialog box values from resources
*/
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
+ int aPlace = 1;
+ if (anIsArrangeBar){
+ aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
+ }
+
int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
myModeCombo->setCurrentItem(aScalarMode);
sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
+ if(orient){
+ sbY1 += sbH*(aPlace-1);
+ } else {
+ sbX1 += sbW*(aPlace-1);
+ }
sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
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);
void VisuGUI_ScalarBarPane::updatePreview()
{
if (myPreviewCheck->isChecked()) {
- if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
deleteScalarBar();
createScalarBar();
vf->Repaint();
*/
void VisuGUI_ScalarBarPane::createScalarBar()
{
- if (VISU::GetViewWindow() == NULL) return;
+ if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
if (myPreviewActor != 0) return;
if (myScalarMap == NULL) return;
- if(!check()) return;
+ if (!check()) return;
if ( myBusy ) return;
aScalarBarActor->Modified();
- VISU::GetViewWindow()->AddActor(myPreviewActor);
+ VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
myBusy = false;
}
if ( myBusy ) return;
if (myPreviewActor == 0) return;
- if (SVTK_ViewWindow* vf = VISU::GetViewWindow()){
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
vf->RemoveActor(myPreviewActor);
myPreviewActor->GetScalarBar()->VisibilityOff();
}
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
*/
void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
{
- if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
if (thePreview) {
createScalarBar();
} else {
*/
void VisuGUI_ScalarBarDlg::accept()
{
- myScalarPane->deletePreview();
- if (myScalarPane->check()) QDialog::accept();
+ if (myScalarPane->check())
+ {
+ myScalarPane->deletePreview();
+ QDialog::accept();
+ }
}
/*!
// 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);