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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_StreamOp.h"
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"
29 #include <HYDROData_Document.h>
30 #include <HYDROData_PolylineXY.h>
31 #include <HYDROData_Profile.h>
32 #include <HYDROData_DTM.h>
34 #include <LightApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <LightApp_UpdateFlags.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_Desktop.h>
41 #include <QApplication>
44 #include <OCCViewer_ViewManager.h>
45 #include <OCCViewer_ViewModel.h>
46 #include <OCCViewer_ViewWindow.h>
54 #include <TopoDS_Face.hxx>
56 #include <BRepBuilderAPI_MakeFace.hxx>
58 #include <HYDROData_StreamLinearInterpolation.h>
60 void insertProfileInToOrder( const QString& theProfileName,
61 const double& theProfilePar,
62 QStringList& theProfiles,
63 QList<double>& theProfileParams )
65 bool anIsInserted = false;
66 for ( int k = 0; k < theProfileParams.length(); ++k )
68 const double& aParam = theProfileParams.value( k );
69 if ( theProfilePar < aParam )
71 theProfiles.insert( k, theProfileName );
72 theProfileParams.insert( k, theProfilePar );
80 theProfiles << theProfileName;
81 theProfileParams << theProfilePar;
85 HYDROGUI_StreamOp::HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool theIsEdit )
86 : HYDROGUI_Operation( theModule ),
87 myIsEdit( theIsEdit ),
90 setName( theIsEdit ? tr( "EDIT_STREAM" ) : tr( "CREATE_STREAM" ) );
93 HYDROGUI_StreamOp::~HYDROGUI_StreamOp()
98 void HYDROGUI_StreamOp::startOperation()
100 HYDROGUI_Operation::startOperation();
101 int mode = 0; //DTM mode by def
103 if ( !myIsEdit || isApplyAndClose() )
104 myEditedObject.Nullify();
107 myProfileParams.clear();
109 // Get panel and reset its state
110 HYDROGUI_StreamDlg* aPanel = (HYDROGUI_StreamDlg*)inputPanel();
113 QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STREAM_NAME" ) );
116 if ( isApplyAndClose() )
118 Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
119 if ( !myEditedObject.IsNull() )
121 mode = myEditedObject->GetInterpolationMethod();
122 anObjectName = myEditedObject->GetName();
123 //aPanel->setMode(mode);
126 Handle(HYDROData_PolylineXY) aHydraulicAxis = myEditedObject->GetHydraulicAxis();
129 HYDROData_Stream::BuildRefFace( aPlane ) ;
130 if ( !aHydraulicAxis.IsNull() )
131 myHydAxis = aHydraulicAxis->GetName();
134 HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles();
135 for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
137 Handle(HYDROData_Profile) aProfile =
138 Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
139 if ( aProfile.IsNull() )
142 QString aProfileName = aProfile->GetName();
143 myProfiles << aProfileName;
145 if (!aHydraulicAxis.IsNull())
147 Standard_Real aProfilePar = 0.0;
148 HYDROData_Stream::HasIntersection( aHydraulicAxis, aProfile, aPlane, aProfilePar );
149 myProfileParams << aProfilePar;
158 // set the edited object name
159 aPanel->setObjectName( anObjectName );
161 // set the existing 2D polylines names to the panel
162 aPanel->setAxisNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
164 aPanel->setLeftBankNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
165 aPanel->setRightBankNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
167 bool isBlocked = aPanel->blockSignals( true );
172 aPanel->setDDZ( myEditedObject->GetDDZ() );
176 aPanel->setNbProfilePoints( myEditedObject->GetNbProfilePoints() );
177 aPanel->setLeftBankName(myEditedObject->GetLeftBank()->GetName());
178 aPanel->setRightBankName(myEditedObject->GetRightBank()->GetName());
180 aPanel->setSpatialStep( myEditedObject->GetSpatialStep() );
183 aPanel->setMode(mode);
184 aPanel->blockSignals( isBlocked );
186 // synchronize the panel state with the edited object state
192 void HYDROGUI_StreamOp::abortOperation()
195 HYDROGUI_Operation::abortOperation();
198 void HYDROGUI_StreamOp::commitOperation()
201 HYDROGUI_Operation::commitOperation();
204 HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const
206 HYDROGUI_StreamDlg* aPanel = new HYDROGUI_StreamDlg( module(), getName() );
208 connect( aPanel, SIGNAL( AddProfiles() ), this, SLOT( onAddProfiles() ) );
209 connect( aPanel, SIGNAL( RemoveProfiles( const QStringList& ) ),
210 this, SLOT( onRemoveProfiles( const QStringList& ) ) );
211 connect( aPanel, SIGNAL( AxisChanged( const QString& ) ),
212 this, SLOT( onAxisChanged( const QString& ) ) );
214 connect( aPanel, SIGNAL( DDZValueChanged( double ) ), this, SLOT( onDDZValueChanged( double ) ) );
215 connect( aPanel, SIGNAL( SSValueChanged( double ) ), this, SLOT( onSSValueChanged( double ) ) );
217 connect( aPanel, SIGNAL( LeftBankChanged( const QString& ) ),
218 this, SLOT( onLeftBankChanged( const QString& ) ) );
220 connect( aPanel, SIGNAL( RightBankChanged( const QString& ) ),
221 this, SLOT( onRightBankChanged( const QString& ) ) );
223 connect( aPanel, SIGNAL( ProfilePointsChanged( int ) ), this, SLOT( onProfilePointsChanged( int ) ) );
225 connect( aPanel, SIGNAL( ModeChanged( bool ) ), this, SLOT( onModeChanged( bool ) ) );
230 void HYDROGUI_StreamOp::apply()
232 QApplication::setOverrideCursor( Qt::WaitCursor );
236 int anUpdateFlags = 0;
239 bool aResult = false;
240 QStringList aBrowseObjectsEntries;
244 aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
246 catch ( Standard_Failure& e )
248 anErrorMsg = e.GetMessageString();
256 QApplication::restoreOverrideCursor();
260 module()->update( anUpdateFlags );
261 commitDocOperation();
263 browseObjects( aBrowseObjectsEntries );
267 myEditedObject->Remove();
268 module()->setObjectRemoved( myEditedObject );
270 if ( isToAbortOnApply() )
274 SUIT_MessageBox::critical( module()->getApp()->desktop(),
275 tr( "CREATE_STREAM_ERROR" ),
280 //#include <HYDROData_StreamLinearInterpolation.h>
281 bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags,
282 QString& theErrorMsg,
283 QStringList& theBrowseObjectsEntries )
285 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
289 // Check whether the object name is not empty
290 QString anObjectName = aPanel->getObjectName().simplified();
291 if ( anObjectName.isEmpty() )
293 theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
297 // Check that there are no other objects with the same name in the document
298 if ( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
300 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
301 if( !anObject.IsNull() )
303 theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
308 if ( myEditedObject.IsNull() ) // Create new data model object
309 myEditedObject = Handle(HYDROData_Stream)::DownCast( doc()->CreateObject( KIND_STREAM ) );
311 Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
312 HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
313 //if ( aHydAxis.IsNull() )
315 // theErrorMsg = tr( "AXIS_NOT_DEFINED" );
319 // Check if at least 2 profiles is set
320 HYDROData_SequenceOfObjects aRefProfiles;
321 for ( int i = 0; i < myProfiles.length(); ++i )
323 QString aProfileName = myProfiles.value( i );
325 Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
326 HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
327 if ( !aProfile.IsNull() )
328 aRefProfiles.Append( aProfile );
331 if ( aRefProfiles.Length() < 2 )
333 theErrorMsg = tr( "PROFILES_NOT_DEFINED" );
337 int InterpMethod = aPanel->getMode();
339 myEditedObject->SetInterpolationMethod(InterpMethod);
341 if (InterpMethod == 0)
344 bool ToOrder = !aHydAxis.IsNull();
345 myEditedObject->SetProfiles (aRefProfiles, ToOrder) ;
346 myEditedObject->SetName( anObjectName );
348 if (!aHydAxis.IsNull())
349 myEditedObject->SetHydraulicAxis( aHydAxis );
350 myEditedObject->SetProfiles( aRefProfiles, false );
351 myEditedObject->SetDDZ( aPanel->getDDZ() );
352 myEditedObject->SetSpatialStep( aPanel->getSpatialStep() );
354 else if (InterpMethod == 1)
357 myEditedObject->SetProfiles (aRefProfiles, false) ;
358 myEditedObject->SetName( anObjectName );
359 if (!aHydAxis.IsNull())
360 myEditedObject->SetHydraulicAxis( aHydAxis );
361 Handle(HYDROData_PolylineXY) aLeftBank = Handle(HYDROData_PolylineXY)::DownCast(
362 HYDROGUI_Tool::FindObjectByName( module(), aPanel->getLeftBankName(), KIND_POLYLINEXY ) );
363 Handle(HYDROData_PolylineXY) aRightBank = Handle(HYDROData_PolylineXY)::DownCast(
364 HYDROGUI_Tool::FindObjectByName( module(), aPanel->getRightBankName(), KIND_POLYLINEXY ) );
366 myEditedObject->SetLeftBank(aLeftBank);
367 myEditedObject->SetRightBank(aRightBank);
369 myEditedObject->SetNbProfilePoints( aPanel->getNbProfilePoints() );
370 myEditedObject->SetHaxStep( aPanel->getSpatialStep() );
373 if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
375 myEditedObject->Update();
376 //NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>> warnings;
377 //myEditedObject->GetWarnings(warnings);
378 //QString totalWarning;
379 //for (NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>::Iterator it(warnings); it.More(); it.Next())
381 // const QSet<QString>& V = it.Value();
384 // const Handle(HYDROData_Profile)& K = it.Key();
385 // QString ProfName = K->GetName();
386 // foreach (QString str, V)
388 // totalWarning + "Profile: " + ProfName + ": " + str + "\n";
391 //if (totalWarning != "")
392 // SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "WARNING" ), totalWarning);
397 myEditedObject->SetFillingColor( myEditedObject->DefaultFillingColor() );
398 myEditedObject->SetBorderColor( myEditedObject->DefaultBorderColor() );
404 // Show the object in case of creation mode of the operation
406 module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
407 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
408 theBrowseObjectsEntries.append( anEntry );
411 module()->setIsToUpdate( myEditedObject );
414 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
419 void HYDROGUI_StreamOp::createPreview()
421 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
422 int mode = aPanel->getMode();
424 LightApp_Application* anApp = module()->getApp();
425 if ( !getPreviewManager() )
427 setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>(
428 anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
431 OCCViewer_ViewManager* aViewManager = getPreviewManager();
432 if ( aViewManager && !myPreviewPrs )
434 if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
436 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
437 if ( !aCtx.IsNull() )
439 myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
441 QColor aFillingColor = Qt::green;
442 QColor aBorderColor = Qt::transparent;
443 if ( !myEditedObject.IsNull() )
445 aFillingColor = myEditedObject->GetFillingColor();
446 aBorderColor = myEditedObject->GetBorderColor();
449 myPreviewPrs->setFillingColor( aFillingColor, false, false );
450 myPreviewPrs->setBorderColor( aBorderColor, false, false );
455 if ( !aViewManager || !myPreviewPrs )
460 Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
461 HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
463 HYDROData_SequenceOfObjects aRefProfiles;
464 //std::vector<Handle(HYDROData_Profile)> aRefProfiles;
465 int plen = myProfiles.length();
466 for ( int i = 0; i < plen; ++i )
468 QString aProfileName = myProfiles.value( i );
470 Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
471 HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
472 if ( !aProfile.IsNull() )
473 aRefProfiles.Append( aProfile );
476 HYDROData_Stream::PrsDefinition aPrsDef;
478 TopoDS_Shape Out3dPres;
479 TopoDS_Shape Out2dPres;
480 TopoDS_Shape OutLeftB;
481 TopoDS_Shape OutRightB;
482 TopoDS_Shape OutInlet;
483 TopoDS_Shape OutOutlet;
485 double ddz = aPanel->getDDZ();
486 double ss = aPanel->getSpatialStep();
488 std::set<int> InvInd;
491 const int MAX_POINTS_IN_PREVIEW = 50000;
493 const int MAX_POINTS_IN_PREVIEW = 500000;
496 HYDROData_Bathymetry::AltitudePoints points;
498 bool ProjStat = true;
499 NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>> warnings;
500 bool ToEstimateWarnings = false;
501 HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB,
502 OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat, warnings, ToEstimateWarnings );
504 aPanel->clearAllBackgroundColorsForProfileList();
505 // for (std::set<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)
506 // aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow));
508 aPrsDef.myInlet = OutInlet;
509 aPrsDef.myOutlet = OutOutlet;
510 aPrsDef.myLeftBank = OutLeftB;
511 aPrsDef.myRightBank = OutRightB;
513 aPrsDef.myPrs2D = Out2dPres;
514 aPrsDef.myPrs3D = Out3dPres;
516 aPanel->clearWarnings();
518 aPanel->addWarning(tr("STREAM_PROJECTION_FAILED"));
520 QVector<QString> warningsStr;
522 for (NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>::Iterator it(warnings); it.More(); it.Next())
524 QSet<QString> V = it.Value();
527 const Handle(HYDROData_Profile)& K = it.Key();
528 QString ProfName = K->GetName();
529 foreach (QString str, V)
531 warningsStr.append(ProfName + ": " + str);
532 //aPanel->addWarning(ProfName + ": " + str);
535 aPanel->setBackgroundColorForProfileList(ProfName, QColor(Qt::yellow));
538 std::sort(warningsStr.begin(), warningsStr.end());
539 for (int k=0;k<warningsStr.size();k++)
540 aPanel->addWarning(warningsStr[k]);
542 myPreviewPrs->setShape( aPrsDef.myPrs2D );
546 aPanel->clearAllBackgroundColorsForProfileList();
547 aPanel->clearWarnings();
548 int nbProfPoints = aPanel->getNbProfilePoints();
549 double ss = aPanel->getSpatialStep();
550 QString axisName = aPanel->getAxisName();
551 QString leftBankName = aPanel->getLeftBankName();
552 QString rightBankName = aPanel->getRightBankName();
553 QList<Handle(HYDROData_Entity)> listProf = aPanel->getProfiles();
554 HYDROData_SequenceOfObjects seqProf;
555 foreach (Handle(HYDROData_Entity) ent, listProf)
558 Handle(HYDROData_PolylineXY) axis = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), axisName, KIND_POLYLINEXY ) );
559 Handle(HYDROData_PolylineXY) LB = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), leftBankName, KIND_POLYLINEXY ) );
560 Handle(HYDROData_PolylineXY) RB = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), rightBankName, KIND_POLYLINEXY ) );
561 HYDROData_Bathymetry::AltitudePoints outBathypoints;
563 std::vector<std::string> warnings;
564 HYDROData_Stream::PrsDefinition prsDef;
566 HYDROData_StreamLinearInterpolation::Perform(seqProf, 500, 1, axis, LB, RB, outBathypoints, true, true, prsDef, &warnings);
568 myPreviewPrs->setShape( prsDef.myPrs2D );
569 for (int i=0;i<warnings.size();i++)
570 aPanel->addWarning(warnings[i].c_str());
574 void HYDROGUI_StreamOp::erasePreview()
583 void HYDROGUI_StreamOp::onAddProfiles()
585 //TODO skip if mode == 1??
586 Handle(HYDROData_PolylineXY) aHydAxis = Handle(HYDROData_PolylineXY)::DownCast(
587 HYDROGUI_Tool::FindObjectByName( module(), myHydAxis, KIND_POLYLINEXY ) );
588 //if ( aHydAxis.IsNull() )
592 HYDROData_Stream::BuildRefFace( aPlane );
594 // Get the current profiles list
595 QStringList aCurrentProfiles = myProfiles;
597 // Get the selected profiles ( in the Object Browser )
598 QStringList anInvalidProfiles;
599 QStringList anExistingProfiles;
600 QStringList aHasNoIntersectionProfiles;
601 QStringList aVerifiedProfiles;
603 HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() );
605 for( int i = 1, n = aSelectedProfiles.Length(); i <= n; i++ )
607 Handle(HYDROData_Profile) aProfile =
608 Handle(HYDROData_Profile)::DownCast( aSelectedProfiles.Value( i ) );
609 if ( aProfile.IsNull() )
612 QString aProfileName = aProfile->GetName();
613 Standard_Real aProfilePar = 0.0;
615 // Check the profile, if all is ok - add it to the list
616 if ( !aProfile->IsValid() )
618 // check whether the profile is valid
619 anInvalidProfiles << aProfileName;
621 else if ( aCurrentProfiles.contains( aProfileName ) )
623 // check whether the profile is already added
624 anExistingProfiles << aProfileName;
626 else if ( !HYDROData_Stream::HasIntersection( aHydAxis, aProfile, aPlane, aProfilePar ) )
628 // check whether the profile has intersection
629 aHasNoIntersectionProfiles << aProfileName;
633 // Insert profile in correct place
634 // if hidr axis is null => the params (myProfileParams) will be igrored. So ordering will be the same as in the aSelectedProfiles
635 insertProfileInToOrder( aProfileName, aProfilePar, myProfiles, myProfileParams );
636 aVerifiedProfiles << aProfileName;
640 // Show message box with the ignored profiles
641 if ( !anInvalidProfiles.isEmpty() ||
642 !anExistingProfiles.isEmpty() ||
643 !aHasNoIntersectionProfiles.isEmpty() )
645 QString aMessage = tr( "IGNORED_PROFILES" );
646 if ( !anInvalidProfiles.isEmpty() )
648 aMessage.append( "\n\n" );
649 aMessage.append( tr("INVALID_PROFILES").arg( anInvalidProfiles.join( "\n" ) ) );
651 if ( !anExistingProfiles.isEmpty() )
653 aMessage.append( "\n\n" );
654 aMessage.append( tr("EXISTING_PROFILES").arg( anExistingProfiles.join( "\n" ) ) );
656 if ( !aHasNoIntersectionProfiles.isEmpty() )
658 aMessage.append( "\n\n" );
659 aMessage.append( tr("NOT_INTERSECTED_PROFILES").arg( aHasNoIntersectionProfiles.join( "\n" ) ) );
662 SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "WARNING" ), aMessage );
665 if ( aVerifiedProfiles.isEmpty() )
675 void HYDROGUI_StreamOp::onRemoveProfiles( const QStringList& theProfilesToRemove )
677 QStringList aToRemove = theProfilesToRemove;
679 aToRemove.removeDuplicates();
680 if ( aToRemove.isEmpty() )
683 bool isRemoved = false;
686 for ( int i = 0; i < aToRemove.length(); ++i )
688 const QString& aProfileName = aToRemove.value( i );
690 int aProfileId = myProfiles.indexOf( aProfileName );
691 if ( aProfileId < 0 )
694 myProfiles.removeAt( aProfileId );
695 myProfileParams.removeAt( aProfileId );
709 void HYDROGUI_StreamOp::onDDZValueChanged( double d )
711 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
714 if (aPanel->getMode() == 0)
718 void HYDROGUI_StreamOp::onSSValueChanged( double d )
720 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
726 void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis )
728 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
732 Handle(HYDROData_PolylineXY) aNewAxis = Handle(HYDROData_PolylineXY)::DownCast(
733 HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) );
735 // Prepare data for intersection check
737 HYDROData_Stream::BuildRefFace( aPlane );
739 // SUIT_MessageBox::critical( module()->getApp()->desktop(),
740 // tr( "BAD_SELECTED_POLYLINE_TLT" ),
741 // tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) );
742 // // To restore the old axis
743 // updatePanelData();
747 QStringList aNewProfiles;
748 QList<double> aNewProfileParams;
749 QStringList aHasNoIntersectionProfiles;
751 // Get list of profiles which do not intersect the axis
752 for ( int i = 0; i < myProfiles.length(); ++i )
754 QString aProfileName = myProfiles.value( i );
756 Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
757 HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
758 if ( aProfile.IsNull() )
761 Standard_Real aProfilePar = 0.0;
762 if ( HYDROData_Stream::HasIntersection( aNewAxis, aProfile, aPlane, aProfilePar ) )
764 // Insert profile in correct place
765 insertProfileInToOrder( aProfileName, aProfilePar, aNewProfiles, aNewProfileParams );
769 aHasNoIntersectionProfiles << aProfile->GetName();
773 // If there are profiles which don't intersect the new axis - show confirmation message box
774 bool isConfirmed = true;
775 if ( !aHasNoIntersectionProfiles.isEmpty() )
777 SUIT_MessageBox::StandardButtons aButtons =
778 SUIT_MessageBox::Yes | SUIT_MessageBox::No;
780 QString aMsg = aHasNoIntersectionProfiles.join( "\n" );
781 isConfirmed = SUIT_MessageBox::question( module()->getApp()->desktop(),
782 tr( "CONFIRMATION" ),
783 tr( "CONFIRM_AXIS_CHANGE" ).arg( aMsg ),
785 SUIT_MessageBox::Yes) == SUIT_MessageBox::Yes;
788 // Check if the user has confirmed axis change
791 // To restore the old axis
797 myHydAxis = theNewAxis;
798 myProfiles = aNewProfiles;
799 myProfileParams = aNewProfileParams;
809 void HYDROGUI_StreamOp::onLeftBankChanged( const QString& theNewAxis )
811 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
814 if (aPanel->getMode() == 1)
818 void HYDROGUI_StreamOp::onRightBankChanged( const QString& theNewAxis )
820 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
823 if (aPanel->getMode() == 1)
827 void HYDROGUI_StreamOp::onProfilePointsChanged( int d )
829 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
832 if (aPanel->getMode() == 1)
836 void HYDROGUI_StreamOp::onModeChanged( bool mode )
841 void HYDROGUI_StreamOp::updatePanelData()
843 HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
847 aPanel->setAxisName( myHydAxis );
848 aPanel->setProfiles( myProfiles );