Salome HOME
*** empty log message ***
authorasl <asl@opencascade.com>
Wed, 13 Jul 2005 09:35:55 +0000 (09:35 +0000)
committerasl <asl@opencascade.com>
Wed, 13 Jul 2005 09:35:55 +0000 (09:35 +0000)
25 files changed:
src/SMESHGUI/Makefile.in
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h
src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_AddMeshElementOp.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx
src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h
src/SMESHGUI/SMESHGUI_AddSubMeshOp.cxx
src/SMESHGUI/SMESHGUI_AddSubMeshOp.h
src/SMESHGUI/SMESHGUI_Dialog.cxx
src/SMESHGUI/SMESHGUI_Dialog.h
src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx
src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h
src/SMESHGUI/SMESHGUI_EditHypothesesOp.cxx
src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx
src/SMESHGUI/SMESHGUI_GroupOpDlg.h
src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx
src/SMESHGUI/SMESHGUI_InitMeshDlg.h
src/SMESHGUI/SMESHGUI_InitMeshOp.cxx
src/SMESHGUI/SMESHGUI_InitMeshOp.h
src/SMESHGUI/SMESHGUI_NodesDlg.cxx
src/SMESHGUI/SMESHGUI_NodesDlg.h
src/SMESHGUI/SMESHGUI_NodesOp.cxx
src/SMESHGUI/SMESHGUI_NodesOp.h

index b587937df98835cc85e0e84e85e9018cdd399ad6..fe959bda12ab626109fc71f45204833d327bfcf5 100644 (file)
@@ -60,6 +60,8 @@ LIB_SRC =     SMESHGUI.cxx \
                SMESHGUI_SpinBox.cxx \
                SMESHGUI_NodesDlg.cxx \
                SMESHGUI_NodesOp.cxx \
+               SMESHGUI_AddMeshElementDlg.cxx \
+               SMESHGUI_AddMeshElementOp.cxx \
                SMESHGUI_InitMeshDlg.cxx \
                SMESHGUI_InitMeshOp.cxx \
                SMESHGUI_AddSubMeshDlg.cxx \
@@ -77,7 +79,6 @@ LIB_SRC =     SMESHGUI.cxx \
                SMESHGUI_aParameterDlg.cxx \
                SMESHGUI_Swig.cxx \
                SMESHGUI_MoveNodesDlg.cxx \
-               SMESHGUI_AddMeshElementDlg.cxx \
                SMESHGUI_EditHypothesesDlg.cxx \
                SMESHGUI_EditHypothesesOp.cxx \
                SMESHGUI_CreateHypothesesDlg.cxx \
@@ -123,6 +124,8 @@ LIB_MOC = \
                SMESHGUI_CreatePatternDlg.h \
                SMESHGUI_NodesDlg.h \
                SMESHGUI_NodesOp.h \
+               SMESHGUI_AddMeshElementDlg.h \
+               SMESHGUI_AddMeshElementOp.h \
                SMESHGUI_SpinBox.h \
                SMESHGUI_InitMeshDlg.h \
                SMESHGUI_InitMeshOp.h \
@@ -140,7 +143,6 @@ LIB_MOC = \
                SMESHGUI_Preferences_SelectionDlg.h \
                SMESHGUI_aParameterDlg.h \
                SMESHGUI_MoveNodesDlg.h \
-               SMESHGUI_AddMeshElementDlg.h \
                SMESHGUI_EditHypothesesDlg.h \
                SMESHGUI_EditHypothesesOp.h \
                SMESHGUI_CreateHypothesesDlg.h \
index 4f484b085467bd99e8630dde3d1cdd6cb9c920c6..0daf4dd4c25bc2c30433854483a0d89cda0a020c 100644 (file)
@@ -27,7 +27,7 @@
 #include "SMESHGUI.h"
 #include "SMESHGUI_InitMeshOp.h"
 #include "SMESHGUI_AddSubMeshOp.h"
-#include "SMESHGUI_NodesDlg.h"
+#include "SMESHGUI_NodesOp.h"
 #include "SMESHGUI_TransparencyDlg.h"
 #include "SMESHGUI_ClippingDlg.h"
 #include "SMESHGUI_GroupDlg.h"
 #include "SMESHGUI_Hypotheses.h"
 #include "SMESHGUI_HypothesesUtils.h"
 #include "SMESHGUI_MoveNodesDlg.h"
-#include "SMESHGUI_AddMeshElementDlg.h"
-#include "SMESHGUI_EditHypothesesDlg.h"
+#include "SMESHGUI_AddMeshElementOp.h"
+#include "SMESHGUI_EditHypothesesOp.h"
 #include "SMESHGUI_CreateHypothesesDlg.h"
 #include "SMESHGUI_FilterDlg.h"
 #include "SMESHGUI_FilterLibraryDlg.h"
 #include "SMESHGUI_SingleEditDlg.h"
 #include "SMESHGUI_MultiEditDlg.h"
-#include "SMESHGUI_GroupOpDlg.h"
+#include "SMESHGUI_GroupOp.h"
 #include "SMESHGUI_DeleteGroupDlg.h"
 #include "SMESHGUI_SmoothingDlg.h"
 #include "SMESHGUI_RenumberingDlg.h"
@@ -1227,7 +1227,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 400:                                    // NODES
     {
       if(checkLock(aStudy)) break;
-
+      startOperation( 400 );
+/*
       if ( vtkwnd ) {
        EmitSignalDeactivateDialog();
 
@@ -1238,7 +1239,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
                              tr("SMESH_WRN_WARNING"), 
                              tr("SMESH_WRN_VIEWER_VTK"),
                              tr("SMESH_BUT_OK"));
-      }
+      }     */
       break;
     }
 
@@ -1393,24 +1394,21 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 704:                                    // EDIT Hypothesis 
     {
       if(checkLock(aStudy)) break;
-      EmitSignalDeactivateDialog();
-      new SMESHGUI_EditHypothesesDlg( this );
+      startOperation( 704 );
       break;
     }
 
   case 705:                                    //  EDIT Global Hypothesis
     {
       if(checkLock(aStudy)) break;
-      EmitSignalDeactivateDialog();
-      new SMESHGUI_EditHypothesesDlg( this );
+      startOperation( 704 );
       break;
     }
 
   case 706:                                    //  EDIT Local Hypothesis
     {
       if(checkLock(aStudy)) break;
-      EmitSignalDeactivateDialog();
-      new SMESHGUI_EditHypothesesDlg( this );
+      startOperation( 704 );
       break;
     }
 
@@ -1438,9 +1436,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       */
       EmitSignalDeactivateDialog();
       if ( theCommandID == 407 )
-        new SMESHGUI_TrianglesInversionDlg(this);
+        startOperation( 407 );
       else
-        new SMESHGUI_UnionOfTwoTrianglesDlg(this);
+        startOperation( 408 );
       break;
     }
     case 409: // Change orientation
@@ -1694,24 +1692,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     case 811: // Intersect groups
     case 812: // Cut groups
     {
-      if ( !vtkwnd )
-      {
-        SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
-          tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
-        break;
-      }
-
-      if ( checkLock( aStudy ) )
-        break;
-
-      EmitSignalDeactivateDialog();
-
-      int aMode;
-      if      ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
-      else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
-      else                            aMode = SMESHGUI_GroupOpDlg::CUT;
-
-      ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
+      if( !checkLock( aStudy ) )
+        startOperation( theCommandID );
       break;
     }
 
