Salome HOME
debug of profileOp
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_StreamOp.cxx
index bceea8f7666b1c4d176981bb58ad0abfa9b3d9ec..89f44d9997b97399b97559e2d379a1deb63634f7 100755 (executable)
@@ -38,6 +38,8 @@
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
 #include <QColor>
+#include <QApplication>
+
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
@@ -194,6 +196,58 @@ HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const
   return aPanel;
 }
 
+void HYDROGUI_StreamOp::apply()
+{
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+
+  startDocOperation();
+
+  int anUpdateFlags = 0;
+  QString anErrorMsg;
+
+  bool aResult = false;
+  QStringList aBrowseObjectsEntries;
+
+  try
+  {
+    aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
+  }
+  catch ( Standard_Failure )
+  {
+    Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+    anErrorMsg = aFailure->GetMessageString();
+    aResult = false;
+  }
+  catch ( ... )
+  {
+    aResult = false;
+  }
+  
+  QApplication::restoreOverrideCursor();
+
+  if ( aResult )
+  {
+    module()->update( anUpdateFlags );
+    commitDocOperation();
+    commit();
+    browseObjects( aBrowseObjectsEntries );
+  }
+  else
+  {
+    myEditedObject->Remove();
+    module()->setObjectRemoved( myEditedObject );  
+
+    if ( isToAbortOnApply() )
+      abortDocOperation();
+
+    abort();
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "CREATE_STREAM_ERROR" ),
+                               anErrorMsg ); 
+
+  } 
+}
+
 bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
                                       QString& theErrorMsg,
                                       QStringList& theBrowseObjectsEntries )
@@ -331,7 +385,7 @@ void HYDROGUI_StreamOp::createPreview()
     HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
 
   HYDROData_SequenceOfObjects aRefProfiles;
-  //std::vector<Handle_HYDROData_Profile> aRefProfiles;
+  //std::vector<Handle(HYDROData_Profile)> aRefProfiles;
   int plen = myProfiles.length();
   for ( int i = 0; i < plen; ++i )
   {
@@ -365,20 +419,26 @@ void HYDROGUI_StreamOp::createPreview()
 #endif
 
   HYDROData_Bathymetry::AltitudePoints points;
+
+  bool ProjStat = true;
   HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB,
-    OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW );
+    OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat );
 
   aPanel->clearAllBackgroundColorsForProfileList();
   for (std::set<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)
     aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow));
 
-  aPrsDef.myInlet = TopoDS::Wire(OutInlet);
-  aPrsDef.myOutlet = TopoDS::Wire(OutOutlet);
-  aPrsDef.myLeftBank = TopoDS::Wire(OutLeftB);
-  aPrsDef.myRightBank = TopoDS::Wire(OutRightB);
-  aPrsDef.myPrs2D = Out2dPres;
+  aPrsDef.myInlet = OutInlet;
+  aPrsDef.myOutlet = OutOutlet;
+  aPrsDef.myLeftBank = OutLeftB;
+  aPrsDef.myRightBank = OutRightB;
+  if (ProjStat)
+    aPrsDef.myPrs2D = Out2dPres;
   aPrsDef.myPrs3D = Out3dPres;
 
+  if (!ProjStat)
+    aPanel->addWarning(tr("STREAM_PROJECTION_FAILED"));
+
   myPreviewPrs->setShape( aPrsDef.myPrs2D );
 }