Salome HOME
Rename and Delete functionalities added.
authorasv <asv@opencascade.com>
Fri, 3 Jun 2005 10:42:52 +0000 (10:42 +0000)
committerasv <asv@opencascade.com>
Fri, 3 Jun 2005 10:42:52 +0000 (10:42 +0000)
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI.h
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.cxx [new file with mode: 0644]
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.h [new file with mode: 0644]
src/GEOMToolsGUI/Makefile.in

index 594d197d69e696321639aa2a3d49aacc16a0337e..4463292d54eec263215c878b44ac29c74359d799 100644 (file)
 #include <SUIT_Tools.h>
 #include <SUIT_FileDlg.h>
 #include <SUIT_Desktop.h>
+#include <SUIT_ViewModel.h>
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
+#include <SalomeApp_SelectionMgr.h>
 
-//#include "OCCViewer_Viewer3d.h"
-//#include "VTKViewer_ViewWindow.h"
-//#include "VTKViewer_RenderWindowInteractor.h"
-
-#include "SALOME_ListIteratorOfListIO.hxx"
-//#include "SALOMEGUI_ImportOperation.h"
-//#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_Prs.h>
 
 #include <qapplication.h>
 #include <qmap.h>
@@ -61,9 +58,7 @@ using namespace std;
 
 typedef QMap<QString, QString> FilterMap;
 
-#include "SALOMEDSClient.hxx"
-#include "SALOMEDS_SObject.hxx"
-#include "SALOMEDS_Study.hxx"
+#include <SALOMEDS_SObject.hxx>
 
 
 
@@ -229,138 +224,140 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
 }
 
 
