AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem *parent) : QGraphicsItem(parent) {
dispatcher = _dispatcher;
params = _params;
- refBlock = _refBlock;
- QFont fontId("Arial",10);
- QFontMetrics fmId(fontId);
+ refBlock = _refBlock;
+ QFontMetrics fmId(params->defaultBlockFont);
nameWidth = fmId.width(refBlock->getName());
nameHeight = fmId.height();
nameMargin = 10;
// NOTE : initInterfaces() is only called in subclasses
}
+AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent) : QGraphicsItem(parent) {
+ dispatcher = _dispatcher;
+ params = _params;
+ refBlock = NULL;
+ nameWidth = 0;
+ nameHeight = 0;
+ nameMargin = 10;
+ ifaceMargin = 10;
+
+ // the six following values will be override in subclass constructors
+ minimumBoxWidth = 0;
+ minimumBoxHeight = 0;
+ boxWidth = 0;
+ boxHeight = 0;
+ totalWidth = 0;
+ totalHeight = 0;
+
+ originPoint = QPointF(0.0,0.0);
+
+ selected = false;
+ currentInterface = NULL;
+ rstClkVisible = false;
+
+ setAcceptHoverEvents(true);
+
+ // NOTE : initInterfaces() is only called in subclasses
+}
+
AbstractBoxItem::~AbstractBoxItem() {
foreach(InterfaceItem* inter, interfaces) {
delete inter;
return false;
}
-void AbstractBoxItem::initInterfaces()
-{
+void AbstractBoxItem::setRefBlock(AbstractBlock* _refBlock) {
+ refBlock = _refBlock;
+ QFontMetrics fmId(params->defaultBlockFont);
+ nameWidth = fmId.width(refBlock->getName());
+ nameHeight = fmId.height();
+}
+
+void AbstractBoxItem::initInterfaces() {
/* TO DO : creating all needed InterfaceItem, with by default, input at west and output at east */
int orientation = Parameters::West;
void AbstractBoxItem::addInterface(InterfaceItem *i, bool resetPosition) {
interfaces.append(i);
if (resetPosition) resetInterfacesPosition();
- updateGeometry();
+ updateGeometry(InterfaceMove);
update();
}
delete i;
//resetInterfacesPosition();
- updateGeometry();
+ updateGeometry(InterfaceMove);
update();
}
}
}
-void AbstractBoxItem::deplaceInterface(QPointF pos) {
+void AbstractBoxItem::moveInterfaceTo(QPointF pos) {
double positionRatio;
if(currentInterface->getOrientation() == Parameters::North || currentInterface->getOrientation() == Parameters::South){
if(pos.x() < 0){
foreach(InterfaceItem *item, interfaces){
item->updatePosition();
}
+ // NB: dunno the utility of this test !!
if (getScene() != NULL) {
// update all connections from/to this block
foreach(ConnectionItem *item, getScene()->getConnectionItems()){
if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) {
- item->setPathes();
+ item->setPath();
}
}
}