Salome HOME
0022751: [EDF] Publish results of the Check Free Faces operation
authorskv <skv@opencascade.com>
Thu, 9 Oct 2014 13:30:30 +0000 (17:30 +0400)
committervsr <vsr@opencascade.com>
Thu, 13 Nov 2014 11:10:07 +0000 (14:10 +0300)
doc/salome/gui/GEOM/images/repair10.png
doc/salome/gui/GEOM/input/free_faces.doc
src/GEOMGUI/GEOM_msg_en.ts
src/RepairGUI/RepairGUI_FreeFacesDlg.cxx
src/RepairGUI/RepairGUI_FreeFacesDlg.h

index ccdebd77b60674cc9bbcc4a6e3fed88cd7b5e0f7..9c67419a585812dadf59ce6a9cf5893769481ce7 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/repair10.png and b/doc/salome/gui/GEOM/images/repair10.png differ
index a5996032b43c87c728f8ecd4d9dc6d50fd3ec6c0..f51ece8b218078fe0d8f8c359ff26e096e2d3f5a 100644 (file)
@@ -8,6 +8,8 @@ A free face is a face, which is not shared between several sub-shapes of the sha
 
 \image html repair10.png
 
+Press \b Apply or <b>Apply and Close</b> button to publish the corresponding faces in the study. 
+
 <b>TUI Command:</b> <em>GetFreeFacesIDs(Shape),</em> where \em Shape is
 a shape to be checked.
 
@@ -15,4 +17,4 @@ a shape to be checked.
 
 See also a \ref tui_free_faces_page "TUI example".
 
-*/
\ No newline at end of file
+*/
index 06cb15a74c071a260c0e206a28cc4996213dac93..cc359f60e8933a3e9808a696cc0876548ed12d4c 100644 (file)
@@ -836,6 +836,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_FREE_FACES</source>
         <translation>Free faces</translation>
     </message>
+    <message>
+        <source>GEOM_FREE_FACES_NAME</source>
+        <translation>Free_face</translation>
+    </message>
     <message>
         <source>GEOM_FREE_FACES_TITLE</source>
         <translation>Free faces</translation>
index 8fe66a4bdab3586484ae59a2b7f2448d3ed7214a..051ca495a1e6c7084a1d08f5755bb2e703d56355 100644 (file)
 //
 #include "RepairGUI_FreeFacesDlg.h"
 
+#include <GEOMBase.h>
+#include <GeometryGUI.h>
+#include <GEOMImpl_Types.hxx>
+#include <GEOM_Constants.h>
+
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Application.h>
-#include <SalomeApp_Tools.h>
 #include <SalomeApp_Study.h>
-
-#include <SUIT_MessageBox.h>
-#include <SUIT_Session.h>
-#include <SUIT_OverrideCursor.h>
+#include <SalomeApp_Tools.h>
 #include <SUIT_Desktop.h>
+#include <SUIT_OverrideCursor.h>
 #include <SUIT_ResourceMgr.h>
-#include <SUIT_ViewWindow.h>
+#include <SUIT_Session.h>
 #include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
 
-#include <GEOMImpl_Types.hxx>
-#include <GEOM_Constants.h>
-
-#include <TopTools_IndexedMapOfShape.hxx>
 #include <TColStd_MapOfInteger.hxx>
 #include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
-#include <GEOMBase.h>
-#include <GeometryGUI.h>
-#include <GEOM_Displayer.h>
-
-#include <QLineEdit>
-#include <QLabel>
 #include <QGroupBox>
-#include <QPushButton>
 #include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QRadioButton>
 #include <QVBoxLayout>
-#include <QKeyEvent>
+
 
 #define SPACING 6
 #define MARGIN  9
 //            TRUE to construct a modal dialog.
 //=================================================================================
 RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* parent,
-                                                bool modal )
-  : QDialog( parent, 0 ),
-    GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
-    myGeomGUI( GUI ), 
-    myDisplayer( 0 )
+                                                bool modal)
+  : GEOMBase_Skeleton(GUI, parent, modal),
+    myDisplayer      (0),
+    myEdit           (0)
 {
-  setAttribute( Qt::WA_DeleteOnClose );
-
-  setSizeGripEnabled( true );
-
+  QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FREE_FACES")));
   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
 
   setWindowTitle( tr( "GEOM_FREE_FACES_TITLE" ) );
 
   /***************************************************************/
 
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_FREE_FACES"));
+  mainFrame()->RadioButton1->setIcon(image0);
+  mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton3->close();
+
+  mainFrame()->GroupBoxName->hide();
+
   QGroupBox* aMainGrp = new QGroupBox( tr( "GEOM_SELECTED_SHAPE" ), this );
   
   QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp );
-  mySelBtn = new QPushButton( aMainGrp );
-  mySelBtn->setIcon( image1 );
+  QPushButton *aSelBtn = new QPushButton( aMainGrp );
+  aSelBtn->setIcon( image1 );
   myEdit = new QLineEdit( aMainGrp );
   myEdit->setReadOnly( true );
   myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
@@ -101,37 +103,19 @@ RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* paren
   aMainLay->setSpacing( SPACING );
   aMainLay->setMargin( MARGIN );
   aMainLay->addWidget( lab );
-  aMainLay->addWidget( mySelBtn );
+  aMainLay->addWidget( aSelBtn );
   aMainLay->addWidget( myEdit );
 
-  QFrame* aFrame = new QFrame( this );
-  aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
-  QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame );
-  QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame );
-
-  QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame );
-  aBtnLay->setSpacing( SPACING );
-  aBtnLay->setMargin( MARGIN );
-  aBtnLay->addWidget( aCloseBtn );
-  aBtnLay->addSpacing( SPACING );
-  aBtnLay->addStretch();
-  aBtnLay->addWidget( aHelpBtn );
-
-  QVBoxLayout* aLay = new QVBoxLayout( this );
-  aLay->setSpacing( SPACING );
-  aLay->setMargin( MARGIN );
-  aLay->addWidget( aMainGrp );
-  aLay->addStretch();
-  aLay->addWidget( aFrame );
-
-  myHelpFileName = "free_faces_page.html";
+  QVBoxLayout* aLay = new QVBoxLayout (centralWidget());
+  aLay->setSpacing(SPACING);
+  aLay->setMargin(MARGIN);
+  aLay->addWidget(aMainGrp);
 
-  connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) );
-  connect( aHelpBtn,  SIGNAL( clicked() ), SLOT( onHelp() ) );
-  connect( mySelBtn,  SIGNAL( clicked() ),
-           this,      SLOT  ( onSetEditCurrentArgument() ) );
+  resize(minimumSizeHint());
   /***************************************************************/
 
+  myHelpFileName = "free_faces_page.html";
+
   Init();
 }
 
@@ -146,92 +130,82 @@ RepairGUI_FreeFacesDlg::~RepairGUI_FreeFacesDlg()
 
 
 //=================================================================================
-// function : onClose
-// purpose  : SLOT. Called when "close" button pressed. Close dialog
+// function : Init()
+// purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::onClose()
+void RepairGUI_FreeFacesDlg::Init()
 {
-  globalSelection();
-  disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
-  myGeomGUI->SetActiveDialogBox( 0 );
-  reject();
-  erasePreview();
+  myObj = GEOM::GEOM_Object::_nil();
+  myEditCurrentArgument = myEdit;
+
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
+  initName(tr("GEOM_FREE_FACES_NAME"));
+  buttonOk()->setEnabled(false);
+  buttonApply()->setEnabled(false);
+  activateSelection();
+  SelectionIntoArgument();
 }
 
 //=================================================================================
-// function : onHelp()
+// function : ClickOnOk()
 // purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::onHelp()
+void RepairGUI_FreeFacesDlg::ClickOnOk()
 {
-  LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
-  if ( app )
-    app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName );
-  else {
-    QString platform;
-#ifdef WIN32
-    platform = "winapplication";
-#else
-    platform = "application";
-#endif
-    SUIT_MessageBox::warning( this, 
-                              tr( "WRN_WARNING" ),
-                              tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
-                              arg( app->resourceMgr()->stringValue( "ExternalBrowser", 
-                                                                    platform ) ).
-                              arg( myHelpFileName ) );
-  }
+  if (ClickOnApply())
+    ClickOnCancel();
 }
 
 //=================================================================================
