コード例 #1
0
void JunctionFlowNode::drawShape ( QPainter &p )
{
	const int _x = ( int ) x();
	const int _y = ( int ) y();

	if ( !m_inFlowConnList.isEmpty() )
	{
		const FlowConnectorList::iterator end = m_inFlowConnList.end();
		for ( FlowConnectorList::iterator it = m_inFlowConnList.begin(); it != end; ++ it )
		{
			Connector * connector = *it;
			if ( !connector )
				continue;

			// Work out the direction of the connector
			const QPointList points = connector->connectorPoints ( false );

			const int count = points.size();
			if ( count < 2 )
				continue;

			QPoint end_0 = points[count-1];
			QPoint end_1 = points[count-2];

			Q3PointArray pa;
			if ( end_0.x() < end_1.x() )
			{
				pa = arrowPoints ( 180 );
				pa.translate ( 4, 0 );
			}
			else if ( end_0.x() > end_1.x() )
			{
				pa = arrowPoints ( 0 );
				pa.translate ( -4, 0 );
			}
			else if ( end_0.y() < end_1.y() )
			{
				pa = arrowPoints ( 270 );
				pa.translate ( 0, 4 );
			}
			else if ( end_0.y() > end_1.y() )
			{
				pa = arrowPoints ( 90 );
				pa.translate ( 0, -4 );
			}
			else	continue;

			pa.translate ( _x, _y );
			p.setPen ( connector->isSelected() ? m_selectedColor : Qt::black );
			p.drawPolygon ( pa );
		}
		return;
	}

	if	( m_dir == 0 )		p.drawLine ( _x, _y, _x-8, _y );
	else if ( m_dir == 90 )		p.drawLine ( _x, _y, _x, _y-8 );
	else if ( m_dir == 180 )	p.drawLine ( _x, _y, _x+8, _y );
	else if ( m_dir == 270 )	p.drawLine ( _x, _y, _x, _y+8 );

}
コード例 #2
0
ファイル: outputflownode.cpp プロジェクト: Munrek/ktechlab
void OutputFlowNode::drawShape ( QPainter &p )
{
	const int _x = ( int ) x();
	const int _y = ( int ) y();



	if	( m_dir == 0 )		p.drawLine ( _x, _y, _x-8, _y );
	else if ( m_dir == 90 )		p.drawLine ( _x, _y, _x, _y-8 );
	else if ( m_dir == 180 )	p.drawLine ( _x, _y, _x+8, _y );
	else if ( m_dir == 270 )	p.drawLine ( _x, _y, _x, _y+8 );

	QPointArray pa ( 3 );

	switch ( m_dir )
	{
		case 0: // right
			pa = arrowPoints ( 0 );
			break;
		case 180: // left
			pa = arrowPoints ( 180 );
			break;
		case 90: // down
			pa = arrowPoints ( 90 );
			break;
		case 270: // up
			pa = arrowPoints ( 270 );
			break;
		default:
			kdError() << k_funcinfo << "BUG: m_dir = " << m_dir << endl;
	}


	// Note: I have not tested the positioning of the arrows for all combinations.
	// In fact, most almost definitely do not work. So feel free to change the code
	// as you see fit if necessary.

	if	( m_dir == 0 ) pa.translate ( -5, 0 );
	else if ( m_dir == 90 ) pa.translate ( 0, -5 );
	else if ( m_dir == 180 ) pa.translate ( 5, 0 );
	else if ( m_dir == 270 ) pa.translate ( 0, 5 );

	pa.translate ( _x, _y );
	p.drawPolygon ( pa );
}