IPAL10786: "Edit" is unnecessary functionality for some Mesh hypotheses

+ Eliminate compilation warnings
This commit is contained in:
eap 2015-10-29 19:18:36 +03:00
parent ffd0606a85
commit a5a9b778aa
19 changed files with 128 additions and 69 deletions

View File

@ -87,6 +87,13 @@ module SMESH
* Verify whether hypothesis supports given entity type
*/
boolean IsDimSupported( in Dimension type );
/*!
* Return true if a hypothesis has parameters.
*
* This method is intended for GUI to know if "Edit" menu item sould be available
*/
boolean HasParameters();
};
typedef sequence<string> ListOfHypothesisName;

View File

@ -4353,7 +4353,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& hasGeomReference" );
createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo);
createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh + " " + subMesh ); // convert to quadratic

View File

@ -129,6 +129,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) );
else if ( p=="hasGeomReference" ) val = QVariant( hasGeomReference( ind ) );
else if ( p=="isEditableHyp" ) val = QVariant( isEditableHyp( ind ) );
else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
@ -495,16 +496,16 @@ int SMESHGUI_Selection::dim( int ind ) const
//purpose : return true for a ready-to-compute mesh
//=======================================================================
QVariant SMESHGUI_Selection::isComputable( int ind ) const
bool SMESHGUI_Selection::isComputable( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
{
QMap<int,int> modeMap;
_PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
SMESHGUI_PrecomputeOp::getAssignedAlgos( so, modeMap );
return QVariant( modeMap.size() > 0 );
return modeMap.size() > 0;
}
return QVariant( false );
return false;
}
//=======================================================================
@ -512,7 +513,7 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const
//purpose : returns true for a mesh with algorithms
//=======================================================================
QVariant SMESHGUI_Selection::isPreComputable( int ind ) const
bool SMESHGUI_Selection::isPreComputable( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
{
@ -523,11 +524,11 @@ QVariant SMESHGUI_Selection::isPreComputable( int ind ) const
_PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
if ( modeMap.size() > 1 )
return QVariant( ( modeMap.contains( SMESH::DIM_3D )) ||
( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
return (( modeMap.contains( SMESH::DIM_3D )) ||
( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
}
}
return QVariant( false );
return false;
}
//=======================================================================
@ -535,15 +536,35 @@ QVariant SMESHGUI_Selection::isPreComputable( int ind ) const
//purpose : returns true for a mesh or sub-mesh on geometry
//=======================================================================
QVariant SMESHGUI_Selection::hasGeomReference( int ind ) const
bool SMESHGUI_Selection::hasGeomReference( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
_PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
return QVariant( !shape->_is_nil() );
return !shape->_is_nil();
}
return QVariant( false );
return false;
}
//=======================================================================
//function : isEditableHyp
//purpose :
//=======================================================================
bool SMESHGUI_Selection::isEditableHyp( int ind ) const
{
bool isEditable = true;
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
{
_PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
if ( !hyp->_is_nil() )
{
isEditable = hyp->HasParameters();
}
}
return isEditable;
}
//=======================================================================
@ -551,17 +572,17 @@ QVariant SMESHGUI_Selection::hasGeomReference( int ind ) const
//purpose :
//=======================================================================
QVariant SMESHGUI_Selection::isVisible( int ind ) const
bool SMESHGUI_Selection::isVisible( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
SMESH_Actor* actor = SMESH::FindActorByEntry( entry( ind ).toLatin1().data() );
if ( actor && actor->hasIO() ) {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
return QVariant( aViewWindow->isVisible( actor->getIO() ) );
return aViewWindow->isVisible( actor->getIO() );
}
}
return QVariant( false );
return false;
}
//=======================================================================

View File

@ -56,10 +56,11 @@ public:
virtual bool isAutoColor( int ) const;
virtual int numberOfNodes( int ) const;
virtual int dim( int ) const;
virtual QVariant isComputable( int ) const;
virtual QVariant isPreComputable( int ) const;
virtual QVariant hasGeomReference( int ) const;
virtual QVariant isVisible( int ) const;
virtual bool isComputable( int ) const;
virtual bool isPreComputable( int ) const;
virtual bool hasGeomReference( int ) const;
virtual bool isEditableHyp( int ) const;
virtual bool isVisible( int ) const;
virtual QString quadratic2DMode( int ) const;

View File

@ -919,7 +919,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
Threshold = SMESH + types[ iGeom ];
#ifdef _DEBUG_
// is types complete? (compilation failure mains that enum GeometryType changed)
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ];
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ]; _assert[0]=1;
#endif
}
if (Type == "SMESH.FT_EntityType")
@ -939,7 +939,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
Threshold = SMESH + types[ iGeom ];
#ifdef _DEBUG_
// is types complete? (compilation failure mains that enum EntityType changed)
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ];
int _assert[( sizeof(types) / sizeof(const char*) == nbTypes ) ? 1 : -1 ]; _assert[0]=1;
#endif
}
}
@ -1930,7 +1930,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
TCollection_AsciiString grIDs = theCommand->GetResultValue();
list< _pyID > idList = theCommand->GetStudyEntries( grIDs );
list< _pyID >::iterator grID = idList.begin();
const int nbGroupsBefore = myGroups.size();
const size_t nbGroupsBefore = myGroups.size();
Handle(_pyObject) obj;
for ( ; grID != idList.end(); ++grID )
{
@ -3133,7 +3133,7 @@ void _pyHypothesis::setCreationArg( const int argNb, const _AString& arg )
{
if ( myCurCrMethod )
{
while ( myCurCrMethod->myArgs.size() < argNb )
while ( (int) myCurCrMethod->myArgs.size() < argNb )
myCurCrMethod->myArgs.push_back( "None" );
if ( arg.IsEmpty() )
myCurCrMethod->myArgs[ argNb-1 ] = "None";
@ -3200,7 +3200,7 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand)
for ( ; type2meth != myAlgoType2CreationMethod.end(); ++type2meth )
{
CreationMethod& crMethod = type2meth->second;
while ( crMethod.myArgs.size() < i+1 )
while ( (int) crMethod.myArgs.size() < i+1 )
crMethod.myArgs.push_back( "[]" );
crMethod.myArgs[ i ] = theCommand->GetArg( 1 ); // arg value
}

View File

@ -115,7 +115,7 @@ class _pyCommand: public Standard_Transient
public:
_pyCommand() {};
_pyCommand( const _AString& theString, int theNb=-1 )
: myString( theString ), myOrderNb( theNb ) {};
: myOrderNb( theNb ), myString( theString ) {};
_AString & GetString() { return myString; }
int GetOrderNb() const { return myOrderNb; }
void SetOrderNb( int theNb ) { myOrderNb = theNb; }

View File

@ -170,21 +170,21 @@ static TopoDS_Shape getShapeByID (const char* theID)
return TopoDS_Shape();
}
static std::string getShapeNameByID (const char* theID)
{
if ( theID && strlen( theID ) > 0 ) {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
if ( !aStudy->_is_nil() ) {
SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
if ( !aSObj->_is_nil() ) {
CORBA::String_var name = aSObj->GetName();
return name.in();
}
}
}
return "";
}
// static std::string getShapeNameByID (const char* theID)
// {
// if ( theID && strlen( theID ) > 0 ) {
// SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
// SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
// if ( !aStudy->_is_nil() ) {
// SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
// if ( !aSObj->_is_nil() ) {
// CORBA::String_var name = aSObj->GetName();
// return name.in();
// }
// }
// }
// return "";
// }
/*
FUNCTORS
@ -1830,9 +1830,9 @@ FunctorType EqualTo_i::GetFunctorType()
Class : LogicalNOT_i
Description : Logical NOT predicate
*/
LogicalNOT_i::LogicalNOT_i()
: myPredicate( NULL ),
myLogicalNOTPtr( new Controls::LogicalNOT() )
LogicalNOT_i::LogicalNOT_i():
myLogicalNOTPtr( new Controls::LogicalNOT() ),
myPredicate( NULL )
{
myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
}
@ -4068,7 +4068,7 @@ static const char** getFunctNames()
#ifdef _DEBUG_
// check if functName is complete, compilation failure means that enum FunctorType changed
const int nbFunctors = sizeof(functName) / sizeof(const char*);
int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 1 : -1 ];
int _assert[( nbFunctors == SMESH::FT_Undefined + 1 ) ? 1 : -1 ]; _assert[0]=1;
#endif
return functName;

