Salome HOME
Avoid compilation problem because of using standard libraries
[modules/geom.git] / src / RepairGUI / RepairGUI_CloseContourDlg.cxx
index ac98b0de8d06847dc3f09db891f77f0b39050098..d24f6f31b47d0c671998a091e4abdff385e9545b 100644 (file)
@@ -1,48 +1,45 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+// GEOM GEOMGUI : GUI for Geometry component
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 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 free software; you can redistribute it and/or 
+// modify it under the terms of the GNU Lesser General Public 
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License. 
 // 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
+// This library is distributed in the hope that it will be useful, 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details. 
 // 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// You should have received a copy of the GNU Lesser General Public 
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// File   : RepairGUI_CloseContourDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
 //
-//
-//  File   : RepairGUI_CloseContourDlg.cxx
-//  Author : Lucien PIGNOLONI
-//  Module : GEOM
-//  $Header$
 
 #include "RepairGUI_CloseContourDlg.h"
 
-#include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
-#include "SUIT_Session.h"
-#include "SALOME_ListIteratorOfListIO.hxx"
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
 
-#include "GEOMImpl_Types.hxx"
+#include <GEOMImpl_Types.hxx>
 
 #include <TopAbs.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 #include <TColStd_MapOfInteger.hxx>
 
-#include <qlabel.h>
-
-using namespace std;
-
 //=================================================================================
 // class    : RepairGUI_CloseContourDlg()
 // purpose  : Constructs a RepairGUI_CloseContourDlg  which is a child of 'parent', with the
@@ -50,57 +47,54 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg(QWidget* parent, const char* name, bool modal, WFlags fl)
-  :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+RepairGUI_CloseContourDlg::RepairGUI_CloseContourDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+                                                     bool modal )
+  : GEOMBase_Skeleton( theGeometryGUI, parent, modal )
 {
-  QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CLOSECONTOUR")));
-  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CLOSECONTOUR" ) ) );
+  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
 
-  setCaption(tr("GEOM_CLOSECONTOUR_TITLE"));
+  setWindowTitle( tr( "GEOM_CLOSECONTOUR_TITLE" ) );
 
   /***************************************************************/
-  GroupConstructors->setTitle(tr("GEOM_CLOSECONTOUR_TITLE"));
-  RadioButton1->setPixmap(image0);
-  RadioButton2->close(TRUE);
-  RadioButton3->close(TRUE);
-
-  GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints");
-  GroupPoints->GroupBox1->setTitle(tr("Contour to close"));
-  GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
-  GroupPoints->PushButton1->setPixmap(image1);
+  mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CLOSECONTOUR_TITLE" ) );
+  mainFrame()->RadioButton1->setIcon( image0 );
+  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton3->close();
+
+  GroupPoints = new DlgRef_2SelExt( centralWidget() );
+  GroupPoints->GroupBox1->setTitle( tr( "Contour to close" ) );
+  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
+  GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->LineEdit1->setReadOnly( true );
 
-  QGridLayout* aSelectWiresLay = new QGridLayout( 0, 1, 1, 0, 6, "aSelectWiresLay");
+  GroupPoints->TextLabel2->setText( tr( "Contour to close" ) );
+  GroupPoints->PushButton2->setIcon( image1 );
+  GroupPoints->LineEdit2->setReadOnly( true );
 
-  mySelectWiresBtn = new QPushButton( GroupPoints->GroupBox1, "mySelectWiresBtn" );
-  mySelectWiresBtn->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresBtn->sizePolicy().hasHeightForWidth() ) );
-  mySelectWiresBtn->setText( trUtf8( "" ) );
-  mySelectWiresBtn->setPixmap(image1);
+  QRadioButton* rb1 = new QRadioButton( tr( "Close by common vertex" ), GroupPoints->Box );
+  QRadioButton* rb2 = new QRadioButton( tr( "Close by new edge" ),      GroupPoints->Box );
 
-  mySelectWiresEdt = new QLineEdit( GroupPoints->GroupBox1, "mySelectWiresEdt" );
-  mySelectWiresEdt->setReadOnly( true );
+  myIsVertexGr = new QButtonGroup( GroupPoints->Box );
+  myIsVertexGr->addButton( rb1, 0 );
+  myIsVertexGr->addButton( rb2, 1 );
+  rb1->setChecked( true );
 
-  mySelectWiresLbl = new QLabel( tr( "Contour to close" ), GroupPoints->GroupBox1, "ContourLbl" );
-  mySelectWiresLbl->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresLbl->sizePolicy().hasHeightForWidth() ) );
+  QVBoxLayout* l = new QVBoxLayout( GroupPoints->Box );
+  l->setMargin( 0 ); l->setSpacing( 6 );
+  l->addWidget( rb1 );
+  l->addWidget( rb2 );
 
