#include <vtkContourFilter.h>
+#define GAP_COEFFICIENT 0.0001
//----------------------------------------------------------------------------
SetNbParts(aPipeLine->GetNbParts());
vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
SetRange(aRange);
+ SetRangeFixed(aPipeLine->IsRangeFixed());
}
}
//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
-::SetRange(vtkFloatingPointType theRange[2])
+::SetRange(vtkFloatingPointType theRange[2], bool theIsForced)
{
- if(VISU::CheckIsSameRange(myRange, theRange))
+ if(VISU::CheckIsSameRange(myRange, theRange) && !theIsForced)
return;
if(theRange[0] <= theRange[1]){
myRange[0] = theRange[0];
myRange[1] = theRange[1];
vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
+ if( IsRangeFixed() ) {
+ double aDelta = fabs( aRange[1] - aRange[0] ) * GAP_COEFFICIENT;
+ aRange[0] += aDelta;
+ aRange[1] -= aDelta;
+ }
if(GetScaling() == VTK_SCALE_LOG10)
VISU_LookupTable::ComputeLogRange(theRange, aRange);
myContourFilter->GenerateValues(GetNbParts(), aRange);
}
+//----------------------------------------------------------------------------
+void
+VISU_IsoSurfacesPL
+::SetRangeFixed(bool theIsFixed)
+{
+ myIsRangeFixed = theIsFixed;
+ SetRange( myRange, true );
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU_IsoSurfacesPL
+::IsRangeFixed()
+{
+ return myIsRangeFixed;
+}
+
+
void
//----------------------------------------------------------------------------
VISU_IsoSurfacesPL
vtkFloatingPointType aScalarRange[2];
GetSourceRange(aScalarRange);
SetRange(aScalarRange);
+
+ SetRangeFixed(true);
}
//----------------------------------------------------------------------------
vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
+ if( IsRangeFixed() ) {
+ double aDelta = fabs( aNewRange[1] - aNewRange[0] ) * GAP_COEFFICIENT;
+ aNewRange[0] += aDelta;
+ aNewRange[1] -= aDelta;
+ }
if(GetScaling() == VTK_SCALE_LOG10)
VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
myContourFilter->GenerateValues(GetNbParts(), aNewRange);
#include <QTabWidget>
#include <QKeyEvent>
#include <QColorDialog>
+#include <QButtonGroup>
+#include <QRadioButton>
using namespace std;
TopGroupLayout->setSpacing( 6 );
TopGroupLayout->setMargin( 11 );
+ QGroupBox* aRangeBox = new QGroupBox( tr( "RANGE" ), this );
+ QRadioButton* aUseScalarBarRange = new QRadioButton( tr( "USE_SCALAR_BAR_RANGE" ), aRangeBox );
+ QRadioButton* aUseCustomRange = new QRadioButton( tr( "USE_CUSTOM_RANGE" ), aRangeBox );
+
+ myRangeGrp = new QButtonGroup( aRangeBox );
+ myRangeGrp->addButton( aUseScalarBarRange, ScalarBarRange );
+ myRangeGrp->addButton( aUseCustomRange, CustomRange );
+ aUseScalarBarRange->setChecked( true );
+
+ connect( myRangeGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onRangeButtonClicked( int ) ) );
+
+ QLabel* LabelMin = new QLabel( tr( "MIN_VALUE" ), aRangeBox );
+ MinIso = new QLineEdit( aRangeBox );
+ MinIso->setValidator( new QDoubleValidator( aRangeBox ) );
+ MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ MinIso->setMinimumSize( 70, 0 );
+ LabelMin->setBuddy( MinIso );
+
+ QLabel* LabelMax = new QLabel( tr( "MAX_VALUE" ), aRangeBox );
+ MaxIso = new QLineEdit( aRangeBox );
+ MaxIso->setValidator( new QDoubleValidator( aRangeBox ) );
+ MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ MaxIso->setMinimumSize( 70, 0 );
+ LabelMax->setBuddy( MaxIso );
+
+ QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", aRangeBox );
+ aUpdateBtn->setEnabled( false );
+ connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
+ connect( aUseCustomRange, SIGNAL( toggled( bool ) ), aUpdateBtn, SLOT( setEnabled( bool ) ) );
+
+ QGridLayout* aRangeLayout = new QGridLayout( aRangeBox );
+ aRangeLayout->setSpacing( 6 );
+ aRangeLayout->setMargin( 11 );
+ aRangeLayout->addWidget( aUseScalarBarRange, 0, 0 );
+ aRangeLayout->addWidget( aUseCustomRange, 0, 1 );
+ aRangeLayout->addWidget( LabelMin, 1, 0 );
+ aRangeLayout->addWidget( MinIso, 1, 1 );
+ aRangeLayout->addWidget( LabelMax, 2, 0 );
+ aRangeLayout->addWidget( MaxIso, 2, 1 );
+ aRangeLayout->addWidget( aUpdateBtn, 3, 0, 1, 2 );
+
+ TopGroupLayout->addWidget( aRangeBox, 0, 0, 1, 2 );
+
QLabel* LabelNbr = new QLabel (tr("NB_SURFACES"), TopGroup);
- TopGroupLayout->addWidget( LabelNbr, 0, 0 );
+ TopGroupLayout->addWidget( LabelNbr, 1, 0 );
NbrIso = new QSpinBox( TopGroup );
NbrIso->setMaximum( 100 );
NbrIso->setMinimum( 1 );
NbrIso->setSingleStep( 1 );
NbrIso->setValue( 1 );
- TopGroupLayout->addWidget( NbrIso, 0, 1 );
-
- QLabel* LabelMin = new QLabel (tr("MIN_VALUE"), TopGroup );
- TopGroupLayout->addWidget(LabelMin, 1, 0);
- //MinIso = new QtxDoubleSpinBox( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
- MinIso = new QLineEdit( TopGroup );
- MinIso->setValidator( new QDoubleValidator(TopGroup) );
- MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MinIso->setMinimumSize( 70, 0 );
- LabelMin->setBuddy(MinIso);
- TopGroupLayout->addWidget( MinIso, 1, 1 );
-
- QLabel* LabelMax = new QLabel (tr("MAX_VALUE"), TopGroup );
- TopGroupLayout->addWidget( LabelMax, 2, 0 );
- //MaxIso = new QtxSpinBoxDbl( -DBL_MAX, DBL_MAX, 0.1, TopGroup );
- MaxIso = new QLineEdit( TopGroup );
- MaxIso->setValidator( new QDoubleValidator(TopGroup) );
- MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MaxIso->setMinimumSize( 70, 0 );
- LabelMax->setBuddy(MaxIso);
- TopGroupLayout->addWidget( MaxIso, 2, 1 );
+ TopGroupLayout->addWidget( NbrIso, 1, 1 );
myUseMagnitude = new QCheckBox(tr("MAGNITUDE_COLORING_CHK"), TopGroup);
myUseMagnitude->setChecked(true);
- TopGroupLayout->addWidget( myUseMagnitude, 3, 0 );
+ TopGroupLayout->addWidget( myUseMagnitude, 2, 0 );
mySelColor = new QtxColorButton( TopGroup );
mySelColor->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- TopGroupLayout->addWidget( mySelColor, 3, 1 );
+ TopGroupLayout->addWidget( mySelColor, 2, 1 );
//connect( mySelColor, SIGNAL( clicked() ), this, SLOT( setColor() ) );
connect( myUseMagnitude, SIGNAL( toggled(bool) ), mySelColor, SLOT( setDisabled(bool) ) );
myUseLabels = new QCheckBox(tr("SHOW_VALUES_CHK"), TopGroup);
myUseLabels->setChecked(false);
- TopGroupLayout->addWidget( myUseLabels, 4, 0 );
+ TopGroupLayout->addWidget( myUseLabels, 3, 0 );
myNbLabels = new QSpinBox( TopGroup );
myNbLabels->setMinimum(1);
myNbLabels->setMaximum(100);
myNbLabels->setSingleStep(1);
myNbLabels->setEnabled(false);
- TopGroupLayout->addWidget( myNbLabels, 4, 1 );
+ TopGroupLayout->addWidget( myNbLabels, 3, 1 );
connect( myUseLabels, SIGNAL( toggled(bool) ), myNbLabels, SLOT( setEnabled(bool) ) );
- QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup);
- TopGroupLayout->addWidget( aUpdateBtn, 5, 0, 1, 2);
- connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) );
mySelColor->setEnabled( !myUseMagnitude->isChecked() );
}
NbrIso->setValue(thePrs->GetNbSurfaces());
MinIso->setText(QString::number(thePrs->GetSubMin()));
MaxIso->setText(QString::number(thePrs->GetSubMax()));
+
+ int anId = thePrs->IsSubRangeFixed() ? ScalarBarRange : CustomRange;
+ bool anIsSubRangeFixed = thePrs->IsSubRangeFixed();
+ myRangeGrp->button( anId )->setChecked( true );
+ onRangeButtonClicked( anId );
+
myUseMagnitude->setChecked(thePrs->IsColored());
SALOMEDS::Color anOldColor = thePrs->GetColor();
QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
int VisuGUI_IsoSurfPane::storeToPrsObject (VISU::IsoSurfaces_i* thePrs)
{
thePrs->SetNbSurfaces(NbrIso->value());
- thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble());
+
+ if( myRangeGrp->checkedId() == ScalarBarRange )
+ {
+ thePrs->SetSubRange( myScalarPane->getMin(), myScalarPane->getMax() );
+ thePrs->SetSubRangeFixed( true );
+ }
+ else // CustomRange
+ {
+ thePrs->SetSubRange( MinIso->text().toDouble(), MaxIso->text().toDouble() );
+ thePrs->SetSubRangeFixed( false );
+ }
+
thePrs->ShowLabels(myUseLabels->isChecked(), myNbLabels->value());
thePrs->ShowColored(myUseMagnitude->isChecked());
if(!thePrs->IsColored()){
return 1;
}
+void VisuGUI_IsoSurfPane::onRangeButtonClicked( int theId )
+{
+ bool isCustomRange = theId == 1;
+ MinIso->setEnabled( isCustomRange );
+ MaxIso->setEnabled( isCustomRange );
+}
+
void VisuGUI_IsoSurfPane::onCBUpdate()
{
myScalarPane->setRange(MinIso->text().toDouble(), MaxIso->text().toDouble(), true);
myNbLabels = VISU::Storable::FindValue(theMap,"myNbLabels").toInt();
myIsLabeled = VISU::Storable::FindValue(theMap,"myIsLabeled").toInt();
SetSubRange(aMin,aMax);
+
+ SetSubRangeFixed(VISU::Storable::FindValue(theMap,"myIsRangeFixed").toInt());
return this;
}
Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
Storable::DataToStream( theStr, "myNbLabels", myNbLabels );
Storable::DataToStream( theStr, "myIsLabeled", myIsLabeled );
+ Storable::DataToStream( theStr, "myIsRangeFixed", IsSubRangeFixed() );
}
//---------------------------------------------------------------
::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
{
VISU::TSetModified aModified(this);
-
+
+ bool isForced = false;
vtkFloatingPointType aRange[2] = {theMin, theMax};
- ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, vtkFloatingPointType*>
- (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRange, aRange));
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_IsoSurfacesPL, vtkFloatingPointType*, bool>
+ (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRange, aRange, isForced));
}
//---------------------------------------------------------------
return myIsoSurfacesPL->GetMax();
}
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::SetSubRangeFixed(CORBA::Boolean theIsFixed)
+{
+ VISU::TSetModified aModified(this);
+
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, bool>
+ (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRangeFixed, theIsFixed));
+}
+
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::IsoSurfaces_i
+::IsSubRangeFixed()
+{
+ return myIsoSurfacesPL->IsRangeFixed();
+}
+
//---------------------------------------------------------------
void