-// function : onDeactivate
-// purpose  : Deactivate this dialog
+// function : ClickOnApply()
+// purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::onDeactivate()
+bool RepairGUI_FreeFacesDlg::ClickOnApply()
 {
-  setEnabled( false );
-  globalSelection();
-  disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
-  myGeomGUI->SetActiveDialogBox( 0 );
+  if (!onAccept())
+    return false;
+
+  initName();
+  return true;
 }
 
 //=================================================================================
-// function : onActivate
-// purpose  : Activate this dialog
+// function : ActivateThisDialog()
+// purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::onActivate()
+void RepairGUI_FreeFacesDlg::ActivateThisDialog()
 {
-  myGeomGUI->EmitSignalDeactivateDialog();
-  setEnabled( true );
-  myGeomGUI->SetActiveDialogBox( this );
-  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 
-           SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
+  GEOMBase_Skeleton::ActivateThisDialog();
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
   activateSelection();
+  displayPreview(true);
 }
 
 //=================================================================================
-// function : Init()
+// function : enterEvent()
 // purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::Init()
+void RepairGUI_FreeFacesDlg::enterEvent(QEvent*)
 {
-  myObj = GEOM::GEOM_Object::_nil();
-
-  /* signals and slots connections */
-  connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT  ( onDeactivate() ) );
-  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 
-           SIGNAL( currentSelectionChanged() ), SLOT  ( onSelectionDone() ) );
-
-  activateSelection();
-  onSelectionDone();
+  if (!mainFrame()->GroupConstructors->isEnabled())
+    ActivateThisDialog();
 }
 
 //=================================================================================
-// function : onSelectionDone
+// function : SelectionIntoArgument
 // purpose  : SLOT. Called when selection changed.
 //=================================================================================
-void RepairGUI_FreeFacesDlg::onSelectionDone()
+void RepairGUI_FreeFacesDlg::SelectionIntoArgument()
 {
+  myEditCurrentArgument->setText("");
+  myObj = GEOM::GEOM_Object::_nil();
   erasePreview();
 
   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@@ -239,7 +213,8 @@ void RepairGUI_FreeFacesDlg::onSelectionDone()
   aSelMgr->selectedObjects(aSelList);
 
   if ( aSelList.Extent() != 1 ) {
-    myEdit->setText( "" );
+    buttonOk()->setEnabled(false);
+    buttonApply()->setEnabled(false);
     return;
   }
 
@@ -247,27 +222,19 @@ void RepairGUI_FreeFacesDlg::onSelectionDone()
     GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
 
   if ( !GEOMBase::IsShape( anObj ) ) {
-    myEdit->setText( "" );
+    buttonOk()->setEnabled(false);
+    buttonApply()->setEnabled(false);
     return;
-  }
-  else {
+  } else {
     myObj = anObj;
+    myEditCurrentArgument->setText(GEOMBase::GetName(myObj));
     displayPreview( true, false, true, true, 3 );
   }
 }
 
-//=================================================================================
-// function : enterEvent()
-// purpose  : Mouse enter onto the dialog to activate it
-//=================================================================================
-void RepairGUI_FreeFacesDlg::enterEvent( QEvent* )
-{
-  onActivate();
-}
-
 //=================================================================================
 // function : activateSelection
-// purpose  : activate selection of faces, shells, and solids
+// purpose  : activate selection of solids
 //=================================================================================
 void RepairGUI_FreeFacesDlg::activateSelection()
 {
@@ -277,15 +244,6 @@ void RepairGUI_FreeFacesDlg::activateSelection()
   globalSelection( aMap );
 }
 
-//=================================================================================
-// function : closeEvent()
-// purpose  :
-//=================================================================================
-void RepairGUI_FreeFacesDlg::closeEvent( QCloseEvent* )
-{
-  onClose();
-}
-
 //=================================================================================
 // function : createOperation
 // purpose  :
@@ -316,11 +274,15 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
   TopoDS_Shape aSelShape;
   TopoDS_Shape aFace; 
   TopTools_IndexedMapOfShape anIndices;
+  int aNbObj = 0;
+
   if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) {
     myEdit->setText( GEOMBase::GetName( myObj ) );
     QString aMess;
     if ( !isValid( aMess ) ) {
       erasePreview( true );
+      buttonOk()->setEnabled(false);
+      buttonApply()->setEnabled(false);
       return false;
     }
     
@@ -349,8 +311,11 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
        }
       }
     }