-  aSelectWiresLay->addWidget( mySelectWiresLbl, 0, 0 );
-  aSelectWiresLay->addWidget( mySelectWiresBtn, 0, 1 );
-  aSelectWiresLay->addWidget( mySelectWiresEdt, 0, 2 );
-  QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding );
-  aSelectWiresLay->addItem( spacer, 1, 2 );
+  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+  layout->setMargin( 0 ); layout->setSpacing( 6 );
+  layout->addWidget( GroupPoints );
 
-  myIsVertexGr = new QButtonGroup( 2, Qt::Vertical, GroupPoints );
-  myIsVertexGr->setFrameStyle( QFrame::NoFrame );
-  myIsVertexGr->setRadioButtonExclusive( true );
-  myIsVertexGr->insert( new QRadioButton( tr( "Close by common vertex" ), myIsVertexGr ), 0 );
-  myIsVertexGr->insert( new QRadioButton( tr( "Close by new edge" ), myIsVertexGr ), 1 );
-  myIsVertexGr->find( 0 )->toggle();
-
-  Layout1->addWidget(GroupPoints, 2, 0);
-  GroupPoints->getGroupBoxLayout()->addLayout( aSelectWiresLay, 1, 0 );
-  GroupPoints->getGroupBoxLayout()->addMultiCellWidget(myIsVertexGr, 2, 2, 0, 2);
   /***************************************************************/
 
+  setHelpFileName( "close_contour_operation_page.html" );
+
   Init();
 }
 
@@ -131,20 +125,16 @@ void RepairGUI_CloseContourDlg::Init()
   initSelection();
 
   /* signals and slots connections */
-  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
-  connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
-  connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
+  connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
 
