fix custome combobox for element geometry type

This commit is contained in:
ptv 2009-02-12 10:40:33 +00:00
parent 4664f0cfde
commit 8bbc839c3c

View File

@ -47,7 +47,6 @@
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_MessageBox.h> #include <SUIT_MessageBox.h>
#include <QtxComboBox.h>
#include <QtxColorButton.h> #include <QtxColorButton.h>
#include <LightApp_Application.h> #include <LightApp_Application.h>
@ -910,15 +909,12 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType)
QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2)); QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2));
if (clrBtn && !clrBtn->color().isValid()) if (clrBtn && !clrBtn->color().isValid())
errMsg = tr( "GROUPCOLOR_ERROR" ); errMsg = tr( "GROUPCOLOR_ERROR" );
} else if (aCriterion == SMESH::FT_ElemGeomType ) {
QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(i, 2));
if (typeBox && typeBox->currentId() == -1)
errMsg = tr( "ERROR" );
} else if (aCriterion == SMESH::FT_RangeOfIds || } else if (aCriterion == SMESH::FT_RangeOfIds ||
aCriterion == SMESH::FT_BelongToGeom || aCriterion == SMESH::FT_BelongToGeom ||
aCriterion == SMESH::FT_BelongToPlane || aCriterion == SMESH::FT_BelongToPlane ||
aCriterion == SMESH::FT_BelongToCylinder || aCriterion == SMESH::FT_BelongToCylinder ||
aCriterion == SMESH::FT_BelongToGenSurface || aCriterion == SMESH::FT_BelongToGenSurface ||
aCriterion == SMESH::FT_ElemGeomType ||
aCriterion == SMESH::FT_LyingOnGeom) { aCriterion == SMESH::FT_LyingOnGeom) {
if (aTable->text(i, 2).isEmpty()) if (aTable->text(i, 2).isEmpty())
errMsg = tr( "ERROR" ); errMsg = tr( "ERROR" );
@ -1031,11 +1027,8 @@ void SMESHGUI_FilterTable::GetCriterion (const int theRow,
theCriterion.ThresholdStr = clrStr.toLatin1().constData(); theCriterion.ThresholdStr = clrStr.toLatin1().constData();
} }
} }
else if ( aCriterionType == SMESH::FT_ElemGeomType ) { else if ( aCriterionType == SMESH::FT_ElemGeomType )
QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(theRow, 2)); theCriterion.Threshold = (double)((ComboItem*)aTable->item(theRow, 2))->value();
if ( typeBox )
theCriterion.Threshold = (double)typeBox->currentId();
}
else if ( aCriterionType != SMESH::FT_RangeOfIds && else if ( aCriterionType != SMESH::FT_RangeOfIds &&
aCriterionType != SMESH::FT_BelongToGeom && aCriterionType != SMESH::FT_BelongToGeom &&
aCriterionType != SMESH::FT_BelongToPlane && aCriterionType != SMESH::FT_BelongToPlane &&
@ -1104,9 +1097,8 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow,
} }
else if (theCriterion.Type == SMESH::FT_ElemGeomType ) else if (theCriterion.Type == SMESH::FT_ElemGeomType )
{ {
QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(theRow, 2)); ComboItem* typeBox = (ComboItem*)aTable->item(theRow, 2);
if ( typeBox ) typeBox->setValue( (int)(theCriterion.Threshold + 0.5) );
typeBox->setCurrentId( (int)(theCriterion.Threshold + 0.5) );
} }
else if (theCriterion.Type != SMESH::FT_RangeOfIds && else if (theCriterion.Type != SMESH::FT_RangeOfIds &&
theCriterion.Type != SMESH::FT_BelongToGeom && theCriterion.Type != SMESH::FT_BelongToGeom &&
@ -1378,35 +1370,36 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
int aCriterionType = GetCriterionType(row); int aCriterionType = GetCriterionType(row);
QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2)); QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(row, 2)); bool isComboItem = aTable->item(row, 2)->type() == ComboItem::Type();
if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
(aCriterionType != SMESH::FT_ElemGeomType && isComboItem) )
{
bool isSignalsBlocked = aTable->signalsBlocked();
aTable->blockSignals( true );
aTable->removeCellWidget( row, 2 );
aTable->setItem( row, 2, new QTableWidgetItem() );
aTable->blockSignals( isSignalsBlocked );
}
if ( (aCriterionType == SMESH::FT_GroupColor && !clrBtn) || if ( (aCriterionType == SMESH::FT_GroupColor && !clrBtn) ||
(aCriterionType == SMESH::FT_ElemGeomType && !typeBox) ) (aCriterionType == SMESH::FT_ElemGeomType && !isComboItem) )
{ {
bool isSignalsBlocked = aTable->signalsBlocked(); bool isSignalsBlocked = aTable->signalsBlocked();
aTable->blockSignals( true ); aTable->blockSignals( true );
if ( aCriterionType == SMESH::FT_GroupColor ) if ( aCriterionType == SMESH::FT_GroupColor )
aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) ); aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) );
else { else {
QtxComboBox* typeBox = new QtxComboBox( aTable );
aTable->setCellWidget( row, 2, typeBox );
QList<int> typeIds = geomTypes( aType ); QList<int> typeIds = geomTypes( aType );
QMap<int, QString> typeNames;
QList<int>::const_iterator anIter = typeIds.begin(); QList<int>::const_iterator anIter = typeIds.begin();
for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i) { for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i)
QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter );
typeBox->addItem( tr( typeKey.toLatin1().data() ) );
typeBox->setId( i, *anIter );
}
}
aTable->blockSignals( isSignalsBlocked );
}
else if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
(aCriterionType != SMESH::FT_ElemGeomType && typeBox) )
{ {
bool isSignalsBlocked = aTable->signalsBlocked(); QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter );
aTable->blockSignals( true ); typeNames[ *anIter ] = tr( typeKey.toLatin1().data() );
aTable->setCellWidget( row, 2, 0 ); }
aTable->setItem( row, 2, new QTableWidgetItem() ); ComboItem* typeBox = new ComboItem( typeNames );
aTable->setItem( row, 2, typeBox );
}
aTable->blockSignals( isSignalsBlocked ); aTable->blockSignals( isSignalsBlocked );
} }
@ -1552,8 +1545,6 @@ void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const boo
if (theTable->item(aCurrRow, 4) == 0 || if (theTable->item(aCurrRow, 4) == 0 ||
theTable->item(aCurrRow, 4)->type() != ComboItem::Type()) theTable->item(aCurrRow, 4)->type() != ComboItem::Type())
{ {
if (anAddBinOpStr >= 0 && if (anAddBinOpStr >= 0 &&
(theTable->item(anAddBinOpStr, 4) == 0 || (theTable->item(anAddBinOpStr, 4) == 0 ||
theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type())) theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type()))
@ -2294,6 +2285,7 @@ void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes)
else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT")); else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT"));
else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT")); else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT"));
else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT")); else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
else if (aType == SMESH::ALL) setWindowTitle(tr("TLT"));
} }
else else
setWindowTitle(tr("TLT")); setWindowTitle(tr("TLT"));