Beispiel #1
0
void WidgetArea::updateMarker(DataWidget *w)
{
    bool do_update = false;

    if(!rect().intersects(w->geometry()))
    {
        QPoint markPos(w->pos().x(), w->pos().y());
        markPos.rx() += w->width()/2;
        markPos.ry() += w->height()/2;

        QSize size;
        getMarkPos(markPos.rx(), markPos.ry(), size);

        m_marks[w->getId()] = QRect(markPos, size);

        do_update = true;

        w->setUpdating(false);
    }
    else
    {
        do_update = m_marks.remove(w->getId());
        if(do_update)
        {
            w->setUpdating(true);
            w->updateForThis();
        }
    }

    if(do_update)
        update();
}
void CalloutNote::drawNoteNodeConnector(QPainter *painter, bool visible)
{	
	float width;
	float height;
	QRectF itemPos;
	if(_scene->_pathBubbles[_pid]==NULL) //does not work
		return;
	PathBubble1* path=_scene->_pathBubbles[_pid];
	if(!path || path==NULL || !path->isVisible())
		return;

	QPointF dis1=this->sceneBoundingRect().center();
	QPointF dis2=path->sceneBoundingRect().center();

	if(fixedSize)
	{		
		width=graphReferenceSize/2*path->_scale; height=graphReferenceSize/2*path->_scale;
	}
	else
	{
		width=this->realRect().width()/2*path->_scale;
	    height=this->realRect().height()/2*path->_scale;
	}

	if(_type == 'L' && _id>=path->ANodeRect.size())
		return;

	switch(_type)
	{
		 case 'C': itemPos = path->complexRect[_id];  break;
		 case 'E': itemPos = path->physicalEntityRect[_id];  break;
		 case 'P': itemPos = path->proteinRect[_id];  break;				
		 case 'S': itemPos = path->smallMoleculeRect[_id];  break;
		 case 'D': itemPos = path->DnaRect[_id];  break;
		 case 'R': itemPos = path->reactionRect[_id];  break;
		 case 'L': itemPos = path->ANodeRect[_id];  break;
		 case 'M': itemPos = path->compartmentRect[_id];  break;
	}

	
	QPointF start,end;
	
	start=QPointF(0,0);
	end=itemPos.center();

	start=start+dis1;
	end=end+dis2;

	QRectF noteRect=this->sceneBoundingRect();	
	QRectF pathRect=path->sceneBoundingRect();
	
	float w,h;
	w=realRect().width(),  h=realRect().height();
	noteRect=QRectF(noteRect.center().x()-w/2, noteRect.center().y()-h/2, w, h );

	QPointF markPos(end.x()+itemPos.width()*0.5, end.y()-itemPos.height()*0.1);
	_deleteMark = QRectF(noteRect.x()+noteRect.width()*0.90, noteRect.y()+noteRect.height()*0.03, noteRect.width()*0.08, noteRect.width()*0.08);	
	_minimizeMark = QRectF(noteRect.x()+noteRect.width()*0.80, noteRect.y()+noteRect.height()*0.03, noteRect.width()*0.08, noteRect.width()*0.08);	

	

	//clip	    
	QColor c=QColor(_colorBoarder.a, _colorBoarder.b, _colorBoarder.c, 255);
	if(visible)
	{		
		
		if(!noteRect.contains(end))
		{
			drawArrow_5(painter, start, markPos-QPointF(itemPos.width()*0.04,0), QRect(noteRect.center().x()-w/2,noteRect.center().y()-h/2, w, h ), width, height, c );						
		}		
		drawCross(painter,_deleteMark, c);
		drawMinus(painter,_minimizeMark, c);
	}
	else 
	{
		//if within the path bubble
		if(pathRect.contains(start)|| pathRect.contains(end))
		   drawNoteMark(painter, start, end,  QRect(noteRect.center().x()-w/2,noteRect.center().y()-h/2, w, h ), markPos, markRect, width, height, c );						
	}		
}