-  connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
-  connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+  connect( GroupPoints->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupPoints->PushButton2, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupPoints->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( GroupPoints->LineEdit2,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
 
-  connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(mySelectWiresBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(mySelectWiresEdt, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect( myGeomGUI->getApp()->selectionMgr(), 
+          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   initName( tr( "CLOSE_CONTOUR_NEW_OBJ_NAME" ) );
 }
@@ -174,7 +164,7 @@ bool RepairGUI_CloseContourDlg::ClickOnApply()
   initName();
 
   myEditCurrentArgument = GroupPoints->LineEdit1;
-  myEditCurrentArgument->setText("");
+  myEditCurrentArgument->setText( "" );
   myObject = GEOM::GEOM_Object::_nil();
   myWiresInd->length( 0 );
 
@@ -183,16 +173,6 @@ bool RepairGUI_CloseContourDlg::ClickOnApply()
   return true;
 }
 
-
-//=================================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=================================================================================
-void RepairGUI_CloseContourDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection as changed or other case
@@ -202,35 +182,31 @@ void RepairGUI_CloseContourDlg::SelectionIntoArgument()
 {
   erasePreview();
   myEditCurrentArgument->setText( "" );
-  mySelectWiresEdt->setText( "" );
+  GroupPoints->LineEdit2->setText( "" );
   
   if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
     myObject = GEOM::GEOM_Object::_nil();
-  else if ( myEditCurrentArgument == mySelectWiresEdt )
+  else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
     myWiresInd->length( 0 );
 
-  if ( IObjectCount() == 1 )
-  {
+  if ( IObjectCount() == 1 ) {
     Handle(SALOME_InteractiveObject) anIO = firstIObject();
 
-    if ( myEditCurrentArgument == GroupPoints->LineEdit1 )  // face selection
-    {
+    if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { // face selection
       Standard_Boolean aRes;
       myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
-      if ( aRes && GEOMBase::IsShape( myObject ) )
-      {
+      if ( aRes && GEOMBase::IsShape( myObject ) ) {
         myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
         TopoDS_Shape aShape;
-        if ( myGeomBase->GetShape( myObject, aShape, TopAbs_WIRE ) )
-          mySelectWiresEdt->setText( myEditCurrentArgument->text() );
+        if ( GEOMBase::GetShape( myObject, aShape, TopAbs_WIRE ) )
+          GroupPoints->LineEdit2->setText( myEditCurrentArgument->text() );
       }
       else
         myObject = GEOM::GEOM_Object::_nil();
     }
-    else if ( myEditCurrentArgument == mySelectWiresEdt )
-    {
+    else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
       TColStd_IndexedMapOfInteger aMap;
-      ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
+      myGeomGUI->getApp()->selectionMgr()->GetIndexes( anIO, aMap );
       const int n = aMap.Extent();
       myWiresInd->length( n );
       for ( int i = 1; i <= n; i++ )
@@ -250,10 +226,9 @@ void RepairGUI_CloseContourDlg::SetEditCurrentArgument()
   const QObject* send = sender();
   if ( send == GroupPoints->PushButton1 )
     myEditCurrentArgument = GroupPoints->LineEdit1; 
-  else if ( send == mySelectWiresBtn && !myObject->_is_nil() )
-    myEditCurrentArgument = mySelectWiresEdt;
-  if ( myEditCurrentArgument )
-  {
+  else if ( send == GroupPoints->PushButton2 && !myObject->_is_nil() )
+    myEditCurrentArgument = GroupPoints->LineEdit2;
+  if ( myEditCurrentArgument ) {
     initSelection();
     myEditCurrentArgument->setFocus();
     SelectionIntoArgument();
@@ -268,25 +243,13 @@ void RepairGUI_CloseContourDlg::SetEditCurrentArgument()
 void RepairGUI_CloseContourDlg::LineEditReturnPressed()
 {
   const QObject* send = sender();
-  if( send == GroupPoints->LineEdit1 || send == mySelectWiresEdt )
-  {
+  if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) {
     myEditCurrentArgument = (QLineEdit*)send;
     GEOMBase_Skeleton::LineEditReturnPressed();
   }
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void RepairGUI_CloseContourDlg::DeactivateActiveDialog()
-{
-  //myGeomGUI->SetState( -1 );
-  GEOMBase_Skeleton::DeactivateActiveDialog();
-}
-
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -294,12 +257,12 @@ void RepairGUI_CloseContourDlg::DeactivateActiveDialog()
 void RepairGUI_CloseContourDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect( myGeomGUI->getApp()->selectionMgr(), 
+          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   myEditCurrentArgument = GroupPoints->LineEdit1;
-  myEditCurrentArgument->setText("");
-  mySelectWiresEdt->setText("");
+  myEditCurrentArgument->setText( "" );
+  GroupPoints->LineEdit2->setText( "" );
   myObject = GEOM::GEOM_Object::_nil();
   myWiresInd->length( 0 );
 
@@ -312,23 +275,13 @@ void RepairGUI_CloseContourDlg::ActivateThisDialog()
 // function : enterEvent()
 // purpose  : Mouse enter onto the dialog to activate it
 //=================================================================================
-void RepairGUI_CloseContourDlg::enterEvent(QEvent* e)
+void RepairGUI_CloseContourDlg::enterEvent( QEvent* )
 {
-  if ( !GroupConstructors->isEnabled() )
+  if ( !mainFrame()->GroupConstructors->isEnabled() )
     ActivateThisDialog();
 }
 
 
-//=================================================================================
-// function : closeEvent()
-// purpose  :
-//=================================================================================
-void RepairGUI_CloseContourDlg::closeEvent(QCloseEvent* e)
-{
-  //myGeomGUI->SetState( -1 );
-  GEOMBase_Skeleton::closeEvent( e );
-}
-
 //=================================================================================
 // function : createOperation
 // purpose  :
@@ -342,10 +295,10 @@ GEOM::GEOM_IOperations_ptr RepairGUI_CloseContourDlg::createOperation()
 // function : isValid
 // purpose  :
 //=================================================================================
-bool RepairGUI_CloseContourDlg::isValid( QString& msg )
+bool RepairGUI_CloseContourDlg::isValid( QString& )
 {
   TopoDS_Shape aTmpShape;
-  return !myObject->_is_nil() && ( myWiresInd->length() || myGeomBase->GetShape( myObject, aTmpShape, TopAbs_WIRE ) );
+  return !myObject->_is_nil() && ( myWiresInd->length() || GEOMBase::GetShape( myObject, aTmpShape, TopAbs_WIRE ) );
 }
 
 //=================================================================================
@@ -368,7 +321,7 @@ bool RepairGUI_CloseContourDlg::execute( ObjectList& objects )
 //=================================================================================
 bool RepairGUI_CloseContourDlg::getIsByVertex() const
 {
-  return myIsVertexGr->find( 0 )->isOn();
+  return myIsVertexGr->button( 0 )->isChecked();
 }
 
 //=================================================================================
@@ -377,8 +330,7 @@ bool RepairGUI_CloseContourDlg::getIsByVertex() const
 //=================================================================================
 void RepairGUI_CloseContourDlg::initSelection()
 {
-  if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
-  {
+  if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
     TColStd_MapOfInteger aTypes;
     aTypes.Add( GEOM_COMPOUND );
     aTypes.Add( GEOM_SOLID );
@@ -388,11 +340,8 @@ void RepairGUI_CloseContourDlg::initSelection()
     
     globalSelection( aTypes );
   }
-  else if ( myEditCurrentArgument == mySelectWiresEdt )
-  {
+  else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
     localSelection( myObject, TopAbs_EDGE );
     localSelection( myObject, TopAbs_WIRE );
   }
 }
-
-