@@ -2003,7 +1985,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 4032:                                   // HEXA
     {
       if(checkLock(aStudy)) break;
-      if ( vtkwnd ) {
+      startOperation( theCommandID );
+/*      if ( vtkwnd ) {
        EmitSignalDeactivateDialog();
         SMDSAbs_ElementType type    = SMDSAbs_Edge;
         int                 nbNodes = 2;
@@ -2028,7 +2011,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
        SUIT_MessageBox::warn1(desktop(),
                              tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
                              tr("SMESH_BUT_OK"));
-      }
+      }*/
       break;
     }
   case 4033:                                   // POLYHEDRON
@@ -3308,7 +3291,35 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
 {
   SalomeApp_Operation* op = 0;
   switch( id )
-  {
+  {     
+    case 400:
+      op = new SMESHGUI_NodesOp();
+      break;
+
+    case 401:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
+      break;
+      
+    case 4021:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
+      break;
+      
+    case 4022:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
+      break;
+      
+    case 4023:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
+      break;
+      
+    case 4031:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
+      break;
+      
+    case 4032:
+      op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
+      break;
+            
     case 702:
       op = new SMESHGUI_AddSubMeshOp();
       break;
@@ -3316,6 +3327,22 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
     case 703:
       op = new SMESHGUI_InitMeshOp();
       break;
+
+    case 704:
+      op = new SMESHGUI_EditHypothesesOp();
+      break;
+
+    case 810:
+      op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
+      break;
+
+    case 811:
+      op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
+      break;
+
+    case 812:
+      op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
+      break;
       
     default:
       op = SalomeApp_Module::createOperation( id );
index bb36d5c0386560a69a3367ccfa2ef27d95267e36..55629dfb7945b94e3e3d2c96bb0082a26426763a 100644 (file)
 //  $Header$
 
 #include "SMESHGUI_AddMeshElementDlg.h"
+#include <SMESHGUI_Operation.h>
 
-#include "SMESHGUI.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_MeshUtils.h"
-#include "SMESHGUI_IdValidator.h"
-#include "SMESH_ActorUtils.h"
+#include <SUIT_ResourceMgr.h>
 
-#include "SMDS_Mesh.hxx"
-#include "SMESH_Actor.h"
+#include <SMDSAbs_ElementType.hxx>
 
-#include "SUIT_Session.h"
-
-#include "SVTK_Selection.h"
-#include "SVTK_Selector.h"
-#include "SALOME_ListIO.hxx"
-#include "SALOME_ListIteratorOfListIO.hxx"
-
-#include "SalomeApp_Study.h"
-#include "SalomeApp_Application.h"
-
-#include "SVTK_ViewModel.h"
-#include "SVTK_ViewWindow.h"
-
-#include "utilities.h"
-
-// OCCT Includes
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
-
-// VTK Includes
-#include <vtkCell.h>
-#include <vtkIdList.h>
-#include <vtkIntArray.h>
-#include <vtkCellArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkDataSetMapper.h>
-
-// QT Includes
-#include <qbuttongroup.h>
+#include <qlayout.h>
 #include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
+#include <qbuttongroup.h>
 #include <qradiobutton.h>
-#include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qimage.h>
-#include <qpixmap.h>
 #include <qcheckbox.h>
-#include <qregexp.h>
-
-// STL includes
-#include <list>
-
-using namespace std;
-
-namespace SMESH {
-
-  class TElementSimulation {
-    SalomeApp_Application* myApplication;
-    SUIT_ViewWindow* myViewWindow;
-    SVTK_ViewWindow* myVTKViewWindow;
-
-    SALOME_Actor* myPreviewActor;
-    vtkDataSetMapper* myMapper;
-    vtkUnstructuredGrid* myGrid;
-
-  public:
-    TElementSimulation (SalomeApp_Application* theApplication)
-    {
-      myApplication = theApplication;
-      SUIT_ViewManager* mgr = theApplication->activeViewManager();
-      if (!mgr) return;
-      myViewWindow = mgr->getActiveView();
-      myVTKViewWindow = GetVtkViewWindow(myViewWindow);
-
-      myGrid = vtkUnstructuredGrid::New();
-
-      // Create and display actor
-      myMapper = vtkDataSetMapper::New();
-      myMapper->SetInput(myGrid);
-
-      myPreviewActor = SALOME_Actor::New();
-      myPreviewActor->PickableOff();
-      myPreviewActor->VisibilityOff();
-      myPreviewActor->SetMapper(myMapper);
-
-      float anRGB[3];
-      vtkProperty* aProp = vtkProperty::New();
-      GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
-      aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
-      myPreviewActor->SetProperty( aProp );
-      aProp->Delete();
-
-      vtkProperty* aBackProp = vtkProperty::New();
-      GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
-      aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
-      myPreviewActor->SetBackfaceProperty( aBackProp );
-      aBackProp->Delete();
-
-      myVTKViewWindow->AddActor(myPreviewActor);
-    }
-
-    typedef std::vector<vtkIdType> TVTKIds;
-    void SetPosition (SMESH_Actor* theActor,
-                      vtkIdType theType,
-                      const TVTKIds& theIds)
-    {
-      vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
-      myGrid->SetPoints(aGrid->GetPoints());
-
-      const int* aConn = NULL;
-      switch (theType) {
-      case VTK_TETRA:
-        {
-          static int anIds[] = {0,2,1,3};
-          aConn = anIds;
-          break;
-        }
-      case VTK_PYRAMID:
-        {
-          static int anIds[] = {0,3,2,1,4};
-          aConn = anIds;
-          break;
-        }
-      case VTK_HEXAHEDRON:
-        {
-          static int anIds[] = {0,3,2,1,4,7,6,5};
-          aConn = anIds;
-          break;
-        }
-      }
-
-      myGrid->Reset();
-      vtkIdList *anIds = vtkIdList::New();
-
-      if(aConn)
-       for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
-         anIds->InsertId(i,theIds[aConn[i]]);
-      else
-       for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
-         anIds->InsertId(i,theIds[i]);
-
-      myGrid->InsertNextCell(theType,anIds);
-      anIds->Delete();
-
-      myGrid->Modified();
-
-      SetVisibility(true);
-    }
-
-
-    void SetVisibility (bool theVisibility)
-    {
-      myPreviewActor->SetVisibility(theVisibility);
-      RepaintCurrentView();
-    }
-
-
-    ~TElementSimulation()
-    {
-      if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
-       myVTKViewWindow->RemoveActor(myPreviewActor);
-      }
-      myPreviewActor->Delete();
-
-      myMapper->RemoveAllInputs();
-      myMapper->Delete();
-
-      myGrid->Delete();
-    }
-  };
-}
 
 //=================================================================================
 // function : SMESHGUI_AddMeshElementDlg()
 // purpose  : constructor
 //=================================================================================
-SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
-                                                       const char* name,
-                                                        SMDSAbs_ElementType ElementType, int nbNodes,
-                                                        bool modal, WFlags fl)
-     : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
-                WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
-     mySMESHGUI( theModule ),
-     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() )
+SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( const QString& elemName, const bool reverse )
+: SMESHGUI_Dialog()
 {
-  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
-    (SUIT_Session::session()->activeApplication());
-  myIsPoly = false;
-  mySimulation = new SMESH::TElementSimulation (anApp);
-
-  // verify nb nodes and type
-  myNbNodes = nbNodes;
-  myElementType = ElementType;
-  switch (ElementType) {
-  case SMDSAbs_Face:
-//     if (myNbNodes != 3 && myNbNodes != 4)
-//       myNbNodes = 3;
-//     break;
-  case SMDSAbs_Volume:
-//     if (myNbNodes != 4 && myNbNodes != 8) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
-//       myNbNodes = 4;
-    break;
-  default:
-    myElementType = SMDSAbs_Edge;
-    myNbNodes = 2;
-  }
-
-  QString elemName;
-  if (myNbNodes == 2)
-    elemName = "EDGE";
-  else if (myNbNodes == 3)
-    elemName = "TRIANGLE";
-  else if (myNbNodes == 4)
-    if (myElementType == SMDSAbs_Face)
-      elemName = "QUADRANGLE";
-    else
-      elemName = "TETRAS";
-  else if (myNbNodes == 8)
-    elemName = "HEXAS";
-  else if (myElementType == SMDSAbs_Face){
-    elemName = "POLYGON";
-    myIsPoly = true;
-  }
-  
   QString iconName      = tr(QString("ICON_DLG_%1").arg(elemName));
   QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName));
   QString caption       = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName));
   QString grBoxTitle    = tr(QString("SMESH_ADD_%1").arg(elemName));
 
-  QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
-  QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
+  QPixmap image0 ( resMgr()->loadPixmap("SMESH", iconName));
+  QPixmap image1 ( resMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
 
-  if (!name)
-    setName("SMESHGUI_AddMeshElementDlg");
+  setName("SMESHGUI_AddMeshElementDlg");
   resize(303, 185);
   setCaption(caption);
 
   setSizeGripEnabled(TRUE);
-  SMESHGUI_AddMeshElementDlgLayout = new QGridLayout(this);
-  SMESHGUI_AddMeshElementDlgLayout->setSpacing(6);
-  SMESHGUI_AddMeshElementDlgLayout->setMargin(11);
+  QVBoxLayout* main = new QVBoxLayout( mainFrame() );
 
   /***************************************************************/
-  GroupConstructors = new QButtonGroup(this, "GroupConstructors");
+  QButtonGroup* GroupConstructors = new QButtonGroup(mainFrame(), "GroupConstructors");
   GroupConstructors->setTitle(buttonGrTitle);
 
   GroupConstructors->setExclusive(TRUE);
   GroupConstructors->setColumnLayout(0, Qt::Vertical);
   GroupConstructors->layout()->setSpacing(0);
   GroupConstructors->layout()->setMargin(0);
-  GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
+  QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
   GroupConstructorsLayout->setAlignment(Qt::AlignTop);
   GroupConstructorsLayout->setSpacing(6);
   GroupConstructorsLayout->setMargin(11);
-  Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
+  QRadioButton* Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
   Constructor1->setText(tr("" ));
   Constructor1->setPixmap(image0);
   Constructor1->setChecked(TRUE);
@@ -298,78 +82,32 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
   GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
   QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
   GroupConstructorsLayout->addItem(spacer, 0, 1);
-  SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupConstructors, 0, 0);
+  main->addWidget(GroupConstructors);
 
   /***************************************************************/
-  GroupButtons = new QGroupBox(this, "GroupButtons");
-  GroupButtons->setGeometry(QRect(10, 10, 281, 48));
-  GroupButtons->setTitle(tr("" ));
-  GroupButtons->setColumnLayout(0, Qt::Vertical);
-  GroupButtons->layout()->setSpacing(0);
-  GroupButtons->layout()->setMargin(0);
-  GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
-  GroupButtonsLayout->setAlignment(Qt::AlignTop);
-  GroupButtonsLayout->setSpacing(6);
-  GroupButtonsLayout->setMargin(11);
-  buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
-  buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
-  buttonCancel->setAutoDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
-  buttonApply = new QPushButton(GroupButtons, "buttonApply");
-  buttonApply->setText(tr("SMESH_BUT_APPLY" ));
-  buttonApply->setAutoDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonApply, 0, 1);
-  QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-  GroupButtonsLayout->addItem(spacer_9, 0, 2);
-  buttonOk = new QPushButton(GroupButtons, "buttonOk");
-  buttonOk->setText(tr("SMESH_BUT_OK" ));
-  buttonOk->setAutoDefault(TRUE);
-  buttonOk->setDefault(TRUE);
-  GroupButtonsLayout->addWidget(buttonOk, 0, 0);
-  SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0);
-
-  /***************************************************************/
-  GroupC1 = new QGroupBox(this, "GroupC1");
+  QGroupBox* GroupC1 = new QGroupBox( mainFrame(), "GroupC1");
   GroupC1->setTitle(grBoxTitle);
 
   GroupC1->setMinimumSize(QSize(0, 0));
   GroupC1->setFrameShape(QGroupBox::Box);
   GroupC1->setFrameShadow(QGroupBox::Sunken);
