coriolis/hurricane/src/viewer/PyViewer.cpp

128 lines
4.3 KiB
C++
Raw Normal View History

2010-07-14 15:07:38 -05:00
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2010-2012, All Rights Reserved
2010-07-14 15:07:38 -05:00
//
// +-----------------------------------------------------------------+
2010-07-14 15:07:38 -05:00
// | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyViewer.cpp" |
// +-----------------------------------------------------------------+
2010-07-14 15:07:38 -05:00
#include "hurricane/isobar/PyHurricane.h"
#include "hurricane/viewer/PyHApplication.h"
#include "hurricane/viewer/PyGraphics.h"
#include "hurricane/viewer/PyDrawingStyle.h"
#include "hurricane/viewer/PyDrawingGroup.h"
#include "hurricane/viewer/PyDisplayStyle.h"
#include "hurricane/viewer/PyHSVr.h"
2010-07-14 15:07:38 -05:00
#include "hurricane/viewer/PyCellViewer.h"
namespace Hurricane {
using std::cerr;
using std::endl;
using Isobar::__cs;
#if !defined(__PYTHON_MODULE__)
// +=================================================================+
2010-07-14 15:07:38 -05:00
// | "PyViewer" Shared Library Code Part |
// +=================================================================+
2010-07-14 15:07:38 -05:00
# else // End of PyHurricane Shared Library Code Part.
// +=================================================================+
2010-07-14 15:07:38 -05:00
// | "PyViewer" Python Module Code Part |
// +=================================================================+
2010-07-14 15:07:38 -05:00
extern "C" {
// +-------------------------------------------------------------+
2010-07-14 15:07:38 -05:00
// | "PyViewer" Module Methods |
// +-------------------------------------------------------------+
2010-07-14 15:07:38 -05:00
static PyMethodDef PyViewer_Methods[] =
{ {NULL, NULL, 0, NULL} /* sentinel */
};
// ---------------------------------------------------------------
// Module Initialization : "initViewer ()"
DL_EXPORT(void) initViewer () {
trace << "initViewer()" << endl;
PyHSVr_LinkPyType ();
PyRawDrawingStyle_LinkPyType ();
PyDrawingStyleVector_LinkPyType ();
PyDrawingGroup_LinkPyType ();
PyDrawingGroupVector_LinkPyType ();
PyDisplayStyle_LinkPyType ();
PyDisplayStyleVector_LinkPyType ();
PyHApplication_LinkPyType ();
PyGraphics_LinkPyType ();
2010-07-14 15:07:38 -05:00
PyCellViewer_LinkPyType ();
PYTYPE_READY ( HSVr );
PYTYPE_READY ( RawDrawingStyle );
PYTYPE_READY ( DrawingStyleVector );
PYTYPE_READY ( DrawingStyleVectorIterator );
PYTYPE_READY ( DrawingGroup );
PYTYPE_READY ( DrawingGroupVector );
PYTYPE_READY ( DrawingGroupVectorIterator );
PYTYPE_READY ( DisplayStyle );
PYTYPE_READY ( DisplayStyleVector );
PYTYPE_READY ( DisplayStyleVectorIterator );
PYTYPE_READY ( HApplication );
PYTYPE_READY ( Graphics );
2010-07-14 15:07:38 -05:00
PYTYPE_READY ( CellViewer );
2010-07-14 15:07:38 -05:00
// Identifier string can take up to 10 characters.
__cs.addType ( "hsvr" , &PyTypeHSVr , "<HSVr>" , false );
__cs.addType ( "displaySty", &PyTypeDisplayStyle, "<DisplayStyle>", false );
__cs.addType ( "graphics" , &PyTypeGraphics , "<Graphics>" , false );
__cs.addType ( "cellView" , &PyTypeCellViewer , "<CellViewer>" , false, "view" );
2010-07-14 15:07:38 -05:00
PyObject* module = Py_InitModule ( "Viewer", PyViewer_Methods );
if ( module == NULL ) {
cerr << "[ERROR]\n"
<< " Failed to initialize Viewer module." << endl;
return;
}
Py_INCREF ( &PyTypeDisplayStyle );
PyModule_AddObject ( module, "DisplayStyle", (PyObject*)&PyTypeDisplayStyle );
Py_INCREF ( &PyTypeHApplication );
PyModule_AddObject ( module, "HApplication", (PyObject*)&PyTypeHApplication );
Py_INCREF ( &PyTypeGraphics );
PyModule_AddObject ( module, "Graphics", (PyObject*)&PyTypeGraphics );
2010-07-14 15:07:38 -05:00
Py_INCREF ( &PyTypeCellViewer );
PyModule_AddObject ( module, "CellViewer", (PyObject*)&PyTypeCellViewer );
PyDisplayStyle_postModuleInit();
trace << "Viewer.so loaded " << (void*)&typeid(string) << endl;
2010-07-14 15:07:38 -05:00
}
} // End of extern "C".
#endif // End of Python Module Code Part.
} // End of Hurricane namespace.