Пример #1
0
bool QGILineBinder::serialize( S11nNode & dest ) const
{
    using namespace s11n::qt;
	if( ! this->Serializable::serialize( dest ) ) return false;
	if( ! impl->ends.first || ! impl->ends.second ) return false;
	// We must ensure that the "pos" property is synced, but we have
	// to violate constness to do it :/
	QGILineBinder * ncthis = const_cast<QGILineBinder*>( this );
	ncthis->setProperty( "pos", this->pos() );
	if( this->metaObject()->propertyCount() )
	{
		S11nNode & pr( s11n::create_child( dest, "properties" ) );
		if( ! QObjectProperties_s11n()( pr, *this ) ) return false;
	}
	QObjectProperties_s11n proxy;
	QObject const * qobj = impl->ends.first; // kludge to avoid an ambiguity
	if( ! proxy(s11n::create_child( dest, "first" ), *qobj) ) return false;
	qobj = impl->ends.second;
	if( ! proxy(s11n::create_child( dest, "second" ), *qobj) ) return false;
	/**
	To avoid offset calculations, we save the absolute LineNode
	positions instead of our m_pts member. This still has the problem
	that if the hard-coded size of the LineNodes changes between
	serializations, we'll place the line slightly differently
	than before when we load.
	*/
	Impl::PointPair pts( impl->ends.first->pos(), impl->ends.second->pos() );
	return s11n::serialize_subnode( dest, "pos", pts );
}
Пример #2
0
void MainWindowImpl::addLine()
{
	QGILineNode * ln = new QGILineNode;
	QGILineNode * rn = new QGILineNode;
	ln->setProperty("color", "#ffff00");
	rn->setProperty("color", "#ff0000");
	rn->setPos(50,50);
	ln->setPos(50,100);
	QGILineBinder * ed = new QGILineBinder(ln,rn);
#if 0
	ed->setProperty("lineColor", "#00ffff");
#endif
	ed->setProperty("lineWidth", 2 );
	ed->setProperty("lineStyle", Qt::DotLine );
	impl->gstate.addItem(ed,true);

}