From 840414b2bdaa2c56808344bd76dc55e5acf9d28a Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 28 Jul 2005 10:53:56 +0000 Subject: [PATCH] IPAL9377: Save button remains inactive if to change the saved study - VISU fixed --- src/VISUGUI/VisuGUI.cxx | 120 ++++++++++++-------------- src/VISUGUI/VisuGUI_Plot3DDlg.cxx | 8 -- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 4 +- src/VISUGUI/VisuGUI_Tools.cxx | 4 +- src/VISUGUI/VisuGUI_Tools.h | 14 ++- 5 files changed, 70 insertions(+), 80 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 71de14b9..d2c810d2 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -171,37 +171,37 @@ OnImportFromFile() aFilter, tr("MEN_IMPORT_FROM_FILE"), true); - if(aFileInfo.exists()){ + if(aFileInfo.exists()) { application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); VISU::Result_var aResult; bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false); - if(VisuGUI_FileDlg::IsBuild){ + if (VisuGUI_FileDlg::IsBuild) { aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); - if(!CORBA::is_nil(aResult.in())) - if(Result_i* aRes = dynamic_cast(GetServant(aResult).in())){ - if(!aRes->IsPossible()) + if (!CORBA::is_nil(aResult.in())) + if (Result_i* aRes = dynamic_cast(GetServant(aResult).in())) { + if (!aRes->IsPossible()) SUIT_MessageBox::warn1(GetDesktop(this), tr("WRN_VISU"), tr("ERR_CANT_BUILD_PRESENTATION"), - tr("BUT_OK") ); + tr("BUT_OK")); else aRes->BuildAll(); } - }else{ + } else { aResourceMgr->setValue("VISU", "full_med_loading", false); aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild); } - if(CORBA::is_nil(aResult.in())) { + if (CORBA::is_nil(aResult.in())) { SUIT_MessageBox::warn1(GetDesktop(this), tr("WRN_VISU"), tr("ERR_ERROR_IN_THE_FILE"), - tr("BUT_OK") ); + tr("BUT_OK")); }else{ - application()->putInfo(aFileInfo.filePath()+tr("INF_DONE")); - updateObjBrowser(); + application()->putInfo(aFileInfo.filePath() + tr("INF_DONE")); + UpdateObjBrowser(this); } } } @@ -232,8 +232,8 @@ OnExploreMEDFile() std::string aStudyName = aStudy->Name(); aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str()); application()->putInfo(aFileInfo.filePath()+tr("INF_DONE")); - //updateObjBrowser(); getApp()->updateObjectBrowser(true); // as need to update MED tree + getApp()->updateActions(); } } @@ -255,19 +255,19 @@ OnImportTableFromFile() aFilter, tr("MEN_IMPORT_TABLE"), true); - if(aFileInfo.exists()){ + if (aFileInfo.exists()) { application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath()); - if(CORBA::is_nil(anObject.in())) { + if (CORBA::is_nil(anObject.in())) { SUIT_MessageBox::warn1(GetDesktop(this), tr("WRN_VISU"), tr("ERR_ERROR_IN_THE_FILE"), - tr("BUT_OK") ); - }else{ + tr("BUT_OK")); + } else { application()->putInfo(aFileInfo.filePath()+tr("INF_DONE")); - updateObjBrowser(); + UpdateObjBrowser(this); } } } @@ -317,7 +317,7 @@ OnImportMedField() } } } - updateObjBrowser(true); + UpdateObjBrowser(this, true); QApplication::restoreOverrideCursor(); } @@ -333,13 +333,14 @@ CreateCurves( SalomeApp_Module* theModule, if ( !aCutDlg ) return; - _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) ); + _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) ); _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() ); - if ( !theCreate && aSObject ){ + if ( !theCreate && aSObject ) { // Remove old Table _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); - for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) { + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject); + for (; aIter->More(); aIter->Next()) { _PTR(SObject) aTblObj = aIter->Value(); if ( aTblObj ) { _PTR(GenericAttribute) anAttr; @@ -354,9 +355,10 @@ CreateCurves( SalomeApp_Module* theModule, if ( aCutDlg->isGenerateTable() ) { GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() ); if ( aCutDlg->isGenerateCurves() ) { - if( aSObject ) { + if ( aSObject ) { _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); - for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) { + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject); + for (; aIter->More(); aIter->Next()) { _PTR(SObject) aTblObj = aIter->Value(); if ( aTblObj ) { _PTR(GenericAttribute) anAttr; @@ -368,6 +370,10 @@ CreateCurves( SalomeApp_Module* theModule, } } } + + if (!theCreate && aSObject) { + UpdateObjBrowser(theModule); + } } template @@ -433,7 +439,10 @@ CreatePrs3d(SalomeApp_Module* theModule, if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) { // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::waitCursor); - CreateCurves( theModule, dynamic_cast( aPrs3d ), aDlg, true ); // in creation mode + CreateCurves( theModule, + dynamic_cast( aPrs3d ), + aDlg, + true ); // in creation mode QApplication::restoreOverrideCursor(); delete aDlg; } else { @@ -471,6 +480,7 @@ CreatePrs3d(SalomeApp_Module* theModule) theModule->application()->putInfo(QObject::tr("INF_DONE")); theModule->updateObjBrowser(); + UpdateObjBrowser(theModule); if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) aView->onFitAll(); @@ -578,7 +588,7 @@ OnCreatePlot2dView() { CheckLock(GetCStudy(GetAppStudy(this))); GetVisuGen( this )->CreateContainer(); - updateObjBrowser(); + UpdateObjBrowser(this); } void @@ -678,7 +688,6 @@ EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d) { TPrs3d_i* aPrsObject = dynamic_cast(thePrs3d); if (aPrsObject) { - //TDlg* aDlg = new TDlg (GetDesktop(theModule), false, true); TDlg* aDlg = new TDlg (theModule); aDlg->initFromPrsObject(aPrsObject); if (aDlg->exec()) { @@ -688,11 +697,16 @@ EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d) } RecreateActor(theModule, aPrsObject); if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) { - //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) { - vw->getRenderer()->ResetCameraClippingRange(); - vw->Repaint(); - //} + vw->getRenderer()->ResetCameraClippingRange(); + vw->Repaint(); } + // Optionally, create table and curves for cut lines + QApplication::setOverrideCursor(Qt::waitCursor); + CreateCurves( theModule, + dynamic_cast( aPrsObject ), + aDlg, + false ); // in edition mode + QApplication::restoreOverrideCursor(); } delete aDlg; } @@ -725,27 +739,9 @@ OnEditPrs() break; case VISU::TCUTPLANES: EditPrs3d(this, aPrs3d); - /*{ - VISU::CutPlanes_i* aPrsObject = dynamic_cast(aPrs3d); - if (aPrsObject) { - VisuGUI_CutPlanesDlg* aDlg = - new VisuGUI_CutPlanesDlg (GetDesktop(this), false, false); - aDlg->initFromPrsObject(aPrsObject); - aDlg->show(); - } - }*/ break; case VISU::TCUTLINES: EditPrs3d(this, aPrs3d); - /*{ - VISU::CutLines_i* aPrsObject = dynamic_cast(aPrs3d); - if (aPrsObject) { - VisuGUI_CutLinesDlg* aDlg = - new VisuGUI_CutLinesDlg (GetDesktop(this), false, false); - aDlg->initFromPrsObject(aPrsObject); - aDlg->show(); - } - }*/ break; case VISU::TISOSURFACE: EditPrs3d(this, aPrs3d); @@ -758,15 +754,6 @@ OnEditPrs() break; case VISU::TPLOT3D: EditPrs3d(this, aPrs3d); - /*{ - VISU::Plot3D_i* aPrsObject = dynamic_cast(aPrs3d); - if (aPrsObject) { - VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(); - aDlg->initFromPrsObject(aPrsObject); - aDlg->show(); - myActiveDialogBox = aDlg; - } - }*/ break; default: return; @@ -1074,7 +1061,7 @@ OnCreateTable() VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject ); if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) { GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() ); - updateObjBrowser(); + UpdateObjBrowser(this); } } @@ -1117,7 +1104,7 @@ OnDeleteObjects() aStudyBuilder->CommitCommand(); //GetActiveStudy()->unHighlightAll(); - updateObjBrowser(true); + UpdateObjBrowser(this, true); } void @@ -1185,7 +1172,7 @@ OnPlotData() } } } - updateObjBrowser(); + UpdateObjBrowser(this); PlotContainer( this, pContainer, VISU::eDisplay ); } } @@ -1256,7 +1243,7 @@ OnPlotData() } } } - updateObjBrowser(); + UpdateObjBrowser(this); PlotContainer( this, pContainer, VISU::eDisplay ); } } @@ -1338,7 +1325,7 @@ OnClearContainer() VISU::Container_i* container = dynamic_cast(VISU::GetServant(aCnt).in()); if (container && container->GetNbCurves() > 0) { container->Clear(); - updateObjBrowser(); + UpdateObjBrowser(this); } } } @@ -1357,12 +1344,11 @@ OnEditContainer() VISU::Container_i* aContainer = dynamic_cast(aServant.in()); if (!aContainer) return; - //VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this)); VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this); aDlg->initFromPrsObject(aContainer); if (aDlg->exec()) { aDlg->storeToPrsObject(aContainer); - updateObjBrowser(true); + UpdateObjBrowser(this, true); } delete aDlg; } @@ -1391,7 +1377,7 @@ OnSaveViewParams() const Handle(SALOME_InteractiveObject)& anIO = aListIO.First(); VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName()); } - updateObjBrowser(); + UpdateObjBrowser(this); } void @@ -1485,7 +1471,7 @@ OnRename() // rename the study object aName->SetValue(Name.latin1()); // rename the SObject anIO->setName(Name.latin1()); // rename the InteractiveObject - updateObjBrowser(false); + UpdateObjBrowser(this, false); QApplication::restoreOverrideCursor(); } @@ -1716,7 +1702,7 @@ OnCopyPresentation() } break; } - updateObjBrowser(); + UpdateObjBrowser(this); } void diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index fe7671e2..78cbcec2 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -562,13 +562,5 @@ void VisuGUI_Plot3DDlg::reject() { myIsoPane->check(); // hide preview -/*if (!isModal() && myIsoPane->GetPrs() && - !VISU::GetActor(myIsoPane->GetPrs(), myViewWindow)) { - _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); - if (!aStudy->GetProperties()->IsLocked()) { - myIsoPane->GetPrs()->RemoveFromStudy(); - myIsoPane->GetStudyFrame()->getStudy()->updateObjBrowser(); - } -}*/ QDialog::reject(); } diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 7d7c0232..509694ec 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1244,14 +1244,14 @@ void VisuGUI_TimeAnimationDlg::onStop() void VisuGUI_TimeAnimationDlg::saveToStudy() { myAnimator->saveAnimation(); - myModule->updateObjBrowser( true ); + VISU::UpdateObjBrowser(myModule, true); } //************************************************************************ void VisuGUI_TimeAnimationDlg::publishToStudy() { myAnimator->publishInStudy(); - myModule->updateObjBrowser( true ); + VISU::UpdateObjBrowser(myModule, true); mySaveBtn->setEnabled(myAnimator->isSavedInStudy()); } diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 47acac98..daa94500 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -415,7 +415,7 @@ namespace VISU } } thePrs->RemoveFromStudy(); - theModule->updateObjBrowser(); //update Object browser + //theModule->updateObjBrowser(); //update Object browser } void @@ -957,7 +957,7 @@ namespace VISU } } } - theModule->updateObjBrowser(); + //theModule->updateObjBrowser(); PlotContainer( theModule, pContainer, VISU::eDisplay ); } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 0c2469bf..2af898e6 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -32,6 +32,9 @@ #include "VISUConfig.hh" +#include "SalomeApp_Module.h" +#include "SalomeApp_Application.h" + #include "SALOMEDSClient_Study.hxx" #include "SALOMEconfig.h" @@ -43,7 +46,6 @@ class VISU_Actor; class SVTK_ViewWindow; class SPlot2d_Viewer; class CAM_Module; -class SalomeApp_Module; class SalomeApp_SelectionMgr; class SalomeApp_Study; @@ -63,6 +65,9 @@ namespace VISU { bool IsStudyLocked( _PTR(Study) theStudy ); bool CheckLock( _PTR(Study) theStudy ); + inline void UpdateObjBrowser(SalomeApp_Module* theModule, + bool updateDataModel = true); + VISU_Gen_i* GetVisuGen(const CAM_Module* theModule); SALOME_MED::MED_Gen_var GetMEDEngine(); @@ -179,4 +184,11 @@ bool VISU::IsSObjectTable( _PTR(SObject) theSObject ) return false; } +void VISU::UpdateObjBrowser(SalomeApp_Module* theModule, + bool updateDataModel) +{ + theModule->updateObjBrowser(updateDataModel); + theModule->getApp()->updateActions(); +} + #endif -- 2.39.2