+
+ updateBtnState();
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::onCurrentChanged()
+// Purpose : SLOT. Called when current cell changed
+//=======================================================================
+void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
+{
+ if( !myIsLocked )
+ updateAdditionalWidget();
+ emit CurrentChanged(theRow, theCol);
+}
+
+//=======================================================================
+// name : geomTypes
+// Purpose : returns available geometry types of elements
+//=======================================================================
+static QList<int> geomTypes( const int theType )
+{
+ QList<int> typeIds;
+ if ( theType == SMESH::NODE )
+ typeIds.append( SMESH::Geom_POINT );
+ if ( theType == SMESH::ALL || theType == SMESH::EDGE )
+ typeIds.append( SMESH::Geom_EDGE );
+ if ( theType == SMESH::ALL || theType == SMESH::FACE )
+ {
+ typeIds.append( SMESH::Geom_TRIANGLE );
+ typeIds.append( SMESH::Geom_QUADRANGLE );
+ typeIds.append( SMESH::Geom_POLYGON );
+ }
+ if ( theType == SMESH::ALL || theType == SMESH::VOLUME )
+ {
+ typeIds.append( SMESH::Geom_TETRA );
+ typeIds.append( SMESH::Geom_PYRAMID );
+ typeIds.append( SMESH::Geom_HEXA );
+ typeIds.append( SMESH::Geom_PENTA );
+ typeIds.append( SMESH::Geom_HEXAGONAL_PRISM );
+ typeIds.append( SMESH::Geom_POLYHEDRA );
+ }
+ if ( theType == SMESH::ALL || theType == SMESH::ELEM0D )
+ {
+ typeIds.append( SMESH::Geom_POINT );
+ }
+ if ( theType == SMESH::ALL || theType == SMESH::BALL )
+ {
+ typeIds.append( SMESH::Geom_BALL );
+ }
+ return typeIds;
+}
+
+//=======================================================================
+// name : entityTypes
+// Purpose : returns available entity types of elements
+//=======================================================================
+
+static QList<int> entityTypes( const int theType )
+{
+ QList<int> typeIds;
+
+ switch ( theType )
+ {
+ case SMESH::NODE:
+ typeIds.append( SMDSEntity_Node );
+ case SMESH::EDGE:
+ typeIds.append( SMDSEntity_Edge );
+ typeIds.append( SMDSEntity_Quad_Edge );
+ break;
+ case SMESH::FACE:
+ typeIds.append( SMDSEntity_Triangle );
+ typeIds.append( SMDSEntity_Quad_Triangle );
+ typeIds.append( SMDSEntity_BiQuad_Triangle );
+ typeIds.append( SMDSEntity_Quadrangle );
+ typeIds.append( SMDSEntity_Quad_Quadrangle );
+ typeIds.append( SMDSEntity_BiQuad_Quadrangle );
+ typeIds.append( SMDSEntity_Polygon );
+ typeIds.append( SMDSEntity_Quad_Polygon );
+ break;
+ case SMESH::VOLUME:
+ typeIds.append( SMDSEntity_Tetra );
+ typeIds.append( SMDSEntity_Quad_Tetra );
+ typeIds.append( SMDSEntity_Pyramid );
+ typeIds.append( SMDSEntity_Quad_Pyramid );
+ typeIds.append( SMDSEntity_Hexa );
+ typeIds.append( SMDSEntity_Quad_Hexa );
+ typeIds.append( SMDSEntity_TriQuad_Hexa );
+ typeIds.append( SMDSEntity_Penta );
+ typeIds.append( SMDSEntity_Quad_Penta );
+ typeIds.append( SMDSEntity_Hexagonal_Prism );
+ typeIds.append( SMDSEntity_Polyhedra );
+ //typeIds.append( SMDSEntity_Quad_Polyhedra );
+ break;
+ case SMESH::ELEM0D:
+ typeIds.append( SMDSEntity_0D );
+ break;
+ case SMESH::BALL:
+ typeIds.append( SMDSEntity_Ball );
+ break;
+ }
+ return typeIds;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::onCriterionChanged()
+// Purpose : Provides reaction on change of criterion
+//=======================================================================
+
+void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, const int entityType)
+{
+ int aType = entityType == -1 ? GetType() : entityType;
+ Table* aTable = myTables[ aType ];
+ ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1);
+
+ // find out type of a existing threshould table item
+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
+ bool isComboItem = false;
+ bool isIntSpinItem = false;
+ bool isDoubleSpinItem = false;
+ if ( QTableWidgetItem* aTableItem = aTable->item(row, 2) )
+ {
+ int aTableType = aTableItem->type();
+ isComboItem = ( aTableType == ComboItem::Type() );
+ isIntSpinItem = ( aTableType == IntSpinItem::Type() );
+ isDoubleSpinItem = ( aTableType == DoubleSpinItem::Type() );
+ }
+
+ // find out a type of item required by a new criterion and other table features
+ int aCriterionType = GetCriterionType(row);
+ bool anIsDoubleCriterion = false;
+ bool anIsIntCriterion = false;
+ bool anIsComboCriterion = false;
+ // other features:
+ QList<int> comboIDs; // values to show in a combo item
+ int nbCompareSigns = 0; // possible values are 0,1,3
+ bool isThresholdEditable = false; // actual for "simple" item types
+ switch ( aCriterionType )
+ {
+ case SMESH::FT_AspectRatio:
+ case SMESH::FT_AspectRatio3D:
+ case SMESH::FT_Warping:
+ case SMESH::FT_MinimumAngle:
+ case SMESH::FT_Taper:
+ case SMESH::FT_Skew:
+ case SMESH::FT_Area:
+ case SMESH::FT_Volume3D:
+ case SMESH::FT_MaxElementLength2D:
+ case SMESH::FT_MaxElementLength3D:
+ anIsDoubleCriterion = true; break;
+
+ case SMESH::FT_FreeBorders:
+ case SMESH::FT_FreeEdges:
+ case SMESH::FT_FreeNodes:
+ case SMESH::FT_FreeFaces:
+ case SMESH::FT_EqualNodes:
+ case SMESH::FT_EqualEdges:
+ case SMESH::FT_EqualFaces:
+ case SMESH::FT_EqualVolumes: break;
+
+ case SMESH::FT_NodeConnectivityNumber:
+ case SMESH::FT_MultiConnection:
+ case SMESH::FT_MultiConnection2D: anIsIntCriterion = true; nbCompareSigns = 3; break;
+
+ case SMESH::FT_Length:
+ case SMESH::FT_Length2D: anIsDoubleCriterion = true; break;
+
+ case SMESH::FT_BelongToMeshGroup: break;
+
+ case SMESH::FT_BelongToGeom:
+ case SMESH::FT_BelongToPlane:
+ case SMESH::FT_BelongToCylinder:
+ case SMESH::FT_BelongToGenSurface:
+ case SMESH::FT_LyingOnGeom: nbCompareSigns = 0; isThresholdEditable = true; break;
+
+ case SMESH::FT_RangeOfIds: nbCompareSigns = 0; isThresholdEditable = true; break;
+
+ case SMESH::FT_BadOrientedVolume:
+ case SMESH::FT_BareBorderVolume:
+ case SMESH::FT_BareBorderFace:
+ case SMESH::FT_OverConstrainedVolume:
+ case SMESH::FT_OverConstrainedFace:
+ case SMESH::FT_LinearOrQuadratic: break;
+
+ case SMESH::FT_GroupColor: nbCompareSigns = 1; isThresholdEditable = true; break;
+
+ case SMESH::FT_ElemGeomType:
+ comboIDs = geomTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break;
+
+ case SMESH::FT_EntityType:
+ comboIDs = entityTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break;
+
+ case SMESH::FT_CoplanarFaces: isThresholdEditable = true; break;
+
+ case SMESH::FT_BallDiameter: anIsDoubleCriterion = true; break;
+
+ case SMESH::FT_ConnectedElements: isThresholdEditable = true; break;
+
+ case SMESH::FT_LessThan:
+ case SMESH::FT_MoreThan:
+ case SMESH::FT_EqualTo:
+ case SMESH::FT_LogicalNOT:
+ case SMESH::FT_LogicalAND:
+ case SMESH::FT_LogicalOR:
+ case SMESH::FT_Undefined:
+ default: return;
+ }
+
+ // get a precision of a double criterion
+ 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 );
+ }
+
+ // check if the current item type satisfies the criterion
+ bool itemTypeKO =
+ ( aCriterionType == SMESH::FT_GroupColor && !clrBtn) ||
+ ( anIsComboCriterion && !isComboItem ) ||
+ ( anIsIntCriterion && !isIntSpinItem ) ||
+ ( anIsDoubleCriterion && !isDoubleSpinItem );
+
+ if ( !itemTypeKO )
+ {
+ if ( anIsDoubleCriterion )
+ {
+ // if the precision is to be changed we should remove the existing
+ // spin item and create another one with new precision
+ if ( DoubleSpinItem* aDoubleSpinItem = dynamic_cast<DoubleSpinItem*>( aTable->item( row, 2 )))
+ itemTypeKO = ( aDoubleSpinItem->precision() != aPrecision );
+ else
+ itemTypeKO = true;
+ }
+ else if ( anIsComboCriterion )
+ {
+ if ( ComboItem* aComboItem = dynamic_cast<ComboItem*>( aTable->item( row, 2 )))
+ itemTypeKO = ( aComboItem->count() != comboIDs.count() );
+ else
+ itemTypeKO = true;
+ }
+ else if ( !anIsIntCriterion && aCriterionType != SMESH::FT_GroupColor )
+ {
+ itemTypeKO = ( clrBtn || isComboItem || isIntSpinItem || isDoubleSpinItem );
+ }
+ }
+
+ // update the table row
+
+ bool isSignalsBlocked = aTable->signalsBlocked();
+ aTable->blockSignals( true );
+
+ // update threshold table item
+ if ( itemTypeKO )
+ {
+ aTable->removeCellWidget( row, 2 );
+
+ if ( aCriterionType == SMESH::FT_GroupColor ) // ---------------------- QtxColorButton
+ {
+ aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) );
+ }
+ else if ( anIsComboCriterion ) // -------------------------------------------ComboItem
+ {
+ QString msgPrefix
+ ( aCriterionType == SMESH::FT_ElemGeomType ? "GEOM_TYPE_%1" : "ENTITY_TYPE_%1" );
+ QMap<int, QString> names;
+ QList<int>::const_iterator id = comboIDs.begin();
+ for ( ; id != comboIDs.end(); ++id )
+ {
+ QString name = msgPrefix.arg( *id );
+ names[ *id ] = tr( name.toLatin1().data() );
+ }
+ ComboItem* comboBox = new ComboItem( names );
+ aTable->setItem( row, 2, comboBox );
+ }
+ else if ( anIsIntCriterion ) // ------------------------------------------ IntSpinItem
+ {
+ IntSpinItem* intSpin = new IntSpinItem( 0 );
+ aTable->setItem( row, 2, intSpin );
+ }
+ else if ( anIsDoubleCriterion ) // -------------------------------------DoubleSpinItem
+ {
+ DoubleSpinItem* dblSpin = new DoubleSpinItem( 0 );
+ dblSpin->setPrecision( aPrecision );
+ aTable->setItem( row, 2, dblSpin );
+ }
+ else // --------------------------------------------------------------QTableWidgetItem
+ {
+ aTable->setItem( row, 2, new QTableWidgetItem() );
+ }
+ }
+
+ // set Compare
+ if ( anIsDoubleCriterion )
+ nbCompareSigns = 3;
+ if ( aCompareItem->count() != nbCompareSigns )
+ {
+ switch ( nbCompareSigns ) {
+ case 0: {
+ aCompareItem->clear();
+ break;
+ }
+ case 1: {
+ QMap<int, QString> aMap;
+ aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO");
+ aCompareItem->setItems(aMap);
+ break;
+ }
+ case 3: {
+ int oldValue = aCompareItem->value();
+ aCompareItem->setItems(getCompare());
+ if ( oldValue >= 0 )
+ aCompareItem->setValue( oldValue );
+ break;
+ }
+ }
+ }
+ aTable->setEditable( nbCompareSigns == 3, row, 1);
+
+ // enable/desable Threshold
+ if ( aCriterionType == SMESH::FT_GroupColor ||
+ anIsComboCriterion ||
+ anIsIntCriterion ||
+ anIsDoubleCriterion )
+ {
+ isThresholdEditable = true;
+ }
+ if ( !isThresholdEditable )
+ {
+ aTable->setItem( row, 2, new QTableWidgetItem() );
+ }
+ aTable->setEditable( isThresholdEditable, row, 2);
+
+
+ aTable->blockSignals( isSignalsBlocked );
+
+ updateAdditionalWidget();
+
+ emit CriterionChanged(row, entityType);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::onCriterionChanged()
+// Purpose : SLOT. Called then contents of table changed
+// Provides reaction on change of criterion
+//=======================================================================
+void SMESHGUI_FilterTable::onCriterionChanged (int row, int col)
+{
+ if( col == 0 )
+ onCriterionChanged(row, col, -1);
+ else if ( col == 2 )
+ emit ThresholdChanged(row, GetType());
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getFirstSelectedRow
+// Purpose : Get first selected row
+//=======================================================================
+int SMESHGUI_FilterTable::getFirstSelectedRow() const
+{
+ Table* aTable = myTables[ GetType() ];
+
+ QList<int> selRows = aTable->selectedRows(); // already sorted
+ int aRow = selRows.count() > 0 ? selRows[0] : aTable->currentRow();
+
+ return aRow >= 0 && aRow < aTable->rowCount() ? aRow : -1;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::addRow
+// Purpose : Add row at the end of table
+//=======================================================================
+void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const bool toTheEnd)
+{
+ int aCurrRow = 0;
+ int aSelectedRow = getFirstSelectedRow();
+ int aCurrCol = theTable->currentColumn();
+
+ myIsLocked = true;
+ if (toTheEnd || aSelectedRow == -1)
+ {
+ theTable->insertRows(theTable->rowCount());
+ aCurrRow = theTable->rowCount() - 1;
+ }
+ else
+ {
+ theTable->insertRows(aSelectedRow);
+ aCurrRow = aSelectedRow;
+ }
+ myIsLocked = false;
+
+ // IPAL19372 - to prevent calling onCriterionChaged() slot before completion of setItem()
+ bool isSignalsBlocked = theTable->signalsBlocked();
+ theTable->blockSignals( true );
+
+ // Criteria
+ theTable->setItem(aCurrRow, 0, getCriterionItem(theType));
+
+ // Compare
+ theTable->setItem(aCurrRow, 1, getCompareItem());
+
+ // Threshold
+ theTable->setItem(aCurrRow, 2, new QTableWidgetItem());
+
+ // Logical operation NOT
+ theTable->setItem(aCurrRow, 3, getUnaryItem());
+
+ // Logical operation AND / OR
+ theTable->setItem(aCurrRow, 4, new QTableWidgetItem());
+
+ theTable->setItem(aCurrRow, 5, new QTableWidgetItem());
+
+ theTable->blockSignals( isSignalsBlocked );
+
+ // Logical binary operation for previous value
+ int anAddBinOpStr = -1;
+ if (aCurrRow == theTable->rowCount() - 1)
+ anAddBinOpStr = aCurrRow - 1;
+ else if (aCurrRow >= 0 )
+ anAddBinOpStr = aCurrRow;
+
+ if (theTable->item(aCurrRow, 4) == 0 ||
+ theTable->item(aCurrRow, 4)->type() != ComboItem::Type())
+ {
+ if (anAddBinOpStr >= 0 &&
+ (theTable->item(anAddBinOpStr, 4) == 0 ||
+ theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type()))
+ theTable->setItem(anAddBinOpStr, 4, getBinaryItem());
+ }
+
+ theTable->setEditable(false, theTable->rowCount() - 1, 4);
+
+ if (aCurrRow >=0 && aCurrRow < theTable->rowCount() &&
+ aCurrCol >=0 && aCurrCol < theTable->rowCount())
+ theTable->setCurrentCell(aCurrRow, aCurrCol);
+
+ onCriterionChanged(aCurrRow, 0);
+
+ updateBtnState();
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getCriterionItem
+// Purpose : Get combo table item for criteria of specified type
+//=======================================================================
+QTableWidgetItem* SMESHGUI_FilterTable::getCriterionItem (const int theType) const
+{
+ return new ComboItem(getCriteria(theType));
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getCompareItem
+// Purpose : Get combo table item for operation of comparision
+//=======================================================================
+QTableWidgetItem* SMESHGUI_FilterTable::getCompareItem () const
+{
+ return new ComboItem(getCompare());
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getBinaryItem
+// Purpose :
+//=======================================================================
+QTableWidgetItem* SMESHGUI_FilterTable::getBinaryItem () const
+{
+ static QMap<int, QString> aMap;
+ if (aMap.isEmpty())
+ {
+ aMap[ SMESH::FT_LogicalAND ] = tr("AND");
+ aMap[ SMESH::FT_LogicalOR ] = tr("OR");
+ }
+
+ return new ComboItem(aMap);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getUnaryItem
+// Purpose : Get check table item
+//=======================================================================
+QTableWidgetItem* SMESHGUI_FilterTable::getUnaryItem () const
+{
+ return new CheckItem(tr("NOT"));
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getSupportedTypes
+// Purpose : Get all supported type
+//=======================================================================
+const QMap<int, QString>& SMESHGUI_FilterTable::getSupportedTypes() const
+{
+ static QMap<int, QString> aTypes;
+ if (aTypes.isEmpty())
+ {
+ aTypes[ SMESH::NODE ] = tr("NODES");
+ aTypes[ SMESH::ELEM0D ] = tr("ELEM0D");
+ aTypes[ SMESH::BALL ] = tr("BALLS");
+ aTypes[ SMESH::EDGE ] = tr("EDGES");
+ aTypes[ SMESH::FACE ] = tr("FACES");
+ aTypes[ SMESH::VOLUME ] = tr("VOLUMES");
+ aTypes[ SMESH::ALL ] = tr("ELEMENTS");
+ }
+
+ return aTypes;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getCriteria
+// Purpose : Get criteria for specified type
+//=======================================================================
+const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType) const
+{
+ if (theType == SMESH::NODE)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_FreeNodes ] = tr("FREE_NODES");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_EqualNodes ] = tr("EQUAL_NODE");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ aCriteria[ SMESH::FT_NodeConnectivityNumber ] = tr("NODE_CONN_NUMBER");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::EDGE)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_FreeBorders ] = tr("FREE_BORDERS");
+ aCriteria[ SMESH::FT_MultiConnection ] = tr("MULTI_BORDERS");
+ aCriteria[ SMESH::FT_Length ] = tr("LENGTH");
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
+ aCriteria[ SMESH::FT_EqualEdges ] = tr("EQUAL_EDGE");
+ aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::FACE)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_AspectRatio ] = tr("ASPECT_RATIO");
+ aCriteria[ SMESH::FT_Warping ] = tr("WARPING");
+ aCriteria[ SMESH::FT_MinimumAngle ] = tr("MINIMUM_ANGLE");
+ aCriteria[ SMESH::FT_Taper ] = tr("TAPER");
+ aCriteria[ SMESH::FT_Skew ] = tr("SKEW");
+ aCriteria[ SMESH::FT_Area ] = tr("AREA");
+ aCriteria[ SMESH::FT_MaxElementLength2D ] = tr("MAX_ELEMENT_LENGTH_2D");
+ aCriteria[ SMESH::FT_FreeEdges ] = tr("FREE_EDGES");
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
+ aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
+ aCriteria[ SMESH::FT_FreeFaces ] = tr("FREE_FACES");
+ aCriteria[ SMESH::FT_BareBorderFace ] = tr("BARE_BORDER_FACE");
+ aCriteria[ SMESH::FT_OverConstrainedFace] = tr("OVER_CONSTRAINED_FACE");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
+ aCriteria[ SMESH::FT_CoplanarFaces ] = tr("COPLANAR_FACES");
+ aCriteria[ SMESH::FT_EqualFaces ] = tr("EQUAL_FACE");
+ aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::VOLUME)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_AspectRatio3D ] = tr("ASPECT_RATIO_3D");
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
+ aCriteria[ SMESH::FT_BareBorderVolume ] = tr("BARE_BORDER_VOLUME");
+ aCriteria[ SMESH::FT_OverConstrainedVolume] = tr("OVER_CONSTRAINED_VOLUME");
+ aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
+ aCriteria[ SMESH::FT_MaxElementLength3D ] = tr("MAX_ELEMENT_LENGTH_3D");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
+ aCriteria[ SMESH::FT_EqualVolumes ] = tr("EQUAL_VOLUME");
+ aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::ELEM0D)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::BALL)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_BallDiameter ] = tr("BALL_DIAMETER");
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else if (theType == SMESH::ELEM0D)
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
+ aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
+ aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+ return aCriteria;
+ }
+ else // SMESH::ALL
+ {
+ static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
+ aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
+ }
+
+ return aCriteria;
+ }
+}
+
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::getCompare
+// Purpose : Get operation of comparison
+//=======================================================================
+const QMap<int, QString>& SMESHGUI_FilterTable::getCompare() const
+{
+ static QMap<int, QString> aMap;
+
+ if (aMap.isEmpty())
+ {
+ aMap[ SMESH::FT_LessThan ] = tr("LESS_THAN");
+ aMap[ SMESH::FT_MoreThan ] = tr("MORE_THAN");
+ aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO" );
+ }
+
+ return aMap;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::createTable
+// Purpose : Create table
+//=======================================================================
+SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* theParent,
+ const int theType)
+{
+ // create table
+ Table* aTable= new Table(0, 6, theParent);
+
+ QHeaderView* aHeaders = aTable->horizontalHeader();
+
+ QFontMetrics aMetrics(aHeaders->font());
+
+ // append spaces to the header of criteria in order to
+ // provide visibility of criterion inside comboboxes
+ static int aMaxLenCr = 0;
+
+ if (aMaxLenCr == 0)
+ {
+ const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
+ QMap<int, QString>::const_iterator anIter;
+ for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
+ aMaxLenCr = qMax(maxLength(getCriteria(anIter.key()), aMetrics), aMaxLenCr);
+ }
+
+ static int aLenCr = qAbs( aMaxLenCr -
+ aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
+
+ QString aCrStr;
+ aCrStr.fill(' ', aLenCr);
+ QString aCoStr;
+ aCoStr.fill(' ', 10);
+
+ QStringList aHeaderLabels;
+ aHeaderLabels.append( tr("CRITERION") + aCrStr );
+ aHeaderLabels.append( tr("COMPARE") + aCoStr );
+ aHeaderLabels.append( tr("THRESHOLD_VALUE") );
+ aHeaderLabels.append( tr("UNARY") );
+ aHeaderLabels.append( tr("BINARY") + " " );
+ aHeaderLabels.append( tr("ID") );
+ aTable->setHorizontalHeaderLabels( aHeaderLabels );
+
+ // set geometry of the table
+ for (int i = 0; i <= 4; i++)
+ aTable->resizeColumnToContents(i);
+
+ // set the ID column invisible
+ aTable->hideColumn( 5 );
+
+ aTable->updateGeometry();
+ QSize aSize = aTable->sizeHint();
+ int aWidth = aSize.width();
+ aTable->setMinimumSize(QSize(aWidth, aWidth / 2));
+ aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+
+ connect(aTable, SIGNAL(cellChanged(int, int)),
+ this, SLOT(onCriterionChanged(int, int)));
+
+ connect(aTable, SIGNAL(currentCellChanged(int, int, int, int)),
+ this, SLOT(onCurrentChanged(int, int)));
+
+ return aTable;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::updateBtnState
+// Purpose : Update button state
+//=======================================================================
+void SMESHGUI_FilterTable::updateBtnState()
+{
+ myRemoveBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
+ myClearBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetEditable
+// Purpose : Set read only flag for tables. Show/hide buttons for work with rows
+//=======================================================================
+void SMESHGUI_FilterTable::SetEditable (const bool isEditable)
+{
+ TableMap::iterator anIter;
+ for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
+ {
+ anIter.value()->setReadOnly(!isEditable);
+
+ // Set Flags for CheckItems directly IPAL 19974
+ Table* aTable = anIter.value();
+ for (int i = 0, n = aTable->rowCount(); i < n; i++)
+ for (int j = 0, m = aTable->columnCount(); j < m; j++)
+ {
+ QTableWidgetItem* anItem = aTable->item(i, j);
+ if ( dynamic_cast<SMESHGUI_FilterTable::CheckItem*>( anItem ) ) {
+ Qt::ItemFlags f = anItem->flags();
+ if (!isEditable) f = f & ~Qt::ItemIsUserCheckable;
+ else f = f | Qt::ItemIsUserCheckable;
+ anItem->setFlags( f );
+ }
+ }
+ //end of IPAL19974
+
+ if (isEditable)
+ {
+ myAddBtn->show();
+ myInsertBtn->show();
+ myRemoveBtn->show();
+ myClearBtn->show();
+ }
+ else
+ {
+ myAddBtn->hide();
+ myInsertBtn->hide();
+ myRemoveBtn->hide();
+ myClearBtn->hide();
+ }
+ }
+
+ QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
+ for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
+ anIter2.value()->SetEditable(isEditable);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetEnabled
+// Purpose : Enable/Disable table. Switching type of elements already enabled
+//=======================================================================
+void SMESHGUI_FilterTable::SetEnabled (const bool isEnabled)
+{
+ myAddBtn->setEnabled(isEnabled);
+ myInsertBtn->setEnabled(isEnabled);
+ myRemoveBtn->setEnabled(isEnabled);
+ myClearBtn->setEnabled(isEnabled);
+
+ if (isEnabled)
+ updateBtnState();
+
+ QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
+ for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
+ anIter2.value()->setEnabled(isEnabled);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::IsEditable
+// Purpose : Verify whether table is editable
+//=======================================================================
+bool SMESHGUI_FilterTable::IsEditable() const
+{
+ return !myTables[ GetType() ]->isReadOnly();
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetLibsEnabled
+// Purpose : Show/hide buttons for work with libraries
+//=======================================================================
+void SMESHGUI_FilterTable::SetLibsEnabled (const bool isEnabled)
+{
+ if (isEnabled)
+ {
+ myCopyFromBtn->show();
+ myAddToBtn->show();
+ }
+ else
+ {
+ myCopyFromBtn->hide();
+ myAddToBtn->hide();
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::onCopyFromBtn
+// Purpose : SLOT. Called the "Copy from ..." button clicked
+// Display filter library dialog
+//=======================================================================
+void SMESHGUI_FilterTable::onCopyFromBtn()
+{
+ if (myLibDlg == 0)
+ myLibDlg = new SMESHGUI_FilterLibraryDlg(
+ mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
+ else
+ myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
+
+ if (myLibDlg->exec() == QDialog::Accepted)
+ {
+ Copy(myLibDlg->GetTable());
+ Update();
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::onAddToBtn
+// Purpose : SLOT. Called the "Add to ..." button clicked
+// Display filter library dialog
+//=======================================================================
+void SMESHGUI_FilterTable::onAddToBtn()
+{
+ if (!IsValid(true))
+ return;
+ if (myLibDlg == 0)
+ myLibDlg = new SMESHGUI_FilterLibraryDlg(
+ mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
+ else
+ myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
+
+ myLibDlg->SetTable(this);
+
+ myLibDlg->exec();
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::Copy
+// Purpose : Initialise table with values of other table
+//=======================================================================
+void SMESHGUI_FilterTable::Copy (const SMESHGUI_FilterTable* theTable)
+{
+ Clear();
+
+ for (int i = 0, n = theTable->NumRows(); i < n; i++)
+ {
+ SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion();
+ theTable->GetCriterion(i, aCriterion);
+ AddCriterion(aCriterion);
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::CurrentCell
+// Purpose : Returns current cell
+//=======================================================================
+bool SMESHGUI_FilterTable::CurrentCell (int& theRow, int& theCol) const
+{
+ theRow = myTables[ GetType() ]->currentRow();
+ theCol = myTables[ GetType() ]->currentColumn();
+ return theRow >= 0 && theCol >= 0;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetText
+// Purpose : Set text and internal value in cell of threshold value
+//=======================================================================
+void SMESHGUI_FilterTable::SetThreshold (const int theRow,
+ const QString& theText,
+ const int theEntityType)
+{
+ Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
+
+ bool isSignalsBlocked = aTable->signalsBlocked();
+ aTable->blockSignals(true);
+
+ aTable->item( theRow, 2 )->setText(theText);
+
+ aTable->blockSignals(isSignalsBlocked);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetText
+// Purpose : Get text and internal value from cell of threshold value
+//=======================================================================
+bool SMESHGUI_FilterTable::GetThreshold (const int theRow,
+ QString& theText,
+ const int theEntityType)
+{
+ Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
+ QTableWidgetItem* anItem = aTable->item(theRow, 2);
+ if (anItem != 0)
+ {
+ theText = anItem->text();
+ return true;
+ }
+ else
+ return false;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::SetID
+// Purpose : Set text and internal value in cell of ID value
+//=======================================================================
+void SMESHGUI_FilterTable::SetID( const int theRow,
+ const QString& theText,
+ const int theEntityType )
+{
+ Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
+ aTable->item( theRow, 5 )->setText( theText );
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterTable::GetID
+// Purpose : Get text and internal value from cell of ID value
+//=======================================================================
+bool SMESHGUI_FilterTable::GetID( const int theRow,
+ QString& theText,
+ const int theEntityType )
+{
+ Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
+ QTableWidgetItem* anItem = aTable->item( theRow, 5 );
+ if ( anItem != 0 )
+ {
+ theText = anItem->text();
+ return true;
+ }
+ else
+ return false;
+}
+
+/*
+ Class : SMESHGUI_FilterDlg
+ Description : Dialog to specify filters for VTK viewer
+*/
+
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
+ const QList<int>& theTypes )
+: QDialog( SMESH::GetDesktop( theModule ) ),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myInitSourceWgOnApply( true ),
+ myInsertEnabled( true ),
+ myDiffSourcesEnabled( true )
+{
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ mySelector = aViewWindow->GetSelector();
+
+ construct(theTypes);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
+ const int theType )
+: QDialog( SMESH::GetDesktop( theModule ) ),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myInitSourceWgOnApply( true ),
+ myInsertEnabled( true ),
+ myDiffSourcesEnabled( true )
+{
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ mySelector = aViewWindow->GetSelector();
+ QList<int> aTypes;
+ aTypes.append(theType);
+ construct(aTypes);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::construct
+// Purpose : Construct dialog (called by constructor)
+//=======================================================================
+void SMESHGUI_FilterDlg::construct (const QList<int>& theTypes)
+{
+ myTypes = theTypes;
+
+ setModal(false);
+ //setAttribute(Qt::WA_DeleteOnClose, true); // VSR ??? is it required?
+ setWindowTitle(tr("CAPTION"));
+
+ QVBoxLayout* aDlgLay = new QVBoxLayout (this);
+ aDlgLay->setMargin(MARGIN);
+ aDlgLay->setSpacing(SPACING);
+
+ myMainFrame = createMainFrame (this);
+ QWidget* aBtnFrame = createButtonFrame(this);
+
+ aDlgLay->addWidget(myMainFrame);
+ aDlgLay->addWidget(aBtnFrame);
+
+ aDlgLay->setStretchFactor(myMainFrame, 1);
+
+ myHelpFileName = "selection_filter_library_page.html";
+
+ Init(myTypes);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::createMainFrame
+// Purpose : Create frame containing dialog's input fields
+//=======================================================================
+QWidget* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
+{
+ QWidget* aMainFrame = new QWidget(theParent);
+ QVBoxLayout* aMainLay = new QVBoxLayout(aMainFrame);
+ aMainLay->setMargin(0);
+ aMainLay->setSpacing(SPACING);
+
+ // filter frame
+
+ myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
+ myTable->SetLibsEnabled(true);
+
+ QGroupBox* aGrp = myTable->GetTableGrp();
+ QGridLayout* aLay = qobject_cast<QGridLayout*>( aGrp->layout() );
+ int rows = aLay->rowCount();
+ int cols = aLay->columnCount();
+
+ // This line looks strange when all additional parameters and mySetInViewer are hidden
+ QFrame* aLine = new QFrame(aGrp);
+ aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ aLay->addWidget(aLine, rows++, 0, 1, cols);
+
+ mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), aGrp);
+ mySetInViewer->setChecked(true);
+ aLay->addWidget(mySetInViewer, rows++, 0, 1, cols);
+
+ // other controls
+ QWidget* aSourceGrp = createSourceGroup(aMainFrame);
+
+ connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
+ SLOT(onCriterionChanged(const int, const int)));
+
+ connect(myTable, SIGNAL(CurrentChanged(int, int)),
+ SLOT(onCurrentChanged(int, int)));
+
+ aMainLay->addWidget(myTable);
+ aMainLay->addWidget(aSourceGrp);
+
+ return aMainFrame;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::createSourceFrame
+// Purpose : Create frame containing source radio button
+//=======================================================================
+QWidget* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent)
+{
+ QGroupBox* aBox = new QGroupBox(tr("SOURCE"), theParent);
+ QHBoxLayout* aLay = new QHBoxLayout(aBox);
+ aLay->setMargin(MARGIN);
+ aLay->setSpacing(SPACING);
+
+ mySourceGrp = new QButtonGroup(theParent);
+
+ QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox);
+ QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox);
+ QRadioButton* aDlgBtn = new QRadioButton(tr("CURRENT_DIALOG"),aBox);
+
+ aLay->addWidget(aMeshBtn);
+ aLay->addWidget(aSelBtn);
+ aLay->addWidget(aDlgBtn);
+
+ mySourceGrp->addButton(aMeshBtn, Mesh);
+ mySourceGrp->addButton(aSelBtn, Selection);
+ mySourceGrp->addButton(aDlgBtn, Dialog);
+
+ aMeshBtn->setChecked(true);
+
+ return aBox;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::updateMainButtons
+// Purpose : Update visibility of main buttons (OK, Cancel, Close ...)
+//=======================================================================
+void SMESHGUI_FilterDlg::updateMainButtons()
+{
+ myButtons[ BTN_Close ]->show();
+ if (myTypes.count() == 1)
+ {
+ myButtons[ BTN_Apply ]->hide();
+ }
+ else
+ {
+ myButtons[ BTN_Apply ]->show();
+ }
+// updateGeometry();
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::createButtonFrame
+// Purpose : Create frame containing buttons
+//=======================================================================
+QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent)
+{
+ QGroupBox* aGrp = new QGroupBox(theParent);
+ QHBoxLayout* aLay = new QHBoxLayout(aGrp);
+ aLay->setMargin(MARGIN);
+ aLay->setSpacing(SPACING);
+
+ myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp);
+ myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp);
+ myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp);
+ myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp);
+
+ aLay->addWidget(myButtons[ BTN_OK ]);
+ aLay->addSpacing(10);
+ aLay->addWidget(myButtons[ BTN_Apply ]);
+ aLay->addSpacing(10);
+ aLay->addStretch();
+ aLay->addWidget(myButtons[ BTN_Close ]);
+ aLay->addWidget(myButtons[ BTN_Help ]);
+
+ connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk()));
+ connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(reject()));
+ connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply()));
+ connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp()));
+
+ updateMainButtons();
+
+ return aGrp;
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg
+// Purpose : Destructor
+//=======================================================================
+SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg()
+{
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::Init
+// Purpose : Init dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SMESHGUI_FilterDlg::Init (const int type, const bool setInViewer)
+{
+ QList<int> aTypes;
+ aTypes.append(type);
+ Init(aTypes,setInViewer);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::Init
+// Purpose : Init dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes, const bool setInViewer)
+{
+ if ( theTypes.empty() )
+ {
+ Init( SMESH::ALL, setInViewer );
+ return;
+ }
+ mySourceWg = 0;
+ myTypes = theTypes;
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ myGroup = SMESH::SMESH_GroupOnFilter::_nil();
+ myIObjects.Clear();
+ myIsSelectionChanged = false;
+ myToRestoreSelMode = false;
+
+ myTable->Init(theTypes);
+
+ // set caption
+ if (theTypes.count() == 1)
+ {
+ int aType = theTypes.first();
+ if (aType == SMESH::NODE ) setWindowTitle(tr("NODES_TLT"));
+ else if (aType == SMESH::ELEM0D) setWindowTitle(tr("ELEM0D_TLT"));
+ else if (aType == SMESH::BALL ) setWindowTitle(tr("BALL_TLT"));
+ else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT"));
+ else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT"));
+ else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
+ else if (aType == SMESH::ALL) setWindowTitle(tr("TLT"));
+ }
+ else
+ setWindowTitle(tr("TLT"));
+
+ qApp->processEvents();
+ updateGeometry();
+ adjustSize();
+ setEnabled(true);
+
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+ connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
+ connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView()));
+
+ updateMainButtons();
+ updateSelection();
+
+ // Initialise filter table with values of previous filter
+ QList<int>::const_iterator anIter;
+ for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter)
+ {
+ myTable->Clear(*anIter);
+ if (!myFilter[ *anIter ]->_is_nil())
+ {
+ SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
+ if (myFilter[ *anIter ]->GetCriteria(aCriteria))
+ {
+ for (int i = 0, n = aCriteria->length(); i < n; i++)
+ myTable->AddCriterion(aCriteria[ i ], *anIter);
+ }
+ }
+ }
+
+ if (myInsertState.contains(theTypes.first()))
+ mySetInViewer->setChecked(myInsertState[ theTypes.first() ]);
+ else
+ mySetInViewer->setChecked(setInViewer);
+
+ mySourceGrp->button(myApplyToState.contains(theTypes.first()) ?
+ myApplyToState[ theTypes.first() ] :
+ Mesh)->setChecked(true);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::onOk
+// Purpose : SLOT called when "Ok" button pressed.
+// Assign filters VTK viewer and close dialog
+//=======================================================================
+void SMESHGUI_FilterDlg::onOk()
+{
+ if (onApply())
+ {
+ restoreSelMode();
+ mySelectionMgr->clearFilters();
+ disconnect(mySMESHGUI, 0, this, 0);
+ disconnect(mySelectionMgr, 0, this, 0);
+ mySMESHGUI->ResetState();
+ accept();
+ emit Accepted();
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::reject
+// Purpose : SLOT called when "Close" button pressed. Close dialog
+//=======================================================================
+void SMESHGUI_FilterDlg::reject()
+{
+ restoreSelMode();
+ // Restore previously selected object
+ if (mySelectionMgr)
+ {
+ SALOME_ListIO aList;
+ mySelectionMgr->clearFilters();
+ mySelectionMgr->clearSelected();
+ SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
+ for ( ; anIter.More(); anIter.Next())
+ {
+ aList.Append(anIter.Key());
+
+ TColStd_MapOfInteger aResMap;
+ const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
+ for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
+ aResMap.Add(anIndMap(i));
+
+ mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->highlight( anIter.Key(), true, true );
+ }
+ mySelectionMgr->setSelectedObjects(aList, false);
+ }
+
+ disconnect(mySMESHGUI, 0, this, 0);
+ disconnect(mySelectionMgr, 0, this, 0);
+ mySMESHGUI->ResetState();
+ QDialog::reject();
+}
+
+//=================================================================================
+// function : onOpenView()
+// purpose :
+//=================================================================================
+void SMESHGUI_FilterDlg::onOpenView()
+{
+ if ( mySelector ) {
+ SMESH::SetPointRepresentation(false);
+ }
+ else {
+ mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+ }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose :
+//=================================================================================
+void SMESHGUI_FilterDlg::onCloseView()
+{
+ mySelector = 0;
+}
+
+//=================================================================================
+// function : onHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_FilterDlg::onHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::onDeactivate
+// Purpose : SLOT called when dialog must be deativated
+//=======================================================================
+void SMESHGUI_FilterDlg::onDeactivate()
+{
+ setEnabled(false);
+}
+
+//=======================================================================
+// name : SMESHGUI_FilterDlg::enterEvent
+// Purpose : Event filter
+//=======================================================================
+void SMESHGUI_FilterDlg::enterEvent (QEvent*)
+{
+// mySMESHGUI->EmitSignalDeactivateDialog();
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+ mySMESHGUI->ResetState();
+ setEnabled(true);