X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/0d3590739ff5a4ca9e87c052ac142f5d1d3a68ab..3bbc311e444c1ef9ac66dd6861fb0acb13ddb72a:/SourceItem.cpp diff --git a/SourceItem.cpp b/SourceItem.cpp index 82a41b0..62f601a 100644 --- a/SourceItem.cpp +++ b/SourceItem.cpp @@ -142,6 +142,7 @@ void SourceItem::updateMinimumSize() { if (minimumBoxHeight < (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1))) { minimumBoxHeight = (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1)); } + cout << "source minimum size = " << minimumBoxWidth << "x" << minimumBoxHeight << endl; } @@ -203,6 +204,7 @@ bool SourceItem::updateGeometry(ChangeType type) { originPoint.setX(x); originPoint.setY(y); + cout << "source size = " << totalWidth << "x" << totalHeight << endl; if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { prepareGeometryChange(); return true; @@ -217,32 +219,34 @@ void SourceItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { 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) { @@ -333,7 +337,7 @@ void SourceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } } else if (mode == GroupScene::ItemEdition) { - setZValue(zValue()+100); + //setZValue(zValue()+100); if (params->cursorState == Parameters::CursorOnInterface) { InterfaceItem *inter = getInterfaceFromCursor(x,y); if (inter != NULL) { @@ -364,7 +368,7 @@ void SourceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - setZValue(zValue()-100); + //setZValue(zValue()-100); int mode = getScene()->getEditionMode(); @@ -385,10 +389,12 @@ void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { 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); @@ -474,7 +480,8 @@ void SourceItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { } } } - QGraphicsItem::hoverMoveEvent(event); + //QGraphicsItem::hoverMoveEvent(event); + event->ignore(); } @@ -648,7 +655,7 @@ void SourceItem::load(QDomElement funcElement) throw(Exception) { 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) { @@ -657,7 +664,7 @@ void SourceItem::load(QDomElement funcElement) throw(Exception) { if (! ctlIface->setAssociatedIface(functionalInterface)) { throw(Exception(PROJECTFILE_CORRUPTED)); } - ctlIface->setName(name+"_ctl"); + ctlIface->setName(name+"_enb"); functionalBlock->addInterface(ctlIface); } }