Example #1
0
EdgeElement::EdgeElement(ElementImpl *impl)
    : mPenStyle(Qt::SolidLine), mPenWidth(1), mPenColor(Qt::black), mStartArrowStyle(NO_ARROW), mEndArrowStyle(NO_ARROW)
    , mSrc(NULL), mDst(NULL)
    , mPortFrom(0), mPortTo(0)
    , mDragPoint(-1), mLongPart(0), mBeginning(NULL), mEnding(NULL)
    , mAddPointAction(tr("Add point"), this)
    , mDelPointAction(tr("Delete point"), this)
    , mSquarizeAction(tr("Squarize"), this)
    , mMinimizeAction(tr("Remove all points"), this)
    , mElementImpl(impl)
    , mLastDragPoint(-1)
{
    mPenStyle = mElementImpl->getPenStyle();
    mPenWidth = mElementImpl->getPenWidth();
    mPenColor = mElementImpl->getPenColor();
    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 &)));
    connect(&mMinimizeAction, SIGNAL(triggered(QPointF const &)), SLOT(minimizeHandler(QPointF const &)));

    mChaoticEdition = SettingsManager::value("ChaoticEdition").toBool();

    ElementTitleFactory factory;

    QList<ElementTitleInterface*> titles;
    mElementImpl->init(factory, titles);
    foreach (ElementTitleInterface *titleIface, titles) {
        ElementTitle *title = dynamic_cast<ElementTitle*>(titleIface);
        if (!title)
            continue;
        title->init(boundingRect());
        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);
	}