Fix for bug PAL10409 (Filter "Belong to geom" fails if 2 geom shapes have the same name);

This commit is contained in:
mzn 2005-11-11 15:31:38 +00:00
parent 1d63486c23
commit 4978ecadd8
5 changed files with 200 additions and 11 deletions

View File

@ -155,7 +155,9 @@ module SMESH
void SetElementType( in ElementType theType );
void SetShapeName( in string theName );
void SetShape( in string theID, in string theName );
string GetShapeName();
string GetShapeID();
};
/*!
@ -167,7 +169,9 @@ module SMESH
void SetTolerance( in double theToler );
double GetTolerance();
void SetShapeName( in string theName, in ElementType theType );
void SetShape( in string theID, in string theName, in ElementType theType );
string GetShapeName();
string GetShapeID();
};
@ -199,7 +203,9 @@ module SMESH
void SetElementType( in ElementType theType );
void SetShapeName( in string theName );
string GetShapeName();
void SetShape( in string theID, in string theName );
string GetShapeName();
string GetShapeID();
};
/*!
@ -291,6 +297,8 @@ module SMESH
* ThresholdStr - Threshold value defined as string. Used for:
* 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
* 2. BelongToGeom predicate for storing name of shape
* ThresholdID - One more threshold value defined as string. Used for:
* 1. BelongToGeom predicate for storing id of shape
* Tolerance - Tolerance is used for comparators (EqualTo comparision) and for
* "Belong to plane" and "Belong to cylinder" predicates
* TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
@ -302,6 +310,7 @@ module SMESH
long Compare;
double Threshold;
string ThresholdStr;
string ThresholdID;
long UnaryOp;
long BinaryOp;
double Tolerance;

View File

@ -782,7 +782,11 @@ void SMESHGUI_FilterTable::GetCriterion( const int theRow,
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 ) )
@ -825,7 +829,11 @@ void SMESHGUI_FilterTable::SetCriterion( const int theRow,
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 ||
@ -1343,7 +1351,7 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget* thePar
const int theType )
{
// create table
Table* aTable= new Table( 0, 5, theParent );
Table* aTable= new Table( 0, 6, theParent );
QHeader* aHeaders = aTable->horizontalHeader();
@ -1374,11 +1382,15 @@ SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget* thePar
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();
@ -1580,6 +1592,37 @@ bool SMESHGUI_FilterTable::GetThreshold( const int theRow,
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
@ -2207,7 +2250,7 @@ bool SMESHGUI_FilterDlg::createFilter( const int theType )
myFilter[ theType ] = aFilterMgr->CreateFilter();
myFilter[ theType ]->SetCriteria( aCriteria.inout() );
return true;
}
@ -2423,6 +2466,7 @@ SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion()
aCriterion.UnaryOp = FT_Undefined;
aCriterion.BinaryOp = FT_Undefined;
aCriterion.ThresholdStr = "";
aCriterion.ThresholdID = "";
aCriterion.TypeOfElement = SMESH::ALL;
return aCriterion;
@ -2448,7 +2492,10 @@ void SMESHGUI_FilterDlg::onSelectionDone()
Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ;
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));
}
}
//=======================================================================

View File

@ -126,6 +126,14 @@ public:
QString& theText,
const int theEntityType = -1 );
void SetID( const int theRow,
const QString& theText,
const int theEntityType = -1 );
bool GetID( const int theRow,
QString& theText,
const int theEntityType = -1 );
void Update();

View File

@ -342,6 +342,7 @@ static SMESH::Filter::Criterion createCriterion()
aCriterion.UnaryOp = FT_Undefined;
aCriterion.BinaryOp = FT_Undefined;
aCriterion.ThresholdStr = "";
aCriterion.ThresholdID = "";
aCriterion.Tolerance = Precision::Confusion();
aCriterion.TypeOfElement = SMESH::ALL;
aCriterion.Precision = -1;
@ -374,7 +375,50 @@ static TopoDS_Shape getShapeByName( const char* theName )
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
@ -693,11 +737,13 @@ BelongToGeom_i::BelongToGeom_i()
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 )
@ -731,11 +777,32 @@ void BelongToGeom_i::SetShapeName( const char* theName )
myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
}
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
@ -745,12 +812,14 @@ BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceTyp
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 )
@ -781,11 +850,32 @@ void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)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 );
@ -845,11 +935,13 @@ LyingOnGeom_i::LyingOnGeom_i()
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 )
@ -883,11 +975,32 @@ void LyingOnGeom_i::SetShapeName( const char* theName )
myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
}
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
@ -1585,6 +1698,7 @@ static inline bool getCriteria( Predicate_i* thePred,
theCriteria[ i ].Type = FT_BelongToGeom;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
return true;
@ -1601,6 +1715,7 @@ static inline bool getCriteria( Predicate_i* thePred,
theCriteria[ i ].Type = aFType;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
theCriteria[ i ].Tolerance = aPred->GetTolerance();
@ -1617,6 +1732,7 @@ static inline bool getCriteria( Predicate_i* thePred,
theCriteria[ i ].Type = FT_LyingOnGeom;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
theCriteria[ i ].ThresholdID = aPred->GetShapeID();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
return true;
@ -1736,6 +1852,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
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;
@ -1792,7 +1909,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
{
SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
tmpPred->SetElementType( aTypeOfElem );
tmpPred->SetShapeName( aThresholdStr );
tmpPred->SetShape( aThresholdID, aThresholdStr );
aPredicate = tmpPred;
}
break;
@ -1804,7 +1921,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
tmpPred = aFilterMgr->CreateBelongToPlane();
else
tmpPred = aFilterMgr->CreateBelongToCylinder();
tmpPred->SetShapeName( aThresholdStr, aTypeOfElem );
tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
tmpPred->SetTolerance( aTolerance );
aPredicate = tmpPred;
}
@ -1813,7 +1930,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
{
SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
tmpPred->SetElementType( aTypeOfElem );
tmpPred->SetShapeName( aThresholdStr );
tmpPred->SetShape( aThresholdID, aThresholdStr );
aPredicate = tmpPred;
}
break;
@ -2236,7 +2353,6 @@ static LDOM_Element createFilterItem( const char* theName,
aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type ) );
aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) );
aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) );
aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) );
aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) );
@ -2353,7 +2469,7 @@ Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
}
else
aCriterion.ThresholdStr = str.GetString();
aCriteria.push_back( aCriterion );
}

View File

@ -347,11 +347,14 @@ public:
void SetGeom( const TopoDS_Shape& theShape );
void SetShapeName( const char* theName );
void SetShape( const char* theID, const char* theName );
char* GetShapeName();
char* GetShapeID();
protected:
Controls::BelongToGeomPtr myBelongToGeomPtr;
char* myShapeName;
char* myShapeID;
};
/*
@ -368,7 +371,9 @@ public:
void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
void SetShapeName( const char* theName, ElementType theType );
void SetShape( const char* theID, const char* theName, ElementType theType );
char* GetShapeName();
char* GetShapeID();
void SetTolerance( CORBA::Double );
CORBA::Double GetTolerance();
@ -376,6 +381,7 @@ public:
protected:
Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr;
char* myShapeName;
char* myShapeID;
Handle(Standard_Type) mySurfaceType;
};
@ -423,11 +429,14 @@ public:
void SetGeom( const TopoDS_Shape& theShape );
void SetShapeName( const char* theName );
void SetShape( const char* theID, const char* theName );
char* GetShapeName();
char* GetShapeID();
protected:
Controls::LyingOnGeomPtr myLyingOnGeomPtr;
char* myShapeName;
char* myShapeID;
};
/*