]> AND Private Git Repository - blast.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
changed connection process
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 10 May 2017 20:30:19 +0000 (22:30 +0200)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 10 May 2017 20:30:19 +0000 (22:30 +0200)
12 files changed:
AbstractInterface.cpp
BoxItem.cpp
ConnectedInterface.cpp
ConnectedInterface.h
Dispatcher.cpp
Dispatcher.h
FunctionalInterface.cpp
GroupInterface.cpp
GroupItem.cpp
Parameters.cpp
SourceItem.cpp
blast.creator.user

index dde5930ab90aebae1d11a4f965bfeb97395c1b48..f57f78042e922ee1567f571f5384d5ff43f297cd 100644 (file)
@@ -172,6 +172,9 @@ int AbstractInterface::typeFromString(const QString &_type) {
   else if (_type == "natural") {
     ret = Natural;
   }
+  else if (_type == "inherited") {
+    ret = Inherited;
+  }
   return ret;
 }
 
index 190200339538cf01b94eb41af66d076e65261b30..43cceecfce17395145bb149f2d86fbe1b520b5bc 100644 (file)
@@ -394,7 +394,7 @@ void BoxItem::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;
         update(iface1->boundingRect());
index 69a484bf764016e681441871e66862caf6d8854d..c053aadb708f727f458c6199a7331ea1e3273258 100644 (file)
@@ -25,16 +25,32 @@ void ConnectedInterface::clearConnectedTo() {
   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
@@ -42,6 +58,7 @@ bool ConnectedInterface::connectFrom(ConnectedInterface *iface) {
   }\r
   return false;\r
 }\r
+*/\r
 \r
 /* getConnectionToParentGroup() :\r
    if an interface among connectedTo is an interface of the parent group\r
index fc89e22c31a811d5e41b137dc0db85e8b67621da..cfea68ce22eb03ea424a688d01f275ddc669370b 100644 (file)
@@ -37,8 +37,9 @@ public :
   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();
 
index e7846b4545b9f2f2febed7b4ca57fdb4b3bc5e50..238c7e5ddb1a2e5efb1bd788782632c807c88467 100644 (file)
@@ -81,12 +81,12 @@ void Dispatcher::closeCurrentProject() {
   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;
@@ -95,21 +95,25 @@ bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *ifac
   // 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)) {
@@ -905,8 +909,7 @@ void Dispatcher::removeConnection(ConnectionItem *conn) {
   // 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);
@@ -931,16 +934,8 @@ void Dispatcher::removeConnection(ConnectionItem *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
@@ -958,6 +953,10 @@ void Dispatcher::removeConnection(ConnectionItem *conn) {
 #endif
 
   if (groupIfaceItem != NULL) {
+    
+    bool groupInterRemove = false;
+    if ((groupIfaceItem->nter->isConnectedTo() == false) && (groupInter->isConnectedFrom() == false)) groupInterRemove = true;
+    
     ConnectedInterface* groupInter = groupIfaceItem->refInter;
     groupItem->removeInterface(groupIfaceItem);
 
@@ -1002,32 +1001,13 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){
   // 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();
index 0ddba40cfcd221d46594c81dd6785f9a9b97da16..95e0183d9e538ad0088ad83b68f4fb57e07d114d 100644 (file)
@@ -124,7 +124,7 @@ public slots:
   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);
 
index 7224b3fc7f923e5cd7fd4820d9a15d5635b1c450..495d60e9b7f31182ed924b7af34d5a4d56a66619 100644 (file)
@@ -76,10 +76,7 @@ AbstractInterface *FunctionalInterface::clone() {
   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
index 67577900b5bb85c22261ff96d2d779b430924b25..934ad08d693cc0805a4a8f0cb18706db4b28bb46 100644 (file)
@@ -2,7 +2,7 @@
 #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;
@@ -14,9 +14,7 @@ bool GroupInterface::isGroupInterface() {
 
 AbstractInterface *GroupInterface::clone() {
     GroupInterface *inter = new GroupInterface(owner,name,direction, purpose);
-    inter->setWidth(width);    
-    inter->connectFrom(NULL);
-
+    inter->setWidth(width);        
     return inter;
 }
 
index 90c5574f025c58578e1277154f3371b8143775dc..27f539cdf9ad11264cc07fb5d14f26834c7b40af 100644 (file)
@@ -448,7 +448,7 @@ void GroupItem::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;
         update(iface1->boundingRect());
index 12f5b2b0e44e73d5cdeae81562323be4db7550d6..848ef7fd09e16e28e9a2483c9c0a4208a18f847c 100644 (file)
@@ -367,7 +367,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     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
index 4f297616dd0397bc47dda4b56c7962740f2b2678..62f601ac790851b614dcfa67709f8732f9608ced 100644 (file)
@@ -389,7 +389,7 @@ 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;
         update(iface1->boundingRect());
index 887802402cf142deaec9070600f423ef0e0e40c9..5d3c6f49dc45f62fbce2d2dc3e4bc88c6c6f3474 100755 (executable)
@@ -1,10 +1,10 @@
 <?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>