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 (boxSizeChanged) {
- updateInterfacesAndConnections();
+ updateInterfaceAndConnectionItems();
}
return false;
}
-void BoxItem::interfaceRenamed() {
+void BoxItem::nameChanged() {
+
+ QFontMetrics fmId(params->defaultBlockFont);
+ nameWidth = fmId.width(refBlock->getName());
+ nameHeight = fmId.height();
+
if (updateGeometry(InterfaceMove)) {
//cout << "must recompute group item geometry" << endl;
(getScene()->getGroupItem())->updateShape();
- }
+ }
+ // force the update in case of size has not changed
+ update();
}
void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
}
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 BoxItem::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->connect(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();
}
-void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
-
+void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
+
QMenu menu;
QAction* titleAction = NULL;
QAction* removeAction = NULL;
QAction* duplicateAction = NULL;
QAction* renameAction = NULL;
- QAction* connectToGroup = NULL;
- QAction* disconnectFromGroup = NULL;
+ QAction* connectToGroup = NULL;
QAction* showProperties = NULL;
QAction* cloneInterface = NULL;
QAction* openWindow = NULL;
QAction* showRstClkIface = NULL;
QAction* showWishboneIface = NULL;
QAction* showParameters = NULL;
+ QAction* showPatterns = 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){
ConnectedInterface* ifaceGroup = NULL;
bool canRemove = true;
-
if ((iface->getDirection() == AbstractInterface::Input) && (iface->getConnectedFrom() == NULL)) {
connectToGroup = menu.addAction("Connect to group input");
}
connectToGroup = menu.addAction("Connect to group output");
}
else if (iface->getConnectionFromParentGroup() != NULL) {
- ifaceGroup = iface->getConnectionFromParentGroup();
- //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) {
- if (!ifaceGroup->isConnectedFrom()) {
- disconnectFromGroup = menu.addAction("Disconnect from group");
- }
- else {
+ ifaceGroup = iface->getConnectionFromParentGroup();
+ if (ifaceGroup->isConnectedFrom()) {
canRemove = false;
}
}
else if (iface->getConnectionToParentGroup() != NULL) {
- ifaceGroup = iface->getConnectionToParentGroup();
- //if ((!ifaceGroup->isConnectedFrom()) || (!ifaceGroup->isConnectedTo())) {
- if (!ifaceGroup->isConnectedTo()) {
- disconnectFromGroup = menu.addAction("Disconnect from group");
- }
- else {
+ ifaceGroup = iface->getConnectionToParentGroup();
+ if (ifaceGroup->isConnectedTo()) {
canRemove = false;
}
}
}
}
}
+ if ((iface->getAssociatedIface() != NULL) && (iface->getDirection() == AbstractInterface::Output)) {
+ showPatterns = menu.addAction("Show patterns");
+ }
}
// menu for blocks (group or func)
else {
dispatcher->removeFunctionalInterface(ifaceItem);
}
else {
- dispatcher->removeBlock(this);
+ dispatcher->removeBoxItem(this);
}
}
else if (selectedAction == duplicateAction) {
- dispatcher->duplicateBlock(this);
+ dispatcher->duplicateBoxItem(this);
}
else if(selectedAction == renameAction){
- if(ifaceItem != NULL)
+ if(ifaceItem != NULL) {
dispatcher->renameInterface(ifaceItem);
- else
- dispatcher->renameBlockOrGroup(this);
+ }
+ else {
+ if (refBlock->isFunctionalBlock()) {
+ dispatcher->renameFunctionalBlock(this);
+ }
+ else if (refBlock->isGroupBlock()) {
+ dispatcher->renameGroupBlock(childGroupItem);
+ }
+ }
}
else if(selectedAction == showProperties){
dispatcher->showProperties(ifaceItem);
else if (selectedAction == connectToGroup){
dispatcher->connectInterToGroup(ifaceItem);
}
- else if (selectedAction == disconnectFromGroup) {
- dispatcher->disconnectInterFromGroup(ifaceItem);
- }
else if (selectedAction == cloneInterface){
- dispatcher->duplicateInterface(ifaceItem);
+ dispatcher->duplicateInterfaceItem(ifaceItem);
}
else if (selectedAction == openWindow){
dispatcher->showRaiseWindow(this);
else if(selectedAction == showWishboneIface) {
dispatcher->showWishboneIface(this);
}
- else if(selectedAction == showParameters){
+ else if(selectedAction == showParameters) {
new ParametersWindow(refBlock, params, NULL);
}
+ else if(selectedAction == showPatterns) {
+ dispatcher->showPatterns(ifaceItem);
+ }
}
+
void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
bool ok = false;
}
GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
- FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
+ FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference);
/* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
reading bif_iface tags. Thus interface are all removed.
*/
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);
writer.writeAttribute("id",QString::number(id));
writer.writeAttribute("inside_group",QString::number(childGroupItem->getId()));
- QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+ QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
writer.writeAttribute("position",attrPos);
QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
writer.writeAttribute("dimension",attrDim);