From: mzn Date: Thu, 9 Jun 2005 09:07:42 +0000 (+0000) Subject: Fix for Bug IPAL9053( 3.0.0: "Check Geometry" and "Load script" functionalities from... X-Git-Tag: T3_0_0_a3~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4915803800e885696c8063715c30b2b0df170f91;p=modules%2Fgui.git Fix for Bug IPAL9053( 3.0.0: "Check Geometry" and "Load script" functionalities from menu "Tools" aren't work.). "Load Script" moved from Geometry module to menu File(so, now it is accessible from all modules). --- diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 1a441fd10..c620afb41 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -49,6 +49,7 @@ #include +#include #include #include #include @@ -252,7 +253,14 @@ void SalomeApp_Application::createActions() SUIT_Desktop* desk = desktop(); SUIT_ResourceMgr* resMgr = resourceMgr(); - + + // Load script + createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(), + tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), + 0, desk, false, this, SLOT( onLoadScript() ) ); + int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); + createMenu( LoadScriptId, fileMenu, 10, -1 ); + // default icon for neutral point ('SALOME' module) QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) ); if ( defIcon.isNull() ) @@ -311,7 +319,7 @@ void SalomeApp_Application::createActions() } SUIT_Tools::simplifySeparators( modTBar ); - + // New window int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); @@ -515,6 +523,11 @@ void SalomeApp_Application::updateCommandsStatus() if ( a ) a->setEnabled( activeStudy() ); } + + // Load script menu + QAction* a = action( LoadScriptId ); + if ( a ) + a->setEnabled( activeStudy() ); } //======================================================================= @@ -649,6 +662,15 @@ LogWindow* SalomeApp_Application::logWindow() return lw; } +PythonConsole* SalomeApp_Application::pythonConsole() +{ + PythonConsole* console = 0; + QWidget* wid = getWindow( WT_PyConsole ); + if ( wid->inherits( "PythonConsole" ) ) + console = (PythonConsole*)wid; + return console; +} + SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create ) { SUIT_ViewManager* aVM = viewManager( vmType ); @@ -754,6 +776,35 @@ void SalomeApp_Application::onStudyClosed( SUIT_Study* ) saveWindowsGeometry(); } +void SalomeApp_Application::onLoadScript( ) +{ + SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); + if ( !appStudy ) return; + _PTR(Study) aStudy = appStudy->studyDS(); + + if ( aStudy->GetProperties()->IsLocked() ) { + SUIT_MessageBox::warn1 ( desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return; + } + + QStringList filtersList; + filtersList.append(tr("PYTHON_FILES_FILTER")); + filtersList.append(tr("ALL_FILES_FILTER")); + + QString aFile = SUIT_FileDlg::getFileName(desktop(), "", filtersList, tr("TOT_DESK_FILE_LOAD_SCRIPT"), true, false); + if(!aFile.isEmpty()) { + QString command = QString("execfile(\"%1\")").arg(aFile); + + PythonConsole* pyConsole = pythonConsole(); + + if(pyConsole) + pyConsole->exec(command); + } +} + QString SalomeApp_Application::getFileFilter() const { return "(*.hdf)"; diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 587d5a2d0..dc2004eb0 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -27,6 +27,7 @@ class QDockWindow; class LogWindow; class OB_Browser; +class PythonConsole; class SalomeApp_Module; class SalomeApp_SelectionMgr; class SalomeApp_WidgetContainer; @@ -49,7 +50,7 @@ public: typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; enum { ModulesListId = STD_Application::UserID, NewGLViewId, - NewPlot2dId, NewOCCViewId, NewVTKViewId, UserID }; + NewPlot2dId, NewOCCViewId, NewVTKViewId, LoadScriptId, UserID }; public: SalomeApp_Application(); @@ -65,6 +66,7 @@ public: OB_Browser* objectBrowser(); LogWindow* logWindow(); + PythonConsole* pythonConsole(); virtual QString getFileFilter() const; SUIT_ViewManager* getViewManager( const QString&, const bool ); @@ -127,6 +129,8 @@ private slots: void onStudyOpened( SUIT_Study* ); void onStudySaved( SUIT_Study* ); void onStudyClosed( SUIT_Study* ); + + void onLoadScript(); private: void updateWindows(); diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 780d08f3c..89035d0f2 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -135,3 +135,20 @@ msgid "SalomeApp_ModuleDlg::ActivateComponent_DESCRIPTION" msgstr "Create, open or load study." //======================================================================================= + +msgid "SalomeApp_Application::ALL_FILES_FILTER" +msgstr "All files ( * )" + +msgid "SalomeApp_Application::PYTHON_FILES_FILTER" +msgstr "PYTHON Files ( *.py )" + +//======================================================================================= + +msgid "TOT_DESK_FILE_LOAD_SCRIPT" +msgstr "Load python script" + +msgid "MEN_DESK_FILE_LOAD_SCRIPT" +msgstr "Load script..." + +msgid "PRP_DESK_FILE_LOAD_SCRIPT" +msgstr "Loads python script from file"