Exemple #1
0
void CNItem::removeDisplayText( const QString &id )
{
	TextMap::iterator it = m_textMap.find(id);
	if ( it == m_textMap.end() )
	{
// 		kError() << "CNItem::removeDisplayText: Could not find text with id \""<<id<<"\""<<endl;
		return;
	}
	it.data()->updateConnectorPoints(false);
	delete it.data();
	m_textMap.remove(it);
}
Exemple #2
0
CNItem::~CNItem()
{
	const TextMap::iterator textMapEnd = m_textMap.end();
	for ( TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it )
	{
		if (it.data()) it.data()->setCanvas(0l);

		delete (Text*)it.data();
	}
	m_textMap.clear();
	
	updateConnectorPoints(false);
}
Exemple #3
0
void FlowPart::updateAttachedPositioning() {
	if (b_deleted) return;

	//BEGIN Rearrange text if appropriate
	const QRect textPos[4] = {
		QRect(offsetX() + width(),	6,				40, 16),
		QRect(0,				offsetY() - 16,		40, 16),
		QRect(offsetX() - 40,		6,				40, 16),
		QRect(0,				offsetY() + height(),	40, 16)
	};

	NodeInfo *stdOutputInfo = m_stdOutput ? &m_nodeMap["stdoutput"] : 0;
	NodeInfo *altOutputInfo = m_altOutput ? &m_nodeMap["altoutput"] : 0;

	Text *outputTrueText = m_textMap.contains("output_true") ? m_textMap["output_true"] : 0;
	Text *outputFalseText = m_textMap.contains("output_false") ? m_textMap["output_false"] : 0;

	if (stdOutputInfo && outputTrueText)
		outputTrueText->setOriginalRect(textPos[ nodeDirToPos(stdOutputInfo->orientation)]);

	if (altOutputInfo && outputFalseText)
		outputFalseText->setOriginalRect(textPos[ nodeDirToPos(altOutputInfo->orientation)]);

	const TextMap::iterator textMapEnd = m_textMap.end();
	for (TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it) {
		QRect pos = it.data()->recommendedRect();
		it.data()->move(pos.x() + x(), pos.y() + y());
		it.data()->setGuiPartSize(pos.width(), pos.height());
	}
	//END Rearrange text if appropriate

	const NodeInfoMap::iterator end = m_nodeMap.end();
	for (NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it) {
		if (!it.data().node) {
			kdError() << k_funcinfo << "Node in nodemap is null" << endl;
			continue;
		}

		double nx = it.data().x;
		double ny = it.data().y;

#define round_8(x) (((x) > 0) ? int(((x)+4)/8)*8 : int(((x)-4)/8)*8)
		nx = round_8(nx);
		ny = round_8(ny);
#undef round_8

		it.data().node->move(int(nx + x()), int(ny + y()));
		it.data().node->setOrientation(it.data().orientation);
	}
}
Exemple #4
0
void CNItem::setVisible( bool yes )
{
	if (b_deleted)
	{
		Item::setVisible(false);
		return;
	}
	
	Item::setVisible(yes);
	
	const TextMap::iterator textMapEnd = m_textMap.end();
	for ( TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it )
	{
		it.data()->setVisible(yes);
	}

	const NodeInfoMap::iterator nodeMapEnd = m_nodeMap.end();
	for ( NodeInfoMap::iterator it = m_nodeMap.begin(); it != nodeMapEnd; ++it )
	{
		it.data().node->setVisible(yes);
	}
	
	CNItem::setDrawWidgets(yes);
	
	if (!yes)
		updateConnectorPoints(false);
}
Exemple #5
0
void CNItem::setDisplayText( const QString &id, const QString &display )
{
	TextMap::iterator it = m_textMap.find(id);
	if ( it == m_textMap.end() )
	{
		kError() << "CNItem::setDisplayText: Could not find text with id \""<<id<<"\""<<endl;
		return;
	}
	it.data()->setText(display);
	updateAttachedPositioning();
}
Exemple #6
0
void CNItem::removeItem()
{
	if (b_deleted)
		return;
	
	const TextMap::iterator textMapEnd = m_textMap.end();
	for ( TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it )
		it.data()->setCanvas(0l);
	
	Item::removeItem();
	updateConnectorPoints(false);
}
Exemple #7
0
void CNItem::updateZ( int baseZ )
{
	Item::updateZ(baseZ);
	
	double _z = z();
	
	const NodeInfoMap::iterator nodeMapEnd = m_nodeMap.end();
	for ( NodeInfoMap::iterator it = m_nodeMap.begin(); it != nodeMapEnd; ++it )
		it.data().node->setZ( _z + 0.5 );
	
	const WidgetMap::iterator widgetMapEnd = m_widgetMap.end();
	for ( WidgetMap::iterator it = m_widgetMap.begin(); it != widgetMapEnd; ++it )
		it.data()->setZ( _z + 0.5 );
	
	const TextMap::iterator textMapEnd = m_textMap.end();
	for ( TextMap::iterator it = m_textMap.begin(); it != textMapEnd; ++it )
		it.data()->setZ( _z + 0.5 );
}
Exemple #8
0
Text* CNItem::addDisplayText( const QString &id, const QRect & pos, const QString &display, bool internal, int flags )
{
	Text *text = 0l;
	TextMap::iterator it = m_textMap.find(id);
	if ( it != m_textMap.end() )
	{
// 		kWarning() << "CNItem::addDisplayText: removing old text"<<endl;
		delete it.data();
		m_textMap.remove(it);
	}
	
	text = new Text( "", this, pos, canvas(), flags );
	text->setZ( z()+(internal?0.1:-0.1) );
	
	m_textMap[id] = text;
	
	// Calculate the correct size
	setDisplayText( id, display );
	text->show();
	return text;
}
Exemple #9
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);
	}
}