Salome HOME
Fix for bug PAL12858(EDF210 GEOM Preferences menu of GEOM: color of the wireframe?)
[modules/geom.git] / src / RepairGUI / RepairGUI_DivideEdgeDlg.cxx
index e9f3730098ed1b03991a8b689e3d0d504f28b64f..648ae2fe961c58d970b1e7fd485947eede9f2871 100644 (file)
@@ -1,23 +1,23 @@
 //  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 
-// 
-//  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 
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 //  Module : GEOM
 //  $Header$
 
-using namespace std;
 #include "RepairGUI_DivideEdgeDlg.h"
 
 #include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SUIT_Session.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
 
@@ -40,6 +39,8 @@ using namespace std;
 
 #include <qlabel.h>
 
+using namespace std;
+
 //=================================================================================
 // class    : RepairGUI_DivideEdgeDlg()
 // purpose  : Constructs a RepairGUI_DivideEdgeDlg  which is a child of 'parent', with the
@@ -47,8 +48,10 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg(QWidget* parent, const char* name, bool modal, WFlags fl)
-  :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
+                                                  const char* name, bool modal, WFlags fl)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
+                      WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
   QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_DIVIDE_EDGE")));
   QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
@@ -75,7 +78,7 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg(QWidget* parent, const char* na
   myIsParameterGr->find( 0 )->toggle();
 
   QGridLayout* aLay = new QGridLayout( 0, 1, 2, 0, 6, "aLay" );
-  myValEdt = new QtxDblSpinBox(0., 1., 0.1, GroupPoints->GroupBox1);// QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0., 1., 0.1, 3 );
+  myValEdt = new QtxDblSpinBox(0., 1., 0.1, GroupPoints->GroupBox1);
   myValEdt->setPrecision( 3 );
   myValEdt->setValue( 0.5 );
   QLabel* aLbl1 = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->GroupBox1 );
@@ -87,10 +90,11 @@ RepairGUI_DivideEdgeDlg::RepairGUI_DivideEdgeDlg(QWidget* parent, const char* na
   GroupPoints->getGroupBoxLayout()->addLayout( aLay, 2, 0 );
   /***************************************************************/
 
+  setHelpFileName("add_point_on_edge.htm");
+
   Init();
 }
 
-
 //=================================================================================
 // function : ~RepairGUI_DivideEdgeDlg()
 // purpose  : Destroys the object and frees any allocated resources
@@ -99,7 +103,6 @@ RepairGUI_DivideEdgeDlg::~RepairGUI_DivideEdgeDlg()
 {
 }
 
-
 //=================================================================================
 // function : Init()
 // purpose  :
@@ -116,18 +119,14 @@ void RepairGUI_DivideEdgeDlg::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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
 
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) );
 }
@@ -144,7 +143,6 @@ void RepairGUI_DivideEdgeDlg::ClickOnOk()
 }
 
 
-
 //=================================================================================
 // function : ClickOnApply()
 // purpose  :
@@ -152,7 +150,7 @@ void RepairGUI_DivideEdgeDlg::ClickOnOk()
 bool RepairGUI_DivideEdgeDlg::ClickOnApply()
 {
   if ( !onAccept() )
-       return false;
+    return false;
 
   initName();
 
@@ -166,16 +164,6 @@ bool RepairGUI_DivideEdgeDlg::ClickOnApply()
 }
 
 
-//=================================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=================================================================================
-void RepairGUI_DivideEdgeDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection as changed or other case
@@ -196,34 +184,36 @@ void RepairGUI_DivideEdgeDlg::SelectionIntoArgument()
     if ( !CORBA::is_nil( aSelectedObj ) && aRes )
     {
       TopoDS_Shape aShape;
-      if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
+      if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
       {
-       const int aType = aShape.ShapeType();
-       if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound
-         {
-           GEOM::short_array anIndexes;
-           
-           TColStd_IndexedMapOfInteger aMap;
-           ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( anIO, aMap );
-
-           if ( !aMap.IsEmpty() ) // subshape selection
-             {
-             myIndex = aMap( 1 );
-             myObject = aSelectedObj;
-             myEditCurrentArgument->setText( tr( "GEOM_EDGE" ) + "_1" );
-             }
-             else if ( aType == TopAbs_EDGE ) // single shape selection
-             {
-             myIndex = -1;
-             myObject = aSelectedObj;
-             myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
-             }
-             else // face, shell, solid or compound was selected, and NOT its subshape.
-             {
-             myIndex = -1;
-             myObject = GEOM::GEOM_Object::_nil();
-             }
-         }
+        const int aType = aShape.ShapeType();
+        if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound
+        {
+          GEOM::short_array anIndexes;
+
+          TColStd_IndexedMapOfInteger aMap;
+          SalomeApp_Application* anApp =
+            (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
+          anApp->selectionMgr()->GetIndexes( anIO, aMap );
+
+          if ( !aMap.IsEmpty() ) // subshape selection
+          {
+            myIndex = aMap( 1 );
+            myObject = aSelectedObj;
+            myEditCurrentArgument->setText( tr( "GEOM_EDGE" ) + "_1" );
+          }
+          else if ( aType == TopAbs_EDGE ) // single shape selection
+          {
+            myIndex = -1;
+            myObject = aSelectedObj;
+            myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
+          }
+          else // face, shell, solid or compound was selected, and NOT its subshape.
+          {
+            myIndex = -1;
+            myObject = GEOM::GEOM_Object::_nil();
+          }
+        }
       }
     }
   }
@@ -253,19 +243,8 @@ void RepairGUI_DivideEdgeDlg::LineEditReturnPressed()
   if( sender() == GroupPoints->LineEdit1 )
   {
     myEditCurrentArgument = GroupPoints->LineEdit1;
-         GEOMBase_Skeleton::LineEditReturnPressed();
-       }
-}
-
-
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void RepairGUI_DivideEdgeDlg::DeactivateActiveDialog()
-{
-  //myGeomGUI->SetState( -1 );
-  GEOMBase_Skeleton::DeactivateActiveDialog();
+    GEOMBase_Skeleton::LineEditReturnPressed();
+  }
 }
 
 
@@ -276,8 +255,8 @@ void RepairGUI_DivideEdgeDlg::DeactivateActiveDialog()
 void RepairGUI_DivideEdgeDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   myObject = GEOM::GEOM_Object::_nil();
   myIndex = -1;
@@ -286,7 +265,6 @@ void RepairGUI_DivideEdgeDlg::ActivateThisDialog()
   initSelection();
 }
 
-
 //=================================================================================
 // function : enterEvent()
 // purpose  : Mouse enter onto the dialog to activate it
@@ -297,7 +275,6 @@ void RepairGUI_DivideEdgeDlg::enterEvent(QEvent* e)
     ActivateThisDialog();
 }
 
-
 //=================================================================================
 // function : closeEvent()
 // purpose  :
@@ -308,6 +285,7 @@ void RepairGUI_DivideEdgeDlg::closeEvent(QCloseEvent* e)
   GEOMBase_Skeleton::closeEvent( e );
 }
 
+
 //=================================================================================
 // function : createOperation
 // purpose  :
@@ -323,7 +301,7 @@ GEOM::GEOM_IOperations_ptr RepairGUI_DivideEdgeDlg::createOperation()
 //=================================================================================
 bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
 {
-       return !myObject->_is_nil();
+  return !myObject->_is_nil();
 }
 
 //=================================================================================
@@ -332,13 +310,13 @@ bool RepairGUI_DivideEdgeDlg::isValid( QString& msg )
 //=================================================================================
 bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
 {
-       GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->DivideEdge(
-               myObject, myIndex, myValEdt->value(), getIsByParameter() );
-       bool aResult = !anObj->_is_nil();
-       if ( aResult )
-               objects.push_back( anObj._retn() );
+  GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->DivideEdge
+    ( myObject, myIndex, myValEdt->value(), getIsByParameter() );
+  bool aResult = !anObj->_is_nil();
+  if ( aResult )
+    objects.push_back( anObj._retn() );
 
-       return aResult;
+  return aResult;
 }
 
 //=================================================================================
@@ -347,7 +325,7 @@ bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects )
 //=================================================================================
 bool RepairGUI_DivideEdgeDlg::getIsByParameter() const
 {
-       return myIsParameterGr->find( 0 )->isOn();
+  return myIsParameterGr->find( 0 )->isOn();
 }
 
 //=================================================================================
@@ -359,6 +337,3 @@ void RepairGUI_DivideEdgeDlg::initSelection()
   GEOM::GEOM_Object_var aNullGeomObject;
   localSelection( aNullGeomObject, TopAbs_EDGE ); // load local selection on ALL objects
 }
-
-
-