+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
+
+ return store( theErrorMsg );
+}
+
+void HYDROGUI_GeoreferencementOp::onModeActivated( const int theActualMode )
+{
+ QString anErrorMsg;
+
+ // Get the panel
+ HYDROGUI_GeoreferencementDlg* aPanel =
+ ::qobject_cast<HYDROGUI_GeoreferencementDlg*>( inputPanel() );
+ if ( !aPanel ) {
+ return;
+ }
+
+ aPanel->setMode( theActualMode == HYDROGUI_GeoreferencementDlg::AllProfiles ?
+ HYDROGUI_GeoreferencementDlg::SelectedProfiles :
+ HYDROGUI_GeoreferencementDlg::AllProfiles);
+
+ // Store the dialog data to the data model
+ bool isToStore = false;
+ // Check if modifications exists
+ if ( aPanel->isModified() ) {
+ // Show confirmation dialog
+ SUIT_MessageBox::StandardButtons aButtons =
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No;
+
+ isToStore = SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "CONFIRMATION" ),
+ tr( "CONFIRM_STORE" ),
+ aButtons,
+ SUIT_MessageBox::Yes) == SUIT_MessageBox::Yes;
+ }
+ // Store modifications if needed
+ if ( isToStore && !store( anErrorMsg ) ) {
+ anErrorMsg.append( "\n" + tr( "INPUT_VALID_DATA" ) );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ tr( "INSUFFICIENT_INPUT_DATA" ),
+ anErrorMsg );
+ return;
+ }
+
+ aPanel->setMode( theActualMode );
+
+ // Get the list of profiles
+ HYDROData_SequenceOfObjects aSeqOfProfiles;
+
+ if( theActualMode == HYDROGUI_GeoreferencementDlg::AllProfiles ) {
+ HYDROData_Iterator aProfilesIter( doc(), KIND_PROFILE );
+ while ( aProfilesIter.More() ) {
+ aSeqOfProfiles.Append( aProfilesIter.Current() );
+ aProfilesIter.Next();
+ }
+ } else if ( theActualMode == HYDROGUI_GeoreferencementDlg::SelectedProfiles ) {
+ aSeqOfProfiles = HYDROGUI_Tool::GetSelectedObjects( module() );
+ }
+
+ // Set the profiles to the panel
+ setPanelData( aSeqOfProfiles );
+}
+
+void HYDROGUI_GeoreferencementOp::onWindowActivated( SUIT_ViewWindow* theViewWindow )
+{
+ if ( !theViewWindow ) {
+ return;
+ }
+
+ OCCViewer_ViewManager* aViewManager =
+ dynamic_cast<OCCViewer_ViewManager*>( theViewWindow->getViewManager() );
+
+ if ( aViewManager ) {
+ HYDROGUI_GeoreferencementDlg* aPanel =
+ ::qobject_cast<HYDROGUI_GeoreferencementDlg*>( inputPanel() );
+ if ( aPanel ) {
+ connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
+ aPanel, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
+ Qt::UniqueConnection);
+ }
+ }
+}
+
+bool HYDROGUI_GeoreferencementOp::store( QString& theErrorMsg )
+{
+ // Clear the error string
+ theErrorMsg.clear();
+
+ // Get the panel