+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
+ int aComboType = ComboItem::Type();
+ int aIntSpinType = IntSpinItem::Type();
+ int aDoubleSpinType = DoubleSpinItem::Type();
+ QTableWidgetItem* aTableItem = aTable->item(row, 2);
+ bool isComboItem = false;
+ bool isIntSpinItem = false;
+ bool isDoubleSpinItem = false;
+ if (aTableItem) {
+ int aTableType = aTable->item(row, 2)->type();
+ isComboItem = ( aTableType == aComboType );
+ isIntSpinItem = ( aTableType == aIntSpinType );
+ isDoubleSpinItem = ( aTableType == aDoubleSpinType );
+ }
+
+ bool anIsDoubleCriterion =
+ aCriterionType == SMESH::FT_AspectRatio ||
+ aCriterionType == SMESH::FT_AspectRatio3D ||
+ aCriterionType == SMESH::FT_Taper ||
+ aCriterionType == SMESH::FT_Warping ||
+ aCriterionType == SMESH::FT_MinimumAngle ||
+ aCriterionType == SMESH::FT_Skew ||
+ aCriterionType == SMESH::FT_Area ||
+ aCriterionType == SMESH::FT_Length ||
+ aCriterionType == SMESH::FT_Length2D ||
+ aCriterionType == SMESH::FT_MaxElementLength2D ||
+ aCriterionType == SMESH::FT_MaxElementLength3D ||
+ aCriterionType == SMESH::FT_Volume3D ||
+ aCriterionType == SMESH::FT_EntityType;
+ int aPrecision = 0;
+ if ( anIsDoubleCriterion ) {
+ const char* aPrecisionType = getPrecision( aCriterionType );
+ SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr( mySMESHGUI );
+ if( aPrecisionType && aResourceMgr )
+ aPrecision = aResourceMgr->integerValue( "SMESH", aPrecisionType, aPrecision );
+ }
+
+ // if the precision is to be changed we should remove the existing
+ // spin item and create another one with new precision
+ bool anIsPrecisionChanged = false;
+ if ( anIsDoubleCriterion && isDoubleSpinItem ) {
+ if ( DoubleSpinItem* aDoubleSpinItem = dynamic_cast<DoubleSpinItem*>( aTable->item( row, 2 ) ) ) {
+ anIsPrecisionChanged = aDoubleSpinItem->precision() != aPrecision;
+ }
+ }
+
+ if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
+ (aCriterionType != SMESH::FT_ElemGeomType && isComboItem) ||
+ (aCriterionType != SMESH::FT_EntityType && isComboItem) ||
+ (aCriterionType != SMESH::FT_MultiConnection && isIntSpinItem) ||
+ (!anIsDoubleCriterion && isDoubleSpinItem) ||
+ anIsPrecisionChanged )
+ {
+ 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) ||
+ (aCriterionType == SMESH::FT_ElemGeomType && !isComboItem) ||
+ (aCriterionType == SMESH::FT_EntityType && !isComboItem) ||
+ (aCriterionType == SMESH::FT_MultiConnection && !isIntSpinItem) ||
+ (anIsDoubleCriterion && !isDoubleSpinItem) ||
+ anIsPrecisionChanged )
+ {
+ bool isSignalsBlocked = aTable->signalsBlocked();
+ aTable->blockSignals( true );
+ if ( aCriterionType == SMESH::FT_GroupColor )
+ aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) );
+ else if ( aCriterionType == SMESH::FT_ElemGeomType ) {
+ QList<int> typeIds = geomTypes( aType );
+ QMap<int, QString> typeNames;
+ QList<int>::const_iterator anIter = typeIds.begin();
+ for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i)
+ {
+ QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter );
+ typeNames[ *anIter ] = tr( typeKey.toLatin1().data() );
+ }
+ ComboItem* typeBox = new ComboItem( typeNames );
+ aTable->setItem( row, 2, typeBox );
+ }
+ else if ( aCriterionType == SMESH::FT_EntityType ) {
+ QList<int> typeIds = entityTypes( aType );
+ QMap<int, QString> typeNames;
+ QList<int>::const_iterator anIter = typeIds.begin();
+ for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i)
+ {
+ QString typeKey = QString( "ENTITY_TYPE_%1" ).arg( *anIter );
+ typeNames[ *anIter ] = tr( typeKey.toLatin1().data() );
+ }
+ ComboItem* typeBox = new ComboItem( typeNames );
+ aTable->setItem( row, 2, typeBox );
+ }
+ else if ( aCriterionType == SMESH::FT_MultiConnection ) {
+ IntSpinItem* intSpin = new IntSpinItem( 0 );
+ aTable->setItem( row, 2, intSpin );
+ }
+ else if ( anIsDoubleCriterion ) {
+ DoubleSpinItem* dblSpin = new DoubleSpinItem( 0 );
+ dblSpin->setPrecision( aPrecision );
+ aTable->setItem( row, 2, dblSpin );
+ }
+ aTable->blockSignals( isSignalsBlocked );
+ }