* ./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:
parent
797a53daec
commit
b985e8c96f
|
@ -37,11 +37,12 @@ namespace Hurricane {
|
|||
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),
|
||||
_name(name),
|
||||
_point(x,y)
|
||||
_point(x,y),
|
||||
_type(type)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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
|
||||
|
|
|
@ -38,21 +38,23 @@ class Reference : public Marker {
|
|||
// *****
|
||||
|
||||
public: typedef Marker Inherit;
|
||||
public: enum Type { Label=1, Position=2 };
|
||||
|
||||
// Attributes
|
||||
// **********
|
||||
|
||||
public: Name _name;
|
||||
public: Point _point;
|
||||
public: static DbU::Unit _extend;
|
||||
private: Name _name;
|
||||
private: Point _point;
|
||||
private: Type _type;
|
||||
private: static DbU::Unit _extend;
|
||||
|
||||
// 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, const Point& point );
|
||||
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, Type type=Position );
|
||||
|
||||
// Accessors
|
||||
// *********
|
||||
|
@ -60,11 +62,13 @@ class Reference : public Marker {
|
|||
public: virtual Box getBoundingBox() const;
|
||||
public: const Name& getName() const {return _name;};
|
||||
public: const Point& getPoint() const {return _point;};
|
||||
public: Type getType() const { return _type; }
|
||||
|
||||
// Updators
|
||||
// ********
|
||||
|
||||
public: virtual void translate(const DbU::Unit& dx, const DbU::Unit& dy);
|
||||
public: void setType ( Type type ) { _type=type; }
|
||||
|
||||
// Others
|
||||
// ******
|
||||
|
|
|
@ -860,14 +860,34 @@ namespace Hurricane {
|
|||
static QRect rectangle;
|
||||
|
||||
const Reference* reference = dynamic_cast<const Reference*>(marker);
|
||||
if ( reference ) {
|
||||
if ( reference and _cellWidget->isDrawable("text.reference") and (getDepth() < 2) ) {
|
||||
_goCount++;
|
||||
Box bb = transformation.getBox(reference->getBoundingBox()).inflate(DbU::lambda(5.0));
|
||||
rectangle = _cellWidget->dbuToDisplayRect ( bb );
|
||||
unsigned int flags = BigFont|Bold|Frame;
|
||||
|
||||
if ( _cellWidget->isDrawable("text.reference") and (getDepth() < 2) ) {
|
||||
const char* refName = reference->getName()._getSharedName()->_getSString().c_str();
|
||||
_cellWidget->drawDisplayText ( rectangle, refName, BigFont|Bold|Center|Frame );
|
||||
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;
|
||||
}
|
||||
|
||||
const char* refName = reference->getName()._getSharedName()->_getSString().c_str();
|
||||
_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;
|
||||
} else if ( flags & Top ) {
|
||||
bottomLeft.ry() += height;
|
||||
} else if ( flags & Left ) {
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
_drawingPlanes.painter(plane).save ();
|
||||
|
||||
QPen pen = _drawingPlanes.painter(plane).pen ();
|
||||
pen.setWidth ( width );
|
||||
|
||||
_drawingPlanes.painter(plane).setPen ( pen );
|
||||
_drawingPlanes.painter(plane).drawPolyline ( points, count );
|
||||
|
||||
_drawingPlanes.painter(plane).restore ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -117,7 +117,9 @@ namespace Hurricane {
|
|||
, Reverse=0x04
|
||||
, Frame =0x08
|
||||
, Center =0x10
|
||||
, Top =0x20
|
||||
, Left =0x20
|
||||
, Right =0x40
|
||||
, Top =0x80
|
||||
};
|
||||
public:
|
||||
// Constructor & Destructor.
|
||||
|
@ -187,6 +189,7 @@ namespace Hurricane {
|
|||
void drawRulers ( QRect );
|
||||
void drawDisplayText ( const QRect& , const char*, unsigned int flags=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 drawScreenRect ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working );
|
||||
void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working );
|
||||
|
|
Loading…
Reference in New Issue