untabify and

-#ifdef WITHGENERICOBJ
This commit is contained in:
eap 2013-05-30 14:20:52 +00:00
parent 036be279a4
commit f72c766475

View File

@ -103,9 +103,6 @@ private:
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================= //=================================================================================
// class : SMESHGUI_TranslationDlg() // class : SMESHGUI_TranslationDlg()
@ -509,84 +506,80 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
switch ( actionButton ) { switch ( actionButton ) {
case MOVE_ELEMS_BUTTON: case MOVE_ELEMS_BUTTON:
if(CheckBoxMesh->isChecked()) if(CheckBoxMesh->isChecked())
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
aMeshEditor->TranslateObject(myObjects[i], aVector, false); aMeshEditor->TranslateObject(myObjects[i], aVector, false);
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
aMeshEditor->Translate(anElementsId, aVector, false); aMeshEditor->Translate(anElementsId, aVector, false);
} }
break; break;
case COPY_ELEMS_BUTTON: case COPY_ELEMS_BUTTON:
if ( makeGroups ) { if ( makeGroups ) {
SMESH::ListOfGroups_var groups; SMESH::ListOfGroups_var groups;
if(CheckBoxMesh->isChecked()) { if(CheckBoxMesh->isChecked()) {
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
groups = aMeshEditor->TranslateObjectMakeGroups(myObjects[i],aVector); groups = aMeshEditor->TranslateObjectMakeGroups(myObjects[i],aVector);
} }
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector); groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
} }
} }
else { else {
if(CheckBoxMesh->isChecked()) { if(CheckBoxMesh->isChecked()) {
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
aMeshEditor->TranslateObject(myObjects[i], aVector, true); aMeshEditor->TranslateObject(myObjects[i], aVector, true);
} }
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
aMeshEditor->Translate(anElementsId, aVector, true); aMeshEditor->Translate(anElementsId, aVector, true);
} }
} }
break; break;
case MAKE_MESH_BUTTON: { case MAKE_MESH_BUTTON: {
SMESH::SMESH_Mesh_var mesh; SMESH::SMESH_Mesh_var mesh;
if (CheckBoxMesh->isChecked()) { if (CheckBoxMesh->isChecked()) {
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) ); QString aName = SMESH::UniqueMeshName( LineEditNewMesh->text().replace( "*", myObjectsNames[i] ) );
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditor();
myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData()); myMeshes[i]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->TranslateObjectMakeMesh(myObjects[i], aVector, makeGroups, mesh = aMeshEditor->TranslateObjectMakeMesh(myObjects[i], aVector, makeGroups,
aName.toLatin1().data()); aName.toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ // obj has been published in study. Its refcount has been incremented.
// obj has been published in study. Its refcount has been incremented. // It is safe to decrement its refcount
// It is safe to decrement its refcount // so that it will be destroyed when the entry in study will be removed
// so that it will be destroyed when the entry in study will be removed mesh->UnRegister();
mesh->UnRegister(); }
#endif }
} else {
} SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
else { myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
myMeshes[0]->SetParameters(aParameters.join( ":" ).toLatin1().constData());
mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented. // obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount // It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed // so that it will be destroyed when the entry in study will be removed
mesh->UnRegister(); mesh->UnRegister();
#endif }
} break;
break;
} }
} }
} catch (...) { } catch (...) {
@ -762,26 +755,26 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument()
Handle(SALOME_InteractiveObject) IO = it.Value(); Handle(SALOME_InteractiveObject) IO = it.Value();
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO ); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
if ( aMesh->_is_nil() ) if ( aMesh->_is_nil() )
return; return;
SMESH_Actor* anActor = SMESH::FindActorByObject( aMesh ); SMESH_Actor* anActor = SMESH::FindActorByObject( aMesh );
if ( !anActor ) if ( !anActor )
anActor = SMESH::FindActorByEntry( IO->getEntry() ); anActor = SMESH::FindActorByEntry( IO->getEntry() );
if ( !anActor && !CheckBoxMesh->isChecked() ) if ( !anActor && !CheckBoxMesh->isChecked() )
return; return;
if ( !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO )->_is_nil() ) { if ( !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO )->_is_nil() ) {
if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) { if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) {
_PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) ); _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) );
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) { if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) {
_PTR(AttributeName) aNameAttr( anAttr ); _PTR(AttributeName) aNameAttr( anAttr );
myObjects << SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO ); myObjects << SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
myObjectsNames << aNameAttr->Value().c_str(); myObjectsNames << aNameAttr->Value().c_str();
myMeshes << aMesh; myMeshes << aMesh;
} }
} }
} }
myActor = anActor; myActor = anActor;
@ -803,7 +796,7 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument()
if (CheckBoxMesh->isChecked()) { if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
if (myMeshes.isEmpty()) if (myMeshes.isEmpty())
return; return;
} else { } else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString); aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString);
myElementsId = aString; myElementsId = aString;
@ -1151,19 +1144,19 @@ void SMESHGUI_TranslationDlg::onDisplaySimulation( bool toDisplayPreview ) {
bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON || bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON ||
ActionGroup->checkedId() == MAKE_MESH_BUTTON ); ActionGroup->checkedId() == MAKE_MESH_BUTTON );
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
QList<SMESH::MeshPreviewStruct_var> aMeshPreviewStruct; QList<SMESH::MeshPreviewStruct_var> aMeshPreviewStruct;
if(CheckBoxMesh->isChecked()) if(CheckBoxMesh->isChecked())
for ( int i = 0; i < myObjects.count(); i++ ) { for ( int i = 0; i < myObjects.count(); i++ ) {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer();
aMeshEditor->TranslateObject(myObjects[i], aVector, copy); aMeshEditor->TranslateObject(myObjects[i], aVector, copy);
aMeshPreviewStruct << aMeshEditor->GetPreviewData(); aMeshPreviewStruct << aMeshEditor->GetPreviewData();
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
aMeshEditor->Translate(anElementsId, aVector, copy); aMeshEditor->Translate(anElementsId, aVector, copy);
aMeshPreviewStruct << aMeshEditor->GetPreviewData(); aMeshPreviewStruct << aMeshEditor->GetPreviewData();
} }
setSimulationPreview( aMeshPreviewStruct ); setSimulationPreview( aMeshPreviewStruct );
} catch (...) { } catch (...) {
} }