QString getShapeEntry() const { return myShapeEntry; }
void setShapeEntry( const QString& theEntry );
+ QString getMainShapeEntry() const { return myMainShapeEntry; }
+ void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; }
+
signals:
void finished( int );
bool myIsCreate;
QtxDialog* myDlg;
QString myShapeEntry;
+ QString myMainShapeEntry;
};
class SMESHGUI_HypothesisDlg : public QtxDialog
removeCustomFilters(); // Issue 0020170
// Get Entry of the Geom object
+ QString aGeomEntry = "";
+ QString aMeshEntry = "";
QString anObjEntry = "";
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- if ( anObjEntry == "" ) {
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- if ( anObjEntry != "" ) {
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
- anObjEntry = ( aGeomVar->_is_nil() ) ? "" : anObjEntry = aGeomVar->GetStudyEntry();
- }
+ aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+
+ if ( aMeshEntry != "" ) { // Get Geom object from Mesh
+ _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
+ }
+
+ if ( aMeshEntry == "" && aGeomEntry == "" ) {
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ aGeomEntry = aGeomVar->GetStudyEntry();
}
- aCreator->setShapeEntry( anObjEntry );
+ if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( pObj ) {
+ // if current object is sub-mesh
+ SMESH::SMESH_subMesh_var aSubMeshVar =
+ SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+ if ( !aSubMeshVar->_is_nil() ) {
+ SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
+ if ( !aMeshVar->_is_nil() ) {
+ _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
+ aMeshEntry = aGeomVar->GetStudyEntry();
+ }
+ }
+ }
+ }
+
+ aCreator->setShapeEntry( aGeomEntry );
+ if ( aMeshEntry != "" )
+ aCreator->setMainShapeEntry( aMeshEntry );
myDlg->setEnabled( false );
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true;
aCreator->setInitParamsHypothesis( initParamHyp );
// Get Entry of the Geom object
+ QString aGeomEntry = "";
+ QString aMeshEntry = "";
QString anObjEntry = "";
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- if ( anObjEntry == "" ) {
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- if ( anObjEntry != "" ) {
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
- GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
- anObjEntry = aGeomVar->GetStudyEntry();
+ aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+
+ if ( aMeshEntry != "" ) { // Get Geom object from Mesh
+ _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
+ }
+
+ if ( aMeshEntry == "" && aGeomEntry == "" ) {
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
+ aGeomEntry = aGeomVar->GetStudyEntry();
+ }
+
+ if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) { // take geometry from submesh
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( pObj ) {
+ // if current object is sub-mesh
+ SMESH::SMESH_subMesh_var aSubMeshVar =
+ SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+ if ( !aSubMeshVar->_is_nil() ) {
+ SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
+ if ( !aMeshVar->_is_nil() ) {
+ _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
+ GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
+ aMeshEntry = aGeomVar->GetStudyEntry();
+ }
+ }
}
}
- aCreator->setShapeEntry( anObjEntry );
+ aCreator->setShapeEntry( aGeomEntry );
+ if ( aMeshEntry != "" )
+ aCreator->setMainShapeEntry( aMeshEntry );
removeCustomFilters(); // Issue 0020170
myDlg->setEnabled( false );
aCreator->edit( aHyp.in(), aHypItem.second, dlg(), this, SLOT( onHypoEdited( int ) ) );
row++;
// 8) reverce edge parameters
- myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERCE_EDGES" ), fr);
+ myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERSED_EDGES" ), fr);
QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox );
myDirectionWidget = new StdMeshersGUI_SubShapeSelectorWdg();
- QString anEntry = getShapeEntry();
- if ( anEntry == "" )
- anEntry = h->GetObjectEntry();
- myDirectionWidget->SetMainShapeEntry( anEntry );
+ QString aGeomEntry = getShapeEntry();
+ QString aMainEntry = getMainShapeEntry();
+ if ( aGeomEntry == "" )
+ aGeomEntry = h->GetObjectEntry();
+ myDirectionWidget->SetGeomShapeEntry( aGeomEntry );
+ myDirectionWidget->SetMainShapeEntry( aMainEntry );
myDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
edgeLay->addWidget( myDirectionWidget );
h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
if (w) {
h->SetReversedEdges( w->GetListOfIDs() );
- const char * entry = w->GetMainShapeEntry();
- h->SetObjectEntry( entry );
+ h->SetObjectEntry( w->GetMainShapeEntry() );
}
}
else if( hypType()=="FixedPoints1D" )
}
if (w2) {
h->SetReversedEdges( w2->GetListOfIDs() );
- const char * entry = w2->GetMainShapeEntry();
- h->SetObjectEntry( entry );
+ h->SetObjectEntry( w2->GetMainShapeEntry() );
}
}
else if( hypType()=="MaxElementArea" )
StdMeshersGUI_SubShapeSelectorWdg* w =
widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
if (w) {
- if( w->GetListOfIDs()->length()>0 ) {
- h->SetTriaVertex( w->GetListOfIDs()[0] );
+ if( int id = w->GetListOfIDs()[0] ) {
+ h->SetTriaVertex( id );
}
const char * entry = w->GetMainShapeEntry();
h->SetObjectEntry( entry );
StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
new StdMeshersGUI_SubShapeSelectorWdg();
- QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
- if ( anEntry == "" )
- anEntry = h->GetObjectEntry();
- aDirectionWidget->SetMainShapeEntry( anEntry );
+ QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+ QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
+ if ( aGeomEntry == "" )
+ aGeomEntry = h->GetObjectEntry();
+
+ aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
+ aDirectionWidget->SetMainShapeEntry( aMainEntry );
aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
aDirectionWidget->showPreview( true );
customWidgets()->append ( aDirectionWidget );
StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
new StdMeshersGUI_SubShapeSelectorWdg();
QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+ QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
if ( anEntry == "" )
anEntry = h->GetObjectEntry();
- aDirectionWidget->SetMainShapeEntry( anEntry );
+ aDirectionWidget->SetGeomShapeEntry( anEntry );
+ aDirectionWidget->SetMainShapeEntry( aMainEntry );
aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
aDirectionWidget->showPreview( true );
customWidgets()->append ( aDirectionWidget );
StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
new StdMeshersGUI_SubShapeSelectorWdg();
QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+ QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
if ( anEntry == "" )
anEntry = h->GetObjectEntry();
- aDirectionWidget->SetMainShapeEntry( anEntry );
+ aDirectionWidget->SetGeomShapeEntry( anEntry );
+ aDirectionWidget->SetMainShapeEntry( aMainEntry );
aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
- aDirectionWidget->SetMainShapeEntry( h->GetObjectEntry() );
aDirectionWidget->showPreview( true );
customWidgets()->append ( aDirectionWidget );
}
aDirectionWidget->SetMaxSize(1);
aDirectionWidget->SetSubShType(TopAbs_VERTEX);
QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+ QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
if ( anEntry == "" )
anEntry = h->GetObjectEntry();
- aDirectionWidget->SetMainShapeEntry( anEntry );
+ aDirectionWidget->SetGeomShapeEntry( anEntry );
+ aDirectionWidget->SetMainShapeEntry( aMainEntry );
SMESH::long_array_var aVec = new SMESH::long_array;
int vertID = h->GetTriaVertex();
if(vertID>0) {
// Author : Open CASCADE S.A.S. (dmv)
// SMESH includes
//
+
#include "StdMeshersGUI_SubShapeSelectorWdg.h"
// SMESH Includes
void StdMeshersGUI_SubShapeSelectorWdg::init()
{
myParamValue = "";
+ myIsNotCorrected = true; // to dont call the GetCorrectedValue method twice
myListOfIDs.clear();
mySelectedIDs.clear();
// function : setGeomShape
// purpose : Called to set geometry
//================================================================================
-void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
+void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEntry )
{
if ( theEntry != "") {
myParamValue = theEntry;
myEntry = theEntry;
- myMainShape = GetTopoDSByEntry( theEntry );
+ myGeomShape = GetTopoDSByEntry( theEntry );
updateState();
+ myIsNotCorrected = true;
}
}
void StdMeshersGUI_SubShapeSelectorWdg::updateState()
{
bool state = false;
- if ( !myMainShape.IsNull() )
+ if ( !myGeomShape.IsNull() )
state = true;
myListWidget->setEnabled( state );
if (state) {
myPreviewActor = new SMESH_PreviewActorsCollection();
myPreviewActor->SetSelector( mySelector );
- //myPreviewActor->Init( myMainShape, TopAbs_EDGE, myEntry );
- myPreviewActor->Init( myMainShape, mySubShType, myEntry );
+ myPreviewActor->Init( myGeomShape, mySubShType, myEntry );
myPreviewActor->SetShown( false );
myIsShown = false;
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
SMESH::long_array_var StdMeshersGUI_SubShapeSelectorWdg::GetListOfIDs()
{
SMESH::long_array_var anArray = new SMESH::long_array;
+
+ if ( myMainEntry != "" && myIsNotCorrected )
+ myListOfIDs = GetCorrectedListOfIDs( true );
+
int size = myListOfIDs.size();
anArray->length( size );
if ( size ) {
int size = theIds->length();
for ( int i = 0; i < size; i++ )
mySelectedIDs.append( theIds[ i ] );
+
+ mySelectedIDs = GetCorrectedListOfIDs( false );
onAdd();
}
+//=================================================================================
+// function : SetMainShapeEntry
+// purpose : Called to set the Main Object Entry
+//=================================================================================
+void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
+{
+ myMainEntry = theEntry;
+ myMainShape = GetTopoDSByEntry( theEntry );
+ myIsNotCorrected = true;
+}
+
+//=================================================================================
+// function : GetMainShapeEntry
+// purpose : Called to get the Main Object Entry
+//=================================================================================
+const char* StdMeshersGUI_SubShapeSelectorWdg::GetMainShapeEntry()
+{
+ if ( myMainEntry == "")
+ return myEntry.toLatin1().data();
+
+ return myMainEntry.toLatin1().data();
+}
+
+//=================================================================================
+// function : GetCorrectedListOfIds
+// purpose : Called to convert the list of IDs from subshape IDs to main shape IDs
+//=================================================================================
+QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape )
+{
+ if ( myMainShape.IsNull() || myGeomShape.IsNull() )
+ return myListOfIDs;
+
+ QList<int> aList;
+ TopTools_IndexedMapOfShape aGeomMap;
+ TopTools_IndexedMapOfShape aMainMap;
+ TopExp::MapShapes(myGeomShape, aGeomMap);
+ TopExp::MapShapes(myMainShape, aMainMap);
+
+ if ( fromSubshapeToMainshape ) { // convert indexes from subshape to mainshape
+ int size = myListOfIDs.size();
+ for (int i = 0; i < size; i++) {
+ TopoDS_Shape aSubShape = aGeomMap.FindKey( myListOfIDs.at(i) );
+ int index = aMainMap.FindIndex( aSubShape );
+ aList.append( index );
+ }
+ myIsNotCorrected = false;
+ } else { // convert indexes from main shape to subshape
+ int size = mySelectedIDs.size();
+ for (int i = 0; i < size; i++) {
+ TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
+ int index = aGeomMap.FindIndex( aSubShape );
+ aList.append( index );
+ }
+ }
+
+ return aList;
+}
SMESH::long_array_var GetListOfIDs();
void SetListOfIDs( SMESH::long_array_var );
+ void SetGeomShapeEntry( const QString& theEntry );
+ const char* GetGeomShapeEntry() { return myEntry.toLatin1().data();}
+
void SetMainShapeEntry( const QString& theEntry );
- const char* GetMainShapeEntry() { return myEntry.toLatin1().data();}
+ const char* GetMainShapeEntry();
+ TopoDS_Shape GetGeomShape() { return myGeomShape; }
TopoDS_Shape GetMainShape() { return myMainShape; }
+ QList<int> GetCorrectedListOfIDs( bool fromSubshapeToMainshape = true );
+
static GEOM::GEOM_Object_var GetGeomObjectByEntry( const QString& );
static TopoDS_Shape GetTopoDSByEntry( const QString& );
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SVTK_Selector* mySelector;
SMESH::SMESH_Mesh_var myMesh;
+ TopoDS_Shape myGeomShape;
TopoDS_Shape myMainShape;
QString myEntry;
+ QString myMainEntry;
vtkRenderer* myRenderer;
QListWidget* myListWidget;
QString myParamValue;
bool myIsShown;
+ bool myIsNotCorrected;
// for manage possible size of myListOfIDs
int myMaxSize;