-  GroupC1->setColumnLayout(0, Qt::Vertical);
-  GroupC1->layout()->setSpacing(0);
-  GroupC1->layout()->setMargin(0);
-  GroupC1Layout = new QGridLayout(GroupC1->layout());
-  GroupC1Layout->setAlignment(Qt::AlignTop);
-  GroupC1Layout->setSpacing(6);
-  GroupC1Layout->setMargin(11);
-  TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1");
-  TextLabelC1A1->setText(tr("SMESH_ID_NODES" ));
-  TextLabelC1A1->setMinimumSize(QSize(50, 0));
-  TextLabelC1A1->setFrameShape(QLabel::NoFrame);
-  TextLabelC1A1->setFrameShadow(QLabel::Plain);
-  GroupC1Layout->addWidget(TextLabelC1A1, 0, 0);
-  SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1");
-  SelectButtonC1A1->setText(tr("" ));
-  SelectButtonC1A1->setPixmap(image1);
-  SelectButtonC1A1->setToggleButton(FALSE);
-  GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1);
-  LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1");
-//  LineEditC1A1->setReadOnly(TRUE);
-  if (!myIsPoly)
-    LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes));
-  GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
+  GroupC1->setColumnLayout(3, Qt::Horizontal);
 
-  if (myElementType == SMDSAbs_Face) {
-    Reverse = new QCheckBox(GroupC1, "Reverse");
-    Reverse->setText(tr("SMESH_REVERSE" ));
-    GroupC1Layout->addWidget(Reverse, 1, 0);
-  }
-  else
-    Reverse = 0;
+  createObject( tr( "SMESH_ID_NODES" ), GroupC1, 0 );
+  setNameIndication( 0, ListOfNames );
+  setReadOnly( 0, false );
+  setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
 
-  SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0);
+  myReverse = 0;
+  if ( reverse ) {
+    myReverse = new QCheckBox(GroupC1, "Reverse");
+    myReverse->setText(tr("SMESH_REVERSE" ));
+  }
 
-  Init(); /* Initialisations */
+  if( myReverse )
+    connect( myReverse, SIGNAL(stateChanged(int)), this, SIGNAL(reverse(int)));
+    
+  main->addWidget(GroupC1);
 }
 
 //=================================================================================
@@ -378,369 +116,25 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
 //=================================================================================
 SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg()
 {
-  // no need to delete child widgets, Qt does it all for us
-  delete mySimulation;
-}
-
-//=================================================================================
-// function : Init()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::Init()
-{
-  GroupC1->show();
-  Constructor1->setChecked(TRUE);
-  myEditCurrentArgument = LineEditC1A1;
-  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
-
-  myNbOkNodes = 0;
-  myActor = 0;
-
-  /* signals and slots connections */
-  connect(buttonOk, SIGNAL(clicked()),     SLOT(ClickOnOk()));
-  connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel()));
-  connect(buttonApply, SIGNAL(clicked()),  SLOT(ClickOnApply()));
-
-  connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument()));
-  connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
-  connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
-  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
-  /* to close dialog if study frame change */
-  connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
-
-  if (Reverse)
-    connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
-
-  // Move widget on the botton right corner of main widget
-  int x, y;
-  mySMESHGUI->DefineDlgPosition(this, x, y);
-  this->move(x, y);
-  this->show(); // displays Dialog
-
-  // set selection mode
-  SMESH::SetPointRepresentation(true);
-
-  myViewWindow->SetSelectionMode( NodeSelection );
-
-  myBusy = false;
-
-  SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : ClickOnApply()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnApply()
-{
-  if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
-    myBusy = true;
-    SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
-    anArrayOfIdeces->length(myNbNodes);
-    bool reverse = (Reverse && Reverse->isChecked());
-    QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
-    for (int i = 0; i < aListId.count(); i++)
-      if (reverse)
-        anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt();
-      else
-        anArrayOfIdeces[i] = aListId[ i ].toInt();
-
-    SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
-    switch (myElementType) {
-    case SMDSAbs_Edge:
-      aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
-    case SMDSAbs_Face:
-      aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
-    case SMDSAbs_Volume:
-      aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
-    default:;
-    }
-
-    SALOME_ListIO aList; aList.Append( myActor->getIO() );
-    mySelectionMgr->setSelectedObjects( aList, false );
-
-    SMESH::UpdateView();
-    mySimulation->SetVisibility(false);
-
-    buttonOk->setEnabled(false);
-    buttonApply->setEnabled(false);
-
-    myEditCurrentArgument->setText("");
-
-    myBusy = false;
-  }
-}
-
-//=================================================================================
-// function : ClickOnOk()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnOk()
-{
-  this->ClickOnApply();
-  this->ClickOnCancel();
-  return;
-}
-
-//=================================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
-{
-  mySelectionMgr->clearSelected();
-  mySimulation->SetVisibility(false);
-  SMESH::SetPointRepresentation(false);
-  myViewWindow->SetSelectionMode( ActorSelection );
-  disconnect(mySelectionMgr, 0, this, 0);
-  mySMESHGUI->ResetState();
-  reject();
-  return;
-}
-
-//=================================================================================
-// function : onTextChange()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText)
-{
-  if (myBusy) return;
-  myBusy = true;
-
-  myNbOkNodes = 0;
-
-  buttonOk->setEnabled(false);
-  buttonApply->setEnabled(false);
-
-  mySimulation->SetVisibility(false);
-
-  // hilight entered nodes
-  SMDS_Mesh* aMesh = 0;
-  if (myActor)
-    aMesh = myActor->GetObject()->GetMesh();
-
-  if (aMesh) {
-    TColStd_MapOfInteger newIndices;
-    
-    QStringList aListId = QStringList::split(" ", theNewText, false);
-    for (int i = 0; i < aListId.count(); i++) {
-      if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
-      {
-       newIndices.Add( n->GetID() );
-       myNbOkNodes++;
-      }
-    }
-    
-    mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
-    myViewWindow->highlight( myActor->getIO(), true, true );
-    
-    bool aNodesOK = false;
-    if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
-      myNbOkNodes = aListId.count();
-      aNodesOK = true;
-    }
-  }
-  
-  if(myNbOkNodes) {
-    buttonOk->setEnabled(true);
-    buttonApply->setEnabled(true);
-    displaySimulation();
-  }
-  
-  myBusy = false;
-}
-
-//=================================================================================
-// function : SelectionIntoArgument()
-// purpose  : Called when selection has changed
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
-{
-  if (myBusy) return;
-
-  // clear
-  myNbOkNodes = 0;
-  myActor = 0;
-
-  myBusy = true;
-  myEditCurrentArgument->setText("");
-  myBusy = false;
-
-  if (!GroupButtons->isEnabled()) // inactive
-    return;
-
-  buttonOk->setEnabled(false);
-  buttonApply->setEnabled(false);
-
-  mySimulation->SetVisibility(false);
-//  SMESH::SetPointRepresentation(true);
-
-  // get selected mesh
-  SALOME_ListIO aList;
-  mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
-
-  if (aList.Extent() != 1)
-    return;
-
-  Handle(SALOME_InteractiveObject) anIO = aList.First();
-  myMesh = SMESH::GetMeshByIO(anIO);
-  if (myMesh->_is_nil())
-    return;
-
-  myActor = SMESH::FindActorByEntry(anIO->getEntry());
-  if (!myActor)
-    return;
-
-  // get selected nodes
-  QString aString = "";
-  int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
-  myBusy = true;
-  myEditCurrentArgument->setText(aString);
-  myBusy = false;
-  if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes >= 3 ) {
-    myNbNodes = nbNodes;
-  } else if (myNbNodes != nbNodes) {
-    return;
-  }
-
-  // OK
-  myNbOkNodes = nbNodes;
-
-  buttonOk->setEnabled(true);
-  buttonApply->setEnabled(true);
-
-  displaySimulation();
-}
-
-//=================================================================================
-// function : displaySimulation()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::displaySimulation()
-{
-  if (myNbOkNodes && GroupButtons->isEnabled()) {
-    SMESH::TElementSimulation::TVTKIds anIds;
-    QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
-    for (int i = 0; i < aListId.count(); i++)
-      anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt()));
-
-    if (Reverse && Reverse->isChecked())
-      reverse(anIds.begin(),anIds.end());
-
-    vtkIdType aType = 0;
-    if (myIsPoly)
-      switch ( myElementType ) {
-      case SMDSAbs_Face  : aType = VTK_POLYGON; break;
-      default: return;
-      }
-    else {
-      switch (myNbNodes) {
-      case 2: aType = VTK_LINE; break;
-      case 3: aType = VTK_TRIANGLE; break;
-      case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
-      case 8: aType = VTK_HEXAHEDRON; break;
-      default: return;
-      }
-    }
-
-    mySimulation->SetPosition(myActor,aType,anIds);
-    SMESH::UpdateView();
-  }
 }
 
 //=================================================================================
