Salome HOME
Merge remote-tracking branch 'remotes/origin/BR_2017' into HEAD
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_StreamOp.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_StreamOp.h"
20
21 #include "HYDROGUI_Module.h"
22 #include <HYDROGUI_DataObject.h>
23 #include "HYDROGUI_Shape.h"
24 #include "HYDROGUI_StreamDlg.h"
25 #include "HYDROGUI_Tool.h"
26 #include "HYDROGUI_Tool2.h"
27 #include "HYDROGUI_UpdateFlags.h"
28
29 #include <HYDROData_Document.h>
30 #include <HYDROData_PolylineXY.h>
31 #include <HYDROData_Profile.h>
32 #include <HYDROData_DTM.h>
33
34 #include <LightApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <LightApp_UpdateFlags.h>
37
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_Desktop.h>
40 #include <QColor>
41 #include <QApplication>
42
43
44 #include <OCCViewer_ViewManager.h>
45 #include <OCCViewer_ViewModel.h>
46 #include <OCCViewer_ViewWindow.h>
47 #include <gp_Ax1.hxx>
48 #include <gp_Ax2.hxx>
49 #include <gp_Ax3.hxx>
50 #include <gp_Vec.hxx>
51 #include <gp_Pnt.hxx>
52 #include <gp_Pln.hxx>
53 #include <gp.hxx>
54 #include <TopoDS_Face.hxx>
55 #include <TopoDS.hxx>
56 #include <BRepBuilderAPI_MakeFace.hxx>
57
58 void insertProfileInToOrder( const QString& theProfileName,
59                              const double&  theProfilePar,
60                              QStringList&   theProfiles,
61                              QList<double>& theProfileParams )
62 {
63   bool anIsInserted = false;
64   for ( int k = 0; k < theProfileParams.length(); ++k )
65   {
66     const double& aParam = theProfileParams.value( k );
67     if ( theProfilePar < aParam )
68     {
69       theProfiles.insert( k, theProfileName );
70       theProfileParams.insert( k, theProfilePar );
71       anIsInserted = true;
72       break;
73     }
74   }
75   
76   if ( !anIsInserted )
77   {
78     theProfiles << theProfileName;
79     theProfileParams << theProfilePar;
80   }
81 }
82
83 HYDROGUI_StreamOp::HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool theIsEdit )
84 : HYDROGUI_Operation( theModule ), 
85   myIsEdit( theIsEdit ),
86   myPreviewPrs( NULL )
87 {
88   setName( theIsEdit ? tr( "EDIT_STREAM" ) : tr( "CREATE_STREAM" ) );
89 }
90
91 HYDROGUI_StreamOp::~HYDROGUI_StreamOp()
92 {
93   erasePreview();
94 }
95
96 void HYDROGUI_StreamOp::startOperation()
97 {
98   HYDROGUI_Operation::startOperation();
99
100   if ( !myIsEdit || isApplyAndClose() )
101     myEditedObject.Nullify();
102   myHydAxis.clear();
103   myProfiles.clear();
104   myProfileParams.clear();
105
106   // Get panel and reset its state
107   HYDROGUI_StreamDlg* aPanel = (HYDROGUI_StreamDlg*)inputPanel();
108   aPanel->reset();
109
110   QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STREAM_NAME" ) );
111   if ( myIsEdit )
112   {
113     if ( isApplyAndClose() )
114       myEditedObject =
115         Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
116     if ( !myEditedObject.IsNull() )
117     {
118       anObjectName = myEditedObject->GetName();
119
120       // Hydraulic axis
121       Handle(HYDROData_PolylineXY) aHydraulicAxis = myEditedObject->GetHydraulicAxis();
122       
123       TopoDS_Face aPlane;
124       HYDROData_Stream::BuildRefFace( aPlane ) ;
125       if ( !aHydraulicAxis.IsNull() )
126         myHydAxis = aHydraulicAxis->GetName();
127
128       // Stream profiles
129       HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles();
130       for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
131       {
132         Handle(HYDROData_Profile) aProfile = 
133           Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
134         if ( aProfile.IsNull() )
135           continue;
136
137         QString aProfileName = aProfile->GetName();        
138         myProfiles      << aProfileName;
139
140         if (!aHydraulicAxis.IsNull())
141         {
142           Standard_Real aProfilePar = 0.0;
143           HYDROData_Stream::HasIntersection( aHydraulicAxis, aProfile, aPlane, aProfilePar );
144           myProfileParams << aProfilePar;
145         }
146
147       }      
148
149     }
150   }
151
152   // Update the panel
153   // set the edited object name
154   aPanel->setObjectName( anObjectName );
155
156   // set the existing 2D polylines names to the panel
157   aPanel->setAxisNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
158
159   if (myIsEdit)
160   {
161     aPanel->setDDZ( myEditedObject->GetDDZ() );
162     aPanel->setSpatialStep( myEditedObject->GetSpatialStep() );
163   }
164
165   // synchronize the panel state with the edited object state
166   updatePanelData();
167
168   // Create preview
169   createPreview();
170 }
171
172 void HYDROGUI_StreamOp::abortOperation()
173 {
174   erasePreview();
175   HYDROGUI_Operation::abortOperation();
176 }
177
178 void HYDROGUI_StreamOp::commitOperation()
179 {
180   erasePreview();
181   HYDROGUI_Operation::commitOperation();
182 }
183
184 HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const
185 {
186   HYDROGUI_StreamDlg* aPanel = new HYDROGUI_StreamDlg( module(), getName() );
187
188   connect( aPanel, SIGNAL( AddProfiles() ), this, SLOT( onAddProfiles() ) );
189   connect( aPanel, SIGNAL( RemoveProfiles( const QStringList& ) ), 
190            this, SLOT( onRemoveProfiles( const QStringList& ) ) );
191   connect( aPanel, SIGNAL( AxisChanged( const QString& ) ), 
192            this, SLOT( onAxisChanged( const QString& ) ) );
193
194   connect( aPanel, SIGNAL( DDZValueChanged( double ) ),  this, SLOT( onDDZValueChanged( double ) ) );
195   connect( aPanel, SIGNAL( SSValueChanged( double ) ),  this, SLOT( onSSValueChanged( double ) ) );
196   return aPanel;
197 }
198
199 void HYDROGUI_StreamOp::apply()
200 {
201   QApplication::setOverrideCursor( Qt::WaitCursor );
202
203   startDocOperation();
204
205   int anUpdateFlags = 0;
206   QString anErrorMsg;
207
208   bool aResult = false;
209   QStringList aBrowseObjectsEntries;
210
211   try
212   {
213     aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
214   }
215   catch ( Standard_Failure )
216   {
217     Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
218     anErrorMsg = aFailure->GetMessageString();
219     aResult = false;
220   }
221   catch ( ... )
222   {
223     aResult = false;
224   }
225   
226   QApplication::restoreOverrideCursor();
227
228   if ( aResult )
229   {
230     module()->update( anUpdateFlags );
231     commitDocOperation();
232     commit();
233     browseObjects( aBrowseObjectsEntries );
234   }
235   else
236   {
237     myEditedObject->Remove();
238     module()->setObjectRemoved( myEditedObject );  
239
240     if ( isToAbortOnApply() )
241       abortDocOperation();
242
243     abort();
244     SUIT_MessageBox::critical( module()->getApp()->desktop(),
245                                tr( "CREATE_STREAM_ERROR" ),
246                                anErrorMsg ); 
247
248   } 
249 }
250
251 bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
252                                       QString& theErrorMsg,
253                                       QStringList& theBrowseObjectsEntries )
254 {
255   HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
256   if ( !aPanel )
257     return false;
258
259   // Check whether the object name is not empty
260   QString anObjectName = aPanel->getObjectName().simplified();
261   if ( anObjectName.isEmpty() )
262   {
263     theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
264     return false;
265   }
266
267   // Check that there are no other objects with the same name in the document
268   if ( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
269   {
270     Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
271     if( !anObject.IsNull() )
272     {
273       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
274       return false;
275     }
276   }
277
278   if ( myEditedObject.IsNull() ) // Create new data model object
279     myEditedObject = Handle(HYDROData_Stream)::DownCast( doc()->CreateObject( KIND_STREAM ) );
280
281   Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
282     HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
283  //if ( aHydAxis.IsNull() )
284  //{
285  //  theErrorMsg = tr( "AXIS_NOT_DEFINED" );
286  //  return false;
287  //}
288
289   // Check if at least 2 profiles is set
290   HYDROData_SequenceOfObjects aRefProfiles;
291   for ( int i = 0; i < myProfiles.length(); ++i )
292   {
293     QString aProfileName = myProfiles.value( i );
294
295     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
296       HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
297     if ( !aProfile.IsNull() )
298       aRefProfiles.Append( aProfile );
299   }
300
301   if ( aRefProfiles.Length() < 2 )
302   {
303     theErrorMsg = tr( "PROFILES_NOT_DEFINED" );
304     return false;
305   }
306
307   bool ToOrder = true;
308
309   if (aHydAxis.IsNull())
310     ToOrder = false;
311
312   myEditedObject->SetProfiles (aRefProfiles, ToOrder) ;
313   myEditedObject->SetName( anObjectName );
314
315   if (!aHydAxis.IsNull())
316     myEditedObject->SetHydraulicAxis( aHydAxis );
317   myEditedObject->SetProfiles( aRefProfiles, false );
318   myEditedObject->SetDDZ( aPanel->getDDZ() );
319   myEditedObject->SetSpatialStep( aPanel->getSpatialStep() );
320
321   if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
322     myEditedObject->Update();
323
324   if ( !myIsEdit )
325   {
326     myEditedObject->SetFillingColor( myEditedObject->DefaultFillingColor() );
327     myEditedObject->SetBorderColor( myEditedObject->DefaultBorderColor() );
328   }
329
330   // Erase preview
331   erasePreview();
332
333   // Show the object in case of creation mode of the operation
334   if( !myIsEdit ) {
335     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
336     QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
337     theBrowseObjectsEntries.append( anEntry );
338   }
339
340   module()->setIsToUpdate( myEditedObject );
341
342   // Set update flags
343   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
344
345   return true;
346 }
347
348 void HYDROGUI_StreamOp::createPreview()
349 {
350   LightApp_Application* anApp = module()->getApp();
351   if ( !getPreviewManager() )
352   {
353     setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
354                        anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
355   }
356
357   OCCViewer_ViewManager* aViewManager = getPreviewManager();
358   if ( aViewManager && !myPreviewPrs )
359   {
360     if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
361     {
362       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
363       if ( !aCtx.IsNull() )
364       {
365         myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
366
367         QColor aFillingColor = Qt::green;
368         QColor aBorderColor = Qt::transparent;
369         if ( !myEditedObject.IsNull() )
370         {
371           aFillingColor = myEditedObject->GetFillingColor();
372           aBorderColor = myEditedObject->GetBorderColor();
373         }
374
375         myPreviewPrs->setFillingColor( aFillingColor, false, false );
376         myPreviewPrs->setBorderColor( aBorderColor, false, false );
377       }
378     }
379   }
380
381   if ( !aViewManager || !myPreviewPrs )
382     return;
383
384   Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
385     HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
386
387   HYDROData_SequenceOfObjects aRefProfiles;
388   //std::vector<Handle(HYDROData_Profile)> aRefProfiles;
389   int plen = myProfiles.length();
390   for ( int i = 0; i < plen; ++i )
391   {
392     QString aProfileName = myProfiles.value( i );
393
394     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
395       HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
396     if ( !aProfile.IsNull() )
397       aRefProfiles.Append( aProfile );
398   }
399
400   HYDROData_Stream::PrsDefinition aPrsDef;
401
402   TopoDS_Shape Out3dPres;
403   TopoDS_Shape Out2dPres;
404   TopoDS_Shape OutLeftB;
405   TopoDS_Shape OutRightB;
406   TopoDS_Shape OutInlet;
407   TopoDS_Shape OutOutlet;
408
409   HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
410   double ddz = aPanel->getDDZ();
411   double ss = aPanel->getSpatialStep();
412
413   std::set<int> InvInd;
414
415 #ifdef _DEBUG
416   const int MAX_POINTS_IN_PREVIEW = 50000;
417 #else
418   const int MAX_POINTS_IN_PREVIEW = 500000;
419 #endif
420
421   HYDROData_Bathymetry::AltitudePoints points;
422
423   bool ProjStat = true;
424   HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB,
425     OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat );
426
427   aPanel->clearAllBackgroundColorsForProfileList();
428   for (std::set<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)
429     aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow));
430
431   aPrsDef.myInlet = OutInlet;
432   aPrsDef.myOutlet = OutOutlet;
433   aPrsDef.myLeftBank = OutLeftB;
434   aPrsDef.myRightBank = OutRightB;
435   if (ProjStat)
436     aPrsDef.myPrs2D = Out2dPres;
437   aPrsDef.myPrs3D = Out3dPres;
438
439   if (!ProjStat)
440     aPanel->addWarning(tr("STREAM_PROJECTION_FAILED"));
441
442   myPreviewPrs->setShape( aPrsDef.myPrs2D );
443 }
444
445 void HYDROGUI_StreamOp::erasePreview()
446 {
447   if( myPreviewPrs )
448   {
449     delete myPreviewPrs;
450     myPreviewPrs = 0;
451   }
452 }
453
454 void HYDROGUI_StreamOp::onAddProfiles()
455 {
456   Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
457     HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
458   //if ( aHydAxis.IsNull() )
459    // return;
460
461   TopoDS_Face aPlane;
462   HYDROData_Stream::BuildRefFace( aPlane );
463
464   // Get the current profiles list
465   QStringList aCurrentProfiles = myProfiles;
466     
467   // Get the selected profiles ( in the Object Browser )
468   QStringList anInvalidProfiles;
469   QStringList anExistingProfiles;
470   QStringList aHasNoIntersectionProfiles;
471   QStringList aVerifiedProfiles;
472
473   HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() ); 
474
475   for( int i = 1, n = aSelectedProfiles.Length(); i <= n; i++ )
476   {
477     Handle(HYDROData_Profile) aProfile = 
478       Handle(HYDROData_Profile)::DownCast( aSelectedProfiles.Value( i ) );
479     if ( aProfile.IsNull() )
480       continue;
481
482     QString aProfileName = aProfile->GetName();
483     Standard_Real aProfilePar = 0.0;
484
485     // Check the profile, if all is ok - add it to the list
486     if ( !aProfile->IsValid() )
487     {
488       // check whether the profile is valid
489       anInvalidProfiles << aProfileName;
490     }
491     else if ( aCurrentProfiles.contains( aProfileName ) )
492     {
493       // check whether the profile is already added
494       anExistingProfiles << aProfileName;
495     }
496     else if ( !HYDROData_Stream::HasIntersection( aHydAxis, aProfile, aPlane, aProfilePar ) )
497     {
498       // check whether the profile has intersection
499       aHasNoIntersectionProfiles << aProfileName;
500     }
501     else
502     {
503       // Insert profile in correct place
504       // if hidr axis is null => the params (myProfileParams) will be igrored. So ordering will be the same as in the aSelectedProfiles
505       insertProfileInToOrder( aProfileName, aProfilePar, myProfiles, myProfileParams );
506       aVerifiedProfiles << aProfileName;
507     }
508   }
509  
510   // Show message box with the ignored profiles
511   if ( !anInvalidProfiles.isEmpty() ||
512        !anExistingProfiles.isEmpty() ||
513        !aHasNoIntersectionProfiles.isEmpty() )
514   {
515     QString aMessage = tr( "IGNORED_PROFILES" );
516     if ( !anInvalidProfiles.isEmpty() )
517     {
518       aMessage.append( "\n\n" );
519       aMessage.append( tr("INVALID_PROFILES").arg( anInvalidProfiles.join( "\n" ) ) );
520     }
521     if ( !anExistingProfiles.isEmpty() )
522     {
523       aMessage.append( "\n\n" );
524       aMessage.append( tr("EXISTING_PROFILES").arg( anExistingProfiles.join( "\n" ) ) );
525     }
526     if ( !aHasNoIntersectionProfiles.isEmpty() )
527     {
528       aMessage.append( "\n\n" );
529       aMessage.append( tr("NOT_INTERSECTED_PROFILES").arg( aHasNoIntersectionProfiles.join( "\n" ) ) );
530     }
531
532     SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "WARNING" ), aMessage );
533   }
534
535   if ( aVerifiedProfiles.isEmpty() )
536     return;
537
538   // Update the panel
539   updatePanelData();
540
541   // Update preview
542   createPreview();
543 }
544
545 void HYDROGUI_StreamOp::onRemoveProfiles( const QStringList& theProfilesToRemove )
546 {
547   QStringList aToRemove = theProfilesToRemove;
548   
549   aToRemove.removeDuplicates();
550   if ( aToRemove.isEmpty() )
551     return;
552
553   bool isRemoved = false;
554
555   // Remove profiles
556   for ( int i = 0; i < aToRemove.length(); ++i )
557   {
558     const QString& aProfileName = aToRemove.value( i );
559
560     int aProfileId = myProfiles.indexOf( aProfileName );
561     if ( aProfileId < 0 )
562       continue;
563
564     myProfiles.removeAt( aProfileId );
565     myProfileParams.removeAt( aProfileId );
566     isRemoved = true;
567   }
568
569   if ( isRemoved )
570   {
571     // Update the panel
572     updatePanelData();
573
574     // Update preview
575     createPreview();
576   }
577 }
578
579 void HYDROGUI_StreamOp::onDDZValueChanged( double d )
580 {
581    createPreview();
582 }
583
584 void HYDROGUI_StreamOp::onSSValueChanged( double d )
585 {
586    createPreview();
587 }
588
589 void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis )
590 {
591   // Get axis object   
592   Handle(HYDROData_PolylineXY) aNewAxis = Handle(HYDROData_PolylineXY)::DownCast(
593     HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) );
594
595   // Prepare data for intersection check
596   TopoDS_Face aPlane;
597   HYDROData_Stream::BuildRefFace( aPlane );
598   //{
599   //  SUIT_MessageBox::critical( module()->getApp()->desktop(), 
600   //                            tr( "BAD_SELECTED_POLYLINE_TLT" ),
601   //                            tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) );
602   //  // To restore the old axis
603   //  updatePanelData();
604   //  return;
605   //}
606
607   QStringList   aNewProfiles;
608   QList<double> aNewProfileParams;
609   QStringList   aHasNoIntersectionProfiles;
610
611   // Get list of profiles which do not intersect the axis
612   for ( int i = 0; i < myProfiles.length(); ++i )
613   {
614     QString aProfileName = myProfiles.value( i );
615
616     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
617       HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
618     if ( aProfile.IsNull() )
619       continue;
620       
621     Standard_Real aProfilePar = 0.0;
622     if ( HYDROData_Stream::HasIntersection( aNewAxis, aProfile, aPlane, aProfilePar ) )
623     {
624       // Insert profile in correct place
625       insertProfileInToOrder( aProfileName, aProfilePar, aNewProfiles, aNewProfileParams );
626     }
627     else
628     {
629       aHasNoIntersectionProfiles << aProfile->GetName();
630     }
631   }
632
633   // If there are profiles which don't intersect the new axis - show confirmation message box
634   bool isConfirmed = true;
635   if ( !aHasNoIntersectionProfiles.isEmpty() )
636   {
637     SUIT_MessageBox::StandardButtons aButtons = 
638       SUIT_MessageBox::Yes | SUIT_MessageBox::No;
639
640     QString aMsg = aHasNoIntersectionProfiles.join( "\n" );
641     isConfirmed = SUIT_MessageBox::question( module()->getApp()->desktop(),
642                                              tr( "CONFIRMATION" ),
643                                              tr( "CONFIRM_AXIS_CHANGE" ).arg( aMsg ),
644                                              aButtons, 
645                                              SUIT_MessageBox::Yes) == SUIT_MessageBox::Yes;
646   }
647
648   // Check if the user has confirmed axis change
649   if ( !isConfirmed )
650   {
651     // To restore the old axis
652     updatePanelData();
653   }
654   else
655   {
656     // Update data
657     myHydAxis = theNewAxis;
658     myProfiles = aNewProfiles;
659     myProfileParams = aNewProfileParams;
660
661     // Update the panel
662     updatePanelData();
663
664     // Update preview
665     createPreview();
666   }
667 }
668
669 void HYDROGUI_StreamOp::updatePanelData()
670 {
671   HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
672   if ( !aPanel )
673     return;
674
675   aPanel->setAxisName( myHydAxis );
676   aPanel->setProfiles( myProfiles );
677 }