+
 //===============================================================================
 // function : OnEditDelete()
 // purpose  :
 //===============================================================================
 void GEOMToolsGUI::OnEditDelete()
 {
-/*
-   SALOME_Selection* Sel = SALOME_Selection::Selection(
-    QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
-    
-  if ( Sel->IObjectCount() == 0 )
-    return;
-  
-  _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-  
-  bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
-  if ( aLocked ) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                           QObject::tr("WRN_WARNING"), 
-                           QObject::tr("WRN_STUDY_LOCKED"),
-                           QObject::tr("BUT_OK") );
-    return;
-  }
-
-  // VSR 17/11/04: check if all objects selected belong to GEOM component --> start
-  QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
-  if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() )  {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                           QObject::tr("ERR_ERROR"), 
-                           QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "GEOM" )),
-                           QObject::tr("BUT_OK") );
-    return;
-  }
-  // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
-
-  if ( QAD_MessageBox::warn2( QAD_Application::getDesktop(),
-                              tr( "GEOM_WRN_WARNING" ),
-                              tr( "GEOM_REALLY_DELETE" ),
-                              tr( "GEOM_BUT_YES" ),
-                              tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 )
-    return;
-
-  int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
-
-  Standard_Boolean found;
-  _PTR(GenericAttribute) anAttr;
-
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  
-  QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() );
-
-  op->start();
-  
-  Standard_Boolean    deleted = false;
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+    if ( aSelMgr && appStudy ) {
+      aSelMgr->selectedObjects( selected );
+      if ( !selected.IsEmpty() ) {
+       _PTR(Study) aStudy = appStudy->studyDS();
+
+       bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
+       if ( aLocked ) {
+         SUIT_MessageBox::warn1 ( app->desktop(),
+                                  QObject::tr("WRN_WARNING"), 
+                                  QObject::tr("WRN_STUDY_LOCKED"),
+                                  QObject::tr("BUT_OK") );
+         return;
+       }
   
-  for ( ;It.More();It.Next() )
-  {
-    Handle( SALOME_InteractiveObject ) IObject = It.Value();
-    
-    if ( !IObject->hasEntry() )
-      continue;
-
-    _PTR(SObject) SO ( aStudy->FindObjectID( IObject->getEntry() ) );
-    _PTR(AttributeIOR) anIOR;
-
-    // Erase child graphical objects
-
-    _PTR(ChildIterator) it ( aStudy->NewChildIterator( SO ) );
-    for ( ; it->More();it->Next() )
-    {
-      _PTR(SObject) CSO ( it->Value() );
-
-      if ( CSO->FindAttribute( anAttr, "AttributeIOR" ) )
-      {
-        anIOR =  anAttr;
-
-        // Delete child( s ) shape in Client :
-
-        const TCollection_AsciiString ASCior( (char*)anIOR->Value().c_str() ) ;
-        GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCior );
-
-        for ( int i = 0; i < nbSf; i++ )
-        {
-          GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( dynamic_cast<SALOMEDS_SObject*>(CSO.get())->GetObject() );
-          if ( !aGeomObj->_is_nil() )
-            GEOM_Displayer().Erase( aGeomObj, true );
-        }
-      }
-    }
-
-    // Erase main graphical object
-
-    for ( int i = 0; i < nbSf; i++ )
-    {
-      QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame( i );
-      GEOM_Displayer().Erase( IObject, true );
-    }
-
-    // Delete main shape in Client :
-
-    if ( SO->FindAttribute( anAttr, "AttributeIOR" ) )
-    {
-      anIOR = anAttr;
-      const TCollection_AsciiString ASCIor( (char*)anIOR->Value().c_str() ) ;
-      GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor );
-    }
-
-    // Erase objects in Study
-
-    _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
-    if ( obj )
-    {
-      _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
-      aStudyBuilder->RemoveObject( obj );
-      
-      GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(dynamic_cast<SALOMEDS_SObject*>(obj.get())->GetObject());
-      if ( !aGeomObj->_is_nil() )
-        GeometryGUI::GetGeomGUI()->GetGeomGen()->RemoveObject( aGeomObj );
+       // VSR 17/11/04: check if all objects selected belong to GEOM component --> start
+       // modifications of ASV 01.06.05
+       QString parentComp = getParentComponent( aStudy, selected );
+       const char* geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
+       QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR ) );
+
+       if ( parentComp != geomComp )  {
+         SUIT_MessageBox::warn1 ( app->desktop(),
+                                 QObject::tr("ERR_ERROR"), 
+                                 QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ),
+                                 QObject::tr("BUT_OK") );
+         return;
+       }
+       // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
+
+       if ( SUIT_MessageBox::warn2( app->desktop(), 
+                                    QObject::tr( "GEOM_WRN_WARNING" ),
+                                    QObject::tr( "GEOM_REALLY_DELETE" ),
+                                    QObject::tr( "GEOM_BUT_YES" ),
+                                    QObject::tr( "GEOM_BUG_NO" ), 1, 0, 0 ) != 1 )
+         return;
+
+       //      QAD_Operation* op = new SALOMEGUI_ImportOperation(.....);
+       //      op->start();
+       
+       // prepare list of SALOME_Views
+       QPtrList<SALOME_View> views;
+       SALOME_View* view;
+       // fill the list
+       ViewManagerList vmans = app->viewManagers();
+       SUIT_ViewManager* vman;
+       for ( vman = vmans.first(); vman; vman = vmans.next() ) {
+         SUIT_ViewModel* vmod = vman->getViewModel();
+         view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
+         if ( view )
+           views.append( view );
+       }
+       
+       _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
+       _PTR(GenericAttribute) anAttr;
+       GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
+
+       // MAIN LOOP OF SELECTED OBJECTS
+       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+
+         Handle(SALOME_InteractiveObject) io = It.Value();
+         if ( !io->hasEntry() )
+           continue;
+
+         _PTR(SObject) obj ( aStudy->FindObjectID( io->getEntry() ) );
+
+         // disable removal of "Geometry" component object
+         if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) )
+           continue;
+
+         // iterate through all childres of obj, find IOR attributes on children and remove shapes that 
+         // correspond to these IORs
+         for ( _PTR(ChildIterator) it ( aStudy->NewChildIterator( obj ) ); it->More();it->Next() ) {
+           _PTR(SObject) child ( it->Value() );
+           if ( child->FindAttribute( anAttr, "AttributeIOR" ) ) {
+             _PTR(AttributeIOR) anIOR( anAttr );
+
+             // Delete child( s ) shape in Client :
+             const TCollection_AsciiString ASCior( (char*)anIOR->Value().c_str() ) ;
+             getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCior );
+
+             for ( view = views.first(); view; view = views.next() ) { 
+               CORBA::Object_var corbaObj = (dynamic_cast<SALOMEDS_SObject*>(child.get()))->GetObject();
+               GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
+               if ( !CORBA::is_nil( geomObj ) )
+                 disp->Erase( geomObj, true, view );
+             }
+           }
+         } // for ( childres of obj )
+
+         // Erase main graphical object
+         for ( view = views.first(); view; view = views.next() ) 
+           disp->Erase( io, true, view );
+
+         // Delete main shape in Client :
+         if ( obj->FindAttribute( anAttr, "AttributeIOR" ) ) {
+           _PTR(AttributeIOR) anIOR( anAttr );
+           const TCollection_AsciiString ASCIor( (char*)anIOR->Value().c_str() ) ;
+           getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor );
+         }
+
+         // Remove objects from Study
+         aStudyBuilder->RemoveObject( obj );
+
+         CORBA::Object_var corbaObj = (dynamic_cast<SALOMEDS_SObject*>(obj.get()))->GetObject();
+         GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
+         if ( !CORBA::is_nil( geomObj ) )
+           GeometryGUI::GetGeomGen()->RemoveObject( geomObj );
       
-      deleted = true;
-    }
-  }   
-
-  if ( deleted )
-    op->finish();
-  else
-    op->abort();
-
-  // Clear any previous selection
-  Sel->ClearIObjects();
-  QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
-  */
+         //deleted = true;
+       } // MAIN LOOP of selected
+       
+       selected.Clear();
+       aSelMgr->setSelectedObjects( selected );
+       getGeometryGUI()->updateObjBrowser();
+      } // if ( selected not empty )
+    } // if ( selMgr && appStudy )
+  } // if ( app )
+
+  //  if ( deleted )
+  //    op->finish();
+  //  else
+  //    op->abort();
 }
 
 