-// function : SetEditCurrentArgument()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument()
-{
-  QPushButton* send = (QPushButton*)sender();
-  if (send == SelectButtonC1A1) {
-    LineEditC1A1->setFocus();
-    myEditCurrentArgument = LineEditC1A1;
-  }
-  SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog()
-{
-  if (GroupConstructors->isEnabled()) {
-    GroupConstructors->setEnabled(false);
-    GroupC1->setEnabled(false);
-    GroupButtons->setEnabled(false);
-    mySimulation->SetVisibility(false);
-    mySMESHGUI->ResetState();
-    mySMESHGUI->SetActiveDialogBox(0);
-  }
-}
-
-//=================================================================================
-// function : ActivateThisDialog()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
-{
-  /* Emit a signal to deactivate the active dialog */
-  mySMESHGUI->EmitSignalDeactivateDialog();
-
-  GroupConstructors->setEnabled(true);
-  GroupC1->setEnabled(true);
-  GroupButtons->setEnabled(true);
-
-  SMESH::SetPointRepresentation(true);
-
-  myViewWindow->SetSelectionMode( NodeSelection );
-  SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : enterEvent()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::enterEvent (QEvent*)
-{
-  if (GroupConstructors->isEnabled())
-    return;
-  ActivateThisDialog();
-  return;
-}
-
-//=================================================================================
-// function : closeEvent()
-// purpose  :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::closeEvent (QCloseEvent*)
-{
-  /* same than click on cancel button */
-  this->ClickOnCancel();
-  return;
-}
-
-//=================================================================================
-// function : hideEvent()
-// purpose  : caused by ESC key
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose  : Destroys the object and frees any allocated resources
 //=================================================================================
-void SMESHGUI_AddMeshElementDlg::hideEvent (QHideEvent*)
+bool SMESHGUI_AddMeshElementDlg::isReverse() const
 {
-  if (!isMinimized())
-    ClickOnCancel();
+  if( myReverse )
+    return myReverse->isChecked();
+  else
+    return false;
 }
 
 //=================================================================================
-// function : CheckBox()
-// purpose  :
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose  : Destroys the object and frees any allocated resources
 //=================================================================================
-void SMESHGUI_AddMeshElementDlg::CheckBox (int state)
+void SMESHGUI_AddMeshElementDlg::setBusy( const bool b )
 {
-  if (!myNbOkNodes)
-    return;
-
-  if (state >= 0) {
-    mySimulation->SetVisibility(false);
-    displaySimulation();
-  }
+  myIsBusy = b;
 }
index a04635c304ea6bd48587bea02d0d3ac9032cb487..e4aa5b58b2687880de57cc4b7832ffecffe34a0b 100644 (file)
 #ifndef DIALOGBOX_ADD_FACE_H
 #define DIALOGBOX_ADD_FACE_H
 
-#include "SalomeApp_SelectionMgr.h"
+#include <SMESHGUI_Dialog.h>
 
-#include "SMDSAbs_ElementType.hxx"
-
-
-// QT Includes
-#include <qvariant.h>
-#include <qdialog.h>
-
-class QVBoxLayout; 
-class QHBoxLayout; 
-class QGridLayout; 
-class QButtonGroup;
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QRadioButton;
 class QCheckBox;
-class SMESHGUI;
-class SMESH_Actor;
-class SMDS_Mesh;
-class SVTK_ViewWindow;
-class SVTK_Selector;
-
-namespace SMESH{
-  struct TElementSimulation;
-}
-
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 //=================================================================================
 // class    : SMESHGUI_AddMeshElementDlg
 // purpose  :
 //=================================================================================
-class SMESHGUI_AddMeshElementDlg : public QDialog
+class SMESHGUI_AddMeshElementDlg : public SMESHGUI_Dialog
 { 
     Q_OBJECT
 
 public:
-    SMESHGUI_AddMeshElementDlg( SMESHGUI*,
-                               const char* = 0, 
-                                SMDSAbs_ElementType ElementType = SMDSAbs_Edge,
-                               int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 );
+    SMESHGUI_AddMeshElementDlg( const QString&, const bool );
     ~SMESHGUI_AddMeshElementDlg();
 
-private:
-    void Init ();
-    void closeEvent (QCloseEvent*);
-    void hideEvent (QHideEvent*);                 /* ESC key */
-    void enterEvent (QEvent*);                    /* mouse enter the QWidget */
-    void displaySimulation();
-
-    SMESHGUI*                   mySMESHGUI;              /* Current SMESHGUI object */
-    SalomeApp_SelectionMgr*     mySelectionMgr;          /* User shape selection */
-    int                         myNbOkNodes;               /* to check when arguments is defined */
-    bool                        myBusy;
-    SVTK_ViewWindow*            myViewWindow;
-    SVTK_Selector*              mySelector;
+    bool isReverse() const;
+    void setBusy( const bool );
 
-    QLineEdit*                  myEditCurrentArgument;   /* Current  LineEdit */
+signals:
+    void reverse( int );
 
-    int                         myElementType;
-    int                         myNbNodes;
-    bool                        myIsPoly;
-
-    SMESH::SMESH_Mesh_var       myMesh;
-    SMESH_Actor*                myActor;
-    SMESH::TElementSimulation*  mySimulation;
-    
-    QButtonGroup* GroupConstructors;
-    QRadioButton* Constructor1;
-    QGroupBox   * GroupButtons;
-    QPushButton * buttonOk;
-    QPushButton * buttonCancel;
-    QPushButton * buttonApply;
-    QGroupBox   * GroupC1;
-    QLabel      * TextLabelC1A1;
-    QPushButton * SelectButtonC1A1;
-    QLineEdit   * LineEditC1A1;
-
-    QCheckBox   * Reverse;
-
-private slots:
-
-    void ClickOnOk();
-    void ClickOnCancel();
-    void ClickOnApply();
-    void SetEditCurrentArgument() ;
-    void SelectionIntoArgument() ;
-    void DeactivateActiveDialog() ;
-    void ActivateThisDialog() ;
-    void CheckBox( int );
-    void onTextChange(const QString&);
-
-protected:
-    QGridLayout* SMESHGUI_AddMeshElementDlgLayout;
-    QGridLayout* GroupConstructorsLayout;
-    QGridLayout* GroupButtonsLayout;
-    QGridLayout* GroupC1Layout;
+private:
+  QCheckBox* myReverse;
 };
 
 #endif // DIALOGBOX_ADD_FACE_H
diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx
new file mode 100644 (file)
index 0000000..fee223e
--- /dev/null
@@ -0,0 +1,459 @@
+//  SMESH SMESHGUI : GUI for SMESH component
+//
+//  Copyright (C) 2003  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 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
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SMESHGUI_AddMeshElementOp.cxx
+//  Author : Alexander SOLOVYOV
+//  Module : SMESH
+//  $Header$
+
+#include "SMESHGUI_AddMeshElementOp.h"
+#include <SMESHGUI_AddMeshElementDlg.h>
+#include <SMESHGUI.h>
+
+#include <SalomeApp_SelectionMgr.h>
+
+#include <SVTK_ViewWindow.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_Selector.h>
+#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
+#include <SMESHGUI_Utils.h>
+#include <SMESHGUI_VTKUtils.h>
+#include <SMESHGUI_MeshUtils.h>
+
+#include <SALOME_ListIO.hxx>
+
+#include <vtkCell.h>
+#include <vtkDataSetMapper.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkIdList.h>
+
+#include <TColStd_MapOfInteger.hxx>
+
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshNode.hxx>
+
+namespace SMESH {
+
+  class TElementSimulation {
+    SVTK_ViewWindow* myVTKViewWindow;
+    SALOME_Actor* myPreviewActor;
+    vtkDataSetMapper* myMapper;
+    vtkUnstructuredGrid* myGrid;
+
+  public:
+    TElementSimulation( SVTK_ViewWindow* wnd )
+    {
+      myVTKViewWindow = wnd;
+
+      myGrid = vtkUnstructuredGrid::New();
+
+      // Create and display actor
+      myMapper = vtkDataSetMapper::New();
+      myMapper->SetInput(myGrid);
+
+      myPreviewActor = SALOME_Actor::New();
+      myPreviewActor->PickableOff();
+      myPreviewActor->VisibilityOff();
+      myPreviewActor->SetMapper(myMapper);
+
+      float anRGB[3];
+      vtkProperty* aProp = vtkProperty::New();
+      GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
+      aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+      myPreviewActor->SetProperty( aProp );
+      aProp->Delete();
+
+      vtkProperty* aBackProp = vtkProperty::New();
+      GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
+      aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+      myPreviewActor->SetBackfaceProperty( aBackProp );
+      aBackProp->Delete();
+
+      myVTKViewWindow->AddActor(myPreviewActor);
+    }
+
+    typedef std::vector<vtkIdType> TVTKIds;
+    void SetPosition (SMESH_Actor* theActor,
+                      vtkIdType theType,
+                      const TVTKIds& theIds)
+    {
+      vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
+      myGrid->SetPoints(aGrid->GetPoints());
+
+      const int* aConn = NULL;
+      switch (theType) {
+      case VTK_TETRA:
+        {
+          static int anIds[] = {0,2,1,3};
+          aConn = anIds;
+          break;
+        }
+      case VTK_PYRAMID:
+        {
+          static int anIds[] = {0,3,2,1,4};
+          aConn = anIds;
+          break;
+        }
+      case VTK_HEXAHEDRON:
+        {
+          static int anIds[] = {0,3,2,1,4,7,6,5};
+          aConn = anIds;
+          break;
+        }
+      }
+
+      myGrid->Reset();
+      vtkIdList *anIds = vtkIdList::New();
+
+      if(aConn)
+       for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
+         anIds->InsertId(i,theIds[aConn[i]]);
+      else
+       for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
+         anIds->InsertId(i,theIds[i]);
+
+      myGrid->InsertNextCell(theType,anIds);
+      anIds->Delete();
+
+      myGrid->Modified();
+
+      SetVisibility(true);
+    }
+
+
+    void SetVisibility (bool theVisibility)
+    {
+      myPreviewActor->SetVisibility(theVisibility);
+      RepaintCurrentView();
+    }
+
+
+    ~TElementSimulation()
+    {
+      SetVisibility( false );
+      if( myVTKViewWindow )
+        myVTKViewWindow->RemoveActor(myPreviewActor);
+        
+      myPreviewActor->Delete();
+
+      myMapper->RemoveAllInputs();
+      myMapper->Delete();
+
+      myGrid->Delete();
+    }
+  };
+}
+
+//=================================================================================
+// function : SMESHGUI_AddMeshElementDlg()
+// purpose  : constructor
+//=================================================================================
+SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes )
+: SMESHGUI_SelectionOp( NodeSelection ),
+  myElementType( t ),
+  myNbNodes( nbNodes ),
+  myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ),
+  mySimulation( 0 ),
+  myDlg( 0 )
+{
+}
+
+//=================================================================================
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose  : destructor
+//=================================================================================
+SMESHGUI_AddMeshElementOp::~SMESHGUI_AddMeshElementOp()
+{
+  if( myDlg )
+    delete myDlg;
+}
+
+//=================================================================================
+// function : dlg()
+// purpose  : 
+//=================================================================================
+SalomeApp_Dialog* SMESHGUI_AddMeshElementOp::dlg() const
+{
+  return myDlg;
+}
+
+//=================================================================================
+// function : startOperation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::startOperation()
+{
+  if( !myDlg )
+  {
+    QString elemName;
+    switch( myNbNodes )
+    {
+      case 2: elemName = "EDGE"; break;
+      case 3: elemName = "TRIANGLE"; break;
+      case 4: if (myElementType == SMDSAbs_Face)
+                elemName = "QUADRANGLE";
+              else
+                elemName = "TETRAS";
+              break;
+      case 5: elemName = "POLYGON"; break;
+      case 8: elemName = "HEXAS"; break;
+    }
+    
+    myDlg = new SMESHGUI_AddMeshElementDlg( elemName, myElementType == SMDSAbs_Face );
+    connect( myDlg, SIGNAL( objectChanged( int, const QStringList& ) ),
+             this,  SLOT( onTextChanged( int, const QStringList& ) ) );
+    connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+    connect( myDlg, SIGNAL( reverse( int ) ), this, SLOT( onReverse( int ) ) );
+  }
+
+  SMESHGUI_SelectionOp::startOperation();
+
+  mySimulation = new SMESH::TElementSimulation( viewWindow() );
+  updateDialog();
+  myDlg->show();
+}
+
+//=================================================================================
+// function : selectionDone()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::selectionDone()
+{
+  if( !mySimulation )
+    return;
+    
+  mySimulation->SetVisibility(false);
+
+  // get selected mesh
+  SALOME_ListIO aList;
+  selectionMgr()->selectedObjects(aList,SVTK_Viewer::Type());
+
+  if( aList.Extent() != 1)
+    return;
+
+  Handle(SALOME_InteractiveObject) anIO = aList.First();
+  myMesh = SMESH::GetMeshByIO(anIO);
+
+  QStringList names, ids; SalomeApp_Dialog::TypesList types;
+  selected( names, types, ids );
+  myDlg->selectObject( names, types, ids );
+
+  updateDialog();
+  displaySimulation();
+}
+
+//=================================================================================
+// function : commitOperation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::commitOperation()
+{
+  if( mySimulation )
+    delete mySimulation;
+  mySimulation = 0;
+  SMESHGUI_SelectionOp::commitOperation();
+}
+
+//=================================================================================
+// function : abortOperation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::abortOperation()
+{
+  if( mySimulation )
+    delete mySimulation;
+  mySimulation = 0;
+  SMESHGUI_SelectionOp::abortOperation();
+}
+
+//=================================================================================
+// function : onApply()
+// purpose  :
+//=================================================================================
+bool SMESHGUI_AddMeshElementOp::onApply()
+{
+  if( !mySimulation )
+    return false;
+
+  QStringList ids; myDlg->selectedObject( 0, ids );
+  if( ids.count()>=myNbNodes && !getSMESHGUI()->isActiveStudyLocked() ) {
+    //myBusy = true;
+    SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+    anArrayOfIdeces->length(myNbNodes);
+    bool reverse = myDlg->isReverse();
+    
+    for (int i = 0; i < myNbNodes; i++)
+    {
+      QString id_str = ids[ i ];
+      int pos = id_str.find( idChar() );
+      int id = -1;
+      if( pos>=0 )
+        id = id_str.mid( pos+1 ).toInt();
+
+      if( id==-1 )
+      {
+        printf( "SMESHGUI_AddMeshElementOp::onApply(): Error!!!\n" );
+        return false;
+      }
+      
+      if (reverse)
+        anArrayOfIdeces[ myNbNodes - i - 1 ] = id;
+      else
+        anArrayOfIdeces[i] = id;
+    }
+
+    SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
+    switch (myElementType) {
+    case SMDSAbs_Edge:
+      aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
+    case SMDSAbs_Face:
+      aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
+    case SMDSAbs_Volume:
+      aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
+    default:;
+    }
+
+    //SALOME_ListIO aList; aList.Append( myActor->getIO() );
+    //mySelectionMgr->setSelectedObjects( aList, false );
+
+    SMESH::UpdateView();
+    mySimulation->SetVisibility(false);
+
+    initDialog();
+    updateDialog();
+
+    return true;
+  }
+  return false;
+}
+
+//=================================================================================
+// function : onTextChanged()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::onTextChanged( int, const QStringList& aListId )
+{
+    myDlg->setBusy( true );
+    TColStd_MapOfInteger newIndices;
+    SALOME_ListIO list; selectionMgr()->selectedObjects( list );
+    if( list.Extent()==0 )
+      return;
+
+    SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() );
+    if( !anActor )
+      return;
+      
+    SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+
+    for (int i = 0; i < aListId.count(); i++)
+      if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
+        newIndices.Add( n->GetID() );
+
+    selector()->AddOrRemoveIndex( list.First(), newIndices, false );
+    highlight( list.First(), true, true );
+
+    selectionDone();
+    myDlg->setBusy( false );
+}
+
+//=================================================================================
+// function : displaySimulation()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::displaySimulation()
+{
+  QStringList ids; myDlg->selectedObject( 0, ids );
+  if( ids.count()>=myNbNodes ) {
+    SMESH::TElementSimulation::TVTKIds anIds;
+
+    SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() );
+    if( !anActor )
+      return;
+    
+    for (int i = 0; i < myNbNodes; i++)
+    {
+      QString id_str = ids[ i ];
+      int pos = id_str.find( idChar() );
+      int id = -1;
+      if( pos>=0 )
+        id = id_str.mid( pos+1 ).toInt();
+
+      if( id==-1 )
+      {
+        printf( "SMESHGUI_AddMeshElementOp::displaySimulation(): Error!!!\n" );
+        return;
+      }
+      
+      anIds.push_back( anActor->GetObject()->GetNodeVTKId( id ) );
+    }
+
+    if( myDlg->isReverse() )
+      reverse( anIds.begin(), anIds.end() );
+
+    vtkIdType aType = 0;
+    if (myIsPoly)
+      switch ( myElementType ) {
+      case SMDSAbs_Face  : aType = VTK_POLYGON; break;
+      default: return;
+      }
+    else {
+      switch (myNbNodes) {
+      case 2: aType = VTK_LINE; break;
+      case 3: aType = VTK_TRIANGLE; break;
+      case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
+      case 8: aType = VTK_HEXAHEDRON; break;
+      default: return;
+      }
+    }
+
+    mySimulation->SetPosition( anActor, aType, anIds );
+    SMESH::UpdateView();
+  }  
+}
+
+//=================================================================================
+// function : onReverse()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::onReverse( int )
+{
+  if( mySimulation )
+  {
+    mySimulation->SetVisibility( false );
+    displaySimulation();
+  }
+}
+
+//=================================================================================
+// function : updateDialog()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::updateDialog()
+{
+  if( myDlg )
+  {
+    QStringList ids; myDlg->selectedObject( 0, ids );
+    myDlg->setButtonEnabled( ids.count()>=myNbNodes, QtxDialog::OK | QtxDialog::Apply );
+  }
+}
diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h
new file mode 100644 (file)
index 0000000..d7429b1
--- /dev/null
@@ -0,0 +1,86 @@
+//  SMESH SMESHGUI : GUI for SMESH component
+//
+//  Copyright (C) 2003  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 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 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : SMESHGUI_AddMeshElementOp.h
+//  Author : Nicolas REJNERI
+//  Module : SMESH
+//  $Header$
+
+#ifndef OPERATION_ADD_FACE_H
+#define OPERATION_ADD_FACE_H
+
+namespace SMESH{
+  struct TElementSimulation;
+}
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include <SMESHGUI_SelectionOp.h>
+#include <SMDSAbs_ElementType.hxx>
+
+class SMESHGUI_AddMeshElementDlg;
+
+//=================================================================================
+// class    : SMESHGUI_AddMeshElementOp
+// purpose  :
+//=================================================================================
+class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp
+{ 
+    Q_OBJECT
+
+public:
+    SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType, const int );
+    ~SMESHGUI_AddMeshElementOp();
+
+    virtual SalomeApp_Dialog* dlg() const;
+
+protected:
+    virtual void startOperation();
+    virtual void selectionDone();
+    virtual void commitOperation();
+    virtual void abortOperation();
+
+    void updateDialog();
+    
+protected slots:
+    virtual bool onApply();
+    void onTextChanged( int, const QStringList& );
+    void onReverse( int );
+
+private:
+    void displaySimulation();
+
+private:
+    int                         myElementType;
+    int                         myNbNodes;
+    bool                        myIsPoly;
+
+    SMESH::SMESH_Mesh_var       myMesh;
+    SMESH::TElementSimulation*  mySimulation;
+
+    SMESHGUI_AddMeshElementDlg* myDlg;
+};
+
+#endif // DIALOGBOX_ADD_FACE_H
index 584533e6c5acb6fb7267187f457e639980bfbad4..da520ad1a085eae933d6e6e53ba12fbb0a5bc781 100644 (file)
@@ -43,8 +43,8 @@
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg()
+: SMESHGUI_Dialog( false, true )
 {
     setCaption(tr("SMESH_ADD_SUBMESH"));
 
index 3b06458478d80c2a139c218d2323ab344ec9bcb4..dd4cc7c88943682cd2d1b40ed469a9b2a1367663 100644 (file)
@@ -45,7 +45,7 @@ public:
     enum { MeshObj, GeomObj, Hypo, Algo };
     
 public:
-    SMESHGUI_AddSubMeshDlg( SMESHGUI* );
+    SMESHGUI_AddSubMeshDlg();
     ~SMESHGUI_AddSubMeshDlg();
 
     void    setSubMeshName( const QString& );
index 1ed50e77719f74314ed3c3d49d40403599fc1840..ddc14b47d0be68da3af3fccf4b1da85f76daedc9 100644 (file)
@@ -21,7 +21,7 @@
 //
 //
 //
-//  File   : SMESHGUI_AddSubMeshDlg.cxx
+//  File   : SMESHGUI_AddSubMeshOp.cxx
 //  Author : Nicolas REJNERI
 //  Module : SMESH
 //  $Header$
 // purpose  :
 //=================================================================================
 SMESHGUI_AddSubMeshOp::SMESHGUI_AddSubMeshOp()
-: SMESHGUI_Operation(),
-  myDlg( 0 ),
-  myMeshFilter( 0 ),
-  myGeomFilter( 0 ),
-  myHypothesisFilter( 0 ),
-  myAlgorithmFilter( 0 )
+: SMESHGUI_SelectionOp(),
+  myDlg( 0 )
 {
   setAutoResumed( true );
 }
@@ -73,18 +69,6 @@ SMESHGUI_AddSubMeshOp::~SMESHGUI_AddSubMeshOp()
 {
   if( myDlg )
     delete myDlg;
-
-  if( myMeshFilter )
-    delete myMeshFilter;
-        
-  if( myGeomFilter )
-    delete myGeomFilter;
-  
-  if( myAlgorithmFilter )
-    delete myAlgorithmFilter;
-
-  if( myHypothesisFilter )
-    delete myHypothesisFilter;    
 }
 
 //=================================================================================
@@ -95,31 +79,12 @@ void SMESHGUI_AddSubMeshOp::startOperation()
 {
   if( !myDlg )
   {
-    myDlg = new SMESHGUI_AddSubMeshDlg( getSMESHGUI() );
-    connect( myDlg, SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) );
-    connect( myDlg, SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) );
-  }
-
-  SMESHGUI_Operation::startOperation();
-
-  if( !myGeomFilter )
-  {
-    TColStd_MapOfInteger allTypesMap;
-    for (int i = 0; i < 10; i++)
-      allTypesMap.Add(i);
-    myGeomFilter       = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+    myDlg = new SMESHGUI_AddSubMeshDlg();
+    connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) );
   }
 