View File

@ -237,6 +237,19 @@ void SMESH_Hypothesis_i::setOldParameters (const char* theParameters)
return myBaseImpl;
}
//================================================================================
/*!
* \brief Return true if a hypothesis has parameters
*/
//================================================================================
CORBA::Boolean SMESH_Hypothesis_i::HasParameters()
{
std::ostringstream os;
myBaseImpl->SaveTo( os );
return ( !os.str().empty() );
}
//=============================================================================
/*!
* SMESH_Hypothesis_i::SaveTo

View File

@ -59,31 +59,34 @@ public:
virtual ~SMESH_Hypothesis_i();
// Get type name of hypothesis
char* GetName();
virtual char* GetName();
// Get plugin library name of hypothesis
char* GetLibName();
virtual char* GetLibName();
// Set plugin library name of hypothesis
void SetLibName( const char* theLibName );
// Get unique id of hypothesis
CORBA::Long GetId();
virtual CORBA::Long GetId();
// Return true if a hypothesis has parameters
virtual CORBA::Boolean HasParameters();
// Set the variable parameter (a variable name or a parameter value); \a method is a name
// of method setting this parameter.
// This method must be called by the hypothesis creator just before calling hyp->method()
void SetVarParameter (const char* parameter, const char* method);
virtual void SetVarParameter (const char* parameter, const char* method);
// Return the variable parameter used at Hypothesis Creation by the name of method
// setting this parameter. The returned variable name is used at Hypothesis Edition.
char* GetVarParameter (const char* methodName);
virtual char* GetVarParameter (const char* methodName);
// Store a hypothesis wrapping this not published one. This hyp, which has
// no own parameters but is published, is used to store variables defining parameters
// of this hypothesis. This method is to be called before setting parameters
// of this hypothesis.
void SetHolderHypothesis(const SMESH::SMESH_Hypothesis_ptr hyp);
virtual void SetHolderHypothesis(const SMESH::SMESH_Hypothesis_ptr hyp);
//Return true if hypothesis was published in study
bool IsPublished();

View File

@ -132,7 +132,8 @@ static bool isNodeType (SMESH::array_of_ElementType_var theTypes)
return theTypes->length() > 0 && theTypes[0] == SMESH::NODE;
}
static double getNumericalValue(SMESH::SMESH_IDSource_ptr theSource, SMESH::Controls::NumericalFunctorPtr theFunctor)
static double getNumericalValue(SMESH::SMESH_IDSource_ptr theSource,
SMESH::Controls::NumericalFunctorPtr theFunctor)
{
double value = 0;
@ -142,7 +143,7 @@ static double getNumericalValue(SMESH::SMESH_IDSource_ptr theSource, SMESH::Cont
theFunctor->SetMesh( aMesh );
SMESH::long_array_var anElementsId = theSource->GetIDs();
for (int i = 0; i < anElementsId->length(); i++) {
for ( CORBA::ULong i = 0; i < anElementsId->length(); i++) {
value += theFunctor->GetValue( anElementsId[i] );
}
}

View File

@ -284,7 +284,7 @@ SMESH::point_array*
list<const gp_XYZ *> xyzList;
set<const SMDS_MeshFace*> fset;
for (int i = 0; i < theFacesIDs.length(); i++)
for ( CORBA::ULong i = 0; i < theFacesIDs.length(); i++)
{
CORBA::Long index = theFacesIDs[i];
const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);
@ -345,7 +345,7 @@ SMESH::point_array*
list<const gp_XYZ *> xyzList;
set<const SMDS_MeshVolume*> vset;
for (int i = 0; i < theVolumesIDs.length(); i++)
for ( CORBA::ULong i = 0; i < theVolumesIDs.length(); i++)
{
CORBA::Long index = theVolumesIDs[i];
const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);

View File

@ -899,7 +899,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const
HDFdataset* aDataset = new HDFdataset( (char*) aDSName.c_str(), aGroup );
aDataset->OpenOnDisk();
// read submesh IDs for all elements sorted by ID
int nbElems = aDataset->GetSize();
size_t nbElems = aDataset->GetSize();
int* smIDs = new int [ nbElems ];
aDataset->ReadFromDisk( smIDs );
aDataset->CloseOnDisk();
@ -921,7 +921,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const
}
// add elements to submeshes
TIDSortedElemSet::iterator iE = elemSet.begin();
for ( int i = 0; i < nbElems; ++i, ++iE )
for ( size_t i = 0; i < nbElems; ++i, ++iE )
{
int smID = smIDs[ i ];
if ( smID == 0 ) continue;

View File

@ -95,7 +95,7 @@ typedef list<SMESHDS_SubMesh*> TListOfSubMeshes;
bool getSubMeshes(::SMESH_subMesh* theSubMesh,
TListOfSubMeshes& theSubMeshList)
{
int size = theSubMeshList.size();
size_t size = theSubMeshList.size();
SMESH_Mesh* aMesh = theSubMesh->GetFather();
SMESHDS_Mesh* aMeshDS = aMesh->GetMeshDS();

View File

@ -551,7 +551,7 @@ namespace
allEdges, theShortEdges[ nbBranchPoints > 0 ] ))
return false;
for ( size_t iS = 0; iS < theShortEdges[ nbBranchPoints ].size(); ++iS )
for ( size_t iS = 0; iS < theShortEdges[ nbBranchPoints > 0 ].size(); ++iS )
shortMap.Add( theShortEdges[ nbBranchPoints ][ iS ]);
++nbBranchPoints;

View File

@ -137,7 +137,7 @@ SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
SMESH::double_array_var anArray = new SMESH::double_array;
std::vector<double> params = this->GetImpl()->GetPoints();
anArray->length( params.size() );
for ( CORBA::Long i = 0; i < params.size(); i++)
for ( CORBA::ULong i = 0; i < params.size(); i++)
anArray [ i ] = params [ i ];
return anArray._retn();
@ -158,7 +158,7 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
anArray->length( nbsegs.size() );
for ( CORBA::Long i = 0; i < nbsegs.size(); i++)
for ( CORBA::ULong i = 0; i < nbsegs.size(); i++)
anArray [ i ] = nbsegs [ i ];
return anArray._retn();
@ -252,7 +252,7 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
SMESH::long_array_var anArray = new SMESH::long_array;
std::vector<int> ids = this->GetImpl()->GetReversedEdges();
anArray->length( ids.size() );
for ( CORBA::Long i = 0; i < ids.size(); i++)
for ( CORBA::ULong i = 0; i < ids.size(); i++)
anArray [ i ] = ids [ i ];
return anArray._retn();

View File

@ -91,7 +91,7 @@ void StdMeshers_ImportSource1D_i::SetSourceEdges(const SMESH::ListOfGroups& grou
std::vector<SMESH_Group*> smesh_groups;
std::vector<string> entries;
SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
for ( int i = 0; i < groups.length(); ++i )
for ( CORBA::ULong i = 0; i < groups.length(); ++i )
if ( SMESH_GroupBase_i* gp_i = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i] ))
{
if ( gp_i->GetType() != SMESH::EDGE )
@ -109,7 +109,7 @@ void StdMeshers_ImportSource1D_i::SetSourceEdges(const SMESH::ListOfGroups& grou
_groupEntries = new SMESH::string_array;
_groupEntries->length( entries.size ());
for ( int i = 0; i < entries.size(); ++i )
for ( size_t i = 0; i < entries.size(); ++i )
_groupEntries[i] = entries[i].c_str();
}
catch ( SALOME_Exception& S_ex )
@ -173,7 +173,7 @@ char* StdMeshers_ImportSource1D_i::SaveTo()
os << " " << _groupEntries->length();
SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
for ( int i = 0; i < _groupEntries->length(); ++i )
for ( size_t i = 0; i < _groupEntries->length(); ++i )
{
// entry
os << " " << _groupEntries[i];
@ -208,7 +208,7 @@ void StdMeshers_ImportSource1D_i::LoadFrom( const char* theStream )
_groupEntries = new SMESH::string_array;
_groupEntries->length( nbGroups );
std::string id, entry;
for ( int i = 0; i < _groupEntries->length(); ++i )
for ( size_t i = 0; i < _groupEntries->length(); ++i )
{
if ( is >> entry )
_groupEntries[i] = entry.c_str();

View File

@ -90,7 +90,7 @@ void StdMeshers_ImportSource2D_i::SetSourceFaces(const SMESH::ListOfGroups& grou
std::vector<SMESH_Group*> smesh_groups;
std::vector<string> entries;
SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
for ( int i = 0; i < groups.length(); ++i )
for ( CORBA::ULong i = 0; i < groups.length(); ++i )
if ( SMESH_GroupBase_i* gp_i = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i] ))
{
if ( gp_i->GetType() != SMESH::FACE )
@ -109,7 +109,7 @@ void StdMeshers_ImportSource2D_i::SetSourceFaces(const SMESH::ListOfGroups& grou
_groupEntries = new SMESH::string_array;
_groupEntries->length( entries.size ());
for ( int i = 0; i < entries.size(); ++i )
for ( size_t i = 0; i < entries.size(); ++i )
_groupEntries[i] = entries[i].c_str();
}
catch ( SALOME_Exception& S_ex )
@ -173,7 +173,7 @@ char* StdMeshers_ImportSource2D_i::SaveTo()
os << " " << _groupEntries->length();
SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
for ( int i = 0; i < _groupEntries->length(); ++i )
for ( CORBA::ULong i = 0; i < _groupEntries->length(); ++i )
{
// entry
os << " " << _groupEntries[i];
@ -210,7 +210,7 @@ void StdMeshers_ImportSource2D_i::LoadFrom( const char* theStream )
_groupEntries = new SMESH::string_array;
_groupEntries->length( nbGroups );
std::string id, entry;
for ( int i = 0; i < _groupEntries->length(); ++i )
for ( CORBA::ULong i = 0; i < _groupEntries->length(); ++i )
{
if ( is >> entry )
_groupEntries[i] = entry.c_str();

View File

@ -105,6 +105,16 @@ CORBA::Long StdMeshers_LengthFromEdges_i::GetMode()
return this->GetImpl()->GetMode();
}
//================================================================================
/*!
* \brief Return false as in SALOME the mode is not used
*/
//================================================================================
CORBA::Boolean StdMeshers_LengthFromEdges_i::HasParameters()
{
return false;
}
//=============================================================================
/*!

View File

@ -59,6 +59,9 @@ public:
// Get mode
CORBA::Long GetMode();
// Return false as in SALOME the mode is not used
CORBA::Boolean HasParameters();
// Get implementation
::StdMeshers_LengthFromEdges* GetImpl();