]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL7330: Provide warning about quantity of not glued faces
authorjfa <jfa@opencascade.com>
Tue, 28 Dec 2004 08:29:50 +0000 (08:29 +0000)
committerjfa <jfa@opencascade.com>
Tue, 28 Dec 2004 08:29:50 +0000 (08:29 +0000)
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/RepairGUI/RepairGUI_GlueDlg.cxx
src/RepairGUI/RepairGUI_GlueDlg.h

index 0eac538b59a106a850dee67622ead31a2a5ff76e..e4b31bfaee87a591a93ad7dd3135123949a1adab 100644 (file)
@@ -528,7 +528,6 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces
 
   // to provide warning
   if (!isWarning) SetErrorCode(OK);
-  SetErrorCode(OK);
   return aGlued;
 }
 
index 11e5858640da9c91b60fa54a670cf1744e4637a9..8af96b95cd775ead8b17ee9b0ce28a9ec3dae08f 100644 (file)
 using namespace std;
 #include "RepairGUI_GlueDlg.h"
 
+#include "DlgRef_1Sel_Ext.h"
+
 #include "QAD_Desktop.h"
 #include "QAD_SpinBoxDbl.h"
+#include "QAD_MessageBox.h"
+#include "QAD_WaitCursor.h"
 
 #include "OCCViewer_Viewer3d.h"
-#include "DlgRef_1Sel_Ext.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOMEGUI_QtCatchCorbaException.hxx"
 
 #include "GEOMImpl_Types.hxx"
 
@@ -143,7 +147,7 @@ void RepairGUI_GlueDlg::ClickOnOk()
 //=================================================================================
 bool RepairGUI_GlueDlg::ClickOnApply()
 {
-  if ( !onAccept() )
+  if ( !onAcceptLocal() )
     return false;
 
   initName();
@@ -288,10 +292,142 @@ bool RepairGUI_GlueDlg::isValid( QString& msg )
 bool RepairGUI_GlueDlg::execute( ObjectList& objects )
 {
   bool aResult = false;
-  GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeGlueFaces( myObject, myTolEdt->value() );
+  GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow
+    ( getOperation() )->MakeGlueFaces( myObject, myTolEdt->value() );
   aResult = !anObj->_is_nil();
   if ( aResult )
     objects.push_back( anObj._retn() );
 
   return aResult;
 }
+
+//================================================================
+// Function : clearShapeBufferLocal
+// Purpose  : 
+//================================================================
+void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj )
+{
+  if ( CORBA::is_nil( theObj ) )
+    return;
+
+  string IOR = GeometryGUI::GetORB()->object_to_string( theObj );
+  TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
+  GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
+
+  if ( !getStudy() || CORBA::is_nil( getStudy()->getStudyDocument() ) )
+    return;
+
+  SALOMEDS::Study_var aStudy = getStudy()->getStudyDocument();
+  SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( IOR.c_str() );
+  if ( CORBA::is_nil( aSObj ) )
+    return;
+
+  SALOMEDS::ChildIterator_var anIt = aStudy->NewChildIterator( aSObj );
+  for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
+    SALOMEDS::GenericAttribute_var anAttr;
+    if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
+      SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+      TCollection_AsciiString asciiIOR( anIOR->Value() );
+      GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );      
+    }
+  }
+}
+
+//================================================================
+// Function : onAccept
+// Purpose  : This method should be called from dialog's slots onOk() and onApply()
+//            It perfroms user input validation, then it 
+//            performs a proper operation and manages transactions, etc.
+//================================================================
+bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransaction )
+{
+  QAD_Study* aDoc = QAD_Application::getDesktop()->getActiveStudy();
+  SALOMEDS::Study_var aStudy = aDoc->getStudyDocument();
+
+  bool aLocked = aStudy->GetProperties()->IsLocked();
+  if ( aLocked ) {
+    MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
+    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
+                          QObject::tr("WRN_WARNING"), 
+                          QObject::tr("WRN_STUDY_LOCKED"),
+                          QObject::tr("BUT_OK") );
+    return false;
+  }
+
+  QString msg;
+  if ( !isValid( msg ) ) {
+    showError( msg );
+    return false;
+  }
+
+  erasePreview( false );
+
+  try {
+    if ( ( !publish && !useTransaction ) || openCommand() ) {
+      QAD_WaitCursor wc;
+      QAD_Application::getDesktop()->putInfo( "" );
+      ObjectList objects;
+      // JFA 28.12.2004 if ( !execute( objects ) || !getOperation()->IsDone() ) {
+      if ( !execute( objects ) ) { // JFA 28.12.2004 // To enable warnings
+       wc.stop();
+       abortCommand();
+       showError();
+      }
+      else {
+       const int nbObjs = objects.size();
+       bool withChildren = false;
+       for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
+         if ( publish ) {
+           QString aName("");
+           if ( nbObjs > 1 )
+             aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) );
+           else {
+             aName = getNewObjectName();
+             // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
+             if ( aName.isEmpty() )
+               aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
+           }
+           addInStudy( *it, aName.latin1() );
+           withChildren = false;
+           display( *it, false );
+         }
+         else { // asv : fix of PAL6454. If publish==false, then the original shape was modified, and need to be re-cached in GEOM_Client 
+                // before redisplay
+           clearShapeBufferLocal( *it );
+           withChildren = true;
+           redisplay( *it, withChildren, false );
+          }
+       }
+
+       if ( nbObjs ) {
+         commitCommand();
+         updateObjBrowser();
+         QAD_Application::getDesktop()->putInfo( QObject::tr("GEOM_PRP_DONE") );
+       }
+       else {
+         abortCommand();
+        }
+
+        // JFA 28.12.2004 BEGIN // To enable warnings
+        if ( !getOperation()->_is_nil() ) {
+          if ( !getOperation()->IsDone() ) {
+            QString msgw = QObject::tr( getOperation()->GetErrorCode() );
+            QAD_MessageBox::warn1(QAD_Application::getDesktop(), 
+                                  QObject::tr( "WRN_WARNING" ), 
+                                  msgw, 
+                                  QObject::tr( "BUT_OK" ));
+          }
+        }
+        // JFA 28.12.2004 END
+      }
+    }
+  }
+  catch( const SALOME::SALOME_Exception& e ) {
+    QtCatchCorbaException( e );
+    abortCommand();
+  }
+
+  updateViewer();
+
+  return true;
+}
index 41aba949a206e8c3768e4da26ff06b246d7c95b3..4278198c8a8b0cdd02865e167f94e21952d99f43 100644 (file)
@@ -58,6 +58,10 @@ private :
     void closeEvent(QCloseEvent* e);
     void initSelection();
 
+    bool onAcceptLocal( const bool publish = true, const bool useTransaction = true );
+    void clearShapeBufferLocal( GEOM::GEOM_Object_ptr );
+    // Reimplementation of onAccept for local case of this class.
+
     GEOM::GEOM_Object_var myObject;
 
     DlgRef_1Sel_Ext* GroupPoints;