else if (_type == "natural") {
ret = Natural;
}
+ else if (_type == "inherited") {
+ ret = Inherited;
+ }
return ret;
}
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;
update(iface1->boundingRect());
connectedTo.clear();\r
}\r
\r
-bool ConnectedInterface::connectTo(ConnectedInterface *iface) {\r
-\r
- if (canConnectTo(iface)) {\r
- connectedTo.append(iface);\r
- return true;\r
+void ConnectedInterface::connectTo(ConnectedInterface *iface) {\r
+ \r
+ connectedTo.append(iface);\r
+ iface->connectedFrom = this;\r
+ ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;\r
+ ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);\r
+ if ((asso1 != NULL) && (asso2 != NULL)) {\r
+ asso1->connectedTo.append(asso2);\r
+ asso2->connectedFrom = asso1;\r
}\r
+}\r
\r
- return false;\r
+void ConnectedInterface::disconnectTo(ConnectedInterface *iface) {\r
+ \r
+ connectedTo.removeAll(iface);\r
+ iface->connectedFrom = NULL;\r
+ ConnectedInterface* asso1 = (ConnectedInterface*)associatedIface;\r
+ ConnectedInterface* asso2 = (ConnectedInterface*)(iface->associatedIface);\r
+ if ((asso1 != NULL) && (asso2 != NULL)) {\r
+ asso1->connectedTo.removeAll(asso2);\r
+ asso2->connectedFrom = NULL;\r
+ }\r
}\r
\r
+\r
+/*\r
bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {\r
if (canConnectFrom(iface)) {\r
connectedFrom = iface;\r
}\r
return false;\r
}\r
+*/\r
\r
/* getConnectionToParentGroup() :\r
if an interface among connectedTo is an interface of the parent group\r
virtual bool canConnectFrom(AbstractInterface* iface) = 0;
// others
- bool connectTo(ConnectedInterface* iface);
- bool connectFrom(ConnectedInterface* iface);
+ void connectTo(ConnectedInterface* iface);
+ void disconnectTo(ConnectedInterface* iface);
+ //bool connectFrom(ConnectedInterface* iface);
ConnectedInterface* getConnectionToParentGroup();
ConnectedInterface* getConnectionFromParentGroup();
sceneCounter = 0;
}
-bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
+bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2) {
ConnectedInterface* ref1 = iface1->refInter;
ConnectedInterface* ref2 = iface2->refInter;
- ConnectedInterface* asso1 = iface1->refInter->getAssociatedIface();
- ConnectedInterface* asso2 = iface2->refInter->getAssociatedIface();
+ ConnectedInterface* asso1 = (ConnectedInterface*)(iface1->refInter->getAssociatedIface());
+ ConnectedInterface* asso2 = (ConnectedInterface*)(iface2->refInter->getAssociatedIface());
// connect both interface
bool ok1 = false;
// test the ref1->ref2 connection
if ((ref1->canConnectTo(ref2)) && (ref2->canConnectFrom(ref1))) {
ref1->connectTo(ref2);
+ /*
ref2->connectFrom(ref1);
if ((asso1 != NULL) && (asso2 != NULL)) {
asso1->connectTo(asso2);
asso2->connectFrom(asso1);
}
+ */
ok1 = true;
}
// if the frist one did not work, test ref2->ref1
if ((ok1 == false) && (ref2->canConnectTo(ref1)) && (ref1->canConnectFrom(ref2))) {
ref2->connectTo(ref1);
+ /*
ref1->connectFrom(ref2);
if ((asso1 != NULL) && (asso2 != NULL)) {
asso1->connectFrom(asso2);
asso2->connectTo(asso1);
}
+ */
ok2 = true;
}
if ((ok1 == true) || (ok2 == true)) {
// process the special case source->group apart
if (fromIfaceItem->getOwner()->isSourceItem()) {
// remove from graph
- fromInter->removeConnectedTo(toInter);
- toInter->clearConnectedFrom();
+ fromInter->disconnectTo(toInter);
// remove from scene
fromIfaceItem->removeConnectionItem(conn);
toIfaceItem->removeConnectionItem(conn);
#ifdef DEBUG
cout << "removing connections from graph ..." ;
#endif
- if (fromInter->getDirection() == AbstractInterface::InOut) {
- fromInter->clearConnectedTo();
- fromInter->clearConnectedFrom();
- toInter->clearConnectedTo();
- toInter->clearConnectedFrom();
- }
- else {
- fromInter->removeConnectedTo(toInter);
- toInter->clearConnectedFrom();
- }
+ fromInter->disconnectTo(toInter);
+
#ifdef DEBUG
cout << "done." << endl ;
#endif
#endif
if (groupIfaceItem != NULL) {
+
+ bool groupInterRemove = false;
+ if ((groupIfaceItem->nter->isConnectedTo() == false) && (groupInter->isConnectedFrom() == false)) groupInterRemove = true;
+
ConnectedInterface* groupInter = groupIfaceItem->refInter;
groupItem->removeInterface(groupIfaceItem);
// creating/adding the group control interface in the graph model
GroupInterface *groupCtlInter = new GroupInterface(parentBlock,refInter->getName()+"_group_enb",refInter->getDirection(),AbstractInterface::Control);
groupCtlInter->setAssociatedIface(groupInter);
- parentItem->getRefBlock()->addInterface(groupCtlInter);
-
- // connect both interface
- bool ok = true;
- if (refInter->getDirection() == AbstractInterface::Output) {
- ok = refInter->connectTo(groupInter);
- ok = ok & groupInter->connectFrom(refInter);
- }
- else if (refInter->getDirection() == AbstractInterface::Input) {
- ok = groupInter->connectTo(refInter);
- ok = ok & refInter->connectFrom(groupInter);
- }
- else if (refInter->getDirection() == AbstractInterface::InOut) {
- ok = refInter->connectTo(groupInter);
- ok = ok & groupInter->connectFrom(refInter);
- ok = ok & groupInter->connectTo(refInter);
- ok = ok & refInter->connectFrom(groupInter);
- }
- if (!ok) {
- cerr << "abnormal case while connecting a block iface to its parent group" << endl;
- }
+ parentItem->getRefBlock()->addInterface(groupCtlInter);
// creating/adding the group interface in the current scene model, and connection item
InterfaceItem *groupIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parentItem,params);
parentItem->addInterface(groupIfaceItem,true);
- parentItem->getScene()->createConnectionItem(item, groupIfaceItem);
+ // creating the connection, in graph and with an item
+ createConnection(item, groupIfaceItem);
// if groupItem is not topGroup, must also add a new interface to the parent BlockItem
BoxItem* parent2Item = parentItem->getParentItem();
void renameInterface(InterfaceItem* item);
// connection ops
- bool createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2);
+ bool createConnection(InterfaceItem *iface1, InterfaceItem *iface2);
void removeAllBlockConnections(AbstractBoxItem *item);
void removeConnection(ConnectionItem *conn);
int id = getInterfaceMultiplicity();\r
if (id < 0) return NULL;\r
FunctionalInterface *inter = new FunctionalInterface(owner, reference);\r
- inter->setWidth(width);\r
- inter->setDirection(direction);\r
- inter->setPurpose(purpose); \r
- inter->connectFrom(NULL);\r
+ inter->setWidth(width); \r
inter->setName(reference->getName()+"_"+QString::number(id+1));\r
return inter;\r
}\r
#include "FunctionalInterface.h"
#include "GroupBlock.h"
-GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,AbstractInterface::Inherited,"",_direction,_purpose) {
+GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"inherited","",_direction,_purpose) {
if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
connectedFrom = NULL;
AbstractInterface *GroupInterface::clone() {
GroupInterface *inter = new GroupInterface(owner,name,direction, purpose);
- inter->setWidth(width);
- inter->connectFrom(NULL);
-
+ inter->setWidth(width);
return inter;
}
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;
update(iface1->boundingRect());
InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
\r
if(iface1 != NULL && iface2 != NULL){\r
- dispatcher->createConnectionItem(iface1,iface2);\r
+ dispatcher->createConnection(iface1,iface2);\r
} else {\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
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;
update(iface1->boundingRect());
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-10T16:30:40. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-10T22:29:52. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
+ <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
- <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/sdomas/Projet/Blast/code/blast</value>
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/sdomas/Projet/Blast/code/blast</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
- <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">blast</value>
+ <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécuter blast</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>