// QToolTip for title and label for SUPERVGUI_CanvasCellNode
SUPERVGUI_ToolTip* aTT = new SUPERVGUI_ToolTip(this);
- QPoint aPoint1 = inverseWorldMatrix().map(theEvent->pos());
- aTT->maybeTip(aPoint1);
+ aTT->maybeTip(theEvent->pos());
}
void SUPERVGUI_ArrayView::contentsMouseReleaseEvent(QMouseEvent* theEvent) {
}
}
-void SUPERVGUI_ToolTip::maybeTip(const QPoint& theP) {
- // compute collision rectangle
- QRect aSel(theP.x()-MARGIN, theP.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
+void SUPERVGUI_ToolTip::maybeTip(const QPoint& thePos) {
+ // mkr : 23.11.2006 - PAL13957 - modifications for correct tooltips displaying after scroll or zoom
+ QPoint theP = ((QCanvasView*)parentWidget())->inverseWorldMatrix().map(thePos);
+
+ int avX, avY;
+ ((QCanvasView*)parentWidget())->contentsToViewport(theP.x(), theP.y(), avX, avY);
+ QPoint avP(avX, avY);
- QCanvasItemList l = ((QCanvasView*)parentWidget())->canvas()->collisions(aSel);
- for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
+ QWMatrix aWM = ((QCanvasView*)parentWidget())->worldMatrix();
+
+ // compute collision rectangle for nodes, ports
+ QRect aNodeSel(theP.x()-MARGIN, theP.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN);
+
+ QCanvasItemList lN = ((QCanvasView*)parentWidget())->canvas()->collisions(aNodeSel);
+ for (QCanvasItemList::Iterator it = lN.begin(); it != lN.end(); ++it)
+ {
// tooltip for node
- if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) {
+ if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node)
+ {
SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it);
QObject* anObj = aNodePrs->getObject(theP);
- if (anObj->inherits("SUPERVGUI_CanvasNode")) {
-
+ if (anObj->inherits("SUPERVGUI_CanvasNode"))
+ {
QRect aTitleRect = aNodePrs->getTitleRect();
QRect aLabelRect = aNodePrs->getLabelRect();
QRect aStatusRect = aNodePrs->getStatusRect();
if (aTitleRect.bottom()+1 == aLabelRect.top() &&
- aLabelRect.bottom()+1 == aStatusRect.top()) {
- QRect aTipRect(aTitleRect.left(), aTitleRect.top(), aTitleRect.width(),
- aTitleRect.height() + aLabelRect.height() + aStatusRect.height());
- tip(aTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
+ aLabelRect.bottom()+1 == aStatusRect.top())
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aTitleRect.left()*aWM.m11()),
+ (int)(aTitleRect.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aTitleRect.width()*aWM.m11()),
+ (int)((aTitleRect.height() + aLabelRect.height() + aStatusRect.height())*aWM.m22()));
+ tip(avTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
return;
}
- if (aTitleRect.contains(theP, true)) {
- tip(aTitleRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
+ if (aTitleRect.contains(theP, true))
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aTitleRect.left()*aWM.m11()),
+ (int)(aTitleRect.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aTitleRect.width()*aWM.m11()), (int)(aTitleRect.height()*aWM.m22()));
+ tip(avTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
return;
}
- if (aLabelRect.contains(theP, true)) {
- tip(aLabelRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
+ if (aLabelRect.contains(theP, true))
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aLabelRect.left()*aWM.m11()),
+ (int)(aLabelRect.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aLabelRect.width()*aWM.m11()), (int)(aLabelRect.height()*aWM.m22()));
+ tip(avTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
return;
}
- if (aStatusRect.contains(theP, true)) {
- tip(aStatusRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
+ if (aStatusRect.contains(theP, true))
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aStatusRect.left()*aWM.m11()),
+ (int)(aStatusRect.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aStatusRect.width()*aWM.m11()), (int)(aStatusRect.height()*aWM.m22()));
+ tip(avTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText());
return;
}
}
// tooltip for nodes' port
- if (anObj->inherits("SUPERVGUI_CanvasPort")) {
+ if (anObj->inherits("SUPERVGUI_CanvasPort"))
+ {
SUPERVGUI_CanvasPort* aPort = (SUPERVGUI_CanvasPort*)anObj;
- tip(aPort->getPrs()->getPortRect(),
- aPort->getEngine()->Type() + QString(" ") + aPort->getPrs()->getText());
+ QRect aPortRect = aPort->getPrs()->getPortRect();
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aPortRect.left()*aWM.m11()),
+ (int)(aPortRect.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aPortRect.width()*aWM.m11()), (int)(aPortRect.height()*aWM.m22()));
+ tip(avTipRect, aPort->getEngine()->Type() + QString(" ") + aPort->getPrs()->getText());
return;
}
}
+ }
+
+ // compute collision rectangle for links
+ QRect aLinkSel((int)( theP.x() + (theP.x()-avP.x())/aWM.m11() ) - MARGIN,
+ (int)( theP.y() + (theP.y()-avP.y())/aWM.m22() ) - MARGIN,
+ 1+2*MARGIN, 1+2*MARGIN);
+
+ QCanvasItemList lL = ((QCanvasView*)parentWidget())->canvas()->collisions(aLinkSel);
+ for (QCanvasItemList::Iterator it = lL.begin(); it != lL.end(); ++it)
+ {
// tootip for links' point
- if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
- SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
- if (aPrs->getLink()->getMain()->getViewType() == CANVAS)
- tip(aSel, aPrs->getLink()->getToolTipText());
- return;
+ if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint)
+ {
+ SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it);
+ if (aPrs->getLink()->getMain()->getViewType() == CANVAS)
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aLinkSel.left()*aWM.m11()),
+ (int)(aLinkSel.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aLinkSel.width()*aWM.m11()), (int)(aLinkSel.height()*aWM.m22()));
+ tip(avTipRect, aPrs->getLink()->getToolTipText());
+ }
+ return;
}
// tooltip for links' edge
- if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
- SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
- if (aPrs->getLink()->getMain()->getViewType() == CANVAS)
- tip(aSel, aPrs->getLink()->getToolTipText());
- return;
+ if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge)
+ {
+ SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it);
+ if (aPrs->getLink()->getMain()->getViewType() == CANVAS)
+ {
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aLinkSel.left()*aWM.m11()),
+ (int)(aLinkSel.top()*aWM.m22()),
+ avX, avY);
+ QRect avTipRect(avX, avY,
+ (int)(aLinkSel.width()*aWM.m11()), (int)(aLinkSel.height()*aWM.m22()));
+ tip(avTipRect, aPrs->getLink()->getToolTipText());
+ }
+ return;
}
- }
+ }
}