* All tools:
- Library linking: there must not be "target_link_library()" for libraries, only when building binaries. Avoid clashes between static module or class variables, and strange reinitialisation of those variables. - Change: Boost is now always linked staticly. * ./hurricane/src/hurricane: - New: TextTranslator to allow translation to and from text & HTML. - Change: In Exception, make uses of TextTranslator to correctly display exception text when in graphic mode. * ./hurricane/src/isobar: - New: Script, small object to wrap around Python scripts.
This commit is contained in:
parent
ff826d31cf
commit
fbd9aba2f5
|
@ -55,13 +55,13 @@ IF(NOT BUILD_SHARED_LIBS)
|
|||
)
|
||||
MESSAGE(STATUS "Building static libraries.")
|
||||
IF(Boost_FOUND)
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
MESSAGE(STATUS "Using Boost static libraries.")
|
||||
ENDIF(Boost_FOUND)
|
||||
ELSE(NOT BUILD_SHARED_LIBS)
|
||||
MESSAGE(STATUS "Building dynamic libraries.")
|
||||
ENDIF(NOT BUILD_SHARED_LIBS)
|
||||
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
MESSAGE(STATUS "Always uses Boost static libraries.")
|
||||
FIND_PACKAGE(Boost 1.33.1 COMPONENTS regex REQUIRED)
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
|
|
|
@ -41,14 +41,14 @@ MACRO(HURRICANE_CHECK_LIBRARIES)
|
|||
ENDMACRO(HURRICANE_CHECK_LIBRARIES)
|
||||
|
||||
MACRO(SET_LIB_LINK_MODE)
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
MESSAGE(STATUS "Always uses Boost static libraries.")
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
# check for qmake
|
||||
FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake-qt4 qmake PATHS
|
||||
/opt/qt4-static-4.3.2/bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
MESSAGE(STATUS "Using Boost static libraries.")
|
||||
MESSAGE(STATUS "Building static libraries.")
|
||||
ELSE(NOT BUILD_SHARED_LIBS)
|
||||
MESSAGE(STATUS "Building dynamic libraries.")
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
hurricane/Vertical.h hurricane/Verticals.h
|
||||
hurricane/Views.h
|
||||
hurricane/Warning.h
|
||||
hurricane/TextTranslator.h
|
||||
)
|
||||
set ( cpps Record.cpp
|
||||
Slot.cpp
|
||||
|
@ -148,8 +149,9 @@
|
|||
Query.cpp
|
||||
Marker.cpp
|
||||
Timer.cpp
|
||||
TextTranslator.cpp
|
||||
)
|
||||
|
||||
add_library ( hurricane ${cpps} )
|
||||
install ( TARGETS hurricane DESTINATION lib${LIB_SUFFIX} )
|
||||
install ( FILES ${includes} DESTINATION include/coriolis2/hurricane )
|
||||
add_library ( hurricane ${cpps} )
|
||||
install ( TARGETS hurricane DESTINATION lib${LIB_SUFFIX} )
|
||||
install ( FILES ${includes} DESTINATION include/coriolis2/hurricane )
|
||||
|
|
|
@ -19,6 +19,42 @@
|
|||
|
||||
#include "hurricane/Exception.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
|
||||
TextTranslator getDefaultTextTranslator ()
|
||||
{
|
||||
TextTranslator translator;
|
||||
|
||||
translator.addTranslation ( "<br>" , "\n" );
|
||||
translator.addTranslation ( "<em>" , "" );
|
||||
translator.addTranslation ( "</em>" , "" );
|
||||
translator.addTranslation ( "<strong>" , "" );
|
||||
translator.addTranslation ( "</strong>", "" );
|
||||
translator.addTranslation ( "<tt>" , "" );
|
||||
translator.addTranslation ( "</tt>" , "" );
|
||||
translator.addTranslation ( "<b>" , "" );
|
||||
translator.addTranslation ( "</b>" , "" );
|
||||
translator.addTranslation ( "<i>" , "" );
|
||||
translator.addTranslation ( "</i>" , "" );
|
||||
translator.addTranslation ( "<big>" , "" );
|
||||
translator.addTranslation ( "</big>" , "" );
|
||||
translator.addTranslation ( "<small>" , "" );
|
||||
translator.addTranslation ( "</small>" , "" );
|
||||
translator.addTranslation ( "<" , "<" );
|
||||
translator.addTranslation ( ">" , ">" );
|
||||
|
||||
return translator;
|
||||
}
|
||||
|
||||
|
||||
} // End of anonymous namespace.
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
|
@ -27,6 +63,10 @@ namespace Hurricane {
|
|||
// Exception implementation
|
||||
// ****************************************************************************************************
|
||||
|
||||
TextTranslator Exception::_textTranslator = getDefaultTextTranslator();
|
||||
TextTranslator Exception::_htmlTranslator;
|
||||
|
||||
|
||||
Exception::Exception()
|
||||
// *******************
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved
|
||||
// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved
|
||||
//
|
||||
// This file is part of Hurricane.
|
||||
//
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define HURRICANE_EXCEPTION
|
||||
|
||||
#include "hurricane/Commons.h"
|
||||
#include "hurricane/TextTranslator.h"
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
@ -33,6 +34,12 @@ namespace Hurricane {
|
|||
class Exception {
|
||||
// **************
|
||||
|
||||
// Attributes
|
||||
// **********
|
||||
|
||||
private: static TextTranslator _textTranslator;
|
||||
private: static TextTranslator _htmlTranslator;
|
||||
|
||||
// Constructors
|
||||
// ************
|
||||
|
||||
|
@ -53,12 +60,16 @@ class Exception {
|
|||
// Accessors
|
||||
// *********
|
||||
|
||||
public: string what() const { return _getString(); };
|
||||
public: string what () const { return textWhat(); };
|
||||
public: string textWhat() const { return _textTranslator.translate(_getString()); };
|
||||
public: string htmlWhat() const { return _htmlTranslator.translate(_getString()); };
|
||||
|
||||
// Others
|
||||
// ******
|
||||
|
||||
public: virtual string _getString() const = 0;
|
||||
public: static void setTextTranslator ( const TextTranslator& translator ) { _textTranslator=translator; }
|
||||
public: static void setHtmlTranslator ( const TextTranslator& translator ) { _htmlTranslator=translator; }
|
||||
public: virtual string _getString () const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,94 +3,93 @@
|
|||
${HURRICANE_SOURCE_DIR}/src/isobar
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
)
|
||||
set ( sources ProxyProperty.cpp
|
||||
PyBox.cpp
|
||||
PyCell.cpp
|
||||
PyCellCollection.cpp
|
||||
PyComponent.cpp
|
||||
PyComponentCollection.cpp
|
||||
PyContact.cpp
|
||||
PyDataBase.cpp
|
||||
PyEntity.cpp
|
||||
PyHorizontal.cpp
|
||||
PyHurricane.cpp
|
||||
PyHyperNet.cpp
|
||||
PyInstance.cpp
|
||||
PyInstanceCollection.cpp
|
||||
PyLayer.cpp
|
||||
PyLibrary.cpp
|
||||
PyNet.cpp
|
||||
PyNetCollection.cpp
|
||||
PyOccurrence.cpp
|
||||
PyOccurrenceCollection.cpp
|
||||
PyPad.cpp
|
||||
PyPath.cpp
|
||||
PyPin.cpp
|
||||
PyPinCollection.cpp
|
||||
PyPlug.cpp
|
||||
PyPlugCollection.cpp
|
||||
PyPoint.cpp
|
||||
PyReference.cpp
|
||||
PyReferenceCollection.cpp
|
||||
PySegment.cpp
|
||||
PySegmentCollection.cpp
|
||||
PyTechnology.cpp
|
||||
PyTransformation.cpp
|
||||
PyDbU.cpp
|
||||
PyUpdateSession.cpp
|
||||
PyVertical.cpp
|
||||
|
||||
)
|
||||
set ( includes hurricane/isobar/ProxyProperty.h
|
||||
hurricane/isobar/PyBox.h
|
||||
hurricane/isobar/PyCell.h
|
||||
hurricane/isobar/PyCellCollection.h
|
||||
hurricane/isobar/PyComponent.h
|
||||
hurricane/isobar/PyComponentCollection.h
|
||||
hurricane/isobar/PyContact.h
|
||||
hurricane/isobar/PyDataBase.h
|
||||
hurricane/isobar/PyEntity.h
|
||||
hurricane/isobar/PyHorizontal.h
|
||||
hurricane/isobar/PyHurricane.h
|
||||
hurricane/isobar/PyHyperNet.h
|
||||
hurricane/isobar/PyInstance.h
|
||||
hurricane/isobar/PyInstanceCollection.h
|
||||
hurricane/isobar/PyLayer.h
|
||||
hurricane/isobar/PyLibrary.h
|
||||
hurricane/isobar/PyNet.h
|
||||
hurricane/isobar/PyNetCollection.h
|
||||
hurricane/isobar/PyOccurrence.h
|
||||
hurricane/isobar/PyOccurrenceCollection.h
|
||||
hurricane/isobar/PyPad.h
|
||||
hurricane/isobar/PyPath.h
|
||||
hurricane/isobar/PyPin.h
|
||||
hurricane/isobar/PyPinCollection.h
|
||||
hurricane/isobar/PyPlug.h
|
||||
hurricane/isobar/PyPlugCollection.h
|
||||
hurricane/isobar/PyPoint.h
|
||||
hurricane/isobar/PyReference.h
|
||||
hurricane/isobar/PyReferenceCollection.h
|
||||
hurricane/isobar/PySegment.h
|
||||
hurricane/isobar/PySegmentCollection.h
|
||||
hurricane/isobar/PyTechnology.h
|
||||
hurricane/isobar/PyTransformation.h
|
||||
hurricane/isobar/PyDbU.h
|
||||
hurricane/isobar/PyUpdateSession.h
|
||||
hurricane/isobar/PyVertical.h
|
||||
set ( sources ProxyProperty.cpp
|
||||
PyBox.cpp
|
||||
PyCell.cpp
|
||||
PyCellCollection.cpp
|
||||
PyComponent.cpp
|
||||
PyComponentCollection.cpp
|
||||
PyContact.cpp
|
||||
PyDataBase.cpp
|
||||
PyEntity.cpp
|
||||
PyHorizontal.cpp
|
||||
PyHurricane.cpp
|
||||
PyHyperNet.cpp
|
||||
PyInstance.cpp
|
||||
PyInstanceCollection.cpp
|
||||
PyLayer.cpp
|
||||
PyLibrary.cpp
|
||||
PyNet.cpp
|
||||
PyNetCollection.cpp
|
||||
PyOccurrence.cpp
|
||||
PyOccurrenceCollection.cpp
|
||||
PyPad.cpp
|
||||
PyPath.cpp
|
||||
PyPin.cpp
|
||||
PyPinCollection.cpp
|
||||
PyPlug.cpp
|
||||
PyPlugCollection.cpp
|
||||
PyPoint.cpp
|
||||
PyReference.cpp
|
||||
PyReferenceCollection.cpp
|
||||
PySegment.cpp
|
||||
PySegmentCollection.cpp
|
||||
PyTechnology.cpp
|
||||
PyTransformation.cpp
|
||||
PyDbU.cpp
|
||||
PyUpdateSession.cpp
|
||||
PyVertical.cpp
|
||||
)
|
||||
set ( includes hurricane/isobar/ProxyProperty.h
|
||||
hurricane/isobar/PyBox.h
|
||||
hurricane/isobar/PyCell.h
|
||||
hurricane/isobar/PyCellCollection.h
|
||||
hurricane/isobar/PyComponent.h
|
||||
hurricane/isobar/PyComponentCollection.h
|
||||
hurricane/isobar/PyContact.h
|
||||
hurricane/isobar/PyDataBase.h
|
||||
hurricane/isobar/PyEntity.h
|
||||
hurricane/isobar/PyHorizontal.h
|
||||
hurricane/isobar/PyHurricane.h
|
||||
hurricane/isobar/PyHyperNet.h
|
||||
hurricane/isobar/PyInstance.h
|
||||
hurricane/isobar/PyInstanceCollection.h
|
||||
hurricane/isobar/PyLayer.h
|
||||
hurricane/isobar/PyLibrary.h
|
||||
hurricane/isobar/PyNet.h
|
||||
hurricane/isobar/PyNetCollection.h
|
||||
hurricane/isobar/PyOccurrence.h
|
||||
hurricane/isobar/PyOccurrenceCollection.h
|
||||
hurricane/isobar/PyPad.h
|
||||
hurricane/isobar/PyPath.h
|
||||
hurricane/isobar/PyPin.h
|
||||
hurricane/isobar/PyPinCollection.h
|
||||
hurricane/isobar/PyPlug.h
|
||||
hurricane/isobar/PyPlugCollection.h
|
||||
hurricane/isobar/PyPoint.h
|
||||
hurricane/isobar/PyReference.h
|
||||
hurricane/isobar/PyReferenceCollection.h
|
||||
hurricane/isobar/PySegment.h
|
||||
hurricane/isobar/PySegmentCollection.h
|
||||
hurricane/isobar/PyTechnology.h
|
||||
hurricane/isobar/PyTransformation.h
|
||||
hurricane/isobar/PyDbU.h
|
||||
hurricane/isobar/PyUpdateSession.h
|
||||
hurricane/isobar/PyVertical.h
|
||||
)
|
||||
# source2 & include2 for module that are *not* Python wrappers but true
|
||||
# Hurricane modules.
|
||||
set ( sources2 Script.cpp )
|
||||
set ( includes2 hurricane/isobar/Script.h)
|
||||
|
||||
|
||||
install ( FILES ${includes} DESTINATION include/coriolis2/hurricane/isobar )
|
||||
|
||||
add_library ( isobar ${sources} )
|
||||
target_link_libraries ( isobar hurricane ${PYTHON_LIBRARIES} -lutil )
|
||||
|
||||
install ( FILES ${includes}
|
||||
${includes2} DESTINATION include/coriolis2/hurricane/isobar )
|
||||
add_library ( isobar ${sources} ${sources2} )
|
||||
add_library ( Hurricane MODULE ${sources} )
|
||||
set_target_properties ( Hurricane PROPERTIES
|
||||
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
|
||||
PREFIX ""
|
||||
)
|
||||
target_link_libraries ( Hurricane isobar hurricane ${PYTHON_LIBRARIES} )
|
||||
|
||||
install ( TARGETS isobar DESTINATION lib${LIB_SUFFIX} )
|
||||
install ( TARGETS Hurricane DESTINATION ${PYTHON_SITE_PACKAGES} )
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved
|
||||
//
|
||||
// This file is part of Hurricane.
|
||||
//
|
||||
// Hurricane is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// Hurricane is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
|
||||
// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the Lesser GNU General Public
|
||||
// License along with Hurricane. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// x-----------------------------------------------------------------x
|
||||
// | |
|
||||
// | H U R R I C A N E |
|
||||
// | 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@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Module : "./Script.cpp" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include "hurricane/Error.h"
|
||||
#include "hurricane/Cell.h"
|
||||
#include "hurricane/isobar/PyCell.h"
|
||||
#include "hurricane/isobar/Script.h"
|
||||
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using std::string;
|
||||
using Hurricane::Cell;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Isobar::Script".
|
||||
|
||||
|
||||
vector<string> Script::_pathes;
|
||||
|
||||
|
||||
void Script::addPath ( const string& path )
|
||||
{ _pathes.push_back ( path ); }
|
||||
|
||||
|
||||
Script::Script ( const string& name )
|
||||
: _moduleName(name)
|
||||
, _sysModule (NULL)
|
||||
, _userModule(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Script::~Script ()
|
||||
{
|
||||
_destroyModules();
|
||||
}
|
||||
|
||||
|
||||
Script* Script::create ( const std::string& name )
|
||||
{
|
||||
Script* script = new Script ( name );
|
||||
return script;
|
||||
}
|
||||
|
||||
|
||||
void Script::destroy ()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
bool Script::runFunction ( const std::string& function, Cell* cell )
|
||||
{
|
||||
bool returnCode = true;
|
||||
|
||||
if ( cell == NULL )
|
||||
throw Error("Script::runFunction(): NULL Cell as argument");
|
||||
|
||||
Py_Initialize ();
|
||||
_importSys ();
|
||||
_importModule ( "Hurricane" );
|
||||
|
||||
_userModule = PyImport_ImportModule ( const_cast<char*>(_moduleName.c_str()) );
|
||||
|
||||
if ( _userModule == NULL ) {
|
||||
if ( PyErr_Occurred() ) {
|
||||
PyErr_Print ();
|
||||
}
|
||||
throw Error("Cannot load python module: <%s>",_moduleName.c_str());
|
||||
}
|
||||
|
||||
PyObject* pyFunction = PyObject_GetAttrString(_userModule, const_cast<char*>(function.c_str()));
|
||||
if ( (pyFunction == NULL) or not PyCallable_Check(pyFunction) ) {
|
||||
_destroyModules ();
|
||||
throw Error("Python module <%s> doesn't contains any <%s> function."
|
||||
,_moduleName.c_str(),function.c_str());
|
||||
}
|
||||
|
||||
PyObject* pyArgs = PyTuple_New(1);
|
||||
PyTuple_SetItem ( pyArgs, 0, (PyObject*)PyCell_Link(cell) );
|
||||
|
||||
PyObject* pyResult = PyEval_CallObject ( pyFunction, pyArgs );
|
||||
|
||||
if ( pyResult == NULL ) {
|
||||
cerr << "Something has gone slightly wrong" << endl;
|
||||
} else
|
||||
Py_DECREF ( pyResult );
|
||||
|
||||
if ( PyErr_Occurred() ) {
|
||||
PyErr_Print ();
|
||||
returnCode = false;
|
||||
}
|
||||
|
||||
Py_DECREF ( pyFunction );
|
||||
Py_DECREF ( pyArgs );
|
||||
|
||||
_destroyModules ();
|
||||
Py_Finalize ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Script::_importSys ()
|
||||
{
|
||||
_sysModule = _importModule ( "sys" );
|
||||
|
||||
PyObject* path = PyObject_GetAttrString ( _sysModule, "path" );
|
||||
if ( path == NULL )
|
||||
throw Error("Script::_importSys(): No \"sys.path\" attribute.");
|
||||
|
||||
vector<string>::iterator ipath = _pathes.begin();
|
||||
|
||||
for ( ; ipath != _pathes.end() ; ++ipath ) {
|
||||
cerr << "PYTHONPATH:" << (*ipath) << endl;
|
||||
|
||||
PyObject* element = PyString_FromString ( const_cast<char*>((*ipath).c_str()) );
|
||||
PyList_Insert ( path, 0, element );
|
||||
}
|
||||
|
||||
int size = PySequence_Size(path);
|
||||
for ( int i=0 ; i<size ; ++i )
|
||||
PyObject* element = PySequence_GetItem(path,i);
|
||||
}
|
||||
|
||||
|
||||
PyObject* Script::_importModule ( const string& moduleName )
|
||||
{
|
||||
if ( not Py_IsInitialized() )
|
||||
throw Error ( "Script::_importModule(): Called before Py_Initialize() while importing <%s>."
|
||||
, moduleName.c_str() );
|
||||
|
||||
PyObject* module = PyImport_ImportModule ( const_cast<char*>(moduleName.c_str()) );
|
||||
if ( module == NULL )
|
||||
throw Error("Script::_importModule(): No <%s> module.",moduleName.c_str());
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
|
||||
void Script::_destroyModules ()
|
||||
{
|
||||
if ( not Py_IsInitialized() ) return;
|
||||
|
||||
if ( _userModule != NULL ) Py_DECREF ( _userModule );
|
||||
if ( _sysModule != NULL ) Py_DECREF ( _sysModule );
|
||||
|
||||
_userModule = NULL;
|
||||
_sysModule = NULL;
|
||||
}
|
||||
|
||||
|
||||
} // End of Isobar namespace.
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved
|
||||
//
|
||||
// This file is part of ISOBAR.
|
||||
//
|
||||
// ISOBAR is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// ISOBAR is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
|
||||
// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the Lesser GNU General Public
|
||||
// License along with ISOBAR. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// x-----------------------------------------------------------------x
|
||||
// | |
|
||||
// | H U R R I C A N E |
|
||||
// | 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@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/isobar/Script.h" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
# ifndef __ISOBAR_SCRIPT__
|
||||
# define __ISOBAR_SCRIPT__
|
||||
|
||||
#include <vector>
|
||||
#include <Python.h>
|
||||
namespace Hurricane {
|
||||
class Cell;
|
||||
}
|
||||
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
|
||||
class Script {
|
||||
public:
|
||||
static void addPath ( const std::string& path );
|
||||
static Script* create ( const std::string& name );
|
||||
void destroy ();
|
||||
inline PyObject* getUserModule ();
|
||||
bool runFunction ( const std::string& function, Hurricane::Cell* cell );
|
||||
protected:
|
||||
static std::vector<std::string> _pathes;
|
||||
std::string _moduleName;
|
||||
PyObject* _sysModule;
|
||||
PyObject* _userModule;
|
||||
protected:
|
||||
Script ( const std::string& name );
|
||||
~Script ();
|
||||
Script ( const Script& );
|
||||
Script& operator= ( const Script& );
|
||||
void _importSys ();
|
||||
PyObject* _importModule ( const std::string& );
|
||||
void _destroyModules ();
|
||||
};
|
||||
|
||||
|
||||
// Inline Methods.
|
||||
inline PyObject* Script::getUserModule () { return _userModule; }
|
||||
|
||||
|
||||
} // End of Isobar namespace.
|
||||
|
||||
|
||||
# endif // __ISOBAR_SCRIPT__
|
|
@ -111,12 +111,6 @@
|
|||
qt4_wrap_cpp ( MOC_SRCS ${mocincludes} )
|
||||
qt4_add_resources ( RCC_SRCS CellViewer.qrc )
|
||||
|
||||
install ( FILES ${exports} DESTINATION include/coriolis2/hurricane/viewer )
|
||||
|
||||
add_library ( viewer ${cpps} ${MOC_SRCS} ${RCC_SRCS} )
|
||||
target_link_libraries ( viewer hurricane
|
||||
${CONFIGURATION_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
install ( TARGETS viewer DESTINATION lib${LIB_SUFFIX} )
|
||||
install ( FILES ${exports} DESTINATION include/coriolis2/hurricane/viewer )
|
||||
add_library ( viewer ${cpps} ${MOC_SRCS} ${RCC_SRCS} )
|
||||
install ( TARGETS viewer DESTINATION lib${LIB_SUFFIX} )
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
# include <assert.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Qt>
|
||||
#include <QBrush>
|
||||
|
@ -31,13 +31,12 @@
|
|||
#include <QApplication>
|
||||
|
||||
#include "hurricane/Name.h"
|
||||
#include "hurricane/Exception.h"
|
||||
|
||||
#include "hurricane/viewer/DisplayStyle.h"
|
||||
#include "hurricane/viewer/Graphics.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
|
@ -45,13 +44,32 @@ namespace Hurricane {
|
|||
|
||||
|
||||
Graphics::Graphics ()
|
||||
: _styles()
|
||||
, _active(NULL)
|
||||
, _fireColorScale()
|
||||
, _rainbowColorScale()
|
||||
: _htmlTranslator ()
|
||||
, _styles ()
|
||||
, _active (NULL)
|
||||
, _fireColorScale ()
|
||||
, _rainbowColorScale ()
|
||||
, _temperatureColorScale()
|
||||
, _qtEnabled(false)
|
||||
, _qtEnabled (false)
|
||||
{
|
||||
_htmlTranslator.addTranslation ( "<br>" , "<br>" );
|
||||
_htmlTranslator.addTranslation ( "<em>" , "<em>" );
|
||||
_htmlTranslator.addTranslation ( "</em>" , "</em>" );
|
||||
_htmlTranslator.addTranslation ( "<strong>" , "<strong>" );
|
||||
_htmlTranslator.addTranslation ( "</strong>", "</strong>" );
|
||||
_htmlTranslator.addTranslation ( "<tt>" , "<tt>" );
|
||||
_htmlTranslator.addTranslation ( "</tt>" , "</tt>" );
|
||||
_htmlTranslator.addTranslation ( "<b>" , "<b>" );
|
||||
_htmlTranslator.addTranslation ( "</b>" , "</b>" );
|
||||
_htmlTranslator.addTranslation ( "<i>" , "<i>" );
|
||||
_htmlTranslator.addTranslation ( "</i>" , "</i>" );
|
||||
_htmlTranslator.addTranslation ( "<big>" , "<big>" );
|
||||
_htmlTranslator.addTranslation ( "</big>" , "</big>" );
|
||||
_htmlTranslator.addTranslation ( "<small>" , "<small>" );
|
||||
_htmlTranslator.addTranslation ( "</small>" , "</small>" );
|
||||
_htmlTranslator.addTranslation ( "<" , "<" );
|
||||
_htmlTranslator.addTranslation ( ">" , ">" );
|
||||
_htmlTranslator.addTranslation ( "\n" , "<br>" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,6 +86,8 @@ namespace Hurricane {
|
|||
DisplayStyle* fallback = new DisplayStyle("Fallback");
|
||||
fallback->setDescription ( "Builtin fallback style" );
|
||||
_singleton->_addStyle ( fallback );
|
||||
|
||||
Exception::setHtmlTranslator ( _singleton->_getHtmlTranslator() );
|
||||
}
|
||||
|
||||
return _singleton;
|
||||
|
@ -277,23 +297,31 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
const TextTranslator& Graphics::getHtmlTranslator ()
|
||||
{
|
||||
return getGraphics()->_getHtmlTranslator();
|
||||
}
|
||||
|
||||
|
||||
string Graphics::toHtml ( const string& s )
|
||||
{
|
||||
string protect = s;
|
||||
return getGraphics()->getHtmlTranslator().translate(s);
|
||||
|
||||
if ( !isEnabled() ) return protect;
|
||||
// string protect = s;
|
||||
|
||||
unsigned int pos = protect.find ( '<' );
|
||||
while ( pos < protect.size() ) {
|
||||
protect.replace ( pos, 1, "<" );
|
||||
pos = protect.find ( '<', pos );
|
||||
}
|
||||
pos = protect.find ( '>' );
|
||||
while ( pos < protect.size() ) {
|
||||
protect.replace ( pos, 1, ">" );
|
||||
pos = protect.find ( '>', pos );
|
||||
}
|
||||
return protect;
|
||||
// if ( !isEnabled() ) return protect;
|
||||
|
||||
// unsigned int pos = protect.find ( '<' );
|
||||
// while ( pos < protect.size() ) {
|
||||
// protect.replace ( pos, 1, "<" );
|
||||
// pos = protect.find ( '<', pos );
|
||||
// }
|
||||
// pos = protect.find ( '>' );
|
||||
// while ( pos < protect.size() ) {
|
||||
// protect.replace ( pos, 1, ">" );
|
||||
// pos = protect.find ( '>', pos );
|
||||
// }
|
||||
// return protect;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "hurricane/Exception.h"
|
||||
#include "hurricane/viewer/Graphics.h"
|
||||
#include "hurricane/viewer/ExceptionWidget.h"
|
||||
#include "hurricane/viewer/HApplication.h"
|
||||
|
||||
|
@ -77,7 +78,7 @@ namespace Hurricane {
|
|||
}
|
||||
catch ( Exception& e ) {
|
||||
ExceptionWidget* ew = new ExceptionWidget ();
|
||||
ew->setMessage ( e.what().c_str() );
|
||||
ew->setMessage ( e.htmlWhat().c_str() );
|
||||
if ( ew->exec() == QDialog::Rejected )
|
||||
kill ( getpid(), SIGSEGV );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
|
||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
|
@ -31,6 +31,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "hurricane/Breakpoint.h"
|
||||
#include "hurricane/TextTranslator.h"
|
||||
#include "hurricane/viewer/DisplayStyle.h"
|
||||
#include "hurricane/viewer/ColorScale.h"
|
||||
#include "hurricane/viewer/BreakpointWidget.h"
|
||||
|
@ -66,6 +67,7 @@ namespace Hurricane {
|
|||
static float getThreshold ( const Name& key );
|
||||
static int getDarkening ();
|
||||
static const ColorScale& getColorScale ( ColorScale::ScaleType );
|
||||
static const TextTranslator& getHtmlTranslator();
|
||||
static string toHtml ( const string& );
|
||||
static bool breakpointStopCb ( const string& message );
|
||||
|
||||
|
@ -81,6 +83,7 @@ namespace Hurricane {
|
|||
// Internals - Attributes.
|
||||
protected:
|
||||
static Graphics* _singleton;
|
||||
TextTranslator _htmlTranslator;
|
||||
vector<DisplayStyle*> _styles;
|
||||
DisplayStyle* _active;
|
||||
FireColorScale _fireColorScale;
|
||||
|
@ -89,28 +92,29 @@ namespace Hurricane {
|
|||
bool _qtEnabled;
|
||||
|
||||
// Internals - Constructors & Destructors.
|
||||
Graphics ();
|
||||
Graphics ( const Graphics& );
|
||||
Graphics& operator= ( const Graphics& );
|
||||
~Graphics ();
|
||||
|
||||
// Internals - Methods.
|
||||
size_t _findStyle ( const Name& key ) const;
|
||||
void _addStyle ( DisplayStyle* displayStyle );
|
||||
void _setStyle ( const Name& key );
|
||||
void _setStyle ( size_t id );
|
||||
DisplayStyle* _getStyle ( const Name& key );
|
||||
DisplayStyle* _getStyle () const;
|
||||
inline const vector<DisplayStyle*>& _getStyles () const;
|
||||
inline const Name& _getGroup ( const Name& key ) const;
|
||||
inline QColor _getColor ( const Name& key, int darkening ) const;
|
||||
inline QPen _getPen ( const Name& key, int darkening ) const;
|
||||
inline QBrush _getBrush ( const Name& key, int darkening ) const;
|
||||
inline const string& _getPattern ( const Name& key ) const;
|
||||
inline float _getThreshold ( const Name& key ) const;
|
||||
inline int _getDarkening () const;
|
||||
inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
|
||||
inline void _enable ();
|
||||
Graphics ();
|
||||
Graphics ( const Graphics& );
|
||||
Graphics& operator= ( const Graphics& );
|
||||
~Graphics ();
|
||||
|
||||
// Internals - Methods.
|
||||
size_t _findStyle ( const Name& key ) const;
|
||||
void _addStyle ( DisplayStyle* displayStyle );
|
||||
void _setStyle ( const Name& key );
|
||||
void _setStyle ( size_t id );
|
||||
DisplayStyle* _getStyle ( const Name& key );
|
||||
DisplayStyle* _getStyle () const;
|
||||
inline const vector<DisplayStyle*>& _getStyles () const;
|
||||
inline const Name& _getGroup ( const Name& key ) const;
|
||||
inline QColor _getColor ( const Name& key, int darkening ) const;
|
||||
inline QPen _getPen ( const Name& key, int darkening ) const;
|
||||
inline QBrush _getBrush ( const Name& key, int darkening ) const;
|
||||
inline const string& _getPattern ( const Name& key ) const;
|
||||
inline float _getThreshold ( const Name& key ) const;
|
||||
inline int _getDarkening () const;
|
||||
inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
|
||||
inline void _enable ();
|
||||
inline const TextTranslator& _getHtmlTranslator () const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -159,6 +163,9 @@ namespace Hurricane {
|
|||
inline const vector<DisplayStyle*>& Graphics::_getStyles () const
|
||||
{ return _styles; }
|
||||
|
||||
inline const TextTranslator& Graphics::_getHtmlTranslator () const
|
||||
{ return _htmlTranslator; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue