From 3ecd20b47b8a6e78157d6fb326c0a9db07dd92a2 Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 1 Jul 2008 11:48:04 +0000 Subject: [PATCH] IPAL 20025 4.x: wrong presentation is created with checked "Logarithmic Scaling" option. --- src/VISUGUI/VisuGUI_Table3dDlg.cxx | 64 ++++++++++++++++++++++++------ src/VISU_I/VISU_PointMap3d_i.cc | 30 +++++++++++++- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx index 2b49f5c9..dd5046eb 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -402,17 +402,13 @@ void VisuGUI_TableScalarBarPane::initFromPrsObject(VISU::PointMap3d_i* thePrs) if( !myBarPrs ) return; - if (myBarPrs->IsPositiveTable()) { - switch(myBarPrs->GetScaling()){ - case VISU::LOGARITHMIC : - CBLog->setChecked( true ); - break; - default: - CBLog->setChecked( false ); - } + switch(myBarPrs->GetScaling()){ + case VISU::LOGARITHMIC : + CBLog->setChecked( true ); + break; + default: + CBLog->setChecked( false ); } - else - CBLog->setEnabled(false); setRange( myBarPrs->GetMin(), myBarPrs->GetMax(), myBarPrs->IsRangeFixed() ); @@ -713,13 +709,53 @@ VisuGUI_Table3DDlg::VisuGUI_Table3DDlg ( SalomeApp_Module* theModule ) VisuGUI_Table3DDlg::~VisuGUI_Table3DDlg() {} +//======================================================================= +//function : Check +//purpose : Called when button is clicked, validates data and closes dialog +//======================================================================= +bool VisuGUI_TableScalarBarPane::check() +{ + double minVal = MinEdit->text().toDouble(); + double maxVal = MaxEdit->text().toDouble(); + if ( RBIrange->isChecked() ) { + if (minVal >= maxVal) { + SUIT_MessageBox::warn1( this,tr("WRN_VISU"), + tr("MSG_MINMAX_VALUES"), + tr("BUT_OK")); + return false; + } + } + + // check if logarithmic mode is on and check imposed range to not contain negative values + if ( CBLog->isChecked() ) { + if ( minVal <= 0.0 || maxVal <= 0.0 ) { + if ( RBIrange->isChecked() ) { + SUIT_MessageBox::warn1( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("BUT_OK")); + } else { + SUIT_MessageBox::warn1( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("BUT_OK")); + RBIrange->setChecked(true); + changeRange(1); + } + return false; + } + } + return true; +} + //======================================================================= //function : accept //purpose : //======================================================================= void VisuGUI_Table3DDlg::accept() { - QDialog::accept(); + if (myScalarBarPane->check()) + QDialog::accept(); } //======================================================================= @@ -737,8 +773,10 @@ void VisuGUI_Table3DDlg::reject() //======================================================================= void VisuGUI_Table3DDlg::onApply() { - storeToPrsObject( myPrsCopy ); - myPrsCopy->UpdateActors(); + if (myScalarBarPane->check()) { + storeToPrsObject( myPrsCopy ); + myPrsCopy->UpdateActors(); + } } //======================================================================= diff --git a/src/VISU_I/VISU_PointMap3d_i.cc b/src/VISU_I/VISU_PointMap3d_i.cc index 95b0766c..a36cc8ca 100644 --- a/src/VISU_I/VISU_PointMap3d_i.cc +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -736,12 +736,38 @@ CORBA::Float VISU::PointMap3d_i::GetMemorySize() //------------------ ColoredPrs3dBase Methods -------------------- CORBA::Double VISU::PointMap3d_i::GetMin() { - return myTablePL->GetScalarRange()[0]; + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + double aMin = aTableOfReal->GetValue(1, 1); + + for (int i=1; i<=aTableOfReal->GetNbColumns(); i++) + for (int j=1; j<=aTableOfReal->GetNbRows(); j++) { + double aVal = aTableOfReal->GetValue(j, i); + if (aVal < aMin) + aMin = aVal; + } + + return aMin; + // return myTablePL->GetScalarRange()[0]; } CORBA::Double VISU::PointMap3d_i::GetMax() { - return myTablePL->GetScalarRange()[1]; + SALOMEDS::GenericAttribute_var anAttr; + mySObj->FindAttribute(anAttr, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + double aMax = aTableOfReal->GetValue(1, 1); + + for (int i=1; i<=aTableOfReal->GetNbColumns(); i++) + for (int j=1; j<=aTableOfReal->GetNbRows(); j++) { + double aVal = aTableOfReal->GetValue(j, i); + if (aVal > aMax) + aMax = aVal; + } + + return aMax; + // return myTablePL->GetScalarRange()[1]; } void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax) -- 2.39.2