Esempio n. 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())));
	}
}
Esempio n. 2
0
void MiniMap::setCurrentScene()
{
	mEditorView = mWindow->getCurrentTab();
	if (mEditorView == NULL) {
		return;
	}

	EditorViewScene *editorViewScene = static_cast<EditorViewScene *>(mEditorView->scene());
	if (editorViewScene->mainWindow() != NULL) {
		setScene(editorViewScene);
		// can affect zoom - need to change it if we make another desision about it
		connect(editorViewScene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(showScene()));
	}
}
Esempio n. 3
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())));
	}
}
Esempio n. 4
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()));
		}
	}
}