#include "SUIT_ResourceMgr.h"
#include "SUIT_Application.h"
-//#include "utilities.h"
-
#include "qapplication.h"
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qwt_legend.h>
-//#include "utilities.h"
-
#define DEFAULT_LINE_WIDTH 0 // (default) line width
#define DEFAULT_MARKER_SIZE 9 // default marker size
#define MIN_RECT_SIZE 11 // min sensibility area size
if ( xmark-2 == pnt.x() ) {
xCoord = majXmark;
xFound = true;
-// MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("<<i<<") = "<<majXmark<<" "<<xmark<<" "<<pnt.x());
break;
}
}
if ( xmark-2 == pnt.x() ) {
xCoord = minXmark;
xFound = true;
-// MESSAGE("Plot2d_ViewFrame::getInfo : close min X mark("<<i<<") = "<<minXmark<<" "<<xmark<<" "<<pnt.x());
break;
}
}
if ( cols[ "blue-min" ] > color.blue() )
cols[ "blue-min" ] = color.blue();
}
- for (IList::Iterator it = mars.begin(); it != mars.end(); ++it)
- MESSAGE("markers( " << it.key() << ") = " << it.data() );
- for (IList::Iterator it = lins.begin(); it != lins.end(); ++it)
- MESSAGE("lines( " << it.key() << ") = " << it.data() );
- for (SList::Iterator it = cols.begin(); it != cols.end(); ++it)
- MESSAGE("colors( " << it.key() << ") = " << it.data() );
#endif
Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY );
#include <vector>
#include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)!
-#include <Container_init_python.hxx>
#include <cStringIO.h>
-#include <utilities.h>
-
-
using namespace std;
-
-//#ifdef _DEBUG_
-//static int MYDEBUG = 1;
-//static int MYPYDEBUG = 1;
-//#else
-//static int MYDEBUG = 0;
-//static int MYPYDEBUG = 0;
-//#endif
-
-
PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
myThreadState(theThreadState),
- mySaveThreadState(KERNEL_PYTHON::_gtstate)
+ mySaveThreadState(0)
{
PyEval_AcquireLock();
mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save,
// set local in current
-// if(MYDEBUG) MESSAGE(" PyLockWrapper "<<this<<" aqcuired: new thread state "<<myThreadState<<" ; old thread state "<<mySaveThreadState);
}
PyLockWrapper::~PyLockWrapper(){
PyThreadState_Swap(mySaveThreadState); // restore previous current (no need to get local,
PyEval_ReleaseLock(); // local thread state* already in _tstate
-// if(MYDEBUG) MESSAGE(" PyLockWrapper "<<this<<" released: new thread state "<<mySaveThreadState);
}
class PyReleaseLock{
public:
~PyReleaseLock(){
-// if(MYPYDEBUG) MESSAGE("~PyReleaseLock()");
PyEval_ReleaseLock();
}
};
*/
PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst(true)
{
-// if(MYPYDEBUG) MESSAGE("PyInterp_base::PyInterp_base() - this = "<<this);
}
PyInterp_base::~PyInterp_base()
{
-// if(MYPYDEBUG) MESSAGE("PyInterp_base::~PyInterp_base() - this = "<<this);
PyLockWrapper aLock(_tstate);
//Py_EndInterpreter(_tstate);
}
init_python();
// Here the global lock is released
-// if(MYPYDEBUG) MESSAGE("PyInterp_base::initialize() - this = "<<this<<"; _gtstate = "<<_gtstate);
// The lock will be acquired in initState. Make provision to release it on exit
PyReleaseLock aReleaseLock;
// used to interpret & compile commands
PyObjWrapper m(PyImport_ImportModule("codeop"));
if(!m){
-// INFOS("PyInterp_base::initialize() - PyImport_ImportModule('codeop') failed");
PyErr_Print();
- ASSERT(0);
return;
}
void PyInterp_base::init_python()
{
- /*
- * Initialize the main state (_gtstate) if not already done
- * The lock is released on init_python output
- * It is the caller responsability to acquire it if needed
- */
- MESSAGE("PyInterp_base::init_python");
- ASSERT(KERNEL_PYTHON::_gtstate); // initialisation in main
- SCRUTE(KERNEL_PYTHON::_gtstate);
+ static PyThreadState *_gtstate = 0;
+
+ _atFirst = false;
+ if (Py_IsInitialized())
+ return;
+
+ Py_SetProgramName(_argv[0]);
+ Py_Initialize(); // Initialize the interpreter
+ PySys_SetArgv(_argc, _argv);
+ PyEval_InitThreads(); // Create (and acquire) the interpreter lock
+ _gtstate = PyEval_SaveThread(); // Release global thread state
// if(!_gtstate){
// PyReleaseLock aReleaseLock;
// Py_Initialize(); // Initialize the interpreter
PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
-// if(MYPYDEBUG) MESSAGE("PyInterp_base::initRun() - this = "<<this<<"; _verr = "<<_verr<<"; _vout = "<<_vout);
return 0;
}