setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
- updateGeometry();
+
+ updateGeometry(InterfaceMove);
QPointF initPos = QPointF(0.0,0.0) - originPoint;
setPos(initPos);
cout << "total size of group: " << totalWidth << "," << totalHeight << endl;
}
void GroupItem::updateShape() {
- updateGeometry();
+ updateGeometry(InterfaceMove);
}
bool GroupItem::updateGeometry(ChangeType type) {
QPointF oldOrigin = originPoint;
QSize oldSize(totalWidth,totalHeight);
- updateMinimumSize();
bool boxSizeChanged = false;
+
+ // whatever the change, the minimum size may have changed
+ updateMinimumSize();
+
+ if (type == Resize) {
+ boxSizeChanged = true;
+ }
+ // if an internal block has moved, the actual box size may be inadequate
if (boxWidth < minimumBoxWidth) {
boxWidth = minimumBoxWidth;
boxSizeChanged = true;
}
if (boxHeight < minimumBoxHeight) {
boxHeight = minimumBoxHeight;
- boxSizeChanged = true;
+ boxSizeChanged = true;
}
+
if (boxSizeChanged) {
updateInterfacesAndConnections();
}
+
// compute the max. width of interfaces' name for 4 orientations.
int maxSouth = 0;
int maxNorth = 0;
originPoint.setY(y);
if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) {
- //cout << "must change group item shape" << endl;
+ cout << "must change group item shape" << endl;
prepareGeometryChange();
return true;
}
cout << "abnormal case while resizing block" << endl;
break;
}
- updateGeometry();
+ updateGeometry(Resize);
/*
// recompute the geometry of the block
updateGeometry();
}
else if(params->editState == Parameters::EditInterfaceMove) {
prepareGeometryChange();
- deplaceInterface(event->pos());
+ moveInterfaceTo(event->pos());
// recompute the geometry of the block
- updateGeometry();
+ updateGeometry(InterfaceMove);
// update connection from/to the selected interface
foreach(ConnectionItem *item, getScene()->getConnectionItems()){
if ((item->getFromInterfaceItem() == currentInterface) || (item->getToInterfaceItem() == currentInterface)) {
- item->setPathes();
+ item->setPath();
}
}
- update();
+ //update();
}
}