Example #1
0
void EmbeddedLinker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
	if (mPressed) {
		mPressed = false;
		EditorViewScene *scene = dynamic_cast<EditorViewScene*>(master->scene());

		if (!scene) {
			return;
		}
		const QString type = "qrm:/" + master->id().editor() + "/" +
							 master->id().diagram() + "/" + edgeType.element();
		if (scene->mainWindow()->manager()->hasElement(Id::loadFromString(type))) {
			master->setConnectingState(true);
			Id edgeId = scene->createElement(type, event->scenePos());
			mEdge = dynamic_cast<EdgeElement*>(scene->getElem(edgeId));
		}

		if (mEdge){
			QPointF point = mapToItem(master, event->pos());
			mEdge->placeStartTo(mEdge->mapFromItem(master, master->getNearestPort(point)));
			mEdge->placeEndTo(mEdge->mapFromScene(mapToScene(event->pos())));
		}
	}

	if (mEdge != NULL) {
		mEdge->arrangeSrcAndDst();
		mEdge->placeEndTo(mEdge->mapFromScene(mapToScene(event->pos())));
	}
}
Example #2
0
void EmbeddedLinker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
	mTimer->start(400);

	if (mPressed) {
		mPressed = false;
		EditorViewScene *scene = dynamic_cast<EditorViewScene*>(mMaster->scene());

		if (!scene) {
			return;
		}
		QString const type = "qrm:/" + mMaster->id().editor() + "/" +
							 mMaster->id().diagram() + "/" + mEdgeType.element();
		if (scene->mainWindow()->editorManager().hasElement(Id::loadFromString(type))) {
			mMaster->setConnectingState(true);
			// FIXME: I am raw. return strange pos() and inside me a small trash
			Id edgeId = scene->createElement(type, event->scenePos(), true, &mCreateEdgeCommand);
			mEdge = dynamic_cast<EdgeElement*>(scene->getElem(edgeId));
		}

		if (mEdge) {
			mMaster->setZValue(1);
			mEdge->setSrc(mMaster);
			mEdge->setDst(NULL);
			mEdge->highlight();
			mEdge->tuneForLinker();
			mEdge->placeEndTo(mEdge->mapFromScene(mapToScene(event->pos())));
			mMaster->arrangeLinks();
			mMaster->adjustLinks();
		}
	}

	if (mEdge) {
		if (mTimeOfUpdate == 14) {
			mTimeOfUpdate = 0;
			mEdge->adjustNeighborLinks();
			mEdge->arrangeSrcAndDst();
		} else {
			mTimeOfUpdate++;
		}
		mEdge->placeEndTo(mEdge->mapFromScene(mapToScene(event->pos())));
	}
}
Example #3
0
void EmbeddedLinker::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
	EditorViewScene *scene = dynamic_cast<EditorViewScene*>(master->scene());

	if (scene)
	{
		const QString type = "qrm:/" + master->uuid().editor() + "/" +
							 master->uuid().diagram() + "/" + edgeType.element();
		if (scene->mainWindow()->manager()->hasElement(Id::loadFromString(type)))
		{
			master->setConnectingState(true);
			Id *edgeId = scene->createElement(type, event->scenePos());
			mEdge = dynamic_cast<EdgeElement*>(scene->getElem(*edgeId));
		}
		if (mEdge)
		{
			master->setSelected(false);
			QPointF point = mapToItem(master,event->pos());
			mEdge->placeStartTo(mEdge->mapFromItem(master,master->getNearestPort(point)));
			mEdge->placeEndTo(mapToItem(mEdge,event->pos()));
		}
	}
}
Example #4
0
NodeElement *CopyHandler::clone(bool toCursorPos, bool searchForParents)
{
	EditorViewScene *evscene = dynamic_cast<EditorViewScene *>(mNode.scene());

	qReal::Id typeId = mNode.id().type();
	qReal::Id resultId = evscene->createElement(typeId.toString(), QPointF(), searchForParents);

	NodeElement *result = dynamic_cast<NodeElement *>(evscene->getElem(resultId));

	copyProperties(*result, mNode);
	copyChildren(*result, mNode);
	QRectF contents = mNode.contentsRect();
	if (toCursorPos) {
		contents.moveTo(evscene->getMousePos());
		result->setGeometry(contents);
		result->storeGeometry();
	}
	else {
		contents.moveTo(mNode.pos());
		result->setGeometry(contents);
	}

	return result;
}