-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_FilterDlg.cxx
// Author : Sergey LITONIN, Open CASCADE S.A.S.
if (aWg->isEnabled() && aWg->validator()->validate(aText, p) != QValidator::Acceptable) {
if (theMsg)
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SMESHGUI_INVALID_PARAMETERS"));
+ tr("SMESHGUI_INVALID_PARAMETERS"));
return false;
}
}
~ComboDelegate();
QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
- const QModelIndex& ) const;
+ const QModelIndex& ) const;
void setEditorData( QWidget*, const QModelIndex& ) const;
void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&,
- const QModelIndex& ) const;
+ const QModelIndex& ) const;
private:
QTableWidget* myTable;
};
}
QWidget* SMESHGUI_FilterTable::ComboDelegate::createEditor( QWidget* parent,
- const QStyleOptionViewItem& option,
- const QModelIndex& index ) const
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index ) const
{
QStringList l = index.data( Qt::UserRole ).toStringList();
if ( !l.isEmpty() ) {
}
void SMESHGUI_FilterTable::ComboDelegate::setEditorData( QWidget* editor,
- const QModelIndex& index ) const
+ const QModelIndex& index ) const
{
QString value = index.model()->data( index, Qt::DisplayRole ).toString();
QComboBox* cb = dynamic_cast<QComboBox*>( editor );
}
void SMESHGUI_FilterTable::ComboDelegate::setModelData( QWidget* editor,
- QAbstractItemModel* model,
- const QModelIndex& index) const
+ QAbstractItemModel* model,
+ const QModelIndex& index) const
{
QComboBox* cb = dynamic_cast<QComboBox*>( editor );
if ( cb ) model->setData( index, cb->currentText(), Qt::DisplayRole );
}
void SMESHGUI_FilterTable::ComboDelegate::updateEditorGeometry( QWidget* editor,
- const QStyleOptionViewItem& option,
- const QModelIndex& index ) const
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index ) const
{
editor->setGeometry( option.rect );
}
void SMESHGUI_FilterTable::Table::setReadOnly( bool on )
{
setEditTriggers( on ?
- QAbstractItemView::NoEditTriggers :
- QAbstractItemView::AllEditTriggers );
+ QAbstractItemView::NoEditTriggers :
+ QAbstractItemView::AllEditTriggers );
}
bool SMESHGUI_FilterTable::Table::isReadOnly() const
theCriterion.Threshold = (double)((ComboItem*)aTable->item(theRow, 2))->value();
else if ( aCriterionType != SMESH::FT_RangeOfIds &&
aCriterionType != SMESH::FT_BelongToGeom &&
- aCriterionType != SMESH::FT_BelongToPlane &&
- aCriterionType != SMESH::FT_BelongToCylinder &&
- aCriterionType != SMESH::FT_BelongToGenSurface &&
- aCriterionType != SMESH::FT_LyingOnGeom)
+ aCriterionType != SMESH::FT_BelongToPlane &&
+ aCriterionType != SMESH::FT_BelongToCylinder &&
+ aCriterionType != SMESH::FT_BelongToGenSurface &&
+ aCriterionType != SMESH::FT_LyingOnGeom)
{
theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
int aCriterionType = GetCriterionType(row);
QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
- bool isComboItem = aTable->item(row, 2)->type() == ComboItem::Type();
+ int aComboType = ComboItem::Type();
+ QTableWidgetItem* aTableItem = aTable->item(row, 2);
+ bool isComboItem = false;
+ if (aTableItem) {
+ int aTableType = aTable->item(row, 2)->type();
+ isComboItem = aTableType == aComboType ? true : false;
+ }
if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
(aCriterionType != SMESH::FT_ElemGeomType && isComboItem) )
}
else
{
- if (aCompareItem->count() != 3)
+ if (aCompareItem && aCompareItem->count() != 3)
{
aCompareItem->setItems(getCompare());
}
- QString aText = aTable->text(row, 2);
- bool isOk = false;
- aText.toDouble(&isOk);
- aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
- if (!aTable->isEditable(row, 1))
- aTable->setEditable(true, row, 1);
- if (!aTable->isEditable(row, 2))
- aTable->setEditable(true, row, 2);
+ if (aTable->item( row, 2 )) {
+ QString aText = aTable->text(row, 2);
+ bool isOk = false;
+ aText.toDouble(&isOk);
+ aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
+ if (!aTable->isEditable(row, 1))
+ aTable->setEditable(true, row, 1);
+ if (!aTable->isEditable(row, 2))
+ aTable->setEditable(true, row, 2);
+ }
}
updateAdditionalWidget();
}
static int aLenCr = qAbs( aMaxLenCr -
- aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
+ aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
QString aCrStr;
aCrStr.fill(' ', aLenCr);
aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
connect(aTable, SIGNAL(cellChanged(int, int)),
- this, SLOT(onCriterionChanged(int, int)));
+ this, SLOT(onCriterionChanged(int, int)));
connect(aTable, SIGNAL(currentCellChanged(int, int, int, int)),
- this, SLOT(onCurrentChanged(int, int)));
+ this, SLOT(onCurrentChanged(int, int)));
return aTable;
}
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 );
- }
- }
+ {
+ 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)
// Purpose : Get text and internal value from cell of ID value
//=======================================================================
bool SMESHGUI_FilterTable::GetID( const int theRow,
- QString& theText,
- const int theEntityType )
+ QString& theText,
+ const int theEntityType )
{
Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
QTableWidgetItem* anItem = aTable->item( theRow, 5 );
mySetInViewer->setChecked(true);
mySourceGrp->button(myApplyToState.contains(theTypes.first()) ?
- myApplyToState[ theTypes.first() ] :
- Selection)->setChecked(true);
+ myApplyToState[ theTypes.first() ] :
+ Selection)->setChecked(true);
}
//=======================================================================
platform = "application";
#endif
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
- tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser",
- platform)).
- arg(myHelpFileName));
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
}
}
SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().constData(), "GEOM");
if (aList.size() == 0) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("BAD_SHAPE_NAME").arg(aName));
+ tr("BAD_SHAPE_NAME").arg(aName));
return false;
}
aFace.IsNull() ||
aFace.ShapeType() != TopAbs_FACE) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SHAPE_IS_NOT_A_FACE").arg(aName));
+ tr("SHAPE_IS_NOT_A_FACE").arg(aName));
return false;
}
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
if (aSurf.IsNull()) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SHAPE_IS_NOT_A_FACE").arg(aName));
+ tr("SHAPE_IS_NOT_A_FACE").arg(aName));
return false;
}
if (aType == SMESH::FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
+ tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
return false;
}
if (aType == SMESH::FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
+ tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
return false;
}
}
//=======================================================================
void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh)
{
- myMesh = theMesh;
+ if ( !theMesh->_is_nil() ) {
+ myMesh = theMesh;
+ if ( !myFilter[ myTable->GetType() ]->_is_nil() && !myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ) {
+ SMESH::Predicate_ptr aPred = myFilter[ myTable->GetType() ]->GetPredicate();
+ aPred->SetMesh(myMesh);
+ }
+ }
const bool isEnable = !(myMesh->_is_nil());
myButtons[BTN_OK]->setEnabled(isEnable);
myButtons[BTN_Apply]->setEnabled(isEnable);