#include <PythonConsole_PyConsole.h>
+#include <SUIT_FileDlg.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ActionOperation.h>
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() )
}
SUIT_Tools::simplifySeparators( modTBar );
-
+
// New window
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
if ( a )
a->setEnabled( activeStudy() );
}
+
+ // Load script menu
+ QAction* a = action( LoadScriptId );
+ if ( a )
+ a->setEnabled( activeStudy() );
}
//=======================================================================
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 );
saveWindowsGeometry();
}
+void SalomeApp_Application::onLoadScript( )
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( 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)";
class LogWindow;
class OB_Browser;
+class PythonConsole;
class SalomeApp_Module;
class SalomeApp_SelectionMgr;
class SalomeApp_WidgetContainer;
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();
OB_Browser* objectBrowser();
LogWindow* logWindow();
+ PythonConsole* pythonConsole();
virtual QString getFileFilter() const;
SUIT_ViewManager* getViewManager( const QString&, const bool );
void onStudyOpened( SUIT_Study* );
void onStudySaved( SUIT_Study* );
void onStudyClosed( SUIT_Study* );
+
+ void onLoadScript();
private:
void updateWindows();
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"