return false;
}
+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) {
if(params->editState == Parameters::EditBlockMove) {
moveInterfaceTo(event->pos());
// recompute the geometry of the block
if (updateGeometry(InterfaceMove)) {
- cout << "must recompute group item geometry" << endl;
+ //cout << "must recompute group item geometry" << endl;
(getScene()->getGroupItem())->updateShape();
}
// update connection from/to the selected interface
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->createConnectionItem(iface1,iface2);
if (ok) {
iface1->selected = false;
// no update needed since the whole scene will be repainted
void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
+ event->accept();
+
QMenu menu;
QAction* titleAction = NULL;
QAction* removeAction = NULL;
if (selectedAction == removeAction) {
if(ifaceItem != NULL) {
- dispatcher->removeBlockInterface(ifaceItem);
+ 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);
dispatcher->disconnectInterFromGroup(ifaceItem);
}
else if (selectedAction == cloneInterface){
- dispatcher->duplicateInterface(ifaceItem);
+ dispatcher->duplicateInterfaceItem(ifaceItem);
}
else if (selectedAction == openWindow){
dispatcher->showRaiseWindow(this);
}
else if(selectedAction == showParameters){
new ParametersWindow(refBlock, params, NULL);
- }
+ }
}
+
void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
bool ok = false;
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
int dimY = dimensionStr.at(1).toInt(&ok);
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
-
+
ReferenceBlock *referenceMd5 = NULL;
ReferenceBlock *referenceXml = NULL;
ReferenceBlock *reference = NULL;
else {
reference = referenceMd5;
}
+
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.
*/
blockParam = functionalBlock->getParameterFromName(name);
if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
blockParam->setValue(value);
- }
+ }
- // recreate all interface because of some may have a multiplicity>1 with several examplars
+ // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars
functionalBlock->removeAllInterfaces();
QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
// setting interfaces (user name, and for multiplicity>1 may be create some new ones)
if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
+ cout << "creating iface from reference named " << qPrintable(refName) << endl;
FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
functionalInterface->setName(name);
functionalBlock->addInterface(functionalInterface);
+
+ // searching for control interface
+ QString ctlRefName = refName+"_ctl";
+ ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName));
+
+ if (ctlRefIface != NULL) {
+ cout << "found a control iface:" << qPrintable(ctlRefName) << endl;
+ FunctionalInterface *ctlIface = new FunctionalInterface(functionalBlock,ctlRefIface);
+ if (! ctlIface->setAssociatedIface(functionalInterface)) {
+ throw(Exception(PROJECTFILE_CORRUPTED));
+ }
+ ctlIface->setName(name+"_ctl");
+ functionalBlock->addInterface(ctlIface);
+ }
}
+
// creating InterfaceItem
initInterfaces();
// setting them with saved values
writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
writer.writeAttribute("name",refBlock->getName());
- 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);