return false;\r
}\r
\r
+bool AbstractBlock::isTopGroupBlock() { \r
+ return false;\r
+}\r
+\r
+bool AbstractBlock::isSourceBlock() {\r
+ return false;\r
+}\r
+\r
void AbstractBlock::addParameter(BlockParameter *param) {\r
params.append(param);\r
}\r
virtual bool isReferenceBlock();\r
virtual bool isFunctionalBlock();\r
virtual bool isGroupBlock();\r
+ virtual bool isSourceBlock();\r
+ virtual bool isTopGroupBlock();\r
bool isWBConfigurable();\r
\r
// others\r
ConnectionItem::ConnectionItem(InterfaceItem* _iface1,
InterfaceItem* _iface2,
Dispatcher* _dispatcher,
- Parameters* _params,
- QGraphicsItem *_parent) : QGraphicsItem(_parent) {
+ Parameters* _params) : QGraphicsItem() {
dispatcher = _dispatcher;
case 1 : ref1 is group interface, and ref2 block interface of a block within the group
case 2 : the opposite of case 1
case 3 : ref1 and ref2 are block interface of blocks that are both within the same parent group.
+ case 4 : ref1 is source interface and ref2 interface of top group
+ case 5 : the opposite of case 4
*/
if (ref1->getOwner() == ref2->getOwner()->getParent()) {
fromInterfaceItem = _iface1;
}
}
+ else if ((ref1->getOwner()->isSourceBlock()) && (ref2->getOwner()->isTopGroupBlock())) {
+ fromInterfaceItem = _iface1;
+ toInterfaceItem = _iface2;
+ }
+ else if ((ref2->getOwner()->isSourceBlock()) && (ref1->getOwner()->isTopGroupBlock())) {
+ fromInterfaceItem = _iface2;
+ toInterfaceItem = _iface1;
+ }
// adding this to interface items
fromInterfaceItem->addConnectionItem(this);
toInterfaceItem->addConnectionItem(this);
// signals to the scene that this connection is going to change of shape.
prepareGeometryChange();
- pointFrom = fromInterfaceItem->getEndPointInGroup();
- pointTo = toInterfaceItem->getEndPointInGroup();
+ bool withinGroup = false;
+ /* NB: four cases
+ 1: from group input iface to box input iface
+ 2: from output box iface to group output iface
+ 3: from output box iface to input box iface
+ 4: from source output iface to input group iface
+
+ For cases 1 & 2, the position of group iface is given by getStartPosition
+ For all other cases, the iface from and to position is given by getEndPosition
+ */
+ if ((fromInterfaceItem->getOwner()->isGroupItem()) && (toInterfaceItem->getOwner()->isBoxItem())) {
+ pointFrom = fromInterfaceItem->getStartPosition();
+ pointTo = toInterfaceItem->getEndPosition();
+ withinGroup = true;
+ }
+ else if ((toInterfaceItem->getOwner()->isGroupItem()) && (fromInterfaceItem->getOwner()->isBoxItem())) {
+ pointFrom = fromInterfaceItem->getEndPosition();
+ pointTo = toInterfaceItem->getStartPosition();
+ withinGroup = true;
+ }
+ else {
+ pointFrom = fromInterfaceItem->getEndPosition();
+ pointTo = toInterfaceItem->getEndPosition();
+ }
int oriFrom, oriTo;
oriFrom = fromInterfaceItem->getOrientation();
/* NB: if src or dest is onwed by a GroupItem the orientation
must be changed as it is a block.
*/
- if(fromInterfaceItem->owner->isGroupItem()){
- switch(fromInterfaceItem->getOrientation()){
- case Parameters::North :
- oriFrom = Parameters::South;
- break;
- case Parameters::South :
- oriFrom = Parameters::North;
- break;
- case Parameters::East :
- oriFrom = Parameters::West;
- break;
- case Parameters::West :
- oriFrom = Parameters::East;
- break;
- }
- }
- if(toInterfaceItem->owner->isGroupItem()){
- switch(toInterfaceItem->getOrientation()){
- case Parameters::North :
- oriTo = Parameters::South;
- break;
- case Parameters::South :
- oriTo = Parameters::North;
- break;
- case Parameters::East :
- oriTo = Parameters::West;
- break;
- case Parameters::West :
- oriTo = Parameters::East;
- break;
+ if (withinGroup) {
+ if(fromInterfaceItem->owner->isGroupItem()){
+ switch(fromInterfaceItem->getOrientation()){
+ case Parameters::North :
+ oriFrom = Parameters::South;
+ break;
+ case Parameters::South :
+ oriFrom = Parameters::North;
+ break;
+ case Parameters::East :
+ oriFrom = Parameters::West;
+ break;
+ case Parameters::West :
+ oriFrom = Parameters::East;
+ break;
+ }
+ }
+ else if(toInterfaceItem->owner->isGroupItem()){
+ switch(toInterfaceItem->getOrientation()){
+ case Parameters::North :
+ oriTo = Parameters::South;
+ break;
+ case Parameters::South :
+ oriTo = Parameters::North;
+ break;
+ case Parameters::East :
+ oriTo = Parameters::West;
+ break;
+ case Parameters::West :
+ oriTo = Parameters::East;
+ break;
+ }
}
}
double gap1 = 0.0;
ConnectionItem(InterfaceItem* _iface1,
InterfaceItem* _iface2,
Dispatcher* _dispatcher,
- Parameters* _params,
- QGraphicsItem* _parent);
+ Parameters* _params);
ConnectionItem (const ConnectionItem & copy);
ConnectionItem();
~ConnectionItem();
}
bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
-
+
ConnectedInterface* ref1 = iface1->refInter;
ConnectedInterface* ref2 = iface2->refInter;
// connect both interface
bool ok1 = false;
bool ok2 = false;
- if (ref1->canConnectTo(ref2)) {
- ok1 = ref1->connectTo(ref2);
- ok1 = ok1 & ref2->connectFrom(ref1);
- }
- if (ref2->canConnectTo(ref1)) {
- ok2 = ref2->connectTo(ref1);
- ok2 = ok2 & ref1->connectFrom(ref2);
+ // test the ref1->ref2 connection
+ if ((ref1->canConnectTo(ref2)) && (ref2->canConnectFrom(ref1))) {
+ ref1->connectTo(ref2);
+ ref2->connectFrom(ref1);
+ 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);
+ ok2 = true;
}
if ((ok1 == true) || (ok2 == true)) {
return true;\r
}\r
\r
+bool FunctionalBlock::isSourceBlock() {\r
+ if (parent == NULL) return true;\r
+ return false;\r
+}\r
+\r
void FunctionalBlock::populate() {\r
int i;\r
BlockParameter* p;\r
\r
// testers\r
bool isFunctionalBlock();\r
+ bool isSourceBlock(); //! a source block has no parent\r
\r
// others\r
\r
2 - iface is owned by the parent group of the block that owns this\r
2.1 - this is an output, iface is an output of the group\r
2.2 - both are inout\r
+ 3 - this is owned by a source block and iface is owned by the top group\r
\r
*/\r
if (direction == Input) return false;\r
if (iface->isReferenceInterface()) return false;\r
if (iface->getConnectedFrom() != NULL) return false;\r
-\r
+ // first case: interface of blocks within the same group\r
if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
\r
if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
}\r
+ // second case: iface = interface of the group that contains owner of this\r
else if (getOwner()->getParent() == iface->getOwner()) {\r
if ((direction == Output) && (iface->getDirection() == Output)) return true;\r
if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\r
}\r
+ else if ((getOwner()->isSourceBlock()) && (iface->getOwner()->isTopGroupBlock())) {\r
+ if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
+ }\r
\r
return false;\r
\r
return true;
}
+bool GroupBlock::isTopGroupBlock() {
+ return topGroup;
+}
+
void GroupBlock::setParent(AbstractBlock *_parent) {
parent = _parent;
if (parent != NULL) {
// testers
bool isGroupBlock();
+ bool isTopGroupBlock();
inline bool isTop() { return topGroup; }
// others
3 - this is owned by a group and iface by its parent group
2.1 - this is an output, iface is an output of the group
2.2 - both are inout
+
*/
if ((direction == Output) && (iface->getDirection() == Output)) return true;
if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
}
+
return false;
}
3 - this is owned by a group and iface by its parent group
2.1 - this is an input, iface is an input of the group
2.2 - both are inout
+ 4 - this is owned by top group and iface is an output of a source block
*/
if (iface->isReferenceInterface()) return false;
if (getConnectedFrom() != NULL) return false;
if ((direction == Input) && (iface->getDirection() == Input)) return true;
if ((direction == InOut) && (iface->getDirection() == InOut)) return true;
}
+ else if ((getOwner()->isTopGroupBlock()) && (iface->getOwner()->isSourceBlock())) {
+ if ((direction == Input) && (iface->getDirection() == Output)) return true;
+ }
return false;
}
dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget());
- /* NOTE : commneted because group interface are normally
- created and the connected directly to a block within
- the group. Furthermore, there can be a single connection
- from a groupe interface.
-
- if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
+ if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) {
InterfaceItem *inter = getInterfaceFromCursor(x,y);
if (inter != NULL) {
}
}
}
- }
- */
- if (mode == GroupScene::ItemEdition) {
+ }
+ else if (mode == GroupScene::ItemEdition) {
if (params->cursorState == Parameters::CursorOnInterface) {
InterfaceItem *inter = getInterfaceFromCursor(x,y);
int mode = getScene()->getEditionMode();
- /* NOTE : commneted because group interface are normally
- created and the connected directly to a block within
- the group. Furthermore, there can be a single connection
- from a groupe interface.
-
- if (mode == GroupScene::AddConnection) {
+ if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection)) {
if (params->editState == Parameters::EditStartConnection) {
params->setEditState(Parameters::EditStartConnection);
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;
update(iface1->boundingRect());
params->setEditState(Parameters::EditNoOperation);
}
}
- }
- */
- if (mode == GroupScene::ItemEdition) {
+ }
+ else if (mode == GroupScene::ItemEdition) {
currentInterface = NULL;
setFlag(ItemIsMovable, true);
params->editState = Parameters::EditNoOperation;
sourceItems.removeAll(item);
}
-void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2, bool withinGroup) {
+void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
ConnectionItem* conn = NULL;
- if (withinGroup) {
- conn = new ConnectionItem(iface1,iface2, dispatcher, params, groupItem);
- }
- else {
- conn = new ConnectionItem(iface1,iface2, dispatcher, params, NULL);
- addItem(conn);
- }
+
+ conn = new ConnectionItem(iface1,iface2, dispatcher, params);
+ addItem(conn);
addConnectionItem(conn);
}
void removeBoxItem(BoxItem* item);
// ConnectionItem related
- void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2, bool withinGroup = true);
+ void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
ConnectionItem* searchConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2);
void addConnectionItem(ConnectionItem* item);
void removeConnectionItem(ConnectionItem* item);
int _orientation,
ConnectedInterface *_refInter,
AbstractBoxItem* _owner,
- Parameters* _params){
+ Parameters* _params) {
positionRatio = _position;
orientation = _orientation;
refInter = _refInter;
}
// draw names
+ if(selected) {
+ painter->setPen(QPen(Qt::red,2));
+ }
+ else {
+ painter->setPen(QPen(Qt::black,1));
+ }
// reset to normal if at west
if(orientation == Parameters::West){
}
}
-QPointF InterfaceItem::getEndPointInGroup() {
- QPointF p;
+QPointF InterfaceItem::getStartPosition() {
+ QPointF p = originPoint;
+ QPointF ownerPos = owner->scenePos();
+ p += ownerPos;
+ return p;
+}
- if (owner->isGroupItem()) {
- p = originPoint;
- }
- else {
- double x = owner->x() + originPoint.x();
- double y = owner->y() + originPoint.y();
- switch(orientation){
- case Parameters::East:
- x += params->arrowWidth+params->arrowLineLength;
- break;
- case Parameters::North:
- y -= params->arrowWidth+params->arrowLineLength;
- break;
- case Parameters::West:
- x -= params->arrowWidth+params->arrowLineLength;
- break;
- case Parameters::South:
- y += params->arrowWidth+params->arrowLineLength;
- break;
- }
- p = QPointF(x,y);
+QPointF InterfaceItem::getEndPosition() {
+ QPointF p = getStartPosition();
+
+ switch(orientation){
+ case Parameters::East:
+ p.setX(p.x()+params->arrowWidth+params->arrowLineLength);
+ break;
+ case Parameters::North:
+ p.setY(p.y() - params->arrowWidth-params->arrowLineLength);
+ break;
+ case Parameters::West:
+ p.setX(p.x() - params->arrowWidth-params->arrowLineLength);
+ break;
+ case Parameters::South:
+ p.setY(p.y() + params->arrowWidth+params->arrowLineLength);
+ break;
}
-
- //cout << "iface end point in group item: " << p.x() << "," << p.y() << endl;
return p;
}
inline int getNameWidth() { return nameWidth; }
inline int getNameHeight() { return nameHeight; }
QString getStrOrientation();
- static int getIntOrientation(QString str);
- QPointF getEndPointInGroup();
+ static int getIntOrientation(QString str);
+ QPointF getEndPosition();
+ QPointF getStartPosition();
// setters
void setOriginPoint();
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-09T19:54:54. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-09T22:33:21. -->
<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">