#include "SalomeApp_Application.h"
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Study.h"
+#include "SalomeApp_CheckFileDlg.h"
#include "LightApp_SelectionMgr.h"
#include "LightApp_Selection.h"
#include "LightApp_Preferences.h"
#include "VisuGUI_PopupTools.h"
#include "VisuGUI_NameDlg.h"
-#include "VisuGUI_FileDlg.h"
#include "VisuGUI_CursorDlg.h"
#include "VisuGUI_Selection.h"
#include "VisuGUI_TimeAnimation.h"
if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
return;
-
- VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
- aBuildProgressDlg->setGenerator( GetVisuGen(this) );
- aBuildProgressDlg->show();
-}
-
-
-void
-VisuGUI::
-OnExploreMEDFile()
-{
- if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
- _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
- if ( CheckLock(aStudy,GetDesktop(this)) )
- return;
-
- SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
-
+
+ // Get file name
QStringList aFilter;
- aFilter.append( tr("FLT_MED_FILES") );
- aFilter.append( tr("FLT_ALL_FILES") );
-
- QFileInfo aFileInfo =
- SUIT_FileDlg::getFileName(GetDesktop(this),
- "",
- aFilter,
- tr("MEN_EXPLORE_MED_FILE"),
- true);
- if(aFileInfo.exists()){
- application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
- std::string aStudyName = aStudy->Name();
- try
+ aFilter.append( tr( "FLT_MED_FILES" ) );
+ aFilter.append( tr( "FLT_ALL_FILES" ) );
+
+ bool toUseBuildProgress = GetResourceMgr()->booleanValue("VISU", "use_build_progress", false);
+
+ SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+ fd->setCaption( tr( "IMPORT_FROM_FILE" ) );
+ fd->setFilters( aFilter );
+ fd->SetChecked( toUseBuildProgress );
+ fd->exec();
+ QFileInfo aFileInfo( fd->selectedFile() );
+ toUseBuildProgress = fd->IsChecked();
+ delete fd;
+
+ // Check the file name
+ if ( !aFileInfo.exists() )
+ return;
+
+ if ( !toUseBuildProgress )
{
- aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
+ QString anInfo("Importing From File " + aFileInfo.filePath() + "..." );
+ application()->putInfo( anInfo );
+ VISU::Result_var aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+ if (CORBA::is_nil(aResult.in())) {
+ SUIT_MessageBox::warn1(GetDesktop(this),
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_IN_THE_FILE"),
+ tr("BUT_OK"));
+ }else{
+ application()->putInfo( anInfo + tr("INF_DONE"));
+ UpdateObjBrowser(this);
+ }
}
- catch(...)
+ else
{
- SUIT_MessageBox::warn1(GetDesktop(this),
- tr("WRN_VISU"),
- tr("ERR_ERROR_IN_THE_FILE"),
- tr("BUT_OK"));
+ VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+ aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+ aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+ aBuildProgressDlg->show();
}
- application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
- getApp()->updateObjectBrowser(true); // as need to update MED tree
- getApp()->updateActions();
- }
}
-
void
VisuGUI::
OnImportTableFromFile()
tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
this, SLOT(OnImportFromFile()));
- createAction( VISU_EXPLORE_MED, "", QIconSet(),
- tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
- this, SLOT(OnExploreMEDFile()));
-
createAction( VISU_IMPORT_TABLE, "", QIconSet(),
tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
this, SLOT(OnImportTableFromFile()));
int aMenuId;
aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
createMenu( separator(), aMenuId, -1, 10 );
- createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
- createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
- createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
+
+ int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
+ createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
+ createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
// group: "MED files import"
int importGr = addPreference( tr( "MED files import" ), srangeTab );
setPreferenceProperty( importGr, "columns", 1 );
+ addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );