Salome HOME
Exlude the user input during process events by application (Bug #325).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ProfileOp.cxx
index 6ed7bd15e3ef70f706ab2d69bc2b83024056b2fb..bda67417e629b265e12c3a3345c31629ace59d38 100644 (file)
@@ -91,23 +91,36 @@ void HYDROGUI_ProfileOp::startOperation()
   QString aProfileName;
   if( !myEditedObject.IsNull() )
   {
-    CurveCreator::Coordinates aCurveCoords;
-    CurveCreator::SectionsMap aSectionsMap;
-
-    HYDROData_ProfileUZ::PointsList aSectPointsList = myEditedObject->GetParametricPoints();
-    CurveCreator::PosPointsList aPoints;
-    for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+    Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ( false );
+    if ( !aProfileUZ.IsNull() )
     {
-      const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
-      aCurveCoords.clear();
-      aCurveCoords.push_back( aSectPoint.X() );
-      aCurveCoords.push_back( aSectPoint.Y() );
+      CurveCreator::Coordinates aCurveCoords;
+      CurveCreator::SectionsMap aSectionsMap;
+
+      HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
+      CurveCreator::PosPointsList aPoints;
+      for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+      {
+        const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
+        aCurveCoords.clear();
+        aCurveCoords.push_back( aSectPoint.X() );
+        aCurveCoords.push_back( aSectPoint.Y() );
+
+        CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
+        aPoints.push_back( aPosPoint );
+      }
+
+      aSectionsMap[0] = aPoints;
+      myProfile->addPointsInternal( aSectionsMap );
 
-      CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
-      aPoints.push_back( aPosPoint );
+      HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 );
+
+      CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
+      if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE )
+        aCurveType = CurveCreator::Spline;
+
+      myProfile->setSectionType( 0, aCurveType );
     }
-    aSectionsMap[0] = aPoints;
-    myProfile->addPointsInternal( aSectionsMap );
 
     aProfileName = myEditedObject->GetName();
   }
@@ -177,6 +190,10 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
   if( aProfileObj.IsNull() )
     return false;
 
+  Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ();
+  if ( aProfileUZ.IsNull() )
+    return false;
+
   aProfileObj->SetName(aProfileName);
 
   HYDROData_ProfileUZ::PointsList aProfileParamPoints;
@@ -200,10 +217,26 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
   }
   aProfileObj->SetParametricPoints( aProfileParamPoints );
 
-  if( !myIsEdit )
-    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aProfileObj, true );
+  HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
+  if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline )
+    aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
+
+  aProfileUZ->SetSectionType( 0, aSectType );
+
+  if ( !myIsEdit )
+  {
+    aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
+  }
+
+  // At first we update the child u,z profile object
+  aProfileUZ->SetToUpdate( true );
+  aProfileUZ->Update();
+
+  // And now we update our edited object
+  aProfileObj->Update();
+  module()->setIsToUpdate( aProfileObj );
 
-  theUpdateFlags = UF_Model;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
   return true;
 }