X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshPatternDlg.cxx;h=cfb1f0e649200e04b3d3db5fa9a6ac26b110c357;hp=8456928f772b1cd96094c5d28c172ea1186fbcc9;hb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index 8456928f7..cfb1f0e64 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_MeshPatternDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. @@ -397,7 +398,7 @@ void SMESHGUI_MeshPatternDlg::Init() updateGeometry(); - resize(minimumSize()); + resize(100,100); activateSelection(); onSelectionDone(); @@ -420,10 +421,10 @@ bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) ok = myNode2->isValid( msg, theMess ) && ok; if( !ok ) { if( theMess ) { - QString str( tr( "SMESH_INCORRECT_INPUT" ) ); - if ( !msg.isEmpty() ) - str += "\n" + msg; - SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); } return false; } @@ -432,22 +433,22 @@ bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) QList ids; if ((isRefine() && (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 || - myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true)))) + (myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true))))) || (!isRefine() && (myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() || - myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil()))) + myGeomObj[ Vertex1 ]->_is_nil() || (myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil())))) { if (theMess) SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"), - tr("SMESHGUI_INVALID_PARAMETERS")); + tr("SMESHGUI_INVALID_PARAMETERS")); return false; } if ( myName->text().isEmpty() ) { if (theMess) SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"), - tr("SMESHGUI_INVALID_PARAMETERS")); + tr("SMESHGUI_INVALID_PARAMETERS")); return false; } @@ -467,22 +468,23 @@ bool SMESHGUI_MeshPatternDlg::onApply() erasePreview(); if (isRefine()) { // Refining existing mesh elements + { + QStringList aParameters; + aParameters << myNode1->text(); + if(myType == Type_3d ) + aParameters << myNode2->text(); + myMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); + } QList ids; getIds(ids); SMESH::long_array_var varIds = new SMESH::long_array(); varIds->length(ids.count()); int i = 0; for (QList::iterator it = ids.begin(); it != ids.end(); ++it) - varIds[i++] = *it; + varIds[i++] = *it; myType == Type_2d - ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) - : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); - - QStringList aParameters; - aParameters << myNode1->text(); - if(myType == Type_3d ) - aParameters << myNode2->text(); - myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) + : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); } else { // Applying a pattern to geometrical object if (myType == Type_2d) @@ -497,18 +499,19 @@ bool SMESHGUI_MeshPatternDlg::onApply() //mySelectionMgr->clearSelected(); bool autoUpdate = SMESHGUI::automaticUpdate(); if (!isRefine() && autoUpdate) { - _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); - SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str()); - if (!anActor) { - anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str()); - if (anActor) { - SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor); - SMESH::FitAll(); - } - } + _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); + SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str()); + if (!anActor) { + anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str()); + if (anActor) { + SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor); + SMESH::FitAll(); + } + } } mySelectionMgr->clearSelected(); SMESH::UpdateView(); + SMESHGUI::Modified(); mySMESHGUI->updateObjBrowser(true); @@ -517,7 +520,7 @@ bool SMESHGUI_MeshPatternDlg::onApply() return true; } else { SUIT_MessageBox::information(this, tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED")); + tr("SMESH_OPERATION_FAILED")); return false; } } catch (const SALOME::SALOME_Exception& S_ex) { @@ -565,17 +568,17 @@ void SMESHGUI_MeshPatternDlg::onHelp() if (app) app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); else { - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -593,7 +596,7 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); if (aList.Extent() != 1) - return; + return; // Retrieve mesh from selection Handle(SALOME_InteractiveObject) anIO = aList.First(); @@ -624,11 +627,11 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); if (aList.Extent() != 1) - return; + return; QString anIds; if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds)) - anIds = ""; + anIds = ""; myBusy = true; mySelEdit[ Ids ]->setText(anIds); @@ -638,7 +641,7 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); if (aList.Extent() != 1) - return; + return; // Get geom object from selection Handle(SALOME_InteractiveObject) anIO = aList.First(); @@ -809,14 +812,14 @@ void SMESHGUI_MeshPatternDlg::onOpen() QFile aFile(fName); if (!aFile.open(QIODevice::ReadOnly)) { SUIT_MessageBox::information(this, tr("SMESH_ERROR"), - tr("ERROR_OF_OPENING")); + tr("ERROR_OF_OPENING")); return; } QByteArray aDataArray = aFile.readAll(); if (aDataArray.isEmpty()) { SUIT_MessageBox::information(this, tr("SMESH_ERROR"), - tr("ERROR_OF_READING")); + tr("ERROR_OF_READING")); return; } @@ -1046,11 +1049,11 @@ void SMESHGUI_MeshPatternDlg::updateWgState() if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) { SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); if (keyPoints->length()) { - myNode1->setEnabled(true); - myNode2->setEnabled(true); - myNode1->setRange(1, keyPoints->length()); - myNode2->setRange(1, keyPoints->length()); - return; + myNode1->setEnabled(true); + myNode2->setEnabled(true); + myNode1->setRange(1, keyPoints->length()); + myNode2->setRange(1, keyPoints->length()); + return; } } @@ -1075,13 +1078,13 @@ void SMESHGUI_MeshPatternDlg::activateSelection() if (myType == Type_2d) { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(FaceSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); } else { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(CellSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(CellSelection); } } else { @@ -1123,7 +1126,7 @@ bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName) SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern(); if (!aPattern->LoadFromFile(theName.toLatin1().data()) || - myType == Type_2d && !aPattern->Is2D()) { + (myType == Type_2d && !aPattern->Is2D())) { SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode(); QString aMess; if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS"); @@ -1146,7 +1149,7 @@ bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName) } catch (const SALOME::SALOME_Exception& S_ex) { SalomeApp_Tools::QtCatchCorbaException(S_ex); SUIT_MessageBox::information(this, tr("SMESH_ERROR"), - tr("ERROR_OF_LOADING") ); + tr("ERROR_OF_LOADING") ); return false; } } @@ -1229,13 +1232,13 @@ vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() varIds->length(ids.count()); int i = 0; for (QList::iterator it = ids.begin(); it != ids.end(); ++it) - varIds[i++] = *it; + varIds[i++] = *it; pnts = myType == Type_2d - ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) - : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); + ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) + : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); } else { pnts = myType == Type_2d - ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked()) + ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked()) : myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]); } @@ -1380,7 +1383,7 @@ void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText) for (int i = 0; i < aListId.count(); i++) { const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume)) - newIndices.Add(e->GetID()); + newIndices.Add(e->GetID()); } mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))