Salome HOME
PR: synchro V7_main tag mergefrom_V6_main_06Mar13
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshPatternDlg.cxx
index 2f3a7a2350c2b2fd7e8f1178a1c9c7a9fdc0bc05..a61175651a9172c7a9e45d7abb2d9b2d56578714 100755 (executable)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  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
@@ -352,7 +352,7 @@ QWidget* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent)
   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()));
 
@@ -390,7 +390,7 @@ void SMESHGUI_MeshPatternDlg::Init()
   // 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()));
 
   myTypeGrp->button(Type_2d)->setChecked(true);
   onTypeChanged(Type_2d);
@@ -433,11 +433,11 @@ bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
   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"),
@@ -468,6 +468,13 @@ 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<int> ids;
       getIds(ids);
       SMESH::long_array_var varIds = new SMESH::long_array();
@@ -479,12 +486,6 @@ bool SMESHGUI_MeshPatternDlg::onApply()
         ? 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( aParameters.join(":").toLatin1().constData() );
-
     } else { // Applying a pattern to geometrical object
       if (myType == Type_2d)
         myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
@@ -537,14 +538,14 @@ bool SMESHGUI_MeshPatternDlg::onApply()
 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();
   SMESH::SetPickable();
@@ -554,7 +555,7 @@ void SMESHGUI_MeshPatternDlg::onClose()
   disconnect(mySMESHGUI, 0, this, 0);
   mySMESHGUI->ResetState();
   erasePreview();
-  reject();
+  QDialog::reject();
 }
 
 //=================================================================================
@@ -723,15 +724,6 @@ void SMESHGUI_MeshPatternDlg::enterEvent (QEvent*)
   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.
@@ -956,7 +948,7 @@ void SMESHGUI_MeshPatternDlg::displayPreview()
 
     // Create and display actor
     vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
-    aMapper->SetInput(aGrid);
+    aMapper->SetInputData(aGrid);
 
     myPreviewActor = SALOME_Actor::New();
     myPreviewActor->PickableOff();
@@ -1125,7 +1117,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");