X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/0d3590739ff5a4ca9e87c052ac142f5d1d3a68ab..2bdaa0aa3fab52f0808f60d9bbdabcd56d0efae9:/InterfaceItem.cpp diff --git a/InterfaceItem.cpp b/InterfaceItem.cpp index ff6329e..1ef3aae 100644 --- a/InterfaceItem.cpp +++ b/InterfaceItem.cpp @@ -11,7 +11,7 @@ InterfaceItem::InterfaceItem(double _position, int _orientation, ConnectedInterface *_refInter, AbstractBoxItem* _owner, - Parameters* _params){ + Parameters* _params, bool forceVisible) { positionRatio = _position; orientation = _orientation; refInter = _refInter; @@ -24,7 +24,7 @@ InterfaceItem::InterfaceItem(double _position, nameWidth = fmName.width(refInter->getName()); nameHeight = fmName.height(); // by default, only data interface are visible - if (refInter->getPurpose() == AbstractInterface::Data) { + if ((forceVisible) || (refInter->getPurpose() == AbstractInterface::Data)) { visible = true; } else { @@ -118,17 +118,36 @@ void InterfaceItem::paint(QPainter *painter) { } // draw arrows - if(refInter->getDirection() == AbstractInterface::Input) { - painter->drawPath(params->inArrow); + if ( (refInter->getPurpose() == AbstractInterface::Clock) || (refInter->getPurpose() == AbstractInterface::Reset)) { + painter->drawPath(params->clkrstArrow); + } + else if(refInter->getDirection() == AbstractInterface::Input) { + painter->drawPath(params->dataArrowIn); } else if(refInter->getDirection() == AbstractInterface::Output) { - painter->drawPath(params->outArrow); + painter->drawPath(params->dataArrowOut); } else if(refInter->getDirection() == AbstractInterface::InOut) { - painter->drawPath(params->inArrow); - painter->drawPath(params->outArrow); + painter->drawPath(params->dataArrowIn); + painter->drawPath(params->dataArrowOut); + } + + // paint modifier box if needed + ConnectedInterface* connIface = AI_TO_CON(refInter->getAssociatedIface()); + if ((connIface != NULL) && (connIface->getInputModifier() != NULL)) { + painter->save(); + painter->translate(params->arrowWidth+params->arrowLineLength,0); + painter->drawRect(0,-5,10,10); + painter->restore(); } + // 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){ @@ -158,39 +177,38 @@ void InterfaceItem::paint(QPainter *painter) { else if((owner->isBoxItem()) || (owner->isSourceItem())){ painter->drawText(-w,-h/2,w,h,Qt::AlignLeft | Qt::TextWordWrap, refInter->getName()); } - } + } + + painter->restore(); } } -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; } @@ -254,7 +272,7 @@ void InterfaceItem::addConnectionItem(ConnectionItem* item) { } void InterfaceItem::removeConnectionItem(ConnectionItem* item) { - connections.removeOne(item); + connections.removeAll(item); } QDataStream &operator <<(QDataStream &out, InterfaceItem *i) {