-  if( !myMeshFilter )
-    myMeshFilter       = new SMESH_TypeFilter (MESH);
-    
-  if( !myAlgorithmFilter )
-    myAlgorithmFilter  = new SMESH_TypeFilter (ALGORITHM);
+  SMESHGUI_SelectionOp::startOperation();
 
-  if( !myHypothesisFilter )
-    myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
-    
-  init();
   myDlg->show();
 }
 
@@ -138,40 +103,36 @@ SalomeApp_Dialog* SMESHGUI_AddSubMeshOp::dlg() const
 //=================================================================================
 void SMESHGUI_AddSubMeshOp::selectionDone()
 {
-  QStringList names, ids;
-  SMESHGUI_Dialog::TypesList types;
-  selected( names, types, ids );
+  SMESHGUI_SelectionOp::selectionDone();
   if( myDlg )
-  {
-    myDlg->selectObject( names, types, ids );
-    myDlg->updateControlState( isValid() );
-  }
+    updateDialog();
 }
 
 //=================================================================================
-// function : onActivateObject
+// function : createFilter
 // purpose  :
 //=================================================================================
-void SMESHGUI_AddSubMeshOp::onActivateObject( int obj )
+SUIT_SelectionFilter* SMESHGUI_AddSubMeshOp::createFilter( const int id ) const
 {
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  if( id==SMESHGUI_AddSubMeshDlg::GeomObj )
+  {
+    TColStd_MapOfInteger allTypesMap;
+    for (int i = 0; i < 10; i++)
+      allTypesMap.Add(i);
+    return new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+  }
 
-  if( !mgr )
-    return;
-    
-  mgr->clearFilters();
+  if( id==SMESHGUI_AddSubMeshDlg::MeshObj )
+    return new SMESH_TypeFilter (MESH);
 
-  if( obj==SMESHGUI_AddSubMeshDlg::MeshObj )
-    mgr->installFilter( myMeshFilter );
+  else if( id==SMESHGUI_AddSubMeshDlg::Algo )
+    return new SMESH_TypeFilter (ALGORITHM);
 
-  else if( obj==SMESHGUI_AddSubMeshDlg::GeomObj )
-    mgr->installFilter( myGeomFilter );
-    
-  else if( obj==SMESHGUI_AddSubMeshDlg::Hypo )
-    mgr->installFilter( myHypothesisFilter );
+  else if( id==SMESHGUI_AddSubMeshDlg::Hypo )
+    return new SMESH_TypeFilter (HYPOTHESIS);
 
-  else if( obj==SMESHGUI_AddSubMeshDlg::Algo )
-    mgr->installFilter( myAlgorithmFilter );
+  else
+    return 0;
 }
 
 //=================================================================================
@@ -250,47 +211,25 @@ bool SMESHGUI_AddSubMeshOp::onApply()
   }
   
   update( UF_Model | UF_ObjBrowser );
-  init();
+  initDialog();
   
   return (nbSuccess > 0);
 }
 
 //=================================================================================
-// function : init()
+// function : initDialog()
 // purpose  :
 //=================================================================================
-void SMESHGUI_AddSubMeshOp::init()
+void SMESHGUI_AddSubMeshOp::initDialog()
 {
+  SMESHGUI_SelectionOp::initDialog();
   if( myDlg )
-  {    
-    myDlg->init();
-    myDlg->updateControlState( false );
+  {
+    myDlg->setSubMeshName( tr( "SMESH_SUBMESH" ) );
+    updateDialog();
   }
 }
 
-//=================================================================================
-// function : isValid()
-// purpose  :
-//=================================================================================
-bool SMESHGUI_AddSubMeshOp::isValid() const
-{
-  bool isEnabled = !myDlg->subMeshName().isEmpty() &&
-                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::MeshObj ) &&
-                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::GeomObj ) &&
-                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Hypo ) &&
-                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Algo );
-                   
-  bool isImportedMesh = false;
-
-  QStringList selMesh;
-  myDlg->selectedObject( SMESHGUI_AddSubMeshDlg::MeshObj, selMesh );
-  _PTR(SObject) SO = studyDS()->FindObjectID( selMesh.first() );
-  GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(SO);
-  isImportedMesh = myGeomShape->_is_nil();
-
-  return isEnabled && !isImportedMesh;
-}
-
 //=================================================================================
 // function : IsFatherOf()
 // purpose  :
@@ -338,7 +277,7 @@ void SMESHGUI_AddSubMeshOp::onSelectionChanged( int id )
 }
 
 //=================================================================================
-// function : onSelectionChanged()
+// function : addSubMesh()
 // purpose  :
 //=================================================================================
 SMESH::SMESH_subMesh_var SMESHGUI_AddSubMeshOp::addSubMesh( SMESH::SMESH_Mesh_ptr theMesh,
@@ -359,15 +298,51 @@ SMESH::SMESH_subMesh_var SMESHGUI_AddSubMeshOp::addSubMesh( SMESH::SMESH_Mesh_pt
   return aSubMesh._retn();
 }
 
+//=================================================================================
+// function : updateDialog()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddSubMeshOp::updateDialog()
+{
+  if( !myDlg )
+    return;
+    
+  bool isEnabled = !myDlg->subMeshName().isEmpty() &&
+                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::MeshObj ) &&
+                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::GeomObj ) &&
+                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Hypo ) &&
+                   myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Algo );
+
+  bool isImportedMesh = false;
+
+  QStringList selMesh;
+  myDlg->selectedObject( SMESHGUI_AddSubMeshDlg::MeshObj, selMesh );
+  _PTR(SObject) SO = studyDS()->FindObjectID( selMesh.first() );
+  GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(SO);
+  isImportedMesh = myGeomShape->_is_nil();
+
+  isEnabled = isEnabled && !isImportedMesh;
+  
+  myDlg->setButtonEnabled( isEnabled, QtxDialog::OK | QtxDialog::Apply );
+}
+
+//=================================================================================
+// function : onNameChanged()
+// purpose  :
+//=================================================================================
+void SMESHGUI_AddSubMeshOp::onNameChanged( const QString& )
+{
+  updateDialog();
+}
+
 //=================================================================================
 // function : isValid
 // purpose  :
 //=================================================================================
 bool SMESHGUI_AddSubMeshOp::isValid( SUIT_Operation* theOtherOp ) const
 {
-  if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_InitMeshOp" ) )
+  //if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_InitMeshOp" ) )
     return true;
-  else
-    return false;
-
+  /*else
+    return false;*/
 }
index 6cbc324ed3ac38c18edfc3e88c7d4b9347c02533..4c26810ec43e4ebaf8122fe7a8b935842239d462 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef OPERATION_ADD_SUB_MESH_H
 #define OPERATION_ADD_SUB_MESH_H
 
-#include <SMESHGUI_Operation.h>
+#include <SMESHGUI_SelectionOp.h>
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Gen)
@@ -43,7 +43,7 @@ class SUIT_SelectionFilter;
 // class    : SMESHGUI_AddSubMeshOp
 // purpose  :
 //=================================================================================
