theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
}
else
- theCriterion.ThresholdStr = aTable->text(theRow, 2).latin1();
+ {
+ theCriterion.ThresholdStr = aTable->text(theRow, 2).latin1();
+ if ( aCriterionType != FT_RangeOfIds )
+ theCriterion.ThresholdID = aTable->text( theRow, 5 ).latin1();
+ }
QTableItem* anItem = aTable->item(theRow, 0);
if (myAddWidgets.contains(anItem))
theCriterion.Type != FT_LyingOnGeom)
aTable->setText(theRow, 2, QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
else
- aTable->setText(theRow, 2, QString(theCriterion.ThresholdStr));
+ {
+ aTable->setText(theRow, 2, QString(theCriterion.ThresholdStr));
+ if ( theCriterion.Type != FT_RangeOfIds )
+ aTable->setText( theRow, 5, QString( theCriterion.ThresholdID ) );
+ }
if (theCriterion.Compare == FT_EqualTo ||
theCriterion.Type == FT_BelongToPlane ||
const int theType)
{
// create table
- Table* aTable= new Table(0, 5, theParent);
+ Table* aTable= new Table(0, 6, theParent);
QHeader* aHeaders = aTable->horizontalHeader();
aHeaders->setLabel(2, tr("THRESHOLD_VALUE"));
aHeaders->setLabel(3, tr("UNARY"));
aHeaders->setLabel(4, tr("BINARY") + " ");
+ aHeaders->setLabel( 5, tr( "ID" ) );
// set geometry of the table
for (int i = 0; i <= 4; i++)
aTable->adjustColumn(i);
+ // set the ID column invisible
+ aTable->hideColumn( 5 );
+
aTable->updateGeometry();
QSize aSize = aTable->sizeHint();
int aWidth = aSize.width();
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->setText( theRow, 5, 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 ];
+ QTableItem* 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
aCriterion.UnaryOp = FT_Undefined;
aCriterion.BinaryOp = FT_Undefined;
aCriterion.ThresholdStr = "";
+ aCriterion.ThresholdID = "";
aCriterion.TypeOfElement = SMESH::ALL;
return aCriterion;
Handle(SALOME_InteractiveObject) anIO = aList.First();
GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
if (!anObj->_is_nil())
- myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
+ {
+ myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
+ myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj));
+ }
}
//=======================================================================
aCriterion.UnaryOp = FT_Undefined;
aCriterion.BinaryOp = FT_Undefined;
aCriterion.ThresholdStr = "";
+ aCriterion.ThresholdID = "";
aCriterion.Tolerance = Precision::Confusion();
aCriterion.TypeOfElement = SMESH::ALL;
aCriterion.Precision = -1;
return TopoDS_Shape();
}
+static TopoDS_Shape getShapeByID( const char* theID )
+{
+ if ( theID != 0 && theID!="" )
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ if ( aStudy != 0 )
+ {
+ CORBA::Object_var obj = aStudy->ConvertIORToObject(theID);
+ GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( obj );
+
+ if ( !aGeomObj->_is_nil() )
+ {
+ GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+ TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
+ return aLocShape;
+ }
+ }
+ }
+ return TopoDS_Shape();
+}
+static char* getShapeNameByID ( const char* theID )
+{
+ char* aName = "";
+
+ if ( theID != 0 && theID!="" )
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+ if ( aStudy != 0 )
+ {
+ SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") )
+ {
+ SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
+ aName = aNameAttr->Value();
+ }
+ }
+ }
+
+ return aName;
+}
/*
FUNCTORS
myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
myShapeName = 0;
+ myShapeID = 0;
}
BelongToGeom_i::~BelongToGeom_i()
{
delete myShapeName;
+ delete myShapeID;
}
void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
}
+void BelongToGeom_i::SetShape( const char* theID, const char* theName )
+{
+ delete myShapeName;
+ myShapeName = strdup( theName );
+ delete myShapeID;
+ if ( theID )
+ myShapeID = strdup( theID );
+ else
+ myShapeID = 0;
+
+ if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+ myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
+ else
+ myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+}
+
char* BelongToGeom_i::GetShapeName()
{
return CORBA::string_dup( myShapeName );
}
+char* BelongToGeom_i::GetShapeID()
+{
+ return CORBA::string_dup( myShapeID );
+}
+
/*
Class : BelongToSurface_i
Description : Predicate for selection on geometrical support
myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
myShapeName = 0;
+ myShapeID = 0;
mySurfaceType = theSurfaceType;
}
BelongToSurface_i::~BelongToSurface_i()
{
delete myShapeName;
+ delete myShapeID;
}
void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
}
+void BelongToSurface_i::SetShape( const char* theID, const char* theName, ElementType theType )
+{
+ delete myShapeName;
+ myShapeName = strdup( theName );
+ delete myShapeID;
+ if ( theID )
+ myShapeID = strdup( theID );
+ else
+ myShapeID = 0;
+
+ if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+ myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
+ else
+ myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
+}
+
char* BelongToSurface_i::GetShapeName()
{
return CORBA::string_dup( myShapeName );
}
+char* BelongToSurface_i::GetShapeID()
+{
+ return CORBA::string_dup( myShapeID );
+}
+
void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
{
myElementsOnSurfacePtr->SetTolerance( theToler );
myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
myShapeName = 0;
+ myShapeID = 0;
}
LyingOnGeom_i::~LyingOnGeom_i()
{
delete myShapeName;
+ delete myShapeID;
}
void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
}
+void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
+{
+ delete myShapeName;
+ myShapeName = strdup( theName );
+ delete myShapeID;
+ if ( theID )
+ myShapeID = strdup( theID );
+ else
+ myShapeID = 0;
+
+ if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+ myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
+ else
+ myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+}
+
char* LyingOnGeom_i::GetShapeName()
{
return CORBA::string_dup( myShapeName );
}
+char* LyingOnGeom_i::GetShapeID()
+{
+ return CORBA::string_dup( myShapeID );
+}
+
/*
Class : FreeBorders_i
Description : Predicate for free borders
theCriteria[ i ].Type = FT_BelongToGeom;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
+ theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
return true;
theCriteria[ i ].Type = aFType;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
+ theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
theCriteria[ i ].Tolerance = aPred->GetTolerance();
theCriteria[ i ].Type = FT_LyingOnGeom;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
+ theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
return true;
int aBinary = theCriteria[ i ].BinaryOp;
double aTolerance = theCriteria[ i ].Tolerance;
const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
+ const char* aThresholdID = theCriteria[ i ].ThresholdID;
ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
long aPrecision = theCriteria[ i ].Precision;
{
SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
tmpPred->SetElementType( aTypeOfElem );
- tmpPred->SetShapeName( aThresholdStr );
+ tmpPred->SetShape( aThresholdID, aThresholdStr );
aPredicate = tmpPred;
}
break;
tmpPred = aFilterMgr->CreateBelongToPlane();
else
tmpPred = aFilterMgr->CreateBelongToCylinder();
- tmpPred->SetShapeName( aThresholdStr, aTypeOfElem );
+ tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
tmpPred->SetTolerance( aTolerance );
aPredicate = tmpPred;
}
{
SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
tmpPred->SetElementType( aTypeOfElem );
- tmpPred->SetShapeName( aThresholdStr );
+ tmpPred->SetShape( aThresholdID, aThresholdStr );
aPredicate = tmpPred;
}
break;
}
else
aCriterion.ThresholdStr = str.GetString();
-
+
aCriteria.push_back( aCriterion );
}