setZValue(100);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
- initInterfaces();
+ initInterfaceItems();
updateGeometry(InterfaceMove);
- resetInterfacesPosition();
+ resetInterfaceItemsPosition();
QPointF initPos = QPointF(0.0,0.0) - originPoint;
setPos(initPos);
//cout << "total size of block: " << totalWidth << "," << totalHeight << endl;
if (minimumBoxHeight < (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1))) {
minimumBoxHeight = (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1));
}
+ cout << "source minimum size = " << minimumBoxWidth << "x" << minimumBoxHeight << endl;
}
}
}
if (boxSizeChanged) {
- updateInterfacesAndConnections();
+ updateInterfaceAndConnectionItems();
}
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(params->editState == Parameters::EditInterfaceMove) {
prepareGeometryChange();
- moveInterfaceTo(event->pos());
+ moveInterfaceItemTo(event->pos());
// recompute the geometry of the block
if (updateGeometry(InterfaceMove)) {
//cout << "must recompute group item geometry" << endl;
dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
- InterfaceItem *inter = getInterfaceFromCursor(x,y);
+ InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
if (inter != NULL) {
if (params->editState == Parameters::EditNoOperation) {
}
}
else if (mode == GroupScene::ItemEdition) {
- setZValue(zValue()+100);
+ //setZValue(zValue()+100);
if (params->cursorState == Parameters::CursorOnInterface) {
- InterfaceItem *inter = getInterfaceFromCursor(x,y);
+ InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
if (inter != NULL) {
if (inter == currentInterface) {
params->setEditState(Parameters::EditInterfaceDeselect);
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);
int mode = getScene()->getEditionMode();
if (mode == GroupScene::AddConnection) {
- InterfaceItem* iface = getInterfaceFromCursor(x,y);
+ InterfaceItem* iface = getInterfaceItemFromCursor(x,y);
if (iface != NULL) {
params->cursorState = Parameters::CursorOnInterface;
setCursor(Qt::PointingHandCursor);
int marginE = 5;
int marginS = 5;
- InterfaceItem* iface = getInterfaceFromCursor(x,y);
+ InterfaceItem* iface = getInterfaceItemFromCursor(x,y);
if (iface != NULL) {
params->cursorState = Parameters::CursorOnInterface;
setCursor(Qt::PointingHandCursor);
}
}
}
- QGraphicsItem::hoverMoveEvent(event);
+ //QGraphicsItem::hoverMoveEvent(event);
+ event->ignore();
}
QAction* showParameters = NULL;
- InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y());
+ InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
// menu for interface
if( ifaceItem != NULL){
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);
}
}
// creating InterfaceItem
- initInterfaces();
+ initInterfaceItems();
// setting them with saved values
for(int i=0; i<interfaceNodes.length(); i++){
double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
- InterfaceItem *interfaceItem = searchInterfaceByName(name);
+ InterfaceItem *interfaceItem = searchInterfaceItemByName(name);
interfaceItem->setId(id);
interfaceItem->setOrientation(orientation);
interfaceItem->setPositionRatio(position);