* ./hurricane:

- New: In Reference, adds a type to differentiate between "Labels" and
        "Position". Labels are strings that we wants to display, and position
        are specific points with a name attached to it.
    - New: In CellWidget, specific display for the two kind of references
        (Label & Display).
This commit is contained in:
Jean-Paul Chaput 2010-04-17 10:13:17 +00:00
parent 797a53daec
commit b985e8c96f
4 changed files with 61 additions and 22 deletions

View File

@ -37,11 +37,12 @@ namespace Hurricane {
DbU::Unit Reference::_extend = 0; DbU::Unit Reference::_extend = 0;
Reference::Reference(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y) Reference::Reference(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y, Type type)
// *************************************************************** // ************************************************************************************
: Inherit(cell), : Inherit(cell),
_name(name), _name(name),
_point(x,y) _point(x,y),
_type(type)
{ {
if ( !_extend ) _extend = DbU::grid(0.5); if ( !_extend ) _extend = DbU::grid(0.5);
@ -49,20 +50,20 @@ Reference::Reference(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y)
throw Error("Can't create " + _TName("Reference") + " : empty name"); throw Error("Can't create " + _TName("Reference") + " : empty name");
} }
Reference* Reference::create(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y) Reference* Reference::create(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y, Type type )
// *********************************************************************** // *********************************************************************************************
{ {
Reference* reference = new Reference(cell, name, x, y); Reference* reference = new Reference(cell, name, x, y, type);
reference->_postCreate(); reference->_postCreate();
return reference; return reference;
} }
Reference* Reference::create(Cell* cell, const Name& name, const Point& point) Reference* Reference::create(Cell* cell, const Name& name, const Point& point, Type type)
// *************************************************************************** // **************************************************************************************
{ {
return create(cell,name,point.getX(),point.getY()); return create(cell,name,point.getX(),point.getY(),type);
} }
Box Reference::getBoundingBox() const Box Reference::getBoundingBox() const

View File

@ -38,21 +38,23 @@ class Reference : public Marker {
// ***** // *****
public: typedef Marker Inherit; public: typedef Marker Inherit;
public: enum Type { Label=1, Position=2 };
// Attributes // Attributes
// ********** // **********
public: Name _name; private: Name _name;
public: Point _point; private: Point _point;
public: static DbU::Unit _extend; private: Type _type;
private: static DbU::Unit _extend;
// Constructors // Constructors
// ************ // ************
protected: Reference(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y); protected: Reference(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y, Type type);
public: static Reference* create(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y ); public: static Reference* create(Cell* cell, const Name& name, DbU::Unit x, DbU::Unit y, Type type=Position );
public: static Reference* create(Cell* cell, const Name& name, const Point& point ); public: static Reference* create(Cell* cell, const Name& name, const Point& point, Type type=Position );
// Accessors // Accessors
// ********* // *********
@ -60,11 +62,13 @@ class Reference : public Marker {
public: virtual Box getBoundingBox() const; public: virtual Box getBoundingBox() const;
public: const Name& getName() const {return _name;}; public: const Name& getName() const {return _name;};
public: const Point& getPoint() const {return _point;}; public: const Point& getPoint() const {return _point;};
public: Type getType() const { return _type; }
// Updators // Updators
// ******** // ********
public: virtual void translate(const DbU::Unit& dx, const DbU::Unit& dy); public: virtual void translate(const DbU::Unit& dx, const DbU::Unit& dy);
public: void setType ( Type type ) { _type=type; }
// Others // Others
// ****** // ******

View File

@ -860,14 +860,34 @@ namespace Hurricane {
static QRect rectangle; static QRect rectangle;
const Reference* reference = dynamic_cast<const Reference*>(marker); const Reference* reference = dynamic_cast<const Reference*>(marker);
if ( reference ) { if ( reference and _cellWidget->isDrawable("text.reference") and (getDepth() < 2) ) {
_goCount++; _goCount++;
Box bb = transformation.getBox(reference->getBoundingBox()).inflate(DbU::lambda(5.0)); unsigned int flags = BigFont|Bold|Frame;
rectangle = _cellWidget->dbuToDisplayRect ( bb );
Box bb = transformation.getBox ( reference->getBoundingBox() );
rectangle = _cellWidget->dbuToDisplayRect ( bb );
rectangle.adjust ( 10, 10, 10, 10 );
if ( reference->getType() == Reference::Position ) {
QPoint point = _cellWidget->dbuToDisplayPoint ( reference->getPoint() );
rectangle.translate ( point.x() - rectangle.x(), point.y() - rectangle.y() );
flags |= Left;
} else {
flags |= Center;
}
if ( _cellWidget->isDrawable("text.reference") and (getDepth() < 2) ) {
const char* refName = reference->getName()._getSharedName()->_getSString().c_str(); const char* refName = reference->getName()._getSharedName()->_getSString().c_str();
_cellWidget->drawDisplayText ( rectangle, refName, BigFont|Bold|Center|Frame ); _cellWidget->drawDisplayText ( rectangle, refName, flags );
if ( reference->getType() == Reference::Position ) {
QPoint losange [5] = { QPoint(rectangle.x() ,rectangle.y()-6)
, QPoint(rectangle.x()-6,rectangle.y() )
, QPoint(rectangle.x() ,rectangle.y()+6)
, QPoint(rectangle.x()+6,rectangle.y() )
, QPoint(rectangle.x() ,rectangle.y()-6)
};
_cellWidget->drawScreenPolyline ( losange, 5, 2 );
} }
} }
} }
@ -1731,6 +1751,7 @@ namespace Hurricane {
bottomLeft.ry() += height/2; bottomLeft.ry() += height/2;
} else if ( flags & Top ) { } else if ( flags & Top ) {
bottomLeft.ry() += height; bottomLeft.ry() += height;
} else if ( flags & Left ) {
} }
if ( flags & Frame ) painter.drawRect ( bottomLeft.x()-1, bottomLeft.y()-height, width+2, height ); if ( flags & Frame ) painter.drawRect ( bottomLeft.x()-1, bottomLeft.y()-height, width+2, height );
@ -1764,13 +1785,23 @@ namespace Hurricane {
} }
void CellWidget::drawScreenPolygon ( const QPoint* points, int count, size_t plane )
{
_drawingPlanes.painter(plane).drawPolygon ( points, count );
}
void CellWidget::drawScreenPolyline ( const QPoint* points, int count, int width, size_t plane ) void CellWidget::drawScreenPolyline ( const QPoint* points, int count, int width, size_t plane )
{ {
_drawingPlanes.painter(plane).save ();
QPen pen = _drawingPlanes.painter(plane).pen (); QPen pen = _drawingPlanes.painter(plane).pen ();
pen.setWidth ( width ); pen.setWidth ( width );
_drawingPlanes.painter(plane).setPen ( pen ); _drawingPlanes.painter(plane).setPen ( pen );
_drawingPlanes.painter(plane).drawPolyline ( points, count ); _drawingPlanes.painter(plane).drawPolyline ( points, count );
_drawingPlanes.painter(plane).restore ();
} }

View File

@ -117,7 +117,9 @@ namespace Hurricane {
, Reverse=0x04 , Reverse=0x04
, Frame =0x08 , Frame =0x08
, Center =0x10 , Center =0x10
, Top =0x20 , Left =0x20
, Right =0x40
, Top =0x80
}; };
public: public:
// Constructor & Destructor. // Constructor & Destructor.
@ -187,6 +189,7 @@ namespace Hurricane {
void drawRulers ( QRect ); void drawRulers ( QRect );
void drawDisplayText ( const QRect& , const char*, unsigned int flags=0 ); void drawDisplayText ( const QRect& , const char*, unsigned int flags=0 );
void drawDisplayText ( const QPoint&, const char*, unsigned int flags=0, int angle=0 ); void drawDisplayText ( const QPoint&, const char*, unsigned int flags=0, int angle=0 );
void drawScreenPolygon ( const QPoint*, int count, size_t plane=PlaneId::Working );
void drawScreenLine ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working, bool mode=true ); void drawScreenLine ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working, bool mode=true );
void drawScreenRect ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working ); void drawScreenRect ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working );
void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working ); void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working );