void GuiPart::updateConnectorPoints( bool add )
{
	ICNDocument *icnd = dynamic_cast<ICNDocument*>(p_parent->itemDocument());
	if ( !icnd)
		return;
	
	Cells * cells = icnd->cells();
	if (!cells)
		return;
	
	if ( !isVisible() )
		add = false;
	
	if ( add == b_pointsAdded )
		return;
	
	b_pointsAdded = add;
	
	int mult = add ? 1 : -1;
	int sx = roundDown( x(), 8 );
	int sy = roundDown( y(), 8 );
	int ex = roundDown( x()+width(), 8 );
	int ey = roundDown( y()+height(), 8 );
	
	for ( int x=sx; x<=ex; ++x )
	{
		for ( int y=sy; y<=ey; ++y )
		{
			if ( cells->haveCell( x, y ) )
				cells->cell( x, y ).CIpenalty += mult*ICNDocument::hs_item/2;
		}
	}
}
void ItemDocument::processItemDocumentEvents() {
	// Copy it incase we have new events requested while doing this...
	unsigned queuedEvents = m_queuedEvents;
	m_queuedEvents = 0;

	if (queuedEvents &ItemDocumentEvent::ResizeCanvasToItems)
		resizeCanvasToItems();

	if (queuedEvents &ItemDocumentEvent::UpdateZOrdering)
		slotUpdateZOrdering();

	ICNDocument *icnd = dynamic_cast<ICNDocument*>(this);
	if (icnd && (queuedEvents & ItemDocumentEvent::UpdateNodeGroups))
		icnd->slotAssignNodeGroups();

	if (icnd && (queuedEvents & ItemDocumentEvent::RerouteInvalidatedConnectors))
		icnd->rerouteInvalidatedConnectors();
}
Exemple #3
0
void Canvas::drawBackground(QPainter &p, const QRect & clip) {
	QCanvas::drawBackground(p, clip);
#if 0
	const int scx = (int)((clip.left() - 4) / 8);
	const int ecx = (int)((clip.right() + 4) / 8);
	const int scy = (int)((clip.top() - 4) / 8);
	const int ecy = (int)((clip.bottom() + 4) / 8);

	ICNDocument * icnd = dynamic_cast<ICNDocument*>(p_itemDocument);

	if (!icnd)
		return;

	Cells * c = icnd->cells();

	if (!c->haveCell(scx, scy) || !c->haveCell(ecx, ecy))
		return;

	for (int x = scx; x <= ecx; x++) {
		for (int y = scy; y <= ecy; y++) {
			const double score = c->cell(x, y).CIpenalty + c->cell(x, y).Cpenalty;
			int value = (int)std::log(score) * 20;

			if (value > 255)
				value = 255;
			else if (value < 0)
				value = 0;

			p.setBrush(QColor(255, (255 - value), (255 - value)));

			p.setPen(Qt::NoPen);

			p.drawRect((x*8), (y*8), 8, 8);
		}
	}

#endif
}