* ./hurricane/src/viewer :

- New feature : display instances names (vertical on bottom left corner
       of the AB). New CellWidget capability : drawText(). Small modification
       of styles & display.xml to distinguish between different kind of texts.
       (instances name, master cell names, ...).
   - New feature : do not create color, pen & brush at start in Graphics/
       DisplayStyles. Now for the graphics to be used it must be enabled with
       a call to "Graphics::enable()" *AFTER* allocating the QApplication.

 * ./coriolis/src/crlcore/src/cyclop :
   - New argument "--text" to check pure text mode.
This commit is contained in:
Jean-Paul Chaput 2008-09-17 11:45:38 +00:00
parent d669774d84
commit a54d86924f
8 changed files with 243 additions and 64 deletions

View File

@ -175,6 +175,20 @@ namespace Hurricane {
}
void CellWidget::DrawingPlanes::setBackground ( const QBrush& brush )
{
_painters[0].setBackground ( brush );
_painters[1].setBackground ( brush );
}
void CellWidget::DrawingPlanes::setBackgroundMode ( Qt::BGMode mode )
{
_painters[0].setBackgroundMode ( mode );
_painters[1].setBackgroundMode ( mode );
}
void CellWidget::DrawingPlanes::setLineMode ( bool mode )
{
if ( _lineMode != mode ) {
@ -282,7 +296,8 @@ namespace Hurricane {
void CellWidget::DrawingQuery::masterCellCallback ()
{
_cellWidget->drawBox ( getTransformation().getBox(getMasterCell()->getAbutmentBox()) );
Box bbox = getTransformation().getBox(getMasterCell()->getAbutmentBox());
_cellWidget->drawBox ( bbox );
}
@ -329,6 +344,45 @@ namespace Hurricane {
}
// -------------------------------------------------------------------
// Class : "Hurricane::CellWidget::TextDrawingQuery".
CellWidget::TextDrawingQuery::TextDrawingQuery ( CellWidget* widget )
: Query()
,_cellWidget(widget)
{
setBasicLayer ( NULL );
setFilter ( Query::DoMasterCells|Query::DoTerminalCells );
setStartLevel ( 0 );
setStopLevel ( 1 );
}
bool CellWidget::TextDrawingQuery::hasMasterCellCallback () const
{ return true; }
void CellWidget::TextDrawingQuery::masterCellCallback ()
{
Box bbox = getTransformation().getBox(getMasterCell()->getAbutmentBox());
if ( getDepth() == 2 )
_cellWidget->drawText ( Point(bbox.getXMin(),bbox.getYMin())
, getInstance()->getName()
, -90
, true
);
}
bool CellWidget::TextDrawingQuery::hasGoCallback () const
{ return false; }
void CellWidget::TextDrawingQuery::goCallback ( Go* go )
{ }
// -------------------------------------------------------------------
// Class : "Hurricane::CellWidget".
@ -345,6 +399,7 @@ namespace Hurricane {
, _offsetVA(_stripWidth,_stripWidth)
, _drawingPlanes(QSize(6*_stripWidth,6*_stripWidth),this)
, _drawingQuery(this)
, _textDrawingQuery(this)
, _queryFilter(Query::DoAll)
, _mousePosition(0,0)
, _spot(this)
@ -355,6 +410,7 @@ namespace Hurricane {
, _selectionHasChanged(false)
, _commands()
, _redrawRectCount(0)
, _textFontHeight(20)
{
//setBackgroundRole ( QPalette::Dark );
//setAutoFillBackground ( false );
@ -371,6 +427,9 @@ namespace Hurricane {
if ( database )
_technology = database->getTechnology ();
QFont font = Graphics::getNormalFont();
_textFontHeight = QFontMetrics(font).ascent();
fitToContents ();
}
@ -471,9 +530,6 @@ namespace Hurricane {
// << _selectionHasChanged << " filter:"
// << _queryFilter << endl;
//_drawingQuery.setStartLevel ( 1 );
//_drawingQuery.setStopLevel ( 2 );
_redrawRectCount = 0;
pushCursor ( Qt::BusyCursor );
@ -498,24 +554,31 @@ namespace Hurricane {
_drawingQuery.setTransformation ( Transformation() );
forEach ( BasicLayer*, iLayer, _technology->getBasicLayers() ) {
_drawingPlanes.setPen ( Graphics::getPen ((*iLayer)->getName(),darkening));
_drawingPlanes.setPen ( Graphics::getPen ((*iLayer)->getName(),darkening) );
_drawingPlanes.setBrush ( Graphics::getBrush((*iLayer)->getName(),darkening) );
if ( isDrawable((*iLayer)->getName()) ) {
//drawCell ( _cell, (*iLayer), redrawBox, Transformation() );
_drawingQuery.setBasicLayer ( *iLayer );
_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells );
_drawingQuery.doQuery ();
_drawingQuery.doQuery ();
}
}
if ( isDrawable("boundaries") ) {
_drawingPlanes.setPen ( Graphics::getPen ("boundaries") );
_drawingPlanes.setBrush ( Graphics::getBrush("boundaries") );
_drawingPlanes.setPen ( Graphics::getPen ("boundaries",darkening) );
_drawingPlanes.setBrush ( Graphics::getBrush("boundaries",darkening) );
//drawBoundaries ( _cell, redrawBox, Transformation() );
_drawingQuery.setBasicLayer ( NULL );
_drawingQuery.setFilter ( _queryFilter & ~Query::DoComponents );
_drawingQuery.doQuery ();
_drawingQuery.doQuery ();
}
if ( isDrawable("text.instance") ) {
_drawingPlanes.setPen ( Graphics::getPen ("text.instance",darkening) );
_drawingPlanes.setBrush ( Graphics::getBrush("text.instance",darkening) );
_drawingPlanes.setBackground ( Graphics::getBrush("boundaries" ,darkening) );
_textDrawingQuery.setArea ( redrawBox );
_textDrawingQuery.setTransformation ( Transformation() );
_textDrawingQuery.doQuery ();
}
}
@ -606,6 +669,20 @@ namespace Hurricane {
}
void CellWidget::drawText ( const Point& point, const Name& text, int angle, bool reverse )
{
_drawingPlanes.painter().save();
if ( reverse ) {
_drawingPlanes.painter().setPen ( Graphics::getPen ("background") );
_drawingPlanes.painter().setBackgroundMode ( Qt::OpaqueMode );
}
_drawingPlanes.painter().translate( dbuToDisplayPoint(point) );
_drawingPlanes.painter().rotate( angle );
_drawingPlanes.painter().drawText ( 0, _textFontHeight, getString(text).c_str() );
_drawingPlanes.painter().restore();
}
void CellWidget::drawLine ( const Point& p1, const Point& p2 )
{
_drawingPlanes.setLineMode ( true );
@ -1036,6 +1113,7 @@ namespace Hurricane {
{
_cell = cell;
_drawingQuery.setCell ( cell );
_textDrawingQuery.setCell ( cell );
fitToContents ();
}

View File

@ -74,7 +74,8 @@ namespace Hurricane {
const Name DisplayStyle::Grid = "grid";
const Name DisplayStyle::Spot = "spot";
const Name DisplayStyle::Ghost = "ghost";
const Name DisplayStyle::Text = "text";
const Name DisplayStyle::TextCell = "text.cell";
const Name DisplayStyle::TextInstance = "text.instance";
const Name DisplayStyle::Undef = "undef";
@ -87,19 +88,17 @@ namespace Hurricane {
, int borderWidth
, float threshold
) : _name(name)
, _red(red)
, _green(green)
, _blue(blue)
, _borderWidth(borderWidth)
, _pattern(pattern)
, _color(QColor(red,green,blue))
, _pen(_color)
, _brush(Hurricane::getBrush(_pattern,red,green,blue))
, _color(NULL)
, _pen(NULL)
, _brush(NULL)
, _threshold(threshold)
, _refcount(1)
{
if ( borderWidth ) {
_pen.setStyle ( Qt::SolidLine );
_pen.setWidth ( borderWidth );
}
else
_pen.setStyle ( Qt::NoPen );
}
@ -117,24 +116,47 @@ namespace Hurricane {
}
void DrawingStyle::qtAllocate ()
{
if ( !_color ) {
_color = new QColor ( _red, _green, _blue );
_pen = new QPen ( *_color );
if ( _borderWidth ) {
_pen->setStyle ( Qt::SolidLine );
_pen->setWidth ( _borderWidth );
} else
_pen->setStyle ( Qt::NoPen );
_brush = Hurricane::getBrush ( _pattern, _red, _green, _blue );
}
}
QColor DrawingStyle::getColor ( int darkening ) const
{
return _color.darker ( darkening );
assert ( _color != NULL );
return _color->darker ( darkening );
}
QPen DrawingStyle::getPen ( int darkening ) const
{
QPen pen ( _pen );
pen.setColor ( _color.darker(darkening) );
assert ( _pen != NULL );
QPen pen ( *_pen );
pen.setColor ( _color->darker(darkening) );
return pen;
}
QBrush DrawingStyle::getBrush ( int darkening ) const
{
QBrush brush ( _brush );
brush.setColor ( _color.darker(darkening) );
assert ( _brush != NULL );
QBrush brush ( *_brush );
brush.setColor ( _color->darker(darkening) );
return brush;
}
@ -142,6 +164,11 @@ namespace Hurricane {
DrawingStyle::~DrawingStyle ()
{
assert ( _refcount == 0 );
if ( _color ) {
delete _color;
delete _pen;
delete _brush;
}
}
@ -168,7 +195,13 @@ namespace Hurricane {
DrawingGroup::DrawingGroup ( const Name& name )
: _name(name), _drawingStyles()
{ }
void DrawingGroup::qtAllocate ()
{
for ( size_t i=0 ; i < _drawingStyles.size() ; i++ )
_drawingStyles[i]->qtAllocate ();
}
@ -251,7 +284,8 @@ namespace Hurricane {
addDrawingStyle ( Viewer, Grid , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 8.0 );
addDrawingStyle ( Viewer, Spot , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 8.0 );
addDrawingStyle ( Viewer, Ghost , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
addDrawingStyle ( Viewer, Text , "8822441188224411", 255, 255, 255, 0, 1.0 );
addDrawingStyle ( Viewer, TextCell , "8822441188224411", 255, 255, 255, 0, 1.0 );
addDrawingStyle ( Viewer, TextInstance , "8822441188224411", 255, 255, 255, 0, 1.0 );
addDrawingStyle ( Viewer, Undef , "2244118822441188", 238, 130, 238, 0, 1.0 );
}
@ -264,6 +298,13 @@ namespace Hurricane {
}
void DisplayStyle::qtAllocate ()
{
for ( size_t gi=0 ; gi < _groups.size() ; gi++ )
_groups[gi]->qtAllocate ();
}
const Name& DisplayStyle::getGroup ( const Name& key ) const
{
for ( size_t gi=0 ; gi < _groups.size() ; gi++ ) {

View File

@ -74,6 +74,7 @@ namespace Hurricane {
Graphics::Graphics ()
: _styles()
, _active(NULL)
, _qtEnabled(false)
{
_styles.push_back ( new DisplayStyle("Fallback") );
_active = _styles[0];
@ -121,6 +122,14 @@ namespace Hurricane {
}
void Graphics::_enable ()
{
_qtEnabled = true;
for ( size_t si=0 ; si < _styles.size() ; si++ )
_styles[si]->qtAllocate ();
}
size_t Graphics::_findStyle ( const Name& name ) const
{
size_t si = 0;
@ -147,6 +156,9 @@ namespace Hurricane {
_styles [ si ] = displayStyle;
_active = _styles [ si ];
if ( _qtEnabled )
_active->qtAllocate ();
}
@ -175,6 +187,9 @@ namespace Hurricane {
DisplayStyle* Graphics::_getStyle ( const Name& key )
{
// if ( !_qtEnabled )
// cerr << "[ERROR] Graphics has not been enabled, you are likely to crash..." << endl;
size_t si = _findStyle(key);
if ( si == _styles.size() )
return NULL;
@ -183,6 +198,18 @@ namespace Hurricane {
}
bool Graphics::isEnabled ()
{
return getGraphics()->_qtEnabled;
}
void Graphics::enable ()
{
return getGraphics()->_enable();
}
void Graphics::addStyle ( DisplayStyle* displayStyle )
{
getGraphics()->_addStyle ( displayStyle );

View File

@ -104,7 +104,7 @@ namespace {
namespace Hurricane {
QBrush getBrush ( const string& pattern, int red, int green, int blue )
QBrush* getBrush ( const string& pattern, int red, int green, int blue )
{
if ( pattern != "FFFFFFFFFFFFFFFF" ) {
uchar bits[8];
@ -112,10 +112,10 @@ QBrush getBrush ( const string& pattern, int red, int green, int blue )
if ( !getPattern(bits,pattern) )
cerr << "[WARNING] Invalid stipple pattern: \"0x" << pattern << "\"." << endl;
return QBrush ( QColor(red,green,blue), QBitmap::fromData(QSize(8,8),bits,QImage::Format_Mono) );
return new QBrush ( QColor(red,green,blue), QBitmap::fromData(QSize(8,8),bits,QImage::Format_Mono) );
}
return QBrush ( QColor(red,green,blue), Qt::SolidPattern );
return new QBrush ( QColor(red,green,blue), Qt::SolidPattern );
}

View File

@ -133,6 +133,7 @@ namespace Hurricane {
bool isDrawable ( const Name& entryName );
void drawBox ( const Box& );
void drawLine ( const Point&, const Point& );
void drawText ( const Point&, const Name&, int angle=0, bool reverse=false );
void drawGrid ();
void drawSpot ();
void drawScreenRect ( const QPoint&, const QPoint& );
@ -219,35 +220,37 @@ namespace Hurricane {
private:
class DrawingPlanes {
public:
DrawingPlanes ( const QSize& size, CellWidget* cw );
~DrawingPlanes ();
inline bool getLineMode () const;
inline int width () const;
inline int height () const;
inline QSize size () const;
inline void select ( size_t i );
inline QPixmap* plane ();
inline QPixmap* plane ( size_t i );
inline QPainter& painter ();
inline QPainter& painter ( size_t i );
inline void painterBegin ();
inline void painterBegin ( size_t i );
inline void paintersBegin ();
inline void painterEnd ();
inline void painterEnd ( size_t i );
inline void paintersEnd ();
void setLineMode ( bool mode );
void setPen ( const QPen& pen );
void setBrush ( const QBrush& brush );
void resize ( const QSize& size );
void shiftLeft ( int dx );
void shiftRight ( int dx );
void shiftUp ( int dy );
void shiftDown ( int dy );
inline void copyToSelect ();
void copyToSelect ( int sx, int sy, int h, int w );
inline void copyToScreen ();
void copyToScreen ( int sx, int sy, int h, int w );
DrawingPlanes ( const QSize& size, CellWidget* cw );
~DrawingPlanes ();
inline bool getLineMode () const;
inline int width () const;
inline int height () const;
inline QSize size () const;
inline void select ( size_t i );
inline QPixmap* plane ();
inline QPixmap* plane ( size_t i );
inline QPainter& painter ();
inline QPainter& painter ( size_t i );
inline void painterBegin ();
inline void painterBegin ( size_t i );
inline void paintersBegin ();
inline void painterEnd ();
inline void painterEnd ( size_t i );
inline void paintersEnd ();
void setLineMode ( bool mode );
void setPen ( const QPen& pen );
void setBrush ( const QBrush& brush );
void setBackground ( const QBrush& brush );
void setBackgroundMode ( Qt::BGMode mode );
void resize ( const QSize& size );
void shiftLeft ( int dx );
void shiftRight ( int dx );
void shiftUp ( int dy );
void shiftDown ( int dy );
inline void copyToSelect ();
void copyToSelect ( int sx, int sy, int h, int w );
inline void copyToScreen ();
void copyToScreen ( int sx, int sy, int h, int w );
private:
CellWidget* _cellWidget;
QPixmap* _planes[2];
@ -284,6 +287,22 @@ namespace Hurricane {
CellWidget* _cellWidget;
};
private:
class TextDrawingQuery : public Query {
public:
TextDrawingQuery ( CellWidget* widget );
inline void setQuery ( const Box& area
, const Transformation& transformation
);
virtual bool hasMasterCellCallback () const;
virtual bool hasGoCallback () const;
virtual void masterCellCallback ();
virtual void goCallback ( Go* go );
protected:
CellWidget* _cellWidget;
};
protected:
// Internal: Attributes.
static const int _stripWidth;
@ -297,6 +316,7 @@ namespace Hurricane {
QPoint _offsetVA;
DrawingPlanes _drawingPlanes;
DrawingQuery _drawingQuery;
TextDrawingQuery _textDrawingQuery;
int _queryFilter;
QPoint _mousePosition;
Spot _spot;
@ -308,6 +328,7 @@ namespace Hurricane {
set<Selector*> _selectors;
vector<Command*> _commands;
size_t _redrawRectCount;
int _textFontHeight;
};

View File

@ -88,6 +88,7 @@ namespace Hurricane {
size_t unlink ();
// Accessors.
void qtAllocate ();
inline const Name& getName () const;
inline const string& getPattern () const;
QColor getColor ( int darkening ) const;
@ -98,10 +99,14 @@ namespace Hurricane {
protected:
// Internal - Attributes.
const Name _name;
int _red;
int _green;
int _blue;
int _borderWidth;
string _pattern;
QColor _color;
QPen _pen;
QBrush _brush;
QColor *_color;
QPen *_pen;
QBrush *_brush;
float _threshold;
size_t _refcount;
@ -130,6 +135,7 @@ namespace Hurricane {
DrawingGroup ( const Name& name );
~DrawingGroup ();
DrawingGroup* getClone ();
void qtAllocate ();
// Methods.
inline const Name& getName () const;
@ -176,7 +182,8 @@ namespace Hurricane {
static const Name Grid;
static const Name Spot;
static const Name Ghost;
static const Name Text;
static const Name TextCell;
static const Name TextInstance;
static const Name Undef;
static const Name UnmatchedGroup;
@ -198,6 +205,7 @@ namespace Hurricane {
DrawingStyle* find ( const Name& key ) const;
// Modifiers.
void qtAllocate ();
inline void setDescription ( const string& description );
inline void setDescription ( const char* description );
void inheritFrom ( const DisplayStyle* base );

View File

@ -79,6 +79,7 @@ namespace Hurricane {
public:
// Accessors.
static Graphics* getGraphics ();
static bool isEnabled ();
static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false );
static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false );
static const Name& getGroup ( const Name& key );
@ -96,12 +97,14 @@ namespace Hurricane {
static DisplayStyle* getStyle ( const Name& key );
static DisplayStyle* getStyle ();
static const vector<DisplayStyle*>& getStyles ();
static void enable ();
// Internals - Attributes.
protected:
static Graphics* _singleton;
vector<DisplayStyle*> _styles;
DisplayStyle* _active;
bool _qtEnabled;
// Internals - Constructors & Destructors.
Graphics ();
@ -124,6 +127,7 @@ namespace Hurricane {
inline const string& _getPattern ( const Name& key ) const;
inline float _getThreshold ( const Name& key ) const;
inline int _getDarkening () const;
inline void _enable ();
};

View File

@ -71,7 +71,7 @@ namespace Hurricane {
// Functions.
QBrush getBrush ( const string& pattern, int red, int green, int blue );
QBrush* getBrush ( const string& pattern, int red, int green, int blue );