if (minimumBoxHeight < (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1))) {
minimumBoxHeight = (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1));
}
+ cout << "source minimum size = " << minimumBoxWidth << "x" << minimumBoxHeight << endl;
}
originPoint.setX(x);
originPoint.setY(y);
+ cout << "source size = " << totalWidth << "x" << totalHeight << endl;
if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) {
prepareGeometryChange();
return true;
int gapX = event->scenePos().x() - cursorPosition.x();
int gapY = event->scenePos().y() - cursorPosition.y();
-
- //cout << "block abs. pos: " << absPos.x() << "," << absPos.y() << " | ";
- //cout << "block current. pos: " << currentPosition.x() << "," << currentPosition.y() << " | ";
-
+
+ bool canMove = true;
+
+ QRectF rectSource = boundingRectInScene();
+ rectSource.moveTo(rectSource.x()+gapX,rectSource.y()+gapY);
+ GroupItem* group = getScene()->getGroupItem();
+ QRectF rectGroup = group->boundingRectInScene();
+ if (rectSource.intersects(rectGroup)) canMove = false;
/*
- if (absPos.x()+gapX < marginConn) {
- gapX = marginConn-absPos.x();
- }
- if (absPos.y()+gapY < marginConn) {
- gapY = marginConn-absPos.y();
+ if (canMove) {
+ foreach(SourceItem* source, getScene()->getSourceItems()) {
+ QRectF rectOther = source->boundingRectInScene();
+ if ((source != this) && (rectSource.intersects(rectOther))) canMove = false;
+ }
}
*/
- //cout << "gap: " << gapX << "," << gapY << endl;
- QPointF gap(gapX,gapY);
- currentPosition = currentPosition+gap;
- setPos(currentPosition);
- // update all connections from/to this block
- foreach(ConnectionItem *item, getScene()->getConnectionItems()){
- if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) {
- item->setPath();
- }
+ if (canMove) {
+ QPointF gap(gapX,gapY);
+ currentPosition = currentPosition+gap;
+ setPos(currentPosition);
+ // update all connections from/to this block
+ foreach(ConnectionItem *item, getScene()->getConnectionItems()){
+ if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) {
+ item->setPath();
+ }
+ }
}
cursorPosition = event->scenePos();
-
- // udpate the groupitem
- (getScene()->getGroupItem())->updateShape();
}
else if(params->editState == Parameters::EditBlockResize) {
}
}
else if (mode == GroupScene::ItemEdition) {
- setZValue(zValue()+100);
+ //setZValue(zValue()+100);
if (params->cursorState == Parameters::CursorOnInterface) {
InterfaceItem *inter = getInterfaceFromCursor(x,y);
if (inter != NULL) {
void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
- setZValue(zValue()-100);
+ //setZValue(zValue()-100);
int mode = getScene()->getEditionMode();
else if (params->editState == Parameters::EditCloseConnection) {
InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
- bool ok = dispatcher->createConnectionItem(iface1,iface2);
+ bool ok = dispatcher->createConnection(iface1,iface2);
if (ok) {
iface1->selected = false;
- // no update needed since the whole scene will be repainted
+ update(iface1->boundingRect());
+ iface2->selected = false;
+ update(iface2->boundingRect());
getScene()->setSelectedInterface(1,NULL);
getScene()->setSelectedInterface(2,NULL);
params->setEditState(Parameters::EditNoOperation);
}
}
}
- QGraphicsItem::hoverMoveEvent(event);
+ //QGraphicsItem::hoverMoveEvent(event);
+ event->ignore();
}
functionalBlock->addInterface(functionalInterface);
// searching for control interface
- QString ctlRefName = refName+"_ctl";
+ QString ctlRefName = refName+"_enb";
ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName));
if (ctlRefIface != NULL) {
if (! ctlIface->setAssociatedIface(functionalInterface)) {
throw(Exception(PROJECTFILE_CORRUPTED));
}
- ctlIface->setName(name+"_ctl");
+ ctlIface->setName(name+"_enb");
functionalBlock->addInterface(ctlIface);
}
}