@@ -558,6 +555,43 @@ bool GEOMToolsGUI::Export()
   return true; 
 }
 
+QString GEOMToolsGUI::getParentComponent( _PTR( Study ) study, const SALOME_ListIO& iobjs )
+{
+  QString parentComp;
+
+  for ( SALOME_ListIteratorOfListIO it( iobjs ); it.More(); it.Next() ) {
+
+    Handle(SALOME_InteractiveObject) io = it.Value();
+    if ( !io->hasEntry() ) 
+      continue;
+
+    QString compName = getParentComponent( study->FindObjectID( io->getEntry() ) );
+
+    if ( parentComp.isNull() )
+      parentComp = compName;
+    else if ( parentComp.compare( compName) != 0 ) { // objects belonging to different components are selected
+      parentComp = QString::null;
+      break;
+    }
+  }
+
+  return parentComp;
+}
+
+QString GEOMToolsGUI::getParentComponent( _PTR( SObject ) obj )
+{
+  if ( obj ) {
+    _PTR(SComponent) comp = obj->GetFatherComponent();
+    if ( comp ) {
+      _PTR(GenericAttribute) anAttr;
+      if ( comp->FindAttribute( anAttr, "AttributeName") ) {
+       _PTR(AttributeName) aName( anAttr );
+       return QString( aName->Value().c_str() );
+      }
+    }
+  }
+  return QString();
+}
 
 //=====================================================================================
 // EXPORTED METHODS
index 626a70cc7a8fe029ad9009b1a8c7d9b2b4275b47..611a6fd623e6a916efd3ae9e4305769253b8082f 100644 (file)
 
 #include "GEOMGUI.h"
 
+#include <SALOMEDSClient.hxx>
+#include <SALOMEDS_Study.hxx>
+#include <SALOME_ListIO.hxx>
+
+
 //=================================================================================
 // class    : GEOMToolsGUI
 // purpose  :
@@ -44,7 +49,7 @@ public :
   bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent );
 
 private:
-  /* Import and export topology methods */
+  // Import and export topology methods
   bool Import();
   bool Export(); 
   
@@ -63,6 +68,11 @@ private:
   void OnTransparency();
   void OnNbIsos();
   void OnOpen();
+
+  // returns name of Module (Component) of given objects (usually selected objects)
+  // if objects belong to different Components, a NULL string is returned. 
+  QString getParentComponent( _PTR( Study ), const SALOME_ListIO& );
+  QString getParentComponent( _PTR(SObject) );
 };
 
 #endif
index 1f455c67ba2458457a9de49b32736a34621ef44e..a3fc3e0401e1ca461d8377f729c1e4e67f031fc3 100644 (file)
@@ -32,6 +32,7 @@
 #include "GEOMBase.h"
 #include "GEOMToolsGUI_TransparencyDlg.h"
 #include "GEOMToolsGUI_NbIsosDlg.h"        // Method ISOS adjustement
+#include "GEOMToolsGUI_NameDlg.h"
 
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
 #include <SUIT_OverrideCursor.h>
+#include <SUIT_MessageBox.h>
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Module.h>
 
 #include <AIS_Drawer.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -158,40 +162,46 @@ void GEOMToolsGUI::OnSettingsStep()
 
 void GEOMToolsGUI::OnRename()
 {
-/*
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-  
-  bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
-  if ( aLocked ) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                           QObject::tr("WRN_WARNING"), 
-                           QObject::tr("WRN_STUDY_LOCKED"),
-                           QObject::tr("BUT_OK") );
-    return;
-  }
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+    if ( aSelMgr && appStudy ) {
+      aSelMgr->selectedObjects( selected );
+      if ( !selected.IsEmpty() ) {
+       _PTR(Study) aStudy = appStudy->studyDS();
+
+       bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
+       if ( aLocked ) {
+         SUIT_MessageBox::warn1 ( app->desktop(),
+                                  QObject::tr("WRN_WARNING"), 
+                                  QObject::tr("WRN_STUDY_LOCKED"),
+                                  QObject::tr("BUT_OK") );
+         return;
+       }
   
-  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-  for(; It.More(); It.Next()) {
-    Handle(SALOME_InteractiveObject) IObject = It.Value();
+       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+         Handle(SALOME_InteractiveObject) IObject = It.Value();
     
-    _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
-    _PTR(GenericAttribute) anAttr;
-    if(obj) {
-      if(obj->FindAttribute(anAttr, "AttributeName")) {
-       _PTR(AttributeName) aName (anAttr);
+         _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
+         _PTR(GenericAttribute) anAttr;
+         if ( obj ) {
+           if( obj->FindAttribute(anAttr, "AttributeName") ) {
+             _PTR(AttributeName) aName (anAttr);
        
-       QString nm = QString(aName->Value().c_str());
-       nm = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), nm);
-       if(!nm.isEmpty()) {
-         QApplication::setOverrideCursor(Qt::waitCursor);
-         QAD_Application::getDesktop()->getActiveStudy()->renameIObject(IObject, nm);
-         QApplication::restoreOverrideCursor();
-       }
+             QString newName = GEOMToolsGUI_NameDlg::getName( app->desktop(), aName->Value().c_str() );
+             if ( !newName.isEmpty() ) {
+               aName->SetValue( newName.latin1() ); // rename the SObject
+               IObject->setName( newName.latin1() );// rename the InteractiveObject
+               (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
+             }
+           } // if ( name attribute )
+         } // if ( obj )
+       } // iterator
       }
     }
   }
-*/
 }
 
 void GEOMToolsGUI::OnCheckGeometry()
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.cxx
new file mode 100644 (file)
index 0000000..2bcb291
--- /dev/null
@@ -0,0 +1,134 @@
+//  SALOME GEOMToolsGUI : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : GEOMToolsGUI_NameDlg.cxx
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#include "GEOMToolsGUI_NameDlg.h"
+
+#include <SUIT_Session.h>
+#include <SUIT_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Tools.h>
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+using namespace std;
+
+/*!
+  Constructor
+*/
+GEOMToolsGUI_NameDlg::GEOMToolsGUI_NameDlg( QWidget* parent )
+    : QDialog( parent ? parent : SUIT_Session::session()->activeApplication()->desktop(), 
+              "GEOMToolsGUI_NameDlg", 
+              true, 
+              WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+  setCaption( tr("TLT_RENAME") );
+  setSizeGripEnabled( TRUE );
+  
+  QVBoxLayout* topLayout = new QVBoxLayout( this );
+  topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
+
+  /***************************************************************/
+  QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
+  GroupC1->setColumnLayout(0, Qt::Vertical );
+  GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );
+  QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );
+  GroupC1Layout->setAlignment( Qt::AlignTop );
+  GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );
+  
+  QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );
+  TextLabel->setText( tr( "NAME_LBL" ) );
+  GroupC1Layout->addWidget( TextLabel );
+  
+  myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );
+  myLineEdit->setMinimumSize( 250, 0 );
+  GroupC1Layout->addWidget( myLineEdit );
+  
+  /***************************************************************/
+  QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+  GroupButtons->setColumnLayout(0, Qt::Vertical );
+  GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); 
+  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
+  
+  myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
+  myButtonOk->setText( tr( "BUT_OK"  ) );
+  myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );
+  GroupButtonsLayout->addWidget( myButtonOk );
+
+  GroupButtonsLayout->addStretch();
+  
+  myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
+  myButtonCancel->setText( tr( "BUT_CANCEL"  ) );
+  myButtonCancel->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( myButtonCancel );
+  /***************************************************************/
+  
+  topLayout->addWidget( GroupC1 );
+  topLayout->addWidget( GroupButtons );
+  
+  // signals and slots connections
+  connect( myButtonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  
+  /* Move widget on the botton right corner of main widget */
+  SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+  Destructor
+*/
+GEOMToolsGUI_NameDlg::~GEOMToolsGUI_NameDlg()
+{
+}
+
+/*!
+  Sets name
+*/
+void GEOMToolsGUI_NameDlg::setName( const QString& name )
+{
+  myLineEdit->setText( name );
+  myLineEdit->end(false);
+  myLineEdit->home(true);
+}
+
+/*!
+  Returns name entered by user
+*/
+QString GEOMToolsGUI_NameDlg::name()
+{
+  return myLineEdit->text();
+}
+
+void GEOMToolsGUI_NameDlg::accept()
+{
+  if ( name().stripWhiteSpace().isEmpty() )
+    return;
+  QDialog::accept();
+}
+
+/*!
+  Creates modal <Rename> dialog and returns name entered [ static ]
+*/
+QString GEOMToolsGUI_NameDlg::getName( QWidget* parent, const QString& oldName )
+{
+  QString n;
+  GEOMToolsGUI_NameDlg* dlg = new GEOMToolsGUI_NameDlg( parent );
+  if ( !oldName.isNull() )
+    dlg->setName( oldName );
+  if ( dlg->exec() == QDialog::Accepted ) 
+    n = dlg->name();
+  delete dlg;
+  return n;
+}
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.h
new file mode 100644 (file)
index 0000000..e9071d6
--- /dev/null
@@ -0,0 +1,46 @@
+//  SALOME GEOMToolsGUI : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : GEOMToolsGUI_NameDlg.h
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#ifndef GEOMToolsGUI_NAMEDLG_H
+#define GEOMToolsGUI_NAMEDLG_H
+
+#include <qdialog.h>
+
+class QLineEdit;
+class QPushButton;
+
+//=================================================================================
+// class    : GEOMToolsGUI_NameDlg
+// purpose  : Common <Rename> dialog box class
+//=================================================================================
+class GEOMToolsGUI_NameDlg : public QDialog
+{ 
+  Q_OBJECT
+
+public:
+  GEOMToolsGUI_NameDlg( QWidget* parent = 0 );
+  ~GEOMToolsGUI_NameDlg();
+    
+  void            setName( const QString& name );
+  QString         name();
+    
+  static QString  getName( QWidget* parent = 0, const QString& oldName = QString::null );
+    
+protected slots:
+  void accept();
+  
+private:
+  QPushButton*    myButtonOk;
+  QPushButton*    myButtonCancel;
+  QLineEdit*      myLineEdit;
+};
+
+#endif // GEOMToolsGUI_NAMEDLG_H
index 29290e11d5e973b7a7dccd546adf2707c5c2f370..1dac4b1abdf385e03ef4b94c80b09000504a8c21 100644 (file)
@@ -43,11 +43,12 @@ EXPORT_HEADERS=
 LIB_SRC =      GEOMToolsGUI.cxx \
                GEOMToolsGUI_1.cxx \
                GEOMToolsGUI_TransparencyDlg.cxx \
-               GEOMToolsGUI_NbIsosDlg.cxx
+               GEOMToolsGUI_NbIsosDlg.cxx \
+               GEOMToolsGUI_NameDlg.cxx
 
-LIB_MOC =      GEOMToolsGUI.h \
-               GEOMToolsGUI_TransparencyDlg.h \
-               GEOMToolsGUI_NbIsosDlg.h 
+LIB_MOC =      GEOMToolsGUI_TransparencyDlg.h \
+               GEOMToolsGUI_NbIsosDlg.h \
+               GEOMToolsGUI_NameDlg.h
 
 LIB_CLIENT_IDL = SALOMEDS_Attributes.idl \
                 SALOME_GenericObj.idl \