Forgotten TextTranslator sources.
This commit is contained in:
parent
2797086746
commit
90527e4533
|
@ -1136,6 +1136,73 @@ class Cell_LeafInstanceOccurrencesUnder : public Collection<Occurrence> {
|
|||
|
||||
};
|
||||
|
||||
// ****************************************************************************************************
|
||||
// Cell_NonLeafInstanceOccurrences declaration
|
||||
// ****************************************************************************************************
|
||||
|
||||
class Cell_NonLeafInstanceOccurrences : public Collection<Occurrence> {
|
||||
// ********************************************************************
|
||||
|
||||
// Types
|
||||
// *****
|
||||
|
||||
public: typedef Collection<Occurrence> Inherit;
|
||||
|
||||
public: class Locator : public Hurricane::Locator<Occurrence> {
|
||||
// ************************************************************
|
||||
|
||||
public: typedef Hurricane::Locator<Occurrence> Inherit;
|
||||
|
||||
private: const Cell* _cell;
|
||||
private: int _state;
|
||||
private: InstanceLocator _nonLeafInstanceLocator;
|
||||
private: OccurrenceLocator _occurrenceLocator;
|
||||
|
||||
public: Locator(const Cell* cell = NULL);
|
||||
public: Locator(const Locator& locator);
|
||||
|
||||
public: Locator& operator=(const Locator& locator);
|
||||
|
||||
public: virtual Occurrence getElement() const;
|
||||
public: virtual Hurricane::Locator<Occurrence>* getClone() const;
|
||||
|
||||
public: virtual bool isValid() const;
|
||||
|
||||
public: virtual void progress();
|
||||
|
||||
public: virtual string _getString() const;
|
||||
|
||||
};
|
||||
|
||||
// Attributes
|
||||
// **********
|
||||
|
||||
private: const Cell* _cell;
|
||||
|
||||
// Constructors
|
||||
// ************
|
||||
|
||||
public: Cell_NonLeafInstanceOccurrences(const Cell* cell = NULL);
|
||||
public: Cell_NonLeafInstanceOccurrences(const Cell_NonLeafInstanceOccurrences& occurrences);
|
||||
|
||||
// Operators
|
||||
// *********
|
||||
|
||||
public: Cell_NonLeafInstanceOccurrences& operator=(const Cell_NonLeafInstanceOccurrences& occurrences);
|
||||
|
||||
// Accessors
|
||||
// *********
|
||||
|
||||
public: virtual Collection<Occurrence>* getClone() const;
|
||||
public: virtual Hurricane::Locator<Occurrence>* getLocator() const;
|
||||
|
||||
// Others
|
||||
// ******
|
||||
|
||||
public: virtual string _getString() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ****************************************************************************************************
|
||||
|
@ -1961,6 +2028,12 @@ Occurrences Cell::getLeafInstanceOccurrencesUnder(const Box& area) const
|
|||
return Cell_LeafInstanceOccurrencesUnder(this, area);
|
||||
}
|
||||
|
||||
Occurrences Cell::getNonLeafInstanceOccurrences() const
|
||||
// ***********************************************
|
||||
{
|
||||
return Cell_NonLeafInstanceOccurrences(this);
|
||||
}
|
||||
|
||||
Occurrences Cell::getComponentOccurrences(const Layer::Mask& mask) const
|
||||
// *******************************************************************
|
||||
{
|
||||
|
@ -3533,6 +3606,174 @@ string Cell_LeafInstanceOccurrencesUnder::Locator::_getString() const
|
|||
|
||||
|
||||
|
||||
|
||||
// ****************************************************************************************************
|
||||
// Cell_NonLeafInstanceOccurrences implementation
|
||||
// ****************************************************************************************************
|
||||
|
||||
Cell_NonLeafInstanceOccurrences::Cell_NonLeafInstanceOccurrences(const Cell* cell)
|
||||
// *******************************************************************************
|
||||
: Inherit(),
|
||||
_cell(cell)
|
||||
{
|
||||
}
|
||||
|
||||
Cell_NonLeafInstanceOccurrences::Cell_NonLeafInstanceOccurrences(const Cell_NonLeafInstanceOccurrences& occurrences)
|
||||
// ****************************************************************************************************
|
||||
: Inherit(),
|
||||
_cell(occurrences._cell)
|
||||
{
|
||||
}
|
||||
|
||||
Cell_NonLeafInstanceOccurrences& Cell_NonLeafInstanceOccurrences::operator=(const Cell_NonLeafInstanceOccurrences& occurrences)
|
||||
// ****************************************************************************************************
|
||||
{
|
||||
_cell = occurrences._cell;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Collection<Occurrence>* Cell_NonLeafInstanceOccurrences::getClone() const
|
||||
// *********************************************************************
|
||||
{
|
||||
return new Cell_NonLeafInstanceOccurrences(*this);
|
||||
}
|
||||
|
||||
Locator<Occurrence>* Cell_NonLeafInstanceOccurrences::getLocator() const
|
||||
// ********************************************************************
|
||||
{
|
||||
return new Locator(_cell);
|
||||
}
|
||||
|
||||
string Cell_NonLeafInstanceOccurrences::_getString() const
|
||||
// *******************************************************
|
||||
{
|
||||
string s = "<" + _TName("Cell::NonLeafInstanceOccurrences");
|
||||
if (_cell) s += " " + getString(_cell);
|
||||
s += ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ****************************************************************************************************
|
||||
// Cell_NonLeafInstanceOccurrences::Locator implementation
|
||||
// ****************************************************************************************************
|
||||
|
||||
Cell_NonLeafInstanceOccurrences::Locator::Locator(const Cell* cell)
|
||||
// ****************************************************************
|
||||
: Inherit ()
|
||||
, _cell (cell)
|
||||
, _state (0)
|
||||
, _nonLeafInstanceLocator()
|
||||
, _occurrenceLocator ()
|
||||
{
|
||||
if ( _cell ) {
|
||||
_nonLeafInstanceLocator = _cell->getNonLeafInstances().getLocator();
|
||||
if ( _nonLeafInstanceLocator.isValid() ) {
|
||||
_state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cell_NonLeafInstanceOccurrences::Locator::Locator(const Locator& locator)
|
||||
// **********************************************************************
|
||||
: Inherit ()
|
||||
, _cell (locator._cell)
|
||||
, _state (locator._state)
|
||||
, _nonLeafInstanceLocator(locator._nonLeafInstanceLocator)
|
||||
, _occurrenceLocator (locator._occurrenceLocator)
|
||||
{ }
|
||||
|
||||
Cell_NonLeafInstanceOccurrences::Locator& Cell_NonLeafInstanceOccurrences::Locator::operator=(const Locator& locator)
|
||||
// ********************************************************************************************************************
|
||||
{
|
||||
_cell = locator._cell;
|
||||
_state = locator._state;
|
||||
_nonLeafInstanceLocator = locator._nonLeafInstanceLocator;
|
||||
_occurrenceLocator = locator._occurrenceLocator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Occurrence Cell_NonLeafInstanceOccurrences::Locator::getElement() const
|
||||
// *********************************************************************
|
||||
{
|
||||
if ( _state ) {
|
||||
switch ( _state ) {
|
||||
case 1 : return Occurrence(_nonLeafInstanceLocator.getElement());
|
||||
case 2 :
|
||||
{
|
||||
Occurrence occurrence = _occurrenceLocator.getElement();
|
||||
Entity* entity = occurrence.getEntity();
|
||||
Path path = Path(_nonLeafInstanceLocator.getElement(), occurrence.getPath());
|
||||
return Occurrence(entity, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Occurrence();
|
||||
}
|
||||
|
||||
Locator<Occurrence>* Cell_NonLeafInstanceOccurrences::Locator::getClone() const
|
||||
// *****************************************************************************
|
||||
{
|
||||
return new Locator(*this);
|
||||
}
|
||||
|
||||
bool Cell_NonLeafInstanceOccurrences::Locator::isValid() const
|
||||
// ************************************************************
|
||||
{
|
||||
return ( _state != 0 );
|
||||
}
|
||||
|
||||
void Cell_NonLeafInstanceOccurrences::Locator::progress()
|
||||
// *******************************************************
|
||||
{
|
||||
if ( _state ) {
|
||||
switch ( _state ) {
|
||||
case 1:
|
||||
{
|
||||
_nonLeafInstanceLocator.progress();
|
||||
if ( _nonLeafInstanceLocator.isValid() ) break;
|
||||
|
||||
_state = 2;
|
||||
_nonLeafInstanceLocator = _cell->getNonLeafInstances().getLocator();
|
||||
if ( not _nonLeafInstanceLocator.isValid() ) {
|
||||
_state = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Cell* masterCell = _nonLeafInstanceLocator.getElement()->getMasterCell();
|
||||
_occurrenceLocator = masterCell->getNonLeafInstanceOccurrences().getLocator();
|
||||
|
||||
if ( _occurrenceLocator.isValid() ) break;
|
||||
}
|
||||
case 2:
|
||||
_occurrenceLocator.progress ();
|
||||
|
||||
while ( (_state != 0) and not _occurrenceLocator.isValid() ) {
|
||||
_nonLeafInstanceLocator.progress();
|
||||
if ( not _nonLeafInstanceLocator.isValid() ) {
|
||||
_state = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Cell* masterCell = _nonLeafInstanceLocator.getElement()->getMasterCell();
|
||||
_occurrenceLocator = masterCell->getNonLeafInstanceOccurrences().getLocator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string Cell_NonLeafInstanceOccurrences::Locator::_getString() const
|
||||
// ****************************************************************
|
||||
{
|
||||
string s = "<" + _TName("Cell::NonLeafInstanceOccurrences::Locator");
|
||||
if (_cell) s += " " + getString(_cell);
|
||||
s += ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ****************************************************************************************************
|
||||
// Cell_TerminalInstanceOccurrences implementation
|
||||
// ****************************************************************************************************
|
||||
|
|
|
@ -304,6 +304,7 @@ void Instance::materialize()
|
|||
// *************************
|
||||
{
|
||||
if (not isMaterialized()) {
|
||||
cerr << "materialize: " << this << endl;
|
||||
Box boundingBox = getBoundingBox();
|
||||
if (!boundingBox.isEmpty()) {
|
||||
QuadTree* quadTree = _cell->_getQuadTree();
|
||||
|
@ -375,10 +376,12 @@ void Instance::setTransformation(const Transformation& transformation)
|
|||
void Instance::setPlacementStatus(const PlacementStatus& placementstatus)
|
||||
// **********************************************************************
|
||||
{
|
||||
cerr << "setPlacementStatus of " << this << " to " << placementstatus << endl;
|
||||
if (placementstatus != _placementStatus) {
|
||||
invalidate(true);
|
||||
|
||||
if (_placementStatus == PlacementStatus::UNPLACED) {
|
||||
cerr << "setPlacementStatus: PLACED/FIXED " << this << endl;
|
||||
materialize ();
|
||||
} else if (placementstatus == PlacementStatus::UNPLACED)
|
||||
unmaterialize ();
|
||||
|
@ -448,6 +451,7 @@ void Instance::setMasterCell(Cell* masterCell, bool secureFlag)
|
|||
void Instance::_postCreate()
|
||||
// *************************
|
||||
{
|
||||
_cell->setTerminal(false);
|
||||
_cell->_getInstanceMap()._insert(this);
|
||||
_masterCell->_getSlaveInstanceSet()._insert(this);
|
||||
|
||||
|
@ -456,9 +460,13 @@ void Instance::_postCreate()
|
|||
end_for;
|
||||
}
|
||||
|
||||
cerr << "Initial placement status " << this << " " << _placementStatus << endl;
|
||||
|
||||
bool autoMaterialization = not autoMaterializationIsDisabled();
|
||||
if ( _placementStatus == PlacementStatus::UNPLACED )
|
||||
if ( _placementStatus == PlacementStatus::UNPLACED ) {
|
||||
disableAutoMaterialization();
|
||||
cerr << "do not materialize: " << this << endl;
|
||||
}
|
||||
|
||||
Inherit::_postCreate();
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
// $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@asim.lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Module : "./TextTranslator.cpp" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "hurricane/TextTranslator.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
|
||||
string TextTranslator::translate ( const string& source ) const
|
||||
{
|
||||
string translated = source;
|
||||
|
||||
for ( size_t pos=0 ; pos<translated.size() ; ) {
|
||||
bool match = false;
|
||||
|
||||
for ( size_t i=0 ; i<_translations.size() ; ++i ) {
|
||||
const string& original = _translations[i]._original;
|
||||
const string& translation = _translations[i]._translation;
|
||||
|
||||
if ( translated.compare(pos,original.size(),original) == 0 ) {
|
||||
translated.replace(pos,original.size(),translation);
|
||||
pos += translation.size();
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos += (match) ? 0 : 1;
|
||||
}
|
||||
|
||||
return translated;
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -272,6 +272,7 @@ class Cell : public Entity {
|
|||
public: Occurrences getTerminalInstanceOccurrencesUnder(const Box& area) const;
|
||||
public: Occurrences getLeafInstanceOccurrences() const;
|
||||
public: Occurrences getLeafInstanceOccurrencesUnder(const Box& area) const;
|
||||
public: Occurrences getNonLeafInstanceOccurrences() const;
|
||||
public: Occurrences getComponentOccurrences(const Layer::Mask& mask = ~0) const;
|
||||
public: Occurrences getComponentOccurrencesUnder(const Box& area, const Layer::Mask& mask = ~0) const;
|
||||
public: Occurrences getHyperNetRootNetOccurrences() const;
|
||||
|
|
|
@ -196,7 +196,19 @@ inline std::string getString<const Hurricane::Instance::PlacementStatus::Code*>
|
|||
( const Hurricane::Instance::PlacementStatus::Code* object )
|
||||
{
|
||||
switch ( *object ) {
|
||||
case Hurricane::Instance::PlacementStatus::UNPLACED: return "PLACED";
|
||||
case Hurricane::Instance::PlacementStatus::UNPLACED: return "UNPLACED";
|
||||
case Hurricane::Instance::PlacementStatus::PLACED: return "PLACED";
|
||||
case Hurricane::Instance::PlacementStatus::FIXED: return "FIXED";
|
||||
}
|
||||
return "ABNORMAL";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string getString<Hurricane::Instance::PlacementStatus::Code>
|
||||
( Hurricane::Instance::PlacementStatus::Code object )
|
||||
{
|
||||
switch ( object ) {
|
||||
case Hurricane::Instance::PlacementStatus::UNPLACED: return "UNPLACED";
|
||||
case Hurricane::Instance::PlacementStatus::PLACED: return "PLACED";
|
||||
case Hurricane::Instance::PlacementStatus::FIXED: return "FIXED";
|
||||
}
|
||||
|
@ -212,13 +224,20 @@ inline Hurricane::Record* getRecord<const Hurricane::Instance::PlacementStatus::
|
|||
return record;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Hurricane::Record* getRecord<const Hurricane::Instance::PlacementStatus::Code>
|
||||
( const Hurricane::Instance::PlacementStatus::Code object )
|
||||
{
|
||||
Hurricane::Record* record = new Hurricane::Record(getString(object));
|
||||
record->add(getSlot("Code", (unsigned int)object));
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
INSPECTOR_P_SUPPORT(Hurricane::Instance);
|
||||
INSPECTOR_P_SUPPORT(Hurricane::Instance::PlacementStatus);
|
||||
INSPECTOR_P_SUPPORT(Hurricane::Instance::PlugMap);
|
||||
INSPECTOR_P_SUPPORT(Hurricane::Instance::SharedPathMap);
|
||||
IOSTREAM_POINTER_SUPPORT(Hurricane::Instance::PlacementStatus::Code);
|
||||
IOSTREAM_VALUE_SUPPORT(Hurricane::Instance::PlacementStatus::Code);
|
||||
|
||||
|
||||
#endif // HURRICANE_INSTANCE
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
// $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@asim.lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./TextTranslator.h" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#ifndef __HURRICANE_TEXT_TRANSLATOR__
|
||||
#define __HURRICANE_TEXT_TRANSLATOR__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class TextTranslator {
|
||||
public:
|
||||
inline TextTranslator ();
|
||||
inline void addTranslation ( const std::string& original, const std::string& translation );
|
||||
std::string translate ( const std::string& source ) const;
|
||||
private:
|
||||
class Translation {
|
||||
public:
|
||||
inline Translation ( const std::string& original, const std::string& translation );
|
||||
public:
|
||||
std::string _original;
|
||||
std::string _translation;
|
||||
};
|
||||
private:
|
||||
std::vector<Translation> _translations;
|
||||
};
|
||||
|
||||
|
||||
// Inline Methods.
|
||||
inline TextTranslator::Translation::Translation ( const std::string& original
|
||||
, const std::string& translation )
|
||||
: _original (original)
|
||||
, _translation(translation)
|
||||
{ }
|
||||
|
||||
inline TextTranslator::TextTranslator () : _translations() {}
|
||||
|
||||
inline void TextTranslator::addTranslation ( const std::string& original
|
||||
, const std::string& translation )
|
||||
{
|
||||
_translations.push_back ( Translation(original,translation) );
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
#endif // __HURRICANE_TEXT_TRANSLATOR__
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
include ( ${QT_USE_FILE} )
|
||||
|
||||
include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane
|
||||
${HURRICANE_SOURCE_DIR}/src/viewer
|
||||
${HURRICANE_SOURCE_DIR}/src/isobar
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
)
|
||||
|
@ -7,6 +10,7 @@
|
|||
PyBox.cpp
|
||||
PyCell.cpp
|
||||
PyCellCollection.cpp
|
||||
PyCellViewer.cpp
|
||||
PyComponent.cpp
|
||||
PyComponentCollection.cpp
|
||||
PyContact.cpp
|
||||
|
@ -44,6 +48,7 @@
|
|||
hurricane/isobar/PyBox.h
|
||||
hurricane/isobar/PyCell.h
|
||||
hurricane/isobar/PyCellCollection.h
|
||||
hurricane/isobar/PyCellViewer.h
|
||||
hurricane/isobar/PyComponent.h
|
||||
hurricane/isobar/PyComponentCollection.h
|
||||
hurricane/isobar/PyContact.h
|
||||
|
|
|
@ -195,7 +195,8 @@ extern "C" {
|
|||
if ( ! PyArg_ParseTuple(args,"|O&:DbU.symbolic",Converter,&arg0) )
|
||||
return ( NULL );
|
||||
|
||||
if ( __cs.getObjectIds() == FLOAT_ARG ) { result = DbU::lambda ( PyFloat_AsDouble ( arg0 ) ); }
|
||||
if ( __cs.getObjectIds() == FLOAT_ARG ) { result = DbU::lambda ( PyFloat_AsDouble ( arg0 ) ); }
|
||||
else if ( __cs.getObjectIds() == INT_ARG ) { result = DbU::lambda ( PyLong_AsLong ( arg0 ) ); }
|
||||
else {
|
||||
PyErr_SetString ( ConstructorError, "invalid number of parameters or bad type for DbU.symbolic converter." );
|
||||
return ( NULL );
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "hurricane/isobar/PyEntity.h"
|
||||
#include "hurricane/isobar/PyCell.h"
|
||||
#include "hurricane/isobar/PyCellCollection.h"
|
||||
#include "hurricane/isobar/PyCellViewer.h"
|
||||
#include "hurricane/isobar/PyLayer.h"
|
||||
#include "hurricane/isobar/PyPin.h"
|
||||
#include "hurricane/isobar/PyPinCollection.h"
|
||||
|
@ -516,7 +517,7 @@ extern "C" {
|
|||
, { "DataBase" , (PyCFunction)PyDataBase_create , METH_NOARGS , "Creates the DataBase." }
|
||||
, { "getDataBase" , (PyCFunction)PyDataBase_getDataBase , METH_NOARGS , "Gets the current DataBase." }
|
||||
, { "Library" , (PyCFunction)PyLibrary_create , METH_VARARGS, "Creates a new Library." }
|
||||
// , { "getLibrary" , (PyCFunction)PyLibrary_getLibrary , METH_NOARGS , "Gets the current Library." }
|
||||
// , { "getLibrary" , (PyCFunction)PyLibrary_getLibrary , METH_NOARGS , "Gets the current Library." }
|
||||
, { "Reference" , (PyCFunction)PyReference_create , METH_VARARGS, "Creates a new Reference." }
|
||||
, { "Cell" , (PyCFunction)PyCell_create , METH_VARARGS, "Creates a new Cell." }
|
||||
, { "Instance" , (PyCFunction)PyInstance_create , METH_VARARGS, "Creates a new Instance." }
|
||||
|
@ -575,6 +576,7 @@ extern "C" {
|
|||
PyContact_LinkPyType ();
|
||||
PyPin_LinkPyType ();
|
||||
PyPlug_LinkPyType ();
|
||||
PyCellViewer_LinkPyType ();
|
||||
|
||||
PYTYPE_READY ( Point )
|
||||
PYTYPE_READY ( Box )
|
||||
|
@ -605,6 +607,7 @@ extern "C" {
|
|||
PYTYPE_READY ( ReferenceCollection )
|
||||
PYTYPE_READY ( ReferenceCollectionLocator )
|
||||
PYTYPE_READY ( HyperNet )
|
||||
PYTYPE_READY ( CellViewer )
|
||||
|
||||
PYTYPE_READY_SUB ( Cell , Entity )
|
||||
PYTYPE_READY_SUB ( Instance , Entity )
|
||||
|
@ -620,48 +623,48 @@ extern "C" {
|
|||
PYTYPE_READY_SUB ( Plug , Component)
|
||||
PYTYPE_READY_SUB ( Pad , Component)
|
||||
|
||||
|
||||
// Identifier string can take up to 10 characters !
|
||||
__cs.addType ( "box" , &PyTypeBox , "<Box>" , false );
|
||||
__cs.addType ( "ent" , &PyTypeEntity , "<Entity>" , false );
|
||||
__cs.addType ( "cell" , &PyTypeCell , "<Cell>" , false, "ent" );
|
||||
__cs.addType ( "cellCol" , &PyTypeCellCollection , "<CellCollection>" , false );
|
||||
__cs.addType ( "comp" , &PyTypeComponent , "<Component>" , false, "ent" );
|
||||
__cs.addType ( "compCol" , &PyTypeComponentCollection, "<ComponentCollection>" , false );
|
||||
__cs.addType ( "contact" , &PyTypeContact , "<Contact>" , false, "comp" );
|
||||
// Do not change the "none" string. It's hardwired to the None object.
|
||||
__cs.addType ( "none" , Py_None->ob_type , "<None>" , true );
|
||||
__cs.addType ( "float" , &PyFloat_Type , "<Float>" , true );
|
||||
__cs.addType ( "int" , &PyInt_Type , "<Int>" , true );
|
||||
__cs.addType ( "bool" , &PyBool_Type , "<Bool>" , true );
|
||||
__cs.addType ( "string" , &PyString_Type , "<String>" , true );
|
||||
__cs.addType ( "list" , &PyList_Type , "<List>" , true );
|
||||
__cs.addType ( "box" , &PyTypeBox , "<Box>" , false );
|
||||
__cs.addType ( "ent" , &PyTypeEntity , "<Entity>" , false );
|
||||
__cs.addType ( "cell" , &PyTypeCell , "<Cell>" , false, "ent" );
|
||||
__cs.addType ( "cellCol" , &PyTypeCellCollection , "<CellCollection>" , false );
|
||||
__cs.addType ( "cellView" , &PyTypeCellViewer , "<CellViewer>" , false, "view" );
|
||||
__cs.addType ( "comp" , &PyTypeComponent , "<Component>" , false, "ent" );
|
||||
__cs.addType ( "compCol" , &PyTypeComponentCollection , "<ComponentCollection>" , false );
|
||||
__cs.addType ( "contact" , &PyTypeContact , "<Contact>" , false, "comp" );
|
||||
// Do not change the "none" string. It's hardwired to the None object.
|
||||
__cs.addType ( "none" , Py_None->ob_type , "<None>" , true );
|
||||
__cs.addType ( "float" , &PyFloat_Type , "<Float>" , true );
|
||||
__cs.addType ( "int" , &PyInt_Type , "<Int>" , true );
|
||||
__cs.addType ( "bool" , &PyBool_Type , "<Bool>" , true );
|
||||
__cs.addType ( "string" , &PyString_Type , "<String>" , true );
|
||||
__cs.addType ( "list" , &PyList_Type , "<List>" , true );
|
||||
// Do not change the "function" string. It's hardwired to callable (function) objects.
|
||||
__cs.addType ( "function" , NULL , "<Function>" , true );
|
||||
__cs.addType ( "horiz" , &PyTypeHorizontal , "<Horizontal>" , false, "segment" );
|
||||
__cs.addType ( "inst" , &PyTypeInstance , "<Instance>" , false, "ent" );
|
||||
__cs.addType ( "instCol" , &PyTypeInstanceCollection, "<InstanceCollection>" , false );
|
||||
__cs.addType ( "layer" , &PyTypeLayer , "<Layer>" , false );
|
||||
__cs.addType ( "library" , &PyTypeLibrary , "<Library>" , false );
|
||||
__cs.addType ( "ref" , &PyTypeReference , "<Reference>" , false, "ent" );
|
||||
__cs.addType ( "refCol" , &PyTypeReferenceCollection, "<ReferenceCollection>" , false );
|
||||
__cs.addType ( "net" , &PyTypeNet , "<Net>" , false, "ent" );
|
||||
__cs.addType ( "netCol" , &PyTypeNetCollection , "<NetCollection>" , false );
|
||||
__cs.addType ( "hyperNet" , &PyTypeHyperNet , "<HyperNet>" , false );
|
||||
__cs.addType ( "pin" , &PyTypePin , "<Pin>" , false, "contact" );
|
||||
__cs.addType ( "pinCol" , &PyTypePinCollection , "<PinCollection>" , false );
|
||||
__cs.addType ( "plug" , &PyTypePlug , "<Plug>" , false, "comp" );
|
||||
__cs.addType ( "plugCol" , &PyTypePlugCollection , "<PlugCollection>" , false );
|
||||
__cs.addType ( "point" , &PyTypePoint , "<Point>" , false );
|
||||
__cs.addType ( "segment" , &PyTypeSegment , "<Segment>" , false, "comp" );
|
||||
__cs.addType ( "pad " , &PyTypePad , "<Pad>" , false, "comp" );
|
||||
__cs.addType ( "segmentCol" , &PyTypeSegmentCollection, "<SegmentCollection>", false );
|
||||
__cs.addType ( "db" , &PyTypeDataBase , "<DataBase>" , false );
|
||||
__cs.addType ( "techno" , &PyTypeTechnology , "<Technology>" , false );
|
||||
__cs.addType ( "transfo" , &PyTypeTransformation , "<Transformation>" , false );
|
||||
__cs.addType ( "vert" , &PyTypeVertical , "<Vertical>" , false, "segment" );
|
||||
__cs.addType ( "path" , &PyTypePath , "<Path>" , false );
|
||||
__cs.addType ( "occur" , &PyTypeOccurrence , "<Occurrence>" , false );
|
||||
__cs.addType ( "function" , NULL , "<Function>" , true );
|
||||
__cs.addType ( "horiz" , &PyTypeHorizontal , "<Horizontal>" , false, "segment" );
|
||||
__cs.addType ( "inst" , &PyTypeInstance , "<Instance>" , false, "ent" );
|
||||
__cs.addType ( "instCol" , &PyTypeInstanceCollection , "<InstanceCollection>" , false );
|
||||
__cs.addType ( "layer" , &PyTypeLayer , "<Layer>" , false );
|
||||
__cs.addType ( "library" , &PyTypeLibrary , "<Library>" , false );
|
||||
__cs.addType ( "ref" , &PyTypeReference , "<Reference>" , false, "ent" );
|
||||
__cs.addType ( "refCol" , &PyTypeReferenceCollection , "<ReferenceCollection>" , false );
|
||||
__cs.addType ( "net" , &PyTypeNet , "<Net>" , false, "ent" );
|
||||
__cs.addType ( "netCol" , &PyTypeNetCollection , "<NetCollection>" , false );
|
||||
__cs.addType ( "hyperNet" , &PyTypeHyperNet , "<HyperNet>" , false );
|
||||
__cs.addType ( "pin" , &PyTypePin , "<Pin>" , false, "contact" );
|
||||
__cs.addType ( "pinCol" , &PyTypePinCollection , "<PinCollection>" , false );
|
||||
__cs.addType ( "plug" , &PyTypePlug , "<Plug>" , false, "comp" );
|
||||
__cs.addType ( "plugCol" , &PyTypePlugCollection , "<PlugCollection>" , false );
|
||||
__cs.addType ( "point" , &PyTypePoint , "<Point>" , false );
|
||||
__cs.addType ( "segment" , &PyTypeSegment , "<Segment>" , false, "comp" );
|
||||
__cs.addType ( "pad " , &PyTypePad , "<Pad>" , false, "comp" );
|
||||
__cs.addType ( "segmentCol" , &PyTypeSegmentCollection , "<SegmentCollection>" , false );
|
||||
__cs.addType ( "db" , &PyTypeDataBase , "<DataBase>" , false );
|
||||
__cs.addType ( "techno" , &PyTypeTechnology , "<Technology>" , false );
|
||||
__cs.addType ( "transfo" , &PyTypeTransformation , "<Transformation>" , false );
|
||||
__cs.addType ( "vert" , &PyTypeVertical , "<Vertical>" , false, "segment" );
|
||||
__cs.addType ( "path" , &PyTypePath , "<Path>" , false );
|
||||
__cs.addType ( "occur" , &PyTypeOccurrence , "<Occurrence>" , false );
|
||||
__cs.addType ( "occurCol" , &PyTypeOccurrenceCollection, "<OccurrenceCollection>", false );
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
@ -42,13 +42,22 @@
|
|||
#include "hurricane/Error.h"
|
||||
#include "hurricane/Cell.h"
|
||||
#include "hurricane/isobar/PyCell.h"
|
||||
#include "hurricane/isobar/PyCellViewer.h"
|
||||
#include "hurricane/isobar/Script.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
const char* __editorKw = "__editor";
|
||||
|
||||
} // End of anonymous namespace.
|
||||
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using std::string;
|
||||
using Hurricane::Cell;
|
||||
using Hurricane::CellViewer;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -62,17 +71,34 @@ namespace Isobar {
|
|||
{ _pathes.push_back ( path ); }
|
||||
|
||||
|
||||
Script::Script ( const string& name )
|
||||
: _moduleName(name)
|
||||
, _sysModule (NULL)
|
||||
, _userModule(NULL)
|
||||
void Script::removePath ( const string& path )
|
||||
{
|
||||
vector<string>::iterator ipath = _pathes.begin();
|
||||
for ( ; ipath != _pathes.end() ; ++ipath ) {
|
||||
if ( (*ipath) == path ) {
|
||||
_pathes.erase ( ipath );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Script::Script ( const string& name )
|
||||
: _moduleName (name)
|
||||
, _sysModule (NULL)
|
||||
, _hurricaneModule(NULL)
|
||||
, _userModule (NULL)
|
||||
, _pyFunction (NULL)
|
||||
, _pyArgs (NULL)
|
||||
, _pyResult (NULL)
|
||||
, _cellViewer (NULL)
|
||||
{ }
|
||||
|
||||
|
||||
Script::~Script ()
|
||||
{
|
||||
_destroyModules();
|
||||
_finalize();
|
||||
Py_Finalize ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,16 +115,15 @@ namespace Isobar {
|
|||
}
|
||||
|
||||
|
||||
void Script::setEditor ( CellViewer* viewer )
|
||||
{ _cellViewer = viewer; }
|
||||
|
||||
|
||||
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" );
|
||||
_initialize ();
|
||||
|
||||
_userModule = PyImport_ImportModule ( const_cast<char*>(_moduleName.c_str()) );
|
||||
|
||||
|
@ -106,36 +131,35 @@ namespace Isobar {
|
|||
if ( PyErr_Occurred() ) {
|
||||
PyErr_Print ();
|
||||
}
|
||||
_finalize ();
|
||||
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 ();
|
||||
_setEditor ();
|
||||
|
||||
_pyFunction = PyObject_GetAttrString(_userModule, const_cast<char*>(function.c_str()));
|
||||
if ( (_pyFunction == NULL) or not PyCallable_Check(_pyFunction) ) {
|
||||
_finalize ();
|
||||
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) );
|
||||
_pyArgs = PyTuple_New(1);
|
||||
if ( cell != NULL ) PyTuple_SetItem ( _pyArgs, 0, (PyObject*)PyCell_Link(cell) );
|
||||
else PyTuple_SetItem ( _pyArgs, 0, Py_None );
|
||||
|
||||
PyObject* pyResult = PyEval_CallObject ( pyFunction, pyArgs );
|
||||
_pyResult = PyEval_CallObject ( _pyFunction, _pyArgs );
|
||||
|
||||
if ( pyResult == NULL ) {
|
||||
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 ();
|
||||
_finalize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -143,6 +167,9 @@ namespace Isobar {
|
|||
|
||||
void Script::_importSys ()
|
||||
{
|
||||
if ( not Py_IsInitialized() )
|
||||
throw Error ( "Script::_importSys(): Called before Py_Initialize()." );
|
||||
|
||||
_sysModule = _importModule ( "sys" );
|
||||
|
||||
PyObject* path = PyObject_GetAttrString ( _sysModule, "path" );
|
||||
|
@ -152,15 +179,22 @@ namespace Isobar {
|
|||
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);
|
||||
|
||||
void Script::_importHurricane ()
|
||||
{
|
||||
if ( not Py_IsInitialized() )
|
||||
throw Error ( "Script::_importHurricane(): Called before Py_Initialize()." );
|
||||
|
||||
_hurricaneModule = PyImport_ImportModule ( "Hurricane" );
|
||||
if ( _hurricaneModule == NULL )
|
||||
throw Error("Script::_importModule(): No Hurricane module.");
|
||||
|
||||
PyModule_AddObject ( _hurricaneModule, const_cast<char*>(__editorKw), Py_None );
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,15 +212,50 @@ namespace Isobar {
|
|||
}
|
||||
|
||||
|
||||
void Script::_destroyModules ()
|
||||
void Script::_initialize ()
|
||||
{
|
||||
Py_Initialize ();
|
||||
_importSys ();
|
||||
_importHurricane ();
|
||||
}
|
||||
|
||||
|
||||
void Script::_finalize ()
|
||||
{
|
||||
if ( not Py_IsInitialized() ) return;
|
||||
|
||||
if ( _userModule != NULL ) Py_DECREF ( _userModule );
|
||||
if ( _sysModule != NULL ) Py_DECREF ( _sysModule );
|
||||
if ( _pyResult != NULL ) Py_DECREF ( _pyResult );
|
||||
if ( _pyArgs != NULL ) Py_DECREF ( _pyArgs );
|
||||
if ( _pyFunction != NULL ) Py_DECREF ( _pyFunction );
|
||||
if ( _userModule != NULL ) Py_DECREF ( _userModule );
|
||||
if ( _hurricaneModule != NULL ) Py_DECREF ( _hurricaneModule );
|
||||
if ( _sysModule != NULL ) Py_DECREF ( _sysModule );
|
||||
|
||||
_userModule = NULL;
|
||||
_sysModule = NULL;
|
||||
Py_Finalize ();
|
||||
|
||||
_userModule = NULL;
|
||||
_sysModule = NULL;
|
||||
_hurricaneModule = NULL;
|
||||
_pyFunction = NULL;
|
||||
_pyArgs = NULL;
|
||||
_pyResult = NULL;
|
||||
}
|
||||
|
||||
|
||||
void Script::_setEditor ()
|
||||
{
|
||||
if ( _userModule == NULL ) return;
|
||||
|
||||
PyObject* dictionary = PyModule_GetDict ( _userModule );
|
||||
|
||||
if ( _cellViewer != NULL ) {
|
||||
PyCellViewer* pyCellViewer = PyObject_NEW ( PyCellViewer, &PyTypeCellViewer );
|
||||
pyCellViewer->_object = _cellViewer;
|
||||
|
||||
PyDict_SetItemString ( dictionary, __editorKw, (PyObject*)pyCellViewer );
|
||||
} else {
|
||||
PyDict_SetItemString ( dictionary, __editorKw, Py_None );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -599,6 +599,33 @@ extern "C" {
|
|||
PyObject_DEL ( self ); \
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Attribute Method For Singleton Deletion.
|
||||
|
||||
// # define SingletonDeleteMethod(SELF_TYPE)
|
||||
// static void Py##SELF_TYPE##_DeAlloc ( Py##SELF_TYPE *self )
|
||||
// {
|
||||
// trace << "PySingletonObject_DeAlloc(" << hex << self << ") "
|
||||
// << self->ACCESS_OBJECT << endl;
|
||||
//
|
||||
// if ( self->ACCESS_OBJECT != NULL ) {
|
||||
// ostringstream message;
|
||||
// message << "Never delete singleton "#SELF_TYPE".";
|
||||
// PyErr_SetString ( ProxyError, message.str().c_str() );
|
||||
// }
|
||||
// PyObject_DEL ( self );
|
||||
// }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Attribute Method For Singleton Deletion.
|
||||
|
||||
# define SingletonDeleteMethod(SELF_TYPE) \
|
||||
static void Py##SELF_TYPE##_DeAlloc ( Py##SELF_TYPE *self ) \
|
||||
{ \
|
||||
trace << "PySingletonObject_DeAlloc(" << hex << self << ") " \
|
||||
<< self->ACCESS_OBJECT << endl; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <Python.h>
|
||||
namespace Hurricane {
|
||||
class Cell;
|
||||
class CellViewer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,29 +54,43 @@ 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 );
|
||||
static void addPath ( const std::string& path );
|
||||
static void removePath ( const std::string& path );
|
||||
static Script* create ( const std::string& name );
|
||||
void destroy ();
|
||||
inline PyObject* getSysModule ();
|
||||
inline PyObject* getHurricaneModule ();
|
||||
inline PyObject* getUserModule ();
|
||||
void setEditor ( Hurricane::CellViewer* );
|
||||
bool runFunction ( const std::string& function, Hurricane::Cell* cell );
|
||||
protected:
|
||||
static std::vector<std::string> _pathes;
|
||||
std::string _moduleName;
|
||||
PyObject* _sysModule;
|
||||
PyObject* _hurricaneModule;
|
||||
PyObject* _userModule;
|
||||
PyObject* _pyFunction;
|
||||
PyObject* _pyArgs;
|
||||
PyObject* _pyResult;
|
||||
Hurricane::CellViewer* _cellViewer;
|
||||
protected:
|
||||
Script ( const std::string& name );
|
||||
~Script ();
|
||||
Script ( const Script& );
|
||||
Script& operator= ( const Script& );
|
||||
void _importSys ();
|
||||
PyObject* _importModule ( const std::string& );
|
||||
void _destroyModules ();
|
||||
Script ( const std::string& name );
|
||||
~Script ();
|
||||
Script ( const Script& );
|
||||
Script& operator= ( const Script& );
|
||||
void _importSys ();
|
||||
void _importHurricane ();
|
||||
PyObject* _importModule ( const std::string& );
|
||||
void _initialize ();
|
||||
void _finalize ();
|
||||
void _setEditor ();
|
||||
};
|
||||
|
||||
|
||||
// Inline Methods.
|
||||
inline PyObject* Script::getUserModule () { return _userModule; }
|
||||
inline PyObject* Script::getSysModule () { return _sysModule; }
|
||||
inline PyObject* Script::getHurricaneModule () { return _hurricaneModule; }
|
||||
inline PyObject* Script::getUserModule () { return _userModule; }
|
||||
|
||||
|
||||
} // End of Isobar namespace.
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
include ( ${QT_USE_FILE} )
|
||||
|
||||
include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane
|
||||
${HURRICANE_SOURCE_DIR}/src/isobar
|
||||
${HURRICANE_SOURCE_DIR}/src/viewer
|
||||
${CONFIGURATION_INCLUDE_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
set ( mocincludes hurricane/viewer/HApplication.h
|
||||
|
@ -32,6 +34,7 @@
|
|||
hurricane/viewer/NetlistWidget.h
|
||||
hurricane/viewer/DisplayFilterWidget.h
|
||||
hurricane/viewer/ControllerWidget.h
|
||||
hurricane/viewer/ScriptWidget.h
|
||||
)
|
||||
set ( exports hurricane/viewer/HApplication.h
|
||||
hurricane/viewer/ScreenUtilities.h
|
||||
|
@ -65,6 +68,7 @@
|
|||
hurricane/viewer/NetlistWidget.h
|
||||
hurricane/viewer/DisplayFilterWidget.h
|
||||
hurricane/viewer/ControllerWidget.h
|
||||
hurricane/viewer/ScriptWidget.h
|
||||
hurricane/viewer/PaletteWidget.h
|
||||
)
|
||||
set ( cpps HApplication.cpp
|
||||
|
@ -106,6 +110,7 @@
|
|||
NetlistWidget.cpp
|
||||
DisplayFilterWidget.cpp
|
||||
ControllerWidget.cpp
|
||||
ScriptWidget.cpp
|
||||
)
|
||||
|
||||
qt4_wrap_cpp ( MOC_SRCS ${mocincludes} )
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "hurricane/viewer/CellViewer.h"
|
||||
#include "hurricane/viewer/MousePositionWidget.h"
|
||||
#include "hurricane/viewer/ControllerWidget.h"
|
||||
#include "hurricane/viewer/ScriptWidget.h"
|
||||
#include "hurricane/viewer/GotoWidget.h"
|
||||
|
||||
|
||||
|
@ -67,6 +68,7 @@ namespace Hurricane {
|
|||
, _rubberChangeAction (NULL)
|
||||
, _clearRulersAction (NULL)
|
||||
, _controllerAction (NULL)
|
||||
, _scriptAction (NULL)
|
||||
, _fileMenu (NULL)
|
||||
, _viewMenu (NULL)
|
||||
, _toolsMenu (NULL)
|
||||
|
@ -74,6 +76,7 @@ namespace Hurricane {
|
|||
//, _mapView (NULL)
|
||||
, _mousePosition (NULL)
|
||||
, _controller (NULL)
|
||||
, _script (NULL)
|
||||
, _goto (NULL)
|
||||
, _cellWidget (NULL)
|
||||
, _moveCommand ()
|
||||
|
@ -96,6 +99,7 @@ namespace Hurricane {
|
|||
CellViewer::~CellViewer ()
|
||||
{
|
||||
_controller->deleteLater ();
|
||||
//_script->deleteLater ();
|
||||
_goto->deleteLater ();
|
||||
}
|
||||
|
||||
|
@ -198,6 +202,12 @@ namespace Hurricane {
|
|||
_controllerAction->setStatusTip ( tr("Fine Tune && Inspect DataBase") );
|
||||
_controllerAction->setIcon ( QIcon(":/images/swiss-knife.png") );
|
||||
_controllerAction->setShortcut ( QKeySequence(tr("CTRL+I")) );
|
||||
|
||||
_scriptAction = new QAction ( tr("Script"), this );
|
||||
_scriptAction->setObjectName ( "viewer.menuBar.tools.script" );
|
||||
_scriptAction->setStatusTip ( tr("Run Python Script") );
|
||||
_scriptAction->setIcon ( QIcon(":/images/python-logo-v3.png") );
|
||||
//_scriptAction->setShortcut ( QKeySequence(tr("CTRL+I")) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,6 +246,7 @@ namespace Hurricane {
|
|||
_toolsMenu = menuBar()->addMenu ( tr("Tools") );
|
||||
_toolsMenu->setObjectName ( "viewer.menuBar.tools" );
|
||||
_toolsMenu->addAction ( _controllerAction );
|
||||
_toolsMenu->addAction ( _scriptAction );
|
||||
}
|
||||
|
||||
|
||||
|
@ -293,6 +304,7 @@ namespace Hurricane {
|
|||
connect ( _rubberChangeAction , SIGNAL(triggered()) , _cellWidget, SLOT(rubberChange()) );
|
||||
connect ( _clearRulersAction , SIGNAL(triggered()) , _cellWidget, SLOT(clearRulers()) );
|
||||
connect ( _controllerAction , SIGNAL(triggered()) , _controller, SLOT(toggleShow()) );
|
||||
connect ( _scriptAction , SIGNAL(triggered()) , this , SLOT(runScript()) );
|
||||
connect ( _gotoAction , SIGNAL(triggered()) , this , SLOT(doGoto()) );
|
||||
|
||||
connect ( _cellWidget , SIGNAL(dbuModeChanged(unsigned int,DbU::UnitPower))
|
||||
|
@ -531,4 +543,10 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
void CellViewer::runScript ()
|
||||
{
|
||||
ScriptWidget::runScript ( this, getCell() );
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<file>images/gtk-go-forward-rtl.png</file>
|
||||
<file>images/gtk-go-forward-ltr.png</file>
|
||||
<file>images/swiss-knife.png</file>
|
||||
<file>images/python-logo-v3.png</file>
|
||||
<file>images/gnome-gmush.png</file>
|
||||
<file>images/gnome-core.png</file>
|
||||
<file>images/i-core.png</file>
|
||||
|
|
|
@ -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
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
|
|
|
@ -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 : "./ScriptWidget.cpp" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
using namespace std;
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
namespace bfs = boost::filesystem;
|
||||
|
||||
#include "hurricane/Warning.h"
|
||||
#include "hurricane/isobar/Script.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "hurricane/viewer/Graphics.h"
|
||||
#include "hurricane/viewer/ScriptWidget.h"
|
||||
#include "hurricane/viewer/CellViewer.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "ScriptWidget".
|
||||
|
||||
|
||||
ScriptWidget::ScriptWidget ( QWidget* parent )
|
||||
: QDialog (parent)
|
||||
, _lineEdit(NULL)
|
||||
{
|
||||
setWindowTitle ( tr("Run Script") );
|
||||
|
||||
QLabel* label = new QLabel ();
|
||||
label->setText ( tr("Python 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 ScriptWidget::getScriptName () const
|
||||
{
|
||||
return _lineEdit->text();
|
||||
}
|
||||
|
||||
|
||||
bool ScriptWidget::runScript ( QWidget* parent, Cell* cell )
|
||||
{
|
||||
ScriptWidget* dialog = new ScriptWidget ( parent );
|
||||
bool doRunScript = (dialog->exec() == Accepted);
|
||||
QString scriptName = dialog->getScriptName ();
|
||||
|
||||
delete dialog;
|
||||
if ( not doRunScript ) return false;
|
||||
|
||||
if ( scriptName.endsWith(".py",Qt::CaseInsensitive) )
|
||||
scriptName.truncate ( scriptName.size()-3 );
|
||||
|
||||
bfs::path userScript = scriptName.toStdString();
|
||||
bfs::path userDirectory = userScript.branch_path();
|
||||
|
||||
if ( not userDirectory.is_complete() )
|
||||
userDirectory = bfs::current_path() / userDirectory;
|
||||
userDirectory.normalize();
|
||||
|
||||
Isobar::Script::addPath ( userDirectory.string() );
|
||||
|
||||
dbo_ptr<Isobar::Script> script = Isobar::Script::create(userScript.leaf());
|
||||
script->setEditor ( qobject_cast<CellViewer*>(parent) );
|
||||
|
||||
bool returnCode = script->runFunction ( "__hurricane_main__", cell );
|
||||
|
||||
Isobar::Script::removePath ( userDirectory.string() );
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -57,6 +57,7 @@ namespace Hurricane {
|
|||
class GotoWidget;
|
||||
class MousePositionWidget;
|
||||
class ControllerWidget;
|
||||
class ScriptWidget;
|
||||
|
||||
|
||||
class CellViewer : public QMainWindow {
|
||||
|
@ -90,6 +91,7 @@ namespace Hurricane {
|
|||
void imageDisplay ();
|
||||
void raiseToolInterrupt ();
|
||||
void clearToolInterrupt ();
|
||||
void runScript ();
|
||||
signals:
|
||||
void showSelectionToggled ( bool );
|
||||
void stateChanged ( shared_ptr<CellWidget::State>& );
|
||||
|
@ -119,6 +121,7 @@ namespace Hurricane {
|
|||
QAction* _rubberChangeAction;
|
||||
QAction* _clearRulersAction;
|
||||
QAction* _controllerAction;
|
||||
QAction* _scriptAction;
|
||||
QMenu* _fileMenu;
|
||||
QMenu* _viewMenu;
|
||||
QMenu* _toolsMenu;
|
||||
|
@ -126,6 +129,7 @@ namespace Hurricane {
|
|||
//MapView* _mapView;
|
||||
MousePositionWidget* _mousePosition;
|
||||
ControllerWidget* _controller;
|
||||
ScriptWidget* _script;
|
||||
GotoWidget* _goto;
|
||||
CellWidget* _cellWidget;
|
||||
MoveCommand _moveCommand;
|
||||
|
|
|
@ -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 : "./ScriptWidget.h" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#ifndef __HURRICANE_SCRIPT_WIDGET__
|
||||
#define __HURRICANE_SCRIPT_WIDGET__
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
class Cell;
|
||||
|
||||
|
||||
class ScriptWidget : public QDialog {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
static bool runScript ( QWidget* parent, Cell* );
|
||||
const QString getScriptName () const;
|
||||
protected:
|
||||
ScriptWidget ( QWidget* parent=NULL );
|
||||
protected:
|
||||
QLineEdit* _lineEdit;
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
#endif // __HURRICANE_SCRIPT_WIDGET__
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in New Issue