return false;\r
}\r
\r
+bool AbstractBlock::isGeneratorBlock() {\r
+ foreach(AbstractInterface* iface, inputs) {\r
+ if (iface->getPurpose() == AbstractInterface::Data) return false;\r
+ }\r
+ return true;\r
+}\r
+\r
void AbstractBlock::addParameter(BlockParameter *param) {\r
params.append(param);\r
}\r
return list;\r
}\r
\r
+QList<AbstractInterface *> AbstractBlock::getControlInputs() {\r
+ QList<AbstractInterface *> list;\r
+ foreach(AbstractInterface* iface, inputs) {\r
+ if (iface->getPurpose() == AbstractInterface::Control) {\r
+ list.append(iface);\r
+ }\r
+ }\r
+ return list;\r
+}\r
+\r
+QList<AbstractInterface *> AbstractBlock::getControlOutputs() {\r
+ QList<AbstractInterface *> list;\r
+ foreach(AbstractInterface* iface, outputs) {\r
+ if (iface->getPurpose() == AbstractInterface::Control) {\r
+ list.append(iface);\r
+ }\r
+ }\r
+ return list;\r
+}\r
+\r
AbstractInterface* AbstractBlock::getIfaceFromName(QString name) {\r
\r
foreach(AbstractInterface* iface, inputs) {\r
class AbstractBlock {\r
\r
public: \r
-\r
+ \r
AbstractBlock();\r
AbstractBlock(const QString& _name);\r
virtual ~AbstractBlock();\r
QList<BlockParameter *> getPortParameters();\r
QList<BlockParameter *> getWishboneParameters();\r
inline AbstractBlock* getParent() { return parent; }\r
+ inline QList<int> getProductionCounter() { return productionCounter; }\r
+ inline int getDelta() { return delta; }\r
+ \r
// setters\r
void setName(const QString& str);\r
virtual void setParent(AbstractBlock* _parent);\r
+ inline void setProductionCounter(QList<int> pattern) { productionCounter = pattern; }\r
+ inline void setDelta(int _delta) { delta = _delta; }\r
\r
// testers\r
virtual bool isReferenceBlock();\r
virtual bool isFunctionalBlock();\r
virtual bool isGroupBlock();\r
- virtual bool isSourceBlock();\r
+ virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)\r
virtual bool isTopGroupBlock();\r
+ bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely\r
bool isWBConfigurable();\r
\r
// others\r
\r
QList<AbstractInterface *> getInterfaces(); //! return all interfaces\r
QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data\r
+ QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control\r
+ QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control\r
AbstractInterface* getIfaceFromName(QString name);\r
BlockParameter* getParameterFromName(QString name);\r
\r
+ // patterns\r
+ virtual void computeOutputPattern(int nbExec = -1) = 0;\r
+ \r
protected:\r
\r
\r
QList<AbstractInterface*> inputs;\r
QList<AbstractInterface*> outputs;\r
QList<AbstractInterface*> bidirs;\r
-\r
+ \r
// others\r
-\r
- // NB: only GroupBlock and FunctionalBlock have a real parent\r
+ \r
+ // patterns\r
+ QList<int> productionCounter; //! only usefull for output interfaces\r
+ int delta;\r
+ \r
+ // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents\r
AbstractBlock* parent;\r
};\r
\r
ifaceItem->visible = b;
}
}
- resetInterfacesPosition();
+ resetInterfaceItemsPosition();
updateGeometry(InterfaceMove);
update();
getScene()->updateConnectionItemsShape();
ifaceItem->visible = b;
}
}
- resetInterfacesPosition();
+ resetInterfaceItemsPosition();
updateGeometry(InterfaceMove);
update();
getScene()->updateConnectionItemsShape();
nameHeight = fmId.height();
}
-void AbstractBoxItem::initInterfaces() {
+void AbstractBoxItem::initInterfaceItems() {
/* TO DO : creating all needed InterfaceItem, with by default, input at west and output at east */
int orientation = Parameters::West;
}
}
-InterfaceItem* AbstractBoxItem::searchInterfaceByName(QString name) {
+InterfaceItem* AbstractBoxItem::searchInterfaceItemByName(QString name) {
foreach(InterfaceItem *inter, interfaces){
if(inter->getName() == name)
return inter;
return NULL;
}
-InterfaceItem* AbstractBoxItem::searchInterfaceByRef(ConnectedInterface *ref) {
+InterfaceItem* AbstractBoxItem::searchInterfaceItemByRef(ConnectedInterface *ref) {
foreach(InterfaceItem *inter, interfaces){
if(inter->refInter == ref) {
return inter;
return NULL;
}
-void AbstractBoxItem::addInterface(InterfaceItem *i, bool resetPosition) {
+void AbstractBoxItem::addInterfaceItem(InterfaceItem *i, bool resetPosition) {
interfaces.append(i);
- if (resetPosition) resetInterfacesPosition();
+ if (resetPosition) resetInterfaceItemsPosition();
updateGeometry(InterfaceMove);
update();
}
-void AbstractBoxItem::removeInterface(InterfaceItem *i) {
+void AbstractBoxItem::removeInterfaceItem(InterfaceItem *i) {
// NB : removing from model is done in dispatcher
- interfaces.removeOne(i);
+ interfaces.removeAll(i);
delete i;
//resetInterfacesPosition();
}
-void AbstractBoxItem::resetInterfacesPosition() {
+void AbstractBoxItem::resetInterfaceItemsPosition() {
int nbNorth=0, nbSouth=0, nbEast=0, nbWest=0;
double cntNorth=1.0,cntSouth=1.0,cntEast=1.0,cntWest=1.0;
}
}
-void AbstractBoxItem::moveInterfaceTo(QPointF pos) {
+void AbstractBoxItem::moveInterfaceItemTo(QPointF pos) {
double positionRatio;
if(currentInterface->getOrientation() == Parameters::North || currentInterface->getOrientation() == Parameters::South){
if(pos.x() < 0){
return nb;
}
-void AbstractBoxItem::updateInterfacesAndConnections() {
+void AbstractBoxItem::updateInterfaceAndConnectionItems() {
// update all interfaces positions
foreach(InterfaceItem *item, interfaces){
boxHeight = y;
}
-InterfaceItem* AbstractBoxItem::getInterfaceFromCursor(qreal x, qreal y) {
+InterfaceItem* AbstractBoxItem::getInterfaceItemFromCursor(qreal x, qreal y) {
foreach(InterfaceItem* inter, interfaces) {
if(x > inter->boundingRect().x() && x < (inter->boundingRect().x() + inter->boundingRect().width())){
class GroupScene;
class ConnectedInterface;
+#define ABI_TO_BI(ptr) ((BoxItem*)ptr)
+#define ABI_TO_GI(ptr) ((GroupItem*)ptr)
+#define ABI_TO_SI(ptr) ((SourceItem*)ptr)
+
class AbstractBoxItem : public QGraphicsItem {
public:
// others
QRectF boundingRectInScene();
virtual void nameChanged() = 0; // called when an interface or box name have changed
- void addInterface(InterfaceItem* i, bool resetPosition = false);
- void removeInterface(InterfaceItem* i);
- void resetInterfacesPosition();
+ void addInterfaceItem(InterfaceItem* i, bool resetPosition = false);
+ void removeInterfaceItem(InterfaceItem* i);
+ void resetInterfaceItemsPosition();
/*!
* \brief moveInterfaceTo
* \param pos the new position (in scene) of the interface
* This method is called when user moves an InterfaceItem.
* see BoxItem::mouseMoveEvent() and GroupItem::mouseMoveEvent()
*/
- void moveInterfaceTo(QPointF pos);
+ void moveInterfaceItemTo(QPointF pos);
/*!
* \brief updateInterfacesAndConnections
*
* that is called in this method. Thus, there is no need to call update() after the termination of
* this method.
*/
- void updateInterfacesAndConnections();
+ void updateInterfaceAndConnectionItems();
- InterfaceItem *searchInterfaceByName(QString name);
- InterfaceItem *searchInterfaceByRef(ConnectedInterface* ref);
- InterfaceItem* getInterfaceFromCursor(qreal x, qreal y);
+ InterfaceItem *searchInterfaceItemByName(QString name);
+ InterfaceItem *searchInterfaceItemByRef(ConnectedInterface* ref);
+ InterfaceItem* getInterfaceItemFromCursor(qreal x, qreal y);
protected:
Dispatcher *dispatcher;
virtual QRectF boundingRect() const =0;
*/
- void initInterfaces();
+ void initInterfaceItems();
int nbInterfacesByOrientation(int orientation);
};
inline AbstractInterface* getAssociatedIface() { return associatedIface; }
double getDoubleWidth() throw(QException);
+
+ inline QList<char> getConsumptionPattern() { return consumptionPattern; }
+ inline QList<char> getProductionPattern() { return productionPattern; }
+ inline QList<char> getOutputPattern() { return outputPattern; }
//virtual QList<AbstractInterface*> getConnectedTo() = 0;
void setPurpose(int _purpose);
void setDirection(int _direction);
bool setAssociatedIface(AbstractInterface* iface);
+
+ inline void setConsumptionPattern(QList<char> pattern) { consumptionPattern = pattern; }
+ inline void setProductionPattern(QList<char> pattern) { productionPattern = pattern; }
+ inline void setOutputPattern(QList<char> pattern) { outputPattern = pattern; }
// testers
virtual bool isReferenceInterface();
* (NB: a test is done in the method to prevent the other case).
*/
AbstractInterface* associatedIface;
+
+ // patterns
+ QList<char> consumptionPattern; //! only usefull for input interfaces
+ QList<char> productionPattern; //! only usefull for output interfaces
+
+ QList<char> outputPattern; //! only usefull for output interfaces
};
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();
}
}
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);
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);
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);
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* showWishboneIface = NULL;
QAction* showParameters = 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;
}
}
else if (selectedAction == connectToGroup){
dispatcher->connectInterToGroup(ifaceItem);
}
- else if (selectedAction == disconnectFromGroup) {
- dispatcher->disconnectInterFromGroup(ifaceItem);
- }
else if (selectedAction == cloneInterface){
dispatcher->duplicateInterfaceItem(ifaceItem);
}
}
// 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);
setAcceptHoverEvents(true);
setFlag(ItemSendsGeometryChanges);
setCursor(Qt::PointingHandCursor);
- setZValue(0);
+ setZValue(200);
if (fromInterfaceItem->refInter->getPurpose() == AbstractInterface::Data) {
visible = true;
}
}
- pps.setWidth(5);
- pathShape = pps.createStroke(pathPaint);
+ //pps.setWidth(5);
+ //pathShape = pps.createStroke(pathPaint);
}
//cout << "drawing an esse" << endl;
pathPaint = QPainterPath(pointFrom);
+ QPainterPath s;
interPoints.clear();
- double gap = marginConn;
+ double gap = marginConn;
+
if ((orientationFrom == Parameters::North)||(orientationFrom == Parameters::West)) gap = -gap;
QPointF p(0.0,0.0);
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+
// must draw a complete esse
- p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ s.moveTo(p);
pathPaint.lineTo(p);
interPoints.append(p);
p = QPointF(pointFrom.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x()-gap,(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x()-gap,pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
// must draw a complete esse
- p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap);
pathPaint.lineTo(p);
+ s.moveTo(p);
interPoints.append(p);
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()-gap);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x(), pointTo.y()-gap);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
void ConnectionItem::computeStaircase(int orientationFrom) {
pathPaint = QPainterPath(pointFrom);
- interPoints.clear();
+ QPainterPath s;
+ double gap = marginConn;
+ interPoints.clear();
QPointF p(0.0,0.0);
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+
+ if (orientationFrom == Parameters::West) gap = -gap;
+ p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ s.moveTo(p);
+
if (pointFrom.y() == pointTo.y()) {
//cout << "drawing straight line" << endl;
pathPaint.lineTo(pointTo);
+
}
else {
//cout << "drawing a staircase" << endl;
// sufficient place to draw a simple staircase
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
+ p = QPointF(pointTo.x()-gap,pointTo.y());
+ s.lineTo(p);
}
else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
+
+ if (orientationFrom == Parameters::North) gap = -gap;
+
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+ s.moveTo(p);
+
if (pointFrom.x() == pointTo.x()) {
//cout << "drawing straight line" << endl;
- pathPaint.lineTo(pointTo);
+ pathPaint.lineTo(pointTo);
}
else {
//cout << "drawing a staircase" << endl;
// sufficient place to draw a simple staircase
p = QPointF(pointFrom.x(),(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x(),(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
+ p = QPointF(pointTo.x(),pointTo.y()-gap);
+ s.lineTo(p);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
/* drawCorner():
pathPaint = QPainterPath(pointFrom);
interPoints.clear();
QPointF p(0.0,0.0);
+ QPainterPath s;
+ double gap = marginConn;
+
//cout << "drawing a corner" << endl;
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+ if (orientationFrom == Parameters::West) gap = -gap;
+ p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ s.moveTo(p);
p = QPointF(pointTo.x(),pointFrom.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x(),pointTo.y()-gap);
+ s.lineTo(p);
}
else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
+ if (orientationFrom == Parameters::North) gap = -gap;
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+ s.moveTo(p);
p = QPointF(pointFrom.x(),pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x()-gap,pointTo.y());
+ s.lineTo(p);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
/* drawOpenRect():
__
|
|_|
+
+ Its beginning and end have always a size of marginConn
*/
void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
pathPaint = QPainterPath(pointFrom);
QPointF p(0.0,0.0);
double gap1 = marginConn;
double gap2 = marginConn;
+ QPainterPath s;
//cout << "drawing an OpenRect" << endl;
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
}
p = QPointF(pointFrom.x()+gap1,pointFrom.y());
pathPaint.lineTo(p);
+ s.moveTo(p);
interPoints.append(p);
p = QPointF(pointFrom.x()+gap1,pointTo.y()+gap2);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x(),pointTo.y()+gap2);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
pathPaint.lineTo(p);
+ s.moveTo(p);
interPoints.append(p);
p = QPointF(pointTo.x()+gap2,pointFrom.y()+gap1);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x()+gap2,pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
+
/* drawHookSmallEnd():
A Hook has the following shape :
void ConnectionItem::computeHookSmallEnd(int orientationFrom, int orientationTo) {
pathPaint = QPainterPath(pointFrom);
interPoints.clear();
- QPointF p(0.0,0.0);
- double gap = marginConn;
+ QPointF p(0.0,0.0);
+ QPainterPath s;
+ double gap2 = marginConn;
+ double gap1 = marginConn;
//cout << "drawing a Hook with small end" << endl;
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
- if (orientationTo == Parameters::North) gap = -gap;
+ if (orientationFrom == Parameters::West) gap1 = -gap1;
+ if (orientationTo == Parameters::North) gap2 = -gap2;
+ p = QPointF(pointFrom.x()+gap1,pointFrom.y());
+ s.moveTo(p);
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
- p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()+gap);
+ p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()+gap2);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
- p = QPointF(pointTo.x(),pointTo.y()+gap);
+ p = QPointF(pointTo.x(),pointTo.y()+gap2);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
- if (orientationTo == Parameters::West) gap = -gap;
-
+ if (orientationFrom == Parameters::North) gap1 = -gap1;
+ if (orientationTo == Parameters::West) gap2 = -gap2;
+
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
+ s.moveTo(p);
p = QPointF(pointFrom.x(),(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
- p = QPointF(pointTo.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
+ p = QPointF(pointTo.x()+gap2,(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
- p = QPointF(pointTo.x()+gap,pointTo.y());
+ p = QPointF(pointTo.x()+gap2,pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
/* drawHookSmallStart():
pathPaint = QPainterPath(pointFrom);
interPoints.clear();
QPointF p(0.0,0.0);
- double gap = marginConn;
+ QPainterPath s;
+ double gap1 = marginConn;
+ double gap2 = marginConn;
//cout << "drawing a Hook with small start" << endl;
if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
- if (orientationFrom == Parameters::West) gap = -gap;
+ if (orientationFrom == Parameters::West) gap1 = -gap1;
+ if (orientationTo == Parameters::North) gap2 = -gap2;
- p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ p = QPointF(pointFrom.x()+gap1,pointFrom.y());
+ s.moveTo(p);
pathPaint.lineTo(p);
interPoints.append(p);
- p = QPointF(pointFrom.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
+ p = QPointF(pointFrom.x()+gap1,(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF(pointTo.x(),(pointFrom.y()+pointTo.y())/2.0);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x(),pointFrom.y()+gap2);
+ s.lineTo(p);
}
else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
- if (orientationFrom == Parameters::North) gap = -gap;
+ if (orientationFrom == Parameters::North) gap1 = -gap1;
+ if (orientationTo == Parameters::West) gap2 = -gap2;
- p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
+ s.moveTo(p);
pathPaint.lineTo(p);
interPoints.append(p);
- p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap);
+ p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap1);
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y());
pathPaint.lineTo(p);
+ s.lineTo(p);
interPoints.append(p);
pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x()+gap2,pointFrom.y());
+ s.lineTo(p);
}
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
/* drawElle():
pathPaint = QPainterPath(pointFrom);
interPoints.clear();
QPointF p(0.0,0.0);
+ QPainterPath s;
+ double gap = marginConn;
+
double x;
double y;
- switch(orientationFrom){
- case Parameters::North :
- if(pointFrom.y() < pointTo.y()) {
- y = pointFrom.y()-marginConn;
- }
- else {
- y = pointTo.y()-marginConn;
- }
- p = QPointF(pointFrom.x(),y);
- pathPaint.lineTo(p);
- interPoints.append(p);
- p = QPointF(pointTo.x(),y);
- pathPaint.lineTo(p);
- interPoints.append(p);
- pathPaint.lineTo(pointTo);
- break;
- case Parameters::South :
- if(pointFrom.y() > pointTo.y()) {
- y = pointFrom.y()+marginConn;
- }
- else {
- y = pointTo.y()+marginConn;
+ if ((orientationFrom == Parameters::North) || (orientationFrom == Parameters::South)) {
+ double diffPos = pointFrom.y() - pointTo.y();
+ if (orientationFrom == Parameters::North) {
+ gap = -gap;
+ diffPos = -diffPos;
}
- p = QPointF(pointFrom.x(),y);
- pathPaint.lineTo(p);
- interPoints.append(p);
- p = QPointF(pointTo.x(),y);
- pathPaint.lineTo(p);
- interPoints.append(p);
- pathPaint.lineTo(pointTo);
- break;
- case Parameters::West :
- if(pointFrom.x() < pointTo.x()) {
- x = pointFrom.x()-marginConn;
+ p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+ s.moveTo(p);
+ if (diffPos >= 0.0) {
+ pathPaint.lineTo(p);
+ interPoints.append(p);
+ p = QPointF(pointTo.x(),pointFrom.y()+gap);
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x(),pointTo.y()+gap);
+ s.lineTo(p);
}
else {
- x = pointTo.x()-marginConn;
+ p = QPointF(pointFrom.x(),pointTo.y()+gap);
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ p = QPointF(pointTo.x(),pointTo.y()+gap);
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ pathPaint.lineTo(pointTo);
+ }
+ }
+ else if ((orientationFrom == Parameters::West) || (orientationFrom == Parameters::East)) {
+ double diffPos = pointFrom.x() - pointTo.x();
+ if (orientationFrom == Parameters::West) {
+ gap = -gap;
+ diffPos = -diffPos;
}
- p = QPointF(x, pointFrom.y());
- pathPaint.lineTo(p);
- interPoints.append(p);
- p = QPointF(x, pointTo.y());
- pathPaint.lineTo(p);
- interPoints.append(p);
- pathPaint.lineTo(pointTo);
- break;
- case Parameters::East :
- if(pointFrom.x() > pointTo.x()) {
- x = pointFrom.x()+marginConn;
+ p = QPointF(pointFrom.x()+gap,pointFrom.y());
+ s.moveTo(p);
+ if (diffPos >= 0.0) {
+ pathPaint.lineTo(p);
+ interPoints.append(p);
+ p = QPointF(pointTo.x()+gap,pointFrom.y());
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ pathPaint.lineTo(pointTo);
+ p = QPointF(pointTo.x()+gap,pointTo.y());
+ s.lineTo(p);
}
else {
- x = pointTo.x()+marginConn;
+ p = QPointF(pointFrom.x()+gap,pointTo.y());
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ p = QPointF(pointTo.x()+gap,pointTo.y());
+ pathPaint.lineTo(p);
+ s.lineTo(p);
+ interPoints.append(p);
+ pathPaint.lineTo(pointTo);
}
- p = QPointF(x, pointFrom.y());
- pathPaint.lineTo(p);
- interPoints.append(p);
- p = QPointF(x, pointTo.y());
- pathPaint.lineTo(p);
- interPoints.append(p);
- pathPaint.lineTo(pointTo);
- break;
}
+
+ pps.setWidth(5);
+ pathShape = pps.createStroke(s);
}
void ConnectionItem::setSelected(bool selected) {
this->selected = selected;
if(selected){
- setZValue(50);
+ setZValue(201);
} else {
- setZValue(0);
+ setZValue(200);
}
}
refB->addInterface(cloneIface);
InterfaceItem *cloneIfaceItem = new InterfaceItem(item->getPosition(),item->getOrientation(),(ConnectedInterface*)cloneIface,item->getOwner(),params);
- item->getOwner()->addInterface(cloneIfaceItem,true);
+ item->getOwner()->addInterfaceItem(cloneIfaceItem,true);
// creating control interface if needed
if (refI->getAssociatedIface() != NULL) {
GroupScene *scene = getSceneById(idScene);
ReferenceBlock* ref = params->getReferenceBlock(idCategory,idBlock);
// if block has no inputs, propose to add it as a source to top scene
- if ((scene->isTopScene()) && (ref->getDataInputs().isEmpty())) {
+ if ((scene->isTopScene()) && (ref->isGeneratorBlock())) {
int ret = QMessageBox::question(NULL,"Adding a block to top scene","Selected block may be used as a source for the top scene. Do you want to add it as a source ?");
if (ret == QMessageBox::Yes) {
newSource = true;
}
-void Dispatcher::removeConnection(ConnectionItem *conn) {
+void Dispatcher::removeConnection(ConnectionItem *connItem) {
static QString fctName = "Dispatcher::removeConnection()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
- InterfaceItem* fromIfaceItem = conn->getFromInterfaceItem();
- InterfaceItem* toIfaceItem = conn->getToInterfaceItem();
+ InterfaceItem* fromIfaceItem = connItem->getFromInterfaceItem();
+ InterfaceItem* toIfaceItem = connItem->getToInterfaceItem();
#ifdef DEBUG
cout << "remove connection from " << qPrintable(fromIfaceItem->refInter->getName()) << " to " << qPrintable(toIfaceItem->refInter->getName()) << endl;
#endif
- InterfaceItem* groupIfaceItem = NULL; // in case of one of the two interface belongs to the GroupItem
- GroupItem* groupItem = NULL;
+ InterfaceItem* groupIfaceItem = NULL; // in case of one of the two interface belongs to the GroupItem, and stays NULL if not
+ GroupItem* groupItem = NULL; // the GroupItem of the scene that contains connItem
ConnectedInterface *fromInter = fromIfaceItem->refInter;
- ConnectedInterface *toInter = toIfaceItem->refInter;
- // process the special case source->group apart
- if (fromIfaceItem->getOwner()->isSourceItem()) {
- // remove from graph
- fromInter->disconnectTo(toInter);
- // remove from scene
- fromIfaceItem->removeConnectionItem(conn);
- toIfaceItem->removeConnectionItem(conn);
- groupItem->getScene()->removeConnectionItem(conn);
- return;
- }
-
+ ConnectedInterface *toInter = toIfaceItem->refInter;
+ // test if one of the interface bounded to item is owned by a GroupItem
if (fromIfaceItem->getOwner()->isGroupItem()) {
- groupIfaceItem = fromIfaceItem;
- groupItem = toIfaceItem->getOwner()->getScene()->getGroupItem();
+ groupItem = ABI_TO_GI(fromIfaceItem->getOwner());
+ groupIfaceItem = fromIfaceItem;
}
else if (toIfaceItem->getOwner()->isGroupItem()) {
- groupIfaceItem = toIfaceItem;
- groupItem = fromIfaceItem->getOwner()->getScene()->getGroupItem();
+ groupItem = ABI_TO_GI(toIfaceItem->getOwner());
+ groupIfaceItem = toIfaceItem;
}
else {
groupItem = fromIfaceItem->getOwner()->getScene()->getGroupItem();
// removing the connection from scene
#ifdef DEBUG
cout << "removing connections from scene ..." ;
-#endif
- fromIfaceItem->removeConnectionItem(conn);
- toIfaceItem->removeConnectionItem(conn);
- groupItem->getScene()->removeConnectionItem(conn);
+#endif
+ groupItem->getScene()->removeConnectionItem(connItem);
#ifdef DEBUG
cout << "done." << endl ;
#endif
-
+
+ // if one of the interface bounded to connItem is owned by the GroupItem of the scene
if (groupIfaceItem != NULL) {
+ // determine if the interface must be removed since it has no more connections.
bool groupInterRemove = false;
- if ((groupIfaceItem->nter->isConnectedTo() == false) && (groupInter->isConnectedFrom() == false)) groupInterRemove = true;
+ if ((groupIfaceItem->refInter->isConnectedTo() == false) && (groupIfaceItem->refInter->isConnectedFrom() == false)) groupInterRemove = true;
- ConnectedInterface* groupInter = groupIfaceItem->refInter;
- groupItem->removeInterface(groupIfaceItem);
-
- BoxItem* parent2Item = groupItem->getParentItem();
- if (parent2Item != NULL) {
- InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter);
- parent2Item->removeInterface(group2IfaceItem);
+ if (groupInterRemove) {
+ // get the GroupInterface from interface item
+ ConnectedInterface* groupInter = groupIfaceItem->refInter;
+ // remove interface from GroupItem, and delete it.
+ groupItem->removeInterfaceItem(groupIfaceItem);
+ // get the parent BoxItem of GroupItem if it exists.
+ BoxItem* parent2Item = groupItem->getParentItem();
+ if (parent2Item != NULL) {
+ InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceItemByRef(groupInter);
+ // remove interface intem in parent BoxItem
+ parent2Item->removeInterfaceItem(group2IfaceItem);
+ }
+ // remove GroupInterface in the graph.
+ groupInter->getOwner()->removeInterface(groupInter);
}
- groupInter->getOwner()->removeInterface(groupInter);
}
}
mainWindow->getLibrary()->raise();
}
-void Dispatcher::showProperties(InterfaceItem *inter)
-{
+void Dispatcher::showProperties(InterfaceItem *inter) {
new InterfacePropertiesWindow(inter);
}
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->addInterfaceItem(groupIfaceItem,true);
// creating the connection, in graph and with an item
createConnection(item, groupIfaceItem);
BoxItem* parent2Item = parentItem->getParentItem();
if(parent2Item != NULL){
InterfaceItem *blockIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parent2Item,params);
- parent2Item->addInterface(blockIfaceItem,true);
+ parent2Item->addInterfaceItem(blockIfaceItem,true);
}
parentItem->getScene()->updateConnectionItemsShape();
unselectAllItems();
params->unsaveModif = true;
-
-
}
-void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) {
- static QString fctName = "Dispatcher::disconnectInterFromGroup()";
-#ifdef DEBUG_FCTNAME
- cout << "call to " << qPrintable(fctName) << endl;
-#endif
-
- // getting the GroupBlock and GroupItem that are parent of the block that owns item
- ConnectedInterface *refInter = item->refInter;
- ConnectedInterface *groupInter = NULL;
- GroupBlock* parentGroup = AB_TO_GRP(refInter->getOwner()->getParent());
- GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
-
- // removing the connection from graph
-#ifdef DEBUG
- cout << "removing connections from graph ..." ;
-#endif
-
- if (refInter->getDirection() == AbstractInterface::Output) {
- groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
- refInter->removeConnectedTo(groupInter);
- groupInter->clearConnectedFrom();
- }
- else if (refInter->getDirection() == AbstractInterface::Input) {
- groupInter = refInter->getConnectedFrom();
- refInter->clearConnectedFrom();
- groupInter->removeConnectedTo(refInter);
- }
- else if (refInter->getDirection() == AbstractInterface::InOut) {
- groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
- refInter->clearConnectedTo();
- refInter->clearConnectedFrom();
- groupInter->clearConnectedTo();
- groupInter->clearConnectedFrom();
- }
-#ifdef DEBUG
- cout << "done." << endl ;
-#endif
-
- if (groupInter == NULL) {
- cerr << "abnormal case 1 while removing an interface item of a block, linked to a parent group" << endl;
- }
-
-#ifdef DEBUG
- cout << "getting group interface item, and connection item ..." ;
-#endif
-
-
- InterfaceItem* groupIfaceItem = parentItem->searchInterfaceByRef(groupInter);
- if (groupIfaceItem == NULL) {
- cerr << "abnormal case 2 while removing an interface item of a block, linked to a parent group" << endl;
- }
- ConnectionItem* conn = parentItem->getScene()->searchConnectionItem(item,groupIfaceItem);
- if (conn == NULL) {
- cerr << "abnormal case 3 while removing an interface item of a block, linked to a parent group" << endl;
- }
-#ifdef DEBUG
- cout << "done." << endl ;
-#endif
-
- // removing the interface group item from the group item, and the connection item
-#ifdef DEBUG
- cout << "removing group interface item, and connection item ..." ;
-#endif
-
- bool groupInterRemove = false;
- if ((groupInter->isConnectedTo() == false) && (groupInter->isConnectedFrom() == false)) groupInterRemove = true;
-
- item->removeConnectionItem(conn);
- groupIfaceItem->removeConnectionItem(conn);
- if (groupInterRemove) {
- parentItem->removeInterface(groupIfaceItem); // CAUTION : this deletes the interface item.
- }
- parentItem->getScene()->removeConnectionItem(conn);
-#ifdef DEBUG
- cout << "done." << endl ;
-#endif
-
- if (groupInterRemove) {
- // removing the interface box item in the parent scene
-#ifdef DEBUG
- cout << "removing the inteeface item of box item in parent scene if needed ..." ;
-#endif
-
- BoxItem* parent2Item = parentItem->getParentItem();
- if (parent2Item != NULL) {
- InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter);
- parent2Item->removeInterface(group2IfaceItem);
- }
-#ifdef DEBUG
- cout << "done." << endl ;
-#endif
-
- // removing the interface group from the group
-#ifdef DEBUG
- cout << "removing group interface ..." ;
-#endif
- parentGroup->removeInterface(groupInter);
-#ifdef DEBUG
- cout << "done." << endl ;
-#endif
- }
-
-}
void Dispatcher::removeFunctionalInterface(InterfaceItem *item) {
static QString fctName = "Dispatcher::removeBlockInterface()";
#ifdef DEBUG_FCTNAME
}
ConnectedInterface* ref = item->refInter;
- item->getOwner()->removeInterface(item);
+ item->getOwner()->removeInterfaceItem(item);
FunctionalBlock* fun = AB_TO_FUN(ref->getOwner());
fun->removeInterface(ref);
}
cout << "call to " << qPrintable(fctName) << endl;
#endif
- /* NB: there is a single connection between item and another one that is owned
- by a BoxItem. Thus, we just have to find it and to call disconnectInterFromGroup();
+ /* NB: just remove all connections from/to this item, since when there are no more
+ ones to a GroupItem, it is automatically deleted.
*/
- ConnectionItem* conn = item->connections.at(0);
- if (conn->getFromInterfaceItem() == item) {
- disconnectInterFromGroup(conn->getToInterfaceItem());
- }
- else {
- disconnectInterFromGroup(conn->getFromInterfaceItem());
+ foreach(ConnectionItem* conn, item->connections) {
+ removeConnection(conn);
}
}
* connect to group in the contextual menu.
* Thus, parameter item is always owned by a BoxItem
*/
- void connectInterToGroup(InterfaceItem* item);
- /*!
- * \brief disconnectInterFromGroup
- * \param item item is always owned by a BoxItem
- *
- * This method is called only when the user right clicks on an InterfaceItem (that belongs
- * to a BoxItem and if it IS connected to an InterfaceItem of the GroupItem) and chooses
- * disconnect from group in the contextual menu.
- * Thus, parameter item is always owned by a BoxItem
- */
- void disconnectInterFromGroup(InterfaceItem* item);
+ void connectInterToGroup(InterfaceItem* item);
/*!
* \brief removeFunctionalInterface
* \param item item is always owned by a BoxItem
reference = _reference;\r
parent = _parent;\r
name = reference->getName();\r
+ consumptionPattern = NULL;\r
+ lengthCP = 0;\r
+ nbConsumingPorts = 0;\r
+ productionPattern = NULL;\r
+ lengthPP = 0;\r
+ nbProducingPorts = 0; \r
}\r
\r
\r
return ((ReferenceBlock *)reference)->getXmlFile();\r
}\r
\r
-QString FunctionalBlock::getReferenceHashMd5()\r
-{\r
+QString FunctionalBlock::getReferenceHashMd5() {\r
return ((ReferenceBlock *)reference)->getHashMd5();\r
}\r
+\r
+void FunctionalBlock::computeOutputPattern(int nbExec) {\r
+ \r
+ /* case 1: the block is a generator for which output pattern\r
+ must be computed for a nbExec following executions\r
+ */\r
+ \r
+ if (nbExec > 0) {\r
+ foreach(AbstractInterface* iface, getControlOutputs()) {\r
+ QList<char> pattern;\r
+ for(int i=0;i<nbExec;i++) pattern += iface->getProductionPattern();\r
+ iface->setOutputPattern(pattern);\r
+ } \r
+ }\r
+ else {\r
+ // initialize consumption and production patterns\r
+ initConsumptionPattern();\r
+ initProductionPattern();\r
+ \r
+ // collect the input patterns for each input \r
+ char** inputPattern = NULL;\r
+ int idIface = 0;\r
+ inputPattern = new char*[nbConsumingPorts];\r
+ int minLen = -1;\r
+ foreach(AbstractInterface* iface, getControlInputs()) { \r
+ QList<char> in = iface->getConnectedFrom()->getOutputPattern();\r
+ if (minLen == -1) {\r
+ minLen = in.size();\r
+ }\r
+ else {\r
+ if (in.size() < minLen) minLen = in.size();\r
+ }\r
+ inputPattern[idIface] = new char[in.size()];\r
+ int i = 0;\r
+ foreach(char c, in) inputPattern[idIface][i++] = c;\r
+ idIface += 1; \r
+ }\r
+ // initialize the output pattern \r
+ char** outputPattern = NULL;\r
+ outputPattern = new char*[nbProducingPorts];\r
+ int lengthOP = 0;\r
+ idIface = 0;\r
+ foreach(AbstractInterface* iface, getControlOutputs()) {\r
+ lengthOP = minLen+iface->getProductionPattern().size();\r
+ outputPattern[idIface] = new char[lengthOP];\r
+ memset(outputPattern[idIface],0,lengthOP);\r
+ idIface += 1;\r
+ }\r
+ \r
+ int clock = 0;\r
+ nbExec = 0;\r
+ // search for the beginning of the first execution.\r
+ while (! isValidDataGroup(inputPattern,nbConsumingPorts,clock)) clock++;\r
+ \r
+ while (clock < minLen) {\r
+ // initialize counters for current execution.\r
+ int p = 0; // index in production pattern\r
+ int o = 0; // clock+o will give the clock cycle of each output group\r
+ int cip = 0; // clock+cip give the clock cycle of an input group\r
+ int ccp = 0; // ccp give a column in the consumptio pattern\r
+ int nip = 0; // number of input data groups already consumed during the current execution, used while exploring IP\r
+ int ncp = 0; // number of input data groups already consumed during the current execution, used while exploring CP\r
+ bool cannotCompleteExec = false;\r
+ for(int m=0;m<productionCounter.size();m++) {\r
+ // search for the first production in PP\r
+ while (!isValidDataGroup(productionPattern,nbProducingPorts,p)) {\r
+ p += 1;\r
+ o += 1;\r
+ }\r
+ int gap = 0; // count the number of extra null columns\r
+ // search for PC(m) valid input group in IP\r
+ while (nip < productionCounter.at(m)) {\r
+ if (clock+cip < minLen) {\r
+ if (isValidDataGroup(inputPattern,nbConsumingPorts,clock+cip)) nip += 1;\r
+ cip += 1;\r
+ gap += 1;\r
+ }\r
+ else {\r
+ cannotCompleteExec = true;\r
+ break;\r
+ } \r
+ }\r
+ \r
+ if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern\r
+ \r
+ // search for PC(m) valid input group in IP\r
+ while (ncp < productionCounter.at(m)) {\r
+ if (isValidDataGroup(consumptionPattern,nbConsumingPorts,ccp)) cip += 1;\r
+ ccp += 1;\r
+ gap -= 1;\r
+ }\r
+ o += gap; // to take into acocunt of extra null columns\r
+ combinePatterns(productionPattern,p,outputPattern,clock+o,1,nbProducingPorts);\r
+ p += 1;\r
+ o += 1;\r
+ }\r
+ \r
+ if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern\r
+ \r
+ // current exec. taken into accunt\r
+ nbExec += 1;\r
+ \r
+ // search for the next exec.\r
+ clock += 1; \r
+ nip = 0;\r
+ while ((clock < minLen) && (nip < delta)) {\r
+ if (isValidDataGroup(inputPattern,nbConsumingPorts,clock)) nip += 1;\r
+ if (nip < delta) clock += 1;\r
+ }\r
+ }\r
+ // find the last valid output data group\r
+ while(! isValidDataGroup(outputPattern,nbProducingPorts,lengthOP-1)) lengthOP -= 1;\r
+ \r
+ // copy back outputPattern info each interface\r
+ idIface = 0;\r
+ foreach(AbstractInterface* iface, getControlOutputs()) {\r
+ QList<char> pattern;\r
+ for(int i=0;i<lengthOP;i++) pattern.append(outputPattern[idIface][i]);\r
+ iface->setOutputPattern(pattern); \r
+ idIface += 1;\r
+ }\r
+ \r
+ // clear inputPattern and outputPattern\r
+ for(int i=0;i<nbConsumingPorts; i++) {\r
+ delete [] inputPattern[i];\r
+ }\r
+ delete [] inputPattern;\r
+ for(int i=0;i<nbProducingPorts; i++) {\r
+ delete [] outputPattern[i];\r
+ }\r
+ delete [] outputPattern;\r
+ }\r
+}\r
+\r
+bool FunctionalBlock::isValidDataGroup(char** pattern, int nbPorts, int clock) {\r
+ \r
+ for(int i=0;i<nbPorts;i++) {\r
+ if (pattern[i][clock] == 1) return true;\r
+ }\r
+ return false; \r
+}\r
+\r
+void FunctionalBlock::combinePatterns(char** patternSrc, int srcCol, char** patternDest, int destCol, int nbCols, int nbPorts ) {\r
+ \r
+ for (int i=0;i<nbCols;i++) {\r
+ for(int j=0;j<nbPorts;j++) {\r
+ patternDest[j][destCol+i] = patternDest[j][destCol+i] | patternSrc[j][srcCol+i];\r
+ }\r
+ }\r
+ \r
+}\r
+\r
+void FunctionalBlock::clearConsumptionPattern() {\r
+ if (consumptionPattern == NULL) return;\r
+ \r
+ for(int i=0;i<nbConsumingPorts; i++) {\r
+ delete [] consumptionPattern[i];\r
+ }\r
+ delete [] consumptionPattern; \r
+}\r
+\r
+void FunctionalBlock::clearProductionPattern() {\r
+ if (productionPattern == NULL) return;\r
+ for(int i=0;i<nbProducingPorts;i++) {\r
+ delete [] productionPattern[i];\r
+ }\r
+ delete [] productionPattern;\r
+}\r
+\r
+void FunctionalBlock::initConsumptionPattern() {\r
+ if (consumptionPattern != NULL) clearConsumptionPattern();\r
+ \r
+ nbConsumingPorts = getControlInputs().size(); \r
+ int idIface = 0;\r
+ consumptionPattern = new char*[nbConsumingPorts]; \r
+ foreach(AbstractInterface* iface, getControlInputs()) {\r
+ \r
+ QList<char> in = iface->getConsumptionPattern();\r
+ lengthCP = in.size(); // normally, all inputs have the same lenght for CP\r
+ consumptionPattern[idIface] = new char[lengthCP];\r
+ int i = 0;\r
+ foreach(char c, in) consumptionPattern[idIface][i++] = c;\r
+ idIface += 1; \r
+ }\r
+}\r
+\r
+void FunctionalBlock::initProductionPattern() {\r
+ if (productionPattern != NULL) clearProductionPattern();\r
+ \r
+ nbProducingPorts = getControlOutputs().size(); \r
+ int idIface = 0;\r
+ productionPattern = new char*[nbProducingPorts]; \r
+ foreach(AbstractInterface* iface, getControlOutputs()) {\r
+ \r
+ QList<char> in = iface->getProductionPattern();\r
+ lengthPP = in.size(); // normally, all inputs have the same lenght for PP\r
+ productionPattern[idIface] = new char[lengthPP];\r
+ int i = 0;\r
+ foreach(char c, in) productionPattern[idIface][i++] = c;\r
+ idIface += 1; \r
+ }\r
+}\r
\r
// testers\r
bool isFunctionalBlock();\r
- bool isSourceBlock(); //! a source block has no parent\r
+ bool isSourceBlock(); //! a source block has no parent and has no data inputs\r
\r
// others\r
\r
\r
QString getReferenceXmlFile();\r
QString getReferenceHashMd5();\r
-\r
+ \r
+ // patterns\r
+ void initConsumptionPattern(); // initialize a char** from patterns defined for each interface\r
+ void initProductionPattern(); // initialize a char** from patterns defined for each interface\r
+ void clearConsumptionPattern();\r
+ void clearProductionPattern();\r
+ \r
private: \r
+ // patterns\r
+ void computeOutputPattern(int nbExec = -1);\r
+ bool isValidDataGroup(char** pattern, int nbPorts, int clock);\r
+ /*!\r
+ * \brief combinePatterns\r
+ * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) \r
+ * \param srcCol the column index within patternSrc\r
+ * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc)\r
+ * \param destClock the column index within patternDest\r
+ * \param nbCols the numer of columns to combine\r
+ * \param nbPorts the number of rows in both patterns\r
+ * BEWARE: no check is done if nbCols is consistent with the real length of both patterns, thus an access outside\r
+ * the patterns is possible.\r
+ */\r
+ void combinePatterns(char** patternSrc, int srcCol, char** patternDest, int destCol, int nbCols, int nbPorts );\r
+\r
+ char** consumptionPattern;\r
+ int nbConsumingPorts;\r
+ int lengthCP;\r
+ char** productionPattern;\r
+ int nbProducingPorts;\r
+ int lengthPP;\r
+ \r
ReferenceBlock* reference;\r
\r
};\r
BlockParameter* p = getParameterFromName(name);
if (p != NULL) params.removeAll(p);
}
+
+void GroupBlock::initInputPattern() {
+ foreach(AbstractInterface* iface, getControlInputs()) {
+ iface->setOutputPattern(iface->getConnectedFrom()->getOutputPattern());
+ }
+}
+
+void GroupBlock::computeOutputPattern(int nbExec) {
+
+ // get the input pattern on each inputs
+ initInputPattern();
+ // find blocks that are connected to that inputs
+
+ foreach(AbstractInterface* iface, getControlOutputs()) {
+ iface->setOutputPattern(iface->getConnectedFrom()->getOutputPattern());
+ }
+}
// public attributes
static int counter;
-private:
+
+private:
+ // patterns
+ /*!
+ * \brief initInputPattern
+ * Since input GroupInterface are just tunnels to input interfaces of inner blocks, they must
+ * have an output pattern that can be provided to inner interfaces. That outpu pattern is just
+ * found by taking the output pattern of the connectedFrom interface.
+ */
+ void initInputPattern();
+ void computeOutputPattern(int nbExec = -1);
+
bool topGroup;
QList<AbstractBlock*> blocks; // contains instances of FunctionalBlock or GroupBlock that are children of this group
}
if (boxSizeChanged) {
- updateInterfacesAndConnections();
+ updateInterfaceAndConnectionItems();
}
}
else if(params->editState == Parameters::EditInterfaceMove) {
prepareGeometryChange();
- moveInterfaceTo(event->pos());
+ moveInterfaceItemTo(event->pos());
// recompute the geometry of the block
updateGeometry(InterfaceMove);
// update connection from/to the selected interface
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) {
if (params->cursorState == Parameters::CursorOnInterface) {
- InterfaceItem *inter = getInterfaceFromCursor(x,y);
+ InterfaceItem *inter = getInterfaceItemFromCursor(x,y);
if (inter != NULL) {
currentInterface = inter;
params->setEditState(Parameters::EditInterfaceMove);
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);
QAction* renameAction = NULL;
QAction* showParameters = 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) {
interfaceItem->setId(id);
groupBlock->addInterface(groupInterface);
- addInterface(interfaceItem, false);
+ addInterfaceItem(interfaceItem, false);
cout << "interface add to " << groupBlock->getName().toStdString() << endl;
}
}
void GroupScene::removeConnectionItem(ConnectionItem* item) {
+
+ // remove connection from/to InterfaceItem
+ InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
+ InterfaceItem* toIfaceItem = item->getToInterfaceItem();
+ fromIfaceItem->removeConnectionItem(item);
+ toIfaceItem->removeConnectionItem(item);
+
// remove item from the viewport
removeItem(item);
// remove item from the QList
}
void InterfaceItem::removeConnectionItem(ConnectionItem* item) {
- connections.removeOne(item);
+ connections.removeAll(item);
}
QDataStream &operator <<(QDataStream &out, InterfaceItem *i) {
double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
- ConnectedInterface *refInter = insideGroup->searchInterfaceByName(refName)->refInter;\r
+ ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter;\r
InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
ifaceItem->setId(id);\r
- upperItem->addInterface(ifaceItem);\r
+ upperItem->addInterfaceItem(ifaceItem);\r
}\r
}\r
}\r
return in;
}
+
+void ReferenceBlock::computeOutputPattern(int nbExec) {
+ // does strictly nothing
+}
// AbstractBlock interface
public:
void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure);
+
+private:
+ // patterns
+ void computeOutputPattern(int nbExec = -1);
};
#endif // __REFERENCEBLOCK_H__
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();
}
}
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);
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);
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);
QAction* showParameters = 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){
}
// 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);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-10T22:29:52. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-11T17:54:38. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
+ <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</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">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</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">/home/sdomas/Projet/Blast/code/blast</value>
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/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">