-class SMESHGUI_AddSubMeshOp : public SMESHGUI_Operation
+class SMESHGUI_AddSubMeshOp : public SMESHGUI_SelectionOp
 {
     Q_OBJECT
 
@@ -52,14 +52,15 @@ public:
   ~SMESHGUI_AddSubMeshOp();
 
   virtual SalomeApp_Dialog* dlg() const;
-  void    init();
+  virtual void              initDialog();
   virtual bool isValid( SUIT_Operation* theOtherOp ) const;
   
 protected:
   virtual void startOperation();
   virtual void selectionDone();
+  virtual SUIT_SelectionFilter* createFilter( const int ) const;
 
-  bool isValid() const;
+  void updateDialog();
 
   SMESH::SMESH_subMesh_var addSubMesh( SMESH::SMESH_Mesh_ptr,
                                        GEOM::GEOM_Object_ptr,
@@ -67,14 +68,13 @@ protected:
 
 protected slots:
   virtual bool onApply();
+  virtual void onSelectionChanged( int );
 
 private slots:
-  void onActivateObject( int );
-  void onSelectionChanged( int );
+  void onNameChanged( const QString& );
 
 private:
   SMESHGUI_AddSubMeshDlg  *myDlg;
-  SUIT_SelectionFilter    *myMeshFilter, *myGeomFilter, *myHypothesisFilter, *myAlgorithmFilter;
 };
 
 #endif // OPERATION_INIT_MESH_H
index 649904c6f97889bf3e3f0eed940fd8feffeff39f..3666b7c4669d7fb4b03a1f96673590fd0a6d2e8c 100644 (file)
@@ -1,16 +1,43 @@
+//  SMESH SMESHGUI : GUI for SMESH component
+//
+//  Copyright (C) 2003  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 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
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SMESHGUI_Dialog.cxx
+//  Author : Alexander SOLOVYOV
+//  Module : SMESH
+//  $Header$
 
 #include <SMESHGUI_Dialog.h>
-#include <SMESHGUI_Utils.h>
 #include <SMESHGUI_Operation.h>
 #include <SMESH_Type.h>
-#include <SMESHGUI.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
 
-#include <SUIT_Desktop.h>
-
-SMESHGUI_Dialog::SMESHGUI_Dialog( SMESHGUI* theModule, const bool modal, const bool allowResize,
-                                  const int flags )
-: SalomeApp_Dialog( SMESH::GetDesktop( theModule ), "", modal, allowResize, flags ),
-  mySMESHGUI( theModule )
+//=================================================================================
+// function : SMESHGUI_Dialog
+// purpose  : Constructor
+//=================================================================================
+SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags )
+: SalomeApp_Dialog( desktop(), "", modal, allowResize, flags )
 {
   int prefix = SMESHGUI_Operation::prefix( "SMESH" );
   typeName( prefix + MESH ) = tr( "DLG_MESH" );
@@ -18,19 +45,50 @@ SMESHGUI_Dialog::SMESHGUI_Dialog( SMESHGUI* theModule, const bool modal, const b
   typeName( prefix + ALGORITHM ) = tr( "DLG_ALGO" );
 }
 
+//=================================================================================
+// function : ~SMESHGUI_Dialog
+// purpose  : Destructor
+//=================================================================================
 SMESHGUI_Dialog::~SMESHGUI_Dialog()
 {
 }
 
+//=================================================================================
+// function : show
+// purpose  :
+//=================================================================================
 void SMESHGUI_Dialog::show()
 {
-  int x, y;
-  mySMESHGUI->DefineDlgPosition(this, x, y);
+  adjustSize();
+  SUIT_Desktop *PP = desktop();
+  int x = abs( PP->x() + PP->size().width() - size().width() - 10 ),
+      y = abs( PP->y() + PP->size().height() - size().height() - 10 );
   move(x, y);
   SalomeApp_Dialog::show();
 }
 
+//=================================================================================
+// function : setContentActive
+// purpose  :
+//=================================================================================
 void SMESHGUI_Dialog::setContentActive( const bool active ) const
 {
   mainFrame()->setEnabled( active );
 }
+
+//=================================================================================
+// function : desktop
+// purpose  :
+//=================================================================================
+SUIT_Desktop* SMESHGUI_Dialog::desktop() const
+{
+  SUIT_Desktop* d = 0;
+  SUIT_Session* s = SUIT_Session::session();
+  if( s )
+  {
+    SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() );
+    if( app )
+      d = app->desktop();
+  }
+  return d;
+}
index 2f9092fea63e88d78da0e74e72c291efe8878778..268b67ae79e2748f0ce1e80423b6956906fb20fc 100644 (file)
@@ -1,17 +1,49 @@
+//  SMESH SMESHGUI : GUI for SMESH component
+//
+//  Copyright (C) 2003  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 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
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SMESHGUI_Dialog.h
+//  Author : Alexander SOLOVYOV
+//  Module : SMESH
+//  $Header$
+
 
 #ifndef SMESHGUI_DIALOG_H
 #define SMESHGUI_DIALOG_H
 
 #include <SalomeApp_Dialog.h>
 
-class SMESHGUI;
+class SUIT_Desktop;
 
+//=================================================================================
+// class    : SMESHGUI_Dialog
+// purpose  : Base dialog for all SMESHGUI dialogs
+//=================================================================================
 class SMESHGUI_Dialog : public SalomeApp_Dialog
 {
   Q_OBJECT
   
 public:
-  SMESHGUI_Dialog( SMESHGUI*, const bool = false, const bool = false, const int = OK | Cancel | Apply );
+  SMESHGUI_Dialog( const bool = false, const bool = false, const int = OK | Cancel | Apply );
   virtual ~SMESHGUI_Dialog();
 
   virtual void show();
@@ -19,8 +51,9 @@ public:
   //! set all content to enable (parameter is true) or disable state
   void setContentActive( const bool ) const;
 
-private:
-  SMESHGUI* mySMESHGUI;
+protected:
+  //! find desktop of active application
+  SUIT_Desktop* desktop() const;
 };
 
 #endif
index a5fa046f74810ed9c64bb05dfe5b94ee7e2a676b..6e9bbca789fc319fc18c0638a7c4f75d40b25d36 100644 (file)
@@ -43,8 +43,8 @@
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg()
+: SMESHGUI_Dialog( false, true )
 {
     setName("SMESHGUI_EditHypothesesDlg");
     setCaption(tr("SMESH_EDIT_HYPOTHESES"));
index 69e5d56caaaa75eff00d1c5412f6c52bd24d66e6..de0b730a9594630ac62ff0d5bd123270e77aff20 100644 (file)
@@ -70,7 +70,7 @@ public:
     typedef enum { HypoDef, HypoAssign, AlgoDef, AlgoAssign } ListType;
     
 public:
-    SMESHGUI_EditHypothesesDlg( SMESHGUI* );
+    SMESHGUI_EditHypothesesDlg();
     ~SMESHGUI_EditHypothesesDlg();
 
     void setListsEnabled( const bool );
index 6c0226cc67502d7339a49fcf133faeaee94ad9ac..115ce0e14d162fb985f0432d600dfa0f216a01a7 100644 (file)
@@ -83,7 +83,7 @@ void SMESHGUI_EditHypothesesOp::startOperation()
 {
   if( !myDlg )
   {
-    myDlg = new SMESHGUI_EditHypothesesDlg( getSMESHGUI() );
+    myDlg = new SMESHGUI_EditHypothesesDlg();
     connect( myDlg, SIGNAL( needToUpdate() ), this, SLOT( onUpdate() ) );
   }
 
index a88045688147028038dda35b89d16dbd931cb9d1..33df4c1a10785daacf1519bd607864fa4831841f 100644 (file)
@@ -44,8 +44,8 @@
 // name    : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg
 // Purpose : Constructor
 //=======================================================================
-SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int aMode )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( const int aMode )
+: SMESHGUI_Dialog( false, true )
 {
   QString caption;
   if( aMode == 0 )
index ad316b1dbdf8842bf8820c4ddd5058a75ed8c84f..8d84db85b8e9cf7b1bdd1894569f9bd8f0bd7e3c 100644 (file)
@@ -42,7 +42,7 @@ class SMESHGUI_GroupOpDlg : public SMESHGUI_Dialog
   Q_OBJECT
 
 public:
-  SMESHGUI_GroupOpDlg( SMESHGUI*, const int );
+  SMESHGUI_GroupOpDlg( const int );
   virtual ~SMESHGUI_GroupOpDlg();
 
   void    setName( const QString& );
index 7dfa03ab9b8f6b5d1a6ef7344a4d992c1f4ce448..f687dfef01f08a88922c85c76284d388bc4d35ef 100644 (file)
@@ -44,8 +44,8 @@
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg()
+: SMESHGUI_Dialog( false, true )
 {
     setCaption(tr("SMESH_INIT_MESH"));
 
index c60f18c23ea375f8add779275343196eb84ea4ae..f4a731d8cd7df56c6e5516f3231f17faf34a4190 100644 (file)
@@ -43,7 +43,7 @@ public:
     enum { GeomObj, Hypo, Algo };
 
 public:
-    SMESHGUI_InitMeshDlg( SMESHGUI* );
+    SMESHGUI_InitMeshDlg();
     ~SMESHGUI_InitMeshDlg();
 
     void    setMeshName( const QString& );
index 1165258e7fbe642cb47aecdf4bbe1b3742bb1432..0ae7d92aab15c84c2b55144d97decf8102f60093 100644 (file)
 // purpose  :
 //=================================================================================
 SMESHGUI_InitMeshOp::SMESHGUI_InitMeshOp()
-: SMESHGUI_Operation(),
-  myDlg( 0 ),
-  myGeomFilter( 0 ),
-  myHypothesisFilter( 0 ),
-  myAlgorithmFilter( 0 )
+: SMESHGUI_SelectionOp(),
+  myDlg( 0 )
 {
   setAutoResumed( true );
 }
@@ -71,15 +68,6 @@ SMESHGUI_InitMeshOp::~SMESHGUI_InitMeshOp()
 {
   if( myDlg )
     delete myDlg;
-    
-  if( myGeomFilter )
-    delete myGeomFilter;
-  
-  if( myAlgorithmFilter )
-    delete myAlgorithmFilter;
-
-  if( myHypothesisFilter )
-    delete myHypothesisFilter;    
 }
 
 //=================================================================================
@@ -90,27 +78,12 @@ void SMESHGUI_InitMeshOp::startOperation()
 {
   if( !myDlg )
   {
-    myDlg = new SMESHGUI_InitMeshDlg( getSMESHGUI() );
-    connect( myDlg, SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) );
-  }
-
-  SMESHGUI_Operation::startOperation();
-
-  if( !myGeomFilter )
-  {
-    TColStd_MapOfInteger allTypesMap;
-    for (int i = 0; i < 10; i++)
-      allTypesMap.Add(i);
-    myGeomFilter       = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+    myDlg = new SMESHGUI_InitMeshDlg();
+    connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) );
   }
 
-  if( !myAlgorithmFilter )
-    myAlgorithmFilter  = new SMESH_TypeFilter (ALGORITHM);
+  SMESHGUI_SelectionOp::startOperation();
 
-  if( !myHypothesisFilter )
-    myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
-    
-  init();
   myDlg->show();
 }
 
