Пример #1
0
void ArrowLine::drawShape(QPainter &p)
{
    p.setPen(darkGray);
    QCanvasLine::drawShape(p);

    double angle = computeAngle(startPoint().x(),
                                startPoint().y(),
                                endPoint().x(),
                                endPoint().y());
    QPointArray pts(3);

    QWMatrix m;
    int x, y;
    m.rotate(angle);
    m.map(-5, -2, &x, &y);
    pts.setPoint(0, x, y);
    m.map(-5, 2, &x, &y);
    pts.setPoint(1, x, y);
    m.map(0, 0, &x, &y);
    pts.setPoint(2, x, y);

    pts.translate(endPoint().x(), endPoint().y());

    p.setBrush(QColor(darkGray));
    p.drawPolygon(pts);
}
Пример #2
0
void MechanicsItemOverlay::slotUpdateResizeHandles()
{
	const PositionInfo absPos = p_mechanicsItem->absolutePosition();
	const QRect sizeRect = p_mechanicsItem->sizeRect();
	
	QPointArray pa(9);
	pa[0] = sizeRect.topLeft();
	pa[2] = sizeRect.topRight();
	pa[1] = (pa[0]+pa[2])/2;
	pa[4] = sizeRect.bottomRight();
	pa[3] = (pa[2]+pa[4])/2;
	pa[6] = sizeRect.bottomLeft();
	pa[5] = (pa[4]+pa[6])/2;
	pa[7] = (pa[6]+pa[0])/2;
	pa[8] = QPoint(0,0);
	
	QWMatrix m;
	m.rotate(absPos.angle() * DPR);
	
	pa = m.map(pa);
	
	m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() );
	m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() );
	m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() );
	m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() );
	m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() );
	m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() );
	m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() );
	m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() );
	m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() );
}
Пример #3
0
QPointArray KoChild::oldPointArray( const QWMatrix &matrix )
{
  QPointArray arr = d->m_old;

  for( int i = 0; i < 4; ++i )
      arr.setPoint( i, matrix.map( arr.point( i ) ) );

  return arr;
}
Пример #4
0
void Node::initPoints() {
	// Bounding rectangle, facing right
	QPointArray pa(QRect(0, -8, m_length, 16));

	QWMatrix m;
	m.rotate(m_dir);
	pa = m.map(pa);
	setPoints(pa);
}
Пример #5
0
void PinNode::initPoints()
{
	int l = - m_length;

	// Bounding rectangle, facing right
	Q3PointArray pa( QRect( 0, -8, l, 16 ) );

	QWMatrix m;
	m.rotate( m_dir );
	pa = m.map(pa);
	setPoints(pa);
}
Пример #6
0
void KoChild::updateMatrix()
{
  QWMatrix r;
  r.rotate( - d->m_rotation );
  QPoint p = r.map( QPoint( d->m_rotationPoint.x(),
			    d->m_rotationPoint.y() ) );

  QWMatrix m;
  m.rotate( d->m_rotation );
  m.translate( -d->m_rotationPoint.x() + d->m_geometry.x(), -d->m_rotationPoint.y() + d->m_geometry.y() );
  m.translate( p.x(), p.y() );
  m.shear( d->m_shearX, d->m_shearY );

  d->m_matrix = m;
}
Пример #7
0
QPointArray KoChild::pointArray( const QRect &r, const QWMatrix &matrix ) const
{
  QPoint topleft = d->m_matrix.map( QPoint( r.left(), r.top() ) );
  QPoint topright = d->m_matrix.map( QPoint( r.right(), r.top() ) );
  QPoint bottomleft = d->m_matrix.map( QPoint( r.left(), r.bottom() ) );
  QPoint bottomright = d->m_matrix.map( QPoint( r.right(), r.bottom() ) );

  QPointArray arr( 4 );
  arr.setPoint( 0, topleft );
  arr.setPoint( 1, topright );
  arr.setPoint( 2, bottomright );
  arr.setPoint( 3, bottomleft );

  for( int i = 0; i < 4; ++i )
      arr.setPoint( i, matrix.map( arr.point( i ) ) );

  return arr;
}
Пример #8
0
void CNItem::updateConnectorPoints( bool add )
{
	if ( b_deleted || !isVisible() )
		add = false;

	if ( b_pointsAdded == add )
		return;

	b_pointsAdded = add;

	Cells *cells = p_icnDocument->cells();
	if (!cells)
		return;
	
	// Get translation matrix
	// Hackish...
	QWMatrix m;
	if ( Component *c = dynamic_cast<Component*>(this) )
		m = c->transMatrix( c->angleDegrees(), c->flipped(), int(x()), int(y()), false );
	
	// Convention used here: _UM = unmapped by both matrix and cell reference, _M = mapped

	const QPoint start_UM = QPoint( int(x()+offsetX())-8, int(y()+offsetY())-8 );
	const QPoint end_UM = start_UM + QPoint( width()+2*8, height()+2*8 );
	
	const QPoint start_M = roundDown( m.map(start_UM), 8 );
	const QPoint end_M = roundDown( m.map(end_UM), 8 );
	
	
	int sx_M = start_M.x();
	int ex_M = end_M.x();
	
	int sy_M = start_M.y();
	int ey_M = end_M.y();
	
	
	// Normalise start and end points
	if ( sx_M > ex_M )
	{
		const int temp = sx_M;
		sx_M = ex_M;
		ex_M = temp;
	}
	if ( sy_M > ey_M )
	{
		const int temp = sy_M;
		sy_M = ey_M;
		ey_M = temp;
	}
	
	ex_M++;
	ey_M++;
	
	const int mult = add ? 1 : -1;
	
	for ( int x = sx_M; x < ex_M; x++ )
	{
		for ( int y = sy_M; y < ey_M; y++ )
		{
			if ( cells->haveCell( x, y ) )
			{
				if ( x != sx_M && y != sy_M && x != (ex_M-1) && y != (ey_M-1) )
				{
					cells->cell( x, y ).CIpenalty += mult*ICNDocument::hs_item;
				}
				else 
				{
//					(*cells)[x][y].CIpenalty += mult*ICNDocument::hs_item/2;
					cells->cell( x, y ).CIpenalty += mult*ICNDocument::hs_connector*5;
				}
			}
		}
	}
	
#if 0
	// And subtract the positions of the node on the border
	NodeInfoMap::iterator end = m_nodeMap.end();
	for ( NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it )
	{
		const int x = (int)((it->second.node->x()-4)/cellSize);
		const int y = (int)((it->second.node->y()-4)/cellSize);
		if ( p_icnDocument->isValidCellReference(x,y) ) {
			(*cells)[x][y].CIpenalty -= mult*ICNDocument::hs_connector*5;
		}
	}
#endif
	
	const TextMap::iterator textMapEnd = m_textMap.end();
	for ( TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it )
	{
		it.data()->updateConnectorPoints(add);
	}
	const WidgetMap::iterator widgetMapEnd = m_widgetMap.end();
	for ( WidgetMap::iterator it = m_widgetMap.begin(); it != widgetMapEnd; ++it )
	{
		it.data()->updateConnectorPoints(add);
	}
}