Example #1
0
EdgeElement::EdgeElement(ElementImpl *impl)
	: mPenStyle(Qt::SolidLine), mStartArrowStyle(NO_ARROW), mEndArrowStyle(NO_ARROW),
	mSrc(NULL), mDst(NULL), mPortFrom(0), mPortTo(0),
	mDragState(-1), mLongPart(0), mBeginning(NULL), mEnding(NULL), mAddPointAction("Add point", this),
	mDelPointAction("Delete point", this), mSquarizeAction("Squarize", this), mElementImpl(impl)
{
	mPenStyle = mElementImpl->getPenStyle();
	setZValue(100);
	setFlag(ItemIsMovable, true);
	// FIXME: draws strangely...
	setFlag(ItemClipsToShape, false);
	setFlag(ItemClipsChildrenToShape, false);

	mLine << QPointF(0, 0) << QPointF(200, 60);

	setAcceptHoverEvents(true);

	connect(&mAddPointAction, SIGNAL(triggered(QPointF const &)), SLOT(addPointHandler(QPointF const &)));
	connect(&mDelPointAction, SIGNAL(triggered(QPointF const &)), SLOT(delPointHandler(QPointF const &)));
	connect(&mSquarizeAction, SIGNAL(triggered(QPointF const &)), SLOT(squarizeHandler(QPointF const &)));

	QSettings settings("SPbSU", "QReal");
	mChaoticEdition = settings.value("ChaoticEdition", false).toBool();

	ElementTitleFactory factory;

	QList<ElementTitleInterface*> titles;
	mElementImpl->init(factory, titles);
	foreach (ElementTitleInterface *titleIface, titles){
		ElementTitle *title = dynamic_cast<ElementTitle*>(titleIface);
		if (!title)
			continue;
		title->setParentItem(this);
		mTitles.append(title);
	}
Example #2
0
NodeElement::NodeElement(ElementImpl* impl)
	: mSwitchGridAction("Switch on grid", this),
		mPortsVisible(false), mDragState(None), mElementImpl(impl), mIsFolded(false),
		mLeftPressed(false), mParentNodeElement(NULL), mPos(QPointF(0,0)),
		mSelectionNeeded(false), mConnectionInProgress(false)
{
	setAcceptHoverEvents(true);
	setFlag(ItemClipsChildrenToShape, false);

	mPortRenderer = new SdfRenderer();
	mRenderer = new SdfRenderer();
	ElementTitleFactory factory;
	QList<ElementTitleInterface*> titles;
	mElementImpl->init(mContents, mPointPorts, mLinePorts, factory, titles, mRenderer, mPortRenderer);
	foreach (ElementTitleInterface *titleIface, titles){
		ElementTitle *title = dynamic_cast<ElementTitle*>(titleIface);
		if (!title)
			continue;
		title->init(mContents);
		title->setParentItem(this);
		mTitles.append(title);
	}