@@ -129,36 +102,33 @@ SalomeApp_Dialog* SMESHGUI_InitMeshOp::dlg() const
 //=================================================================================
 void SMESHGUI_InitMeshOp::selectionDone()
 {
-  QStringList names, ids;
-  SMESHGUI_Dialog::TypesList types;
-  selected( names, types, ids );
+  SMESHGUI_SelectionOp::selectionDone();
   if( myDlg )
-  {
-    myDlg->selectObject( names, types, ids );
-    myDlg->updateControlState();
-  }
+    updateDialog();
 }
 
 //=================================================================================
-// function : onActivateObject
+// function : createFilter
 // purpose  :
 //=================================================================================
-void SMESHGUI_InitMeshOp::onActivateObject( int obj )
+SUIT_SelectionFilter* SMESHGUI_InitMeshOp::createFilter( const int id ) const
 {
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  if( id==SMESHGUI_InitMeshDlg::GeomObj )
+  {
+    TColStd_MapOfInteger allTypesMap;
+    for (int i = 0; i < 10; i++)
+      allTypesMap.Add(i);
+    return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
+  }
 
-  if( !mgr )
-    return;
-    
-  mgr->clearFilters();
-  if( obj==SMESHGUI_InitMeshDlg::GeomObj )
-    mgr->installFilter( myGeomFilter );
-    
-  else if( obj==SMESHGUI_InitMeshDlg::Hypo )
-    mgr->installFilter( myHypothesisFilter );
+  else if( id==SMESHGUI_InitMeshDlg::Hypo )
+    return new SMESH_TypeFilter (HYPOTHESIS);
+
+  else if( id==SMESHGUI_InitMeshDlg::Algo )
+    return new SMESH_TypeFilter (ALGORITHM);
 
-  else if( obj==SMESHGUI_InitMeshDlg::Algo )
-    mgr->installFilter( myAlgorithmFilter );
+  else
+    return 0;
 }
 
 //=================================================================================
@@ -236,7 +206,7 @@ bool SMESHGUI_InitMeshOp::onApply()
 
   update( UF_Model | UF_ObjBrowser );
 
-  init();
+  initDialog();
   return true;
 }
 
@@ -263,13 +233,13 @@ QString SMESHGUI_InitMeshOp::defaultMeshName() const
 // function : init()
 // purpose  :
 //=================================================================================
-void SMESHGUI_InitMeshOp::init()
+void SMESHGUI_InitMeshOp::initDialog()
 {
+  SMESHGUI_SelectionOp::initDialog();
   if( myDlg )
   {
     myDlg->setMeshName( defaultMeshName() );
-    myDlg->clearSelection();
-    myDlg->updateControlState();
+    updateDialog();
   }    
 }
 
@@ -323,28 +293,40 @@ void SMESHGUI_InitMeshOp::onSelectionChanged( int id )
   }
 }
 
+//=================================================================================
+// function : onNameChanged()
+// purpose  :
+//=================================================================================
+void SMESHGUI_InitMeshOp::onNameChanged( const QString& )
+{
+  updateDialog();
+}
+
+//=================================================================================
+// function : updateDialog()
+// purpose  :
+//=================================================================================
+void SMESHGUI_InitMeshOp::updateDialog()
+{
+  if( !myDlg )
+    return;
+    
+  bool isEnabled = !myDlg->meshName().isEmpty() &&
+                   myDlg->hasSelection( SMESHGUI_InitMeshDlg::GeomObj ) &&
+                   myDlg->hasSelection( SMESHGUI_InitMeshDlg::Hypo ) &&
+                   myDlg->hasSelection( SMESHGUI_InitMeshDlg::Algo );
+  myDlg->setButtonEnabled( isEnabled, QtxDialog::OK | QtxDialog::Apply );
+}
+
 //=================================================================================
 // function : isValid
 // purpose  :
 //=================================================================================
 bool SMESHGUI_InitMeshOp::isValid( SUIT_Operation* theOtherOp ) const
 {
-  if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_AddSubMeshOp" ) )
+  //if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_AddSubMeshOp" ) )
     return true;
-  else
+  /*else
     return false;
-    
+    */
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
index f81b776a5182c6a8a92cb260932e02e649f62e10..1eb67d3f5ba6237a1acfd8d1e5a40a28b87ba08d 100644 (file)
 #ifndef OPERATION_INIT_MESH_H
 #define OPERATION_INIT_MESH_H
 
-#include <SMESHGUI_Operation.h>
+#include <SMESHGUI_SelectionOp.h>
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 #include CORBA_SERVER_HEADER(SMESH_Gen)
 
 class SMESHGUI_InitMeshDlg;
-class SUIT_SelectionFilter;
 
 //=================================================================================
 // class    : SMESHGUI_InitMeshOp
 // purpose  :
 //=================================================================================
-class SMESHGUI_InitMeshOp : public SMESHGUI_Operation
+class SMESHGUI_InitMeshOp : public SMESHGUI_SelectionOp
 {
     Q_OBJECT
 
@@ -51,7 +50,8 @@ public:
   ~SMESHGUI_InitMeshOp();
 
   virtual SalomeApp_Dialog* dlg() const;
-  void    init();
+  virtual void              initDialog();
+  
   QString defaultMeshName() const;
 
   virtual bool isValid( SUIT_Operation* theOtherOp ) const;
@@ -59,19 +59,21 @@ public:
 protected:
   virtual void startOperation();
   virtual void selectionDone();
+  virtual SUIT_SelectionFilter* createFilter( const int ) const;
 
   SMESH::SMESH_Mesh_var initMesh( GEOM::GEOM_Object_ptr, const QString& );
 
+  void updateDialog();
+
 protected slots:
   virtual bool onApply();
+  virtual void onSelectionChanged( int );
 
 private slots:
-  void onActivateObject( int );
-  void onSelectionChanged( int );
+  void onNameChanged( const QString& );
 
 private:
   SMESHGUI_InitMeshDlg  *myDlg;
-  SUIT_SelectionFilter  *myGeomFilter, *myHypothesisFilter, *myAlgorithmFilter;
 };
 
 #endif // OPERATION_INIT_MESH_H
index 097a0dda589d979ecb4d6aaa3c3d4766eb61ce30..65de0746bc996ce642f2027f73522d9f5e292648 100644 (file)
@@ -41,8 +41,8 @@
 // class    : SMESHGUI_NodesDlg()
 // purpose  :
 //=================================================================================
-SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, false, OK | Apply | Close )
+SMESHGUI_NodesDlg::SMESHGUI_NodesDlg()
+: SMESHGUI_Dialog( false, false, OK | Apply | Close )
 {
   QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
   setName("SMESHGUI_NodesDlg");
@@ -112,6 +112,8 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule )
   connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
   
   SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0);
+
+  setFocusProxy( SpinBox_X );
 }
 
 //=======================================================================
@@ -142,7 +144,4 @@ void SMESHGUI_NodesDlg::setCoords( const double x, const double y, const double
   SpinBox_X->setValue( x );
   SpinBox_Y->setValue( y );
   SpinBox_Z->setValue( z );
-  SpinBox_X->clearFocus();
-  SpinBox_Y->clearFocus();
-  SpinBox_Z->clearFocus();
 }
index 41843db0fe7a257c833541940fd7f12a95e9132b..0cc693206682aca0f5b7703d3c725c9e23368928 100644 (file)
@@ -42,7 +42,7 @@ class SMESHGUI_NodesDlg : public SMESHGUI_Dialog
     Q_OBJECT
 
 public:
-    SMESHGUI_NodesDlg( SMESHGUI* );
+    SMESHGUI_NodesDlg();
     ~SMESHGUI_NodesDlg();
 
     void coords( double&, double&, double& ) const;
index 4e0ff14f26c1f79beba9b371dba6be905d3ce7d9..2313f1aca387a1f1ffc0eae38ec7a83eb976b174 100644 (file)
@@ -228,13 +228,13 @@ void SMESHGUI_NodesOp::startOperation()
 {
   if( !myDlg )
   {
-    myDlg = new SMESHGUI_NodesDlg( getSMESHGUI() );
+    myDlg = new SMESHGUI_NodesDlg();
     connect( myDlg, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) );
     connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
   }
 
   SMESHGUI_SelectionOp::startOperation();
-    
+
   mySimulation = new SMESH::TNodeSimulation( viewWindow() );
   myDlg->show();
 }
@@ -245,7 +245,8 @@ void SMESHGUI_NodesOp::startOperation()
 //=================================================================================
 void SMESHGUI_NodesOp::commitOperation()
 {
-  delete mySimulation;
+  if( mySimulation )
+    delete mySimulation;
   mySimulation = 0;
   SMESHGUI_SelectionOp::commitOperation();
 }
@@ -256,7 +257,8 @@ void SMESHGUI_NodesOp::commitOperation()
 //=================================================================================
 void SMESHGUI_NodesOp::abortOperation()
 {
-  delete mySimulation;
+  if( mySimulation )
+    delete mySimulation;
   mySimulation = 0;
   SMESHGUI_SelectionOp::abortOperation();
 }
index bf3dfb60202b3d1b354cff9cae9bc5c79a4ca39e..45acb92f497879617852edd359f79fea3761f87f 100644 (file)
@@ -62,7 +62,7 @@ protected:
     virtual void commitOperation();
     virtual void abortOperation();
 
-    void initDialog();
+    virtual void initDialog();
 
 protected slots:
     virtual bool onApply();