-    
-    for ( int i = 0, n = aFaceLst->length(); i < n; i++ ) {
+
+    int i;
+    int n = aFaceLst->length();
+
+    for (i = 0; i < n; i++ ) {
       aFace = anIndices.FindKey( aFaceLst[i] );
       try {
         getDisplayer()->SetColor( Quantity_NOC_RED );
@@ -363,9 +328,27 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
       catch( const SALOME::SALOME_Exception& e )
       {
         SalomeApp_Tools::QtCatchCorbaException( e );
+        buttonOk()->setEnabled(false);
+        buttonApply()->setEnabled(false);
+        return false;
       }
     }
+
+    // Create sub-objects
+    GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObj, aFaceLst);
+
+    aNbObj = aList->length();
+
+    for (i = 0; i < aNbObj; i++) {
+      objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
+    }
+
+    aResult = true;
   }
+
+  buttonOk()->setEnabled(aNbObj > 0);
+  buttonApply()->setEnabled(aNbObj > 0);
+
   return aResult;
 }
 
@@ -380,28 +363,12 @@ GEOM_Displayer* RepairGUI_FreeFacesDlg::getDisplayer()
   return myDisplayer;
 }
 
-//=================================================================================
-// function : SetEditCurrentArgument
-// purpose  :
-//=================================================================================
-void RepairGUI_FreeFacesDlg::onSetEditCurrentArgument()
-{
-  myEdit->setFocus();
-  onSelectionDone();
-}
-
-//=================================================================================
-// function : keyPressEvent()
-// purpose  :
-//=================================================================================
-void RepairGUI_FreeFacesDlg::keyPressEvent( QKeyEvent* e )
+//================================================================
+// Function : getFather
+// Purpose  : Get father object for object to be added in study
+//            (called with addInStudy method)
+//================================================================
+GEOM::GEOM_Object_ptr RepairGUI_FreeFacesDlg::getFather (GEOM::GEOM_Object_ptr)
 {
-  QDialog::keyPressEvent( e );
-  if ( e->isAccepted() )
-    return;
-
-  if ( e->key() == Qt::Key_F1 ) {
-    e->accept();
-    onHelp();
-  }
+  return myObj;
 }
index 160d4bffad692333004e942c3f0049fd25a4d364..2e3f12f7f0d660e212881b4fb9cca7f8559e0a8e 100644 (file)
 #ifndef REPAIRGUI_FREEFACESDLG_H
 #define REPAIRGUI_FREEFACESDLG_H
 
-#include <QDialog>
-#include <GEOMBase_Helper.h>
+#include <GEOMBase_Skeleton.h>
 
 class GEOM_Displayer;
-class QPushButton;
 class QLineEdit;
 class GeometryGUI;
 
@@ -39,8 +37,7 @@ class GeometryGUI;
 // class    : RepairGUI_FreeFacesDlg
 // purpose  :
 //=================================================================================
-class RepairGUI_FreeFacesDlg : public QDialog,
-                               public GEOMBase_Helper
+class RepairGUI_FreeFacesDlg : public GEOMBase_Skeleton
 {
   Q_OBJECT
 
@@ -53,30 +50,24 @@ protected:
   virtual GEOM::GEOM_IOperations_ptr createOperation();
   virtual bool                       isValid( QString& );
   virtual bool                       execute( ObjectList& );
-  
+  virtual GEOM::GEOM_Object_ptr      getFather (GEOM::GEOM_Object_ptr);
+
 private:
   void                               Init();
   void                               enterEvent( QEvent* );
-  void                               closeEvent( QCloseEvent* );
-  void                               keyPressEvent( QKeyEvent* );
   void                               activateSelection();
   GEOM_Displayer*                    getDisplayer();
 
 private slots:
-  void                               onClose();
-  void                               onHelp(); 
-  void                               onDeactivate();
-  void                               onActivate();
-  void                               onSelectionDone();
-  void                               onSetEditCurrentArgument();
+  void                               ClickOnOk();
+  bool                               ClickOnApply();
+  void                               SelectionIntoArgument();
+  void                               ActivateThisDialog();
 
 private:
   GEOM_Displayer*                    myDisplayer;
   GEOM::GEOM_Object_var              myObj;
-  QPushButton*                       mySelBtn;
   QLineEdit*                         myEdit;
-  GeometryGUI*                       myGeomGUI;
-  QString                            myHelpFileName;
 };
 
 #endif // REPAIRGUI_FREEFACESDLG_H