-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 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, or (at your option) any later version.
//
-// 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.
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
-#include <VTKViewer_CellLocationsArray.h>
+//#include <VTKViewer_CellLocationsArray.h>
// SALOME KERNEL includes
#include <SALOMEDS_SObject.hxx>
aDlgLay->setMargin( MARGIN );
aDlgLay->setSpacing( SPACING );
- QWidget* aMainFrame = createMainFrame ( this );
+ myMainFrame = createMainFrame ( this );
QWidget* aBtnFrame = createButtonFrame( this );
- aDlgLay->addWidget( aMainFrame );
+ aDlgLay->addWidget( myMainFrame );
aDlgLay->addWidget( aBtnFrame );
- aDlgLay->setStretchFactor( aMainFrame, 1 );
+ aDlgLay->setStretchFactor( myMainFrame, 1 );
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
- myHelpFileName = "pattern_mapping_page.html";
+ myHelpFileName = "pattern_mapping.html";
Init();
}
aLay->addWidget(myHelpBtn);
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
- connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
+ connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject()));
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
// selection and SMESHGUI
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
- connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
+ connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT( onOpenView()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT( onCloseView()));
myTypeGrp->button(Type_2d)->setChecked(true);
onTypeChanged(Type_2d);
updateGeometry();
- resize(minimumSize());
+ resize(100,100);
activateSelection();
onSelectionDone();
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;
}
QList<int> 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;
}
erasePreview();
if (isRefine()) { // Refining existing mesh elements
+ {
+ QStringList aParameters;
+ aParameters << myNode1->text();
+ if(myType == Type_3d )
+ aParameters << myNode2->text();
+ myMesh->SetParameters( aParameters.join(":").toUtf8().constData() );
+ }
QList<int> ids;
getIds(ids);
- SMESH::long_array_var varIds = new SMESH::long_array();
+ SMESH::smIdType_array_var varIds = new SMESH::smIdType_array();
varIds->length(ids.count());
- int i = 0;
+ CORBA::ULong i = 0;
for (QList<int>::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)
//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->GetID().c_str());
+ if (anActor) {
+ SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
+ SMESH::FitAll();
+ }
+ }
}
mySelectionMgr->clearSelected();
SMESH::UpdateView();
+ SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
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) {
void SMESHGUI_MeshPatternDlg::onOk()
{
if (onApply())
- onClose();
+ reject();
}
//=======================================================================
-// name : SMESHGUI_MeshPatternDlg::onClose
+// name : SMESHGUI_MeshPatternDlg::reject
// Purpose : SLOT called when "Close" button pressed. Close dialog
//=======================================================================
-void SMESHGUI_MeshPatternDlg::onClose()
+void SMESHGUI_MeshPatternDlg::reject()
{
mySelectionMgr->clearFilters();
+ mySelInput = Mesh;
SMESH::SetPickable();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
disconnect(mySMESHGUI, 0, this, 0);
mySMESHGUI->ResetState();
erasePreview();
- reject();
+ QDialog::reject();
+}
+
+//=================================================================================
+// function : onOpenView()
+// purpose :
+//=================================================================================
+void SMESHGUI_MeshPatternDlg::onOpenView()
+{
+ if(!mySelector) {
+ mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ setEnabled(true);
+ activateSelection();
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+ }
}
+//=================================================================================
+// function : onCloseView()
+// purpose :
+//=================================================================================
+void SMESHGUI_MeshPatternDlg::onCloseView()
+{
+ onDeactivate();
+ mySelector = 0;
+}
+
+
//=================================================================================
// function : onHelp()
// purpose :
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));
}
}
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();
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);
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();
//=======================================================================
// name : SMESHGUI_MeshPatternDlg::onDeactivate
-// Purpose : SLOT called when dialog must be deativated
+// Purpose : SLOT called when dialog must be deactivated
//=======================================================================
void SMESHGUI_MeshPatternDlg::onDeactivate()
{
if (myIsCreateDlgOpen)
return;
- if (myReverseChk->isChecked())
+ if (myReverseChk->isChecked()) {
+ SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+ if ( aViewWindow && !mySelector) {
+ mySelector = aViewWindow->GetSelector();
+ }
displayPreview();
+ }
mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true);
activateSelection();
onTextChanged(mySelEdit[Ids]->text());
}
-//=======================================================================
-// name : SMESHGUI_MeshPatternDlg::closeEvent
-// Purpose :
-//=======================================================================
-void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*)
-{
- onClose();
-}
-
//=======================================================================
// name : SMESHGUI_MeshPatternDlg::onSelInputChanged
// Purpose : SLOT. Called when -> button clicked.
SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true);
aDlg->setWindowTitle(tr("LOAD_PATTERN"));
aDlg->setFileMode(QFileDialog::ExistingFile);
- aDlg->setFilters(prepareFilters());
+ aDlg->setNameFilters(prepareFilters());
if (!myName->text().isEmpty())
aDlg->selectFile(myName->text() + ".smp");
- QPushButton* anOkBtn = qFindChild<QPushButton*>( aDlg, "OK" );
+ QPushButton* anOkBtn = aDlg->findChild<QPushButton*>( "OK" );
if (anOkBtn != 0)
anOkBtn->setText(tr("SMESH_BUT_OK"));
if (QFileInfo(fName).suffix().isEmpty())
fName = autoExtension(fName);
- fName = QDir::convertSeparators(fName);
+ fName = QDir::toNativeSeparators(fName);
- QString prev = QDir::convertSeparators(myName->text());
+ QString prev = QDir::toNativeSeparators(myName->text());
if (prev == fName)
return;
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;
}
//=======================================================================
// name : SMESHGUI_MeshPatternDlg::onReverse
-// Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
+// Purpose : SLOT. Called when state of "Reverse order..." checkbox changed
// Calculate new points of the mesh to be created. Redisplay preview
//=======================================================================
void SMESHGUI_MeshPatternDlg::onReverse (bool)
// Create and display actor
vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
- aMapper->SetInput(aGrid);
+ aMapper->SetInputData(aGrid);
myPreviewActor = SALOME_Actor::New();
myPreviewActor->PickableOff();
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;
}
}
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 {
try {
SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
- if (!aPattern->LoadFromFile(theName.toLatin1().data()) ||
- myType == Type_2d && !aPattern->Is2D()) {
+ if (!aPattern->LoadFromFile(theName.toUtf8().data()) ||
+ (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");
} 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;
}
}
myNode2Lbl->show();
myNode2 ->show();
}
-
mySelInput = Mesh;
activateSelection();
updateWgState();
displayPreview();
+ myPicture2d->hide();
+ myPicture2d->show();
+ myPicture2d->resize(minimumSizeHint());
+ myMainFrame->hide();
+ myMainFrame->show();
+ resize(minimumSizeHint());
}
//=======================================================================
SMESH::point_array_var pnts;
QList<int> ids;
if (isRefine() && getIds(ids)) {
- SMESH::long_array_var varIds = new SMESH::long_array();
+ SMESH::smIdType_array_var varIds = new SMESH::smIdType_array();
varIds->length(ids.count());
- int i = 0;
+ CORBA::ULong i = 0;
for (QList<int>::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 ]);
}
for (int i = 0, n = elemPoints->length(); i < n; i++)
aCellsSize += elemPoints[ i ].length();
- // Create unstructured grid and other usefull arrays
+ // Create unstructured grid and other useful arrays
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
vtkCellArray* aConnectivity = vtkCellArray::New();
else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL);
}
- VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
+ vtkIdTypeArray* aCellLocationsArray = vtkIdTypeArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbCells);
aConnectivity->InitTraversal();
- for (vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
+ vtkIdType const *pts(nullptr);
+ for (vtkIdType idType = 0, npts; aConnectivity->GetNextCell(npts, pts); idType++)
aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
aGrid->SetPoints(aPoints);
{
on ? myRefineGrp->show() : myRefineGrp->hide();
on ? myGeomGrp->hide() : myGeomGrp->show();
-
+ myMainFrame->hide();
+ myMainFrame->show();
displayPreview();
+ resize(minimumSizeHint());
}
//=======================================================================
activateSelection();
}
- // hilight entered elements/nodes
+ // highlight entered elements/nodes
SMDS_Mesh* aMesh = 0;
SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
if (anActor)
if (aMesh) {
QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
- TColStd_MapOfInteger newIndices;
+ SVTK_TVtkIDsMap newIndices;
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 ))