diff --git a/hurricane/src/viewer/CMakeLists.txt b/hurricane/src/viewer/CMakeLists.txt
index 80fb051c..3d86585a 100644
--- a/hurricane/src/viewer/CMakeLists.txt
+++ b/hurricane/src/viewer/CMakeLists.txt
@@ -35,6 +35,7 @@
hurricane/viewer/DisplayFilterWidget.h
hurricane/viewer/ControllerWidget.h
hurricane/viewer/ScriptWidget.h
+ hurricane/viewer/StratusWidget.h
)
set ( includes hurricane/viewer/ScreenUtilities.h
hurricane/viewer/DisplayStyle.h
@@ -94,6 +95,7 @@
DisplayFilterWidget.cpp
ControllerWidget.cpp
ScriptWidget.cpp
+ StratusWidget.cpp
)
set ( pycpps PyViewer.cpp
PyCellViewer.cpp
diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp
index c2a8b568..46cde454 100644
--- a/hurricane/src/viewer/CellViewer.cpp
+++ b/hurricane/src/viewer/CellViewer.cpp
@@ -45,6 +45,7 @@
#include "hurricane/viewer/MousePositionWidget.h"
#include "hurricane/viewer/ControllerWidget.h"
#include "hurricane/viewer/ScriptWidget.h"
+#include "hurricane/viewer/StratusWidget.h"
#include "hurricane/viewer/GotoWidget.h"
@@ -71,6 +72,7 @@ namespace Hurricane {
, _clearRulersAction (NULL)
, _controllerAction (NULL)
, _scriptAction (NULL)
+ , _stratusAction (NULL)
, _fileMenu (NULL)
, _viewMenu (NULL)
, _toolsMenu (NULL)
@@ -218,6 +220,11 @@ namespace Hurricane {
_scriptAction->setStatusTip ( tr("Run Python Script") );
_scriptAction->setIcon ( QIcon(":/images/python-logo-v3.png") );
//_scriptAction->setShortcut ( QKeySequence(tr("CTRL+I")) );
+
+ _stratusAction = new QAction ( tr("Stratus"), this );
+ _stratusAction->setObjectName ( "viewer.menuBar.tools.stratusScript" );
+ _stratusAction->setStatusTip ( tr("Run Stratus Script") );
+ _stratusAction->setIcon ( QIcon(":/images/stratus-cloud.png") );
}
@@ -261,6 +268,7 @@ namespace Hurricane {
_toolsMenu->setObjectName ( "viewer.menuBar.tools" );
_toolsMenu->addAction ( _controllerAction );
_toolsMenu->addAction ( _scriptAction );
+ _toolsMenu->addAction ( _stratusAction );
}
@@ -319,6 +327,7 @@ namespace Hurricane {
connect ( _clearRulersAction , SIGNAL(triggered()) , _cellWidget, SLOT(clearRulers()) );
connect ( _controllerAction , SIGNAL(triggered()) , _controller, SLOT(toggleShow()) );
connect ( _scriptAction , SIGNAL(triggered()) , this , SLOT(runScript()) );
+ connect ( _stratusAction , SIGNAL(triggered()) , this , SLOT(runStratusScript()) );
connect ( _gotoAction , SIGNAL(triggered()) , this , SLOT(doGoto()) );
connect ( _cellWidget , SIGNAL(dbuModeChanged(unsigned int,DbU::UnitPower))
@@ -558,9 +567,11 @@ namespace Hurricane {
void CellViewer::runScript ()
- {
- ScriptWidget::runScript ( this, getCell() );
- }
+ { ScriptWidget::runScript ( this, getCell() ); }
+
+
+ void CellViewer::runStratusScript ()
+ { StratusWidget::runScript ( this ); }
} // End of Hurricane namespace.
diff --git a/hurricane/src/viewer/CellViewer.qrc b/hurricane/src/viewer/CellViewer.qrc
index b9c33291..6955f120 100644
--- a/hurricane/src/viewer/CellViewer.qrc
+++ b/hurricane/src/viewer/CellViewer.qrc
@@ -10,6 +10,7 @@
images/gtk-go-forward-ltr.png
images/swiss-knife.png
images/python-logo-v3.png
+ images/stratus-cloud.png
images/gnome-gmush.png
images/gnome-core.png
images/i-core.png
diff --git a/hurricane/src/viewer/Script.cpp b/hurricane/src/viewer/Script.cpp
index e6a23f84..a56474d8 100644
--- a/hurricane/src/viewer/Script.cpp
+++ b/hurricane/src/viewer/Script.cpp
@@ -119,7 +119,7 @@ namespace Isobar {
{ _cellViewer = viewer; }
- bool Script::runFunction ( const std::string& function, Cell* cell )
+ bool Script::runFunction ( const std::string& function, Cell* cell, unsigned int flags )
{
bool returnCode = true;
@@ -148,7 +148,7 @@ namespace Isobar {
if ( cell != NULL ) PyTuple_SetItem ( _pyArgs, 0, (PyObject*)PyCell_Link(cell) );
else PyTuple_SetItem ( _pyArgs, 0, Py_None );
- _pyResult = PyEval_CallObject ( _pyFunction, _pyArgs );
+ _pyResult = PyEval_CallObject ( _pyFunction, (flags&NoScriptArgs) ? NULL : _pyArgs );
if ( _pyResult == NULL ) {
cerr << "Something has gone slightly wrong" << endl;
diff --git a/hurricane/src/viewer/StratusWidget.cpp b/hurricane/src/viewer/StratusWidget.cpp
new file mode 100644
index 00000000..6754e094
--- /dev/null
+++ b/hurricane/src/viewer/StratusWidget.cpp
@@ -0,0 +1,141 @@
+
+// -*- C++ -*-
+//
+// This file is part of the Coriolis Software.
+// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
+//
+// ===================================================================
+//
+// $Id$
+//
+// x-----------------------------------------------------------------x
+// | |
+// | C O R I O L I S |
+// | V L S I B a c k e n d D a t a - B a s e |
+// | |
+// | Author : Jean-Paul CHAPUT |
+// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
+// | =============================================================== |
+// | C++ Module : "./StratusWidget.cpp" |
+// | *************************************************************** |
+// | U p d a t e s |
+// | |
+// x-----------------------------------------------------------------x
+
+
+#include
+#include
+using namespace std;
+
+#include
+namespace bfs = boost::filesystem;
+
+#include "hurricane/Warning.h"
+#include "hurricane/viewer/Script.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "hurricane/viewer/Graphics.h"
+#include "hurricane/viewer/StratusWidget.h"
+#include "hurricane/viewer/CellViewer.h"
+
+
+namespace Hurricane {
+
+
+// -------------------------------------------------------------------
+// Class : "StratusWidget".
+
+
+ StratusWidget::StratusWidget ( QWidget* parent )
+ : QDialog (parent)
+ , _lineEdit(NULL)
+ {
+ setWindowTitle ( tr("Execute Stratus Script") );
+
+ QLabel* label = new QLabel ();
+ label->setText ( tr("Stratus script to execute") );
+ label->setFont ( Graphics::getNormalFont(true) );
+
+ _lineEdit = new QLineEdit ();
+ _lineEdit->setMinimumWidth ( 400 );
+
+ QPushButton* okButton = new QPushButton ();
+ okButton->setText ( "OK" );
+ okButton->setDefault ( true );
+
+ QPushButton* cancelButton = new QPushButton ();
+ cancelButton->setText ( "Cancel" );
+
+ QHBoxLayout* hLayout1 = new QHBoxLayout ();
+ hLayout1->addStretch ();
+ hLayout1->addWidget ( okButton );
+ hLayout1->addStretch ();
+ hLayout1->addWidget ( cancelButton );
+ hLayout1->addStretch ();
+
+ //QFrame* separator = new QFrame ();
+ //separator->setFrameShape ( QFrame::HLine );
+ //separator->setFrameShadow ( QFrame::Sunken );
+
+ QVBoxLayout* vLayout = new QVBoxLayout ();
+ vLayout->setSizeConstraint ( QLayout::SetFixedSize );
+ vLayout->addWidget ( label );
+ vLayout->addWidget ( _lineEdit );
+ vLayout->addLayout ( hLayout1 );
+ //vLayout->addWidget ( separator );
+
+ setLayout ( vLayout );
+ //setModal ( true );
+
+ connect ( okButton, SIGNAL(clicked()) , this, SLOT(accept()) );
+ connect ( cancelButton, SIGNAL(clicked()) , this, SLOT(reject()) );
+ }
+
+
+ const QString StratusWidget::getScriptName () const
+ {
+ return _lineEdit->text();
+ }
+
+
+ bool StratusWidget::runScript ( QWidget* parent )
+ {
+ StratusWidget* dialog = new StratusWidget ( parent );
+ bool doRunStratus = (dialog->exec() == Accepted);
+ QString scriptName = dialog->getScriptName ();
+
+ delete dialog;
+ if ( not doRunStratus ) return false;
+
+ if ( scriptName.endsWith(".py",Qt::CaseInsensitive) )
+ scriptName.truncate ( scriptName.size()-3 );
+
+ bfs::path userStratus = scriptName.toStdString();
+ bfs::path userDirectory = userStratus.branch_path();
+
+ if ( not userDirectory.is_complete() )
+ userDirectory = bfs::current_path() / userDirectory;
+ userDirectory.normalize();
+
+ Isobar::Script::addPath ( userDirectory.string() );
+
+ dbo_ptr script = Isobar::Script::create(userStratus.leaf());
+ script->setEditor ( qobject_cast(parent) );
+
+ bool returnCode = script->runFunction ( "StratusScript", NULL, Isobar::Script::NoScriptArgs );
+
+ Isobar::Script::removePath ( userDirectory.string() );
+
+ return returnCode;
+ }
+
+
+} // End of Hurricane namespace.
diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h
index 1e9e6d07..6db7a03f 100644
--- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h
+++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h
@@ -92,6 +92,7 @@ namespace Hurricane {
void raiseToolInterrupt ();
void clearToolInterrupt ();
void runScript ();
+ void runStratusScript ();
signals:
void showSelectionToggled ( bool );
void stateChanged ( shared_ptr& );
@@ -124,6 +125,7 @@ namespace Hurricane {
QAction* _clearRulersAction;
QAction* _controllerAction;
QAction* _scriptAction;
+ QAction* _stratusAction;
QMenu* _fileMenu;
QMenu* _viewMenu;
QMenu* _toolsMenu;
diff --git a/hurricane/src/viewer/hurricane/viewer/Script.h b/hurricane/src/viewer/hurricane/viewer/Script.h
index 31edd481..18a8a69e 100644
--- a/hurricane/src/viewer/hurricane/viewer/Script.h
+++ b/hurricane/src/viewer/hurricane/viewer/Script.h
@@ -53,6 +53,8 @@ namespace Isobar {
class Script {
+ public:
+ enum Flags { NoScriptArgs=0x1 };
public:
static void addPath ( const std::string& path );
static void removePath ( const std::string& path );
@@ -62,7 +64,7 @@ namespace Isobar {
inline PyObject* getHurricaneModule ();
inline PyObject* getUserModule ();
void setEditor ( Hurricane::CellViewer* );
- bool runFunction ( const std::string& function, Hurricane::Cell* cell );
+ bool runFunction ( const std::string& function, Hurricane::Cell* cell, unsigned int flags=0 );
protected:
static std::vector _pathes;
std::string _moduleName;
diff --git a/hurricane/src/viewer/hurricane/viewer/StratusWidget.h b/hurricane/src/viewer/hurricane/viewer/StratusWidget.h
new file mode 100644
index 00000000..2eb91db1
--- /dev/null
+++ b/hurricane/src/viewer/hurricane/viewer/StratusWidget.h
@@ -0,0 +1,55 @@
+
+// -*- C++ -*-
+//
+// This file is part of the Coriolis Software.
+// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
+//
+// ===================================================================
+//
+// $Id$
+//
+// x-----------------------------------------------------------------x
+// | |
+// | C O R I O L I S |
+// | V L S I B a c k e n d D a t a - B a s e |
+// | |
+// | Author : Jean-Paul CHAPUT |
+// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
+// | =============================================================== |
+// | C++ Header : "./StratusWidget.h" |
+// | *************************************************************** |
+// | U p d a t e s |
+// | |
+// x-----------------------------------------------------------------x
+
+
+#ifndef __HURRICANE_STRATUS_WIDGET__
+#define __HURRICANE_STRATUS_WIDGET__
+
+#include
+
+class QLineEdit;
+
+
+namespace Hurricane {
+
+ class Cell;
+
+
+ class StratusWidget : public QDialog {
+ Q_OBJECT;
+ public:
+ static bool runScript ( QWidget* parent );
+ const QString getScriptName () const;
+ protected:
+ StratusWidget ( QWidget* parent=NULL );
+ protected:
+ QLineEdit* _lineEdit;
+ };
+
+
+} // End of Hurricane namespace.
+
+
+#endif // __HURRICANE_STRATUS_WIDGET__
+
diff --git a/hurricane/src/viewer/images/stratus-cloud.png b/hurricane/src/viewer/images/stratus-cloud.png
new file mode 100644
index 00000000..3b60d863
Binary files /dev/null and b/hurricane/src/viewer/images/stratus-cloud.png differ