Esempio n. 1
0
PasteCommand::PasteCommand(const models::Models &models
		, bool isGraphicalCopy
		, const QPointF &mousePosition
		, const Id &rootGraphicalId)
	: CreateElementsCommand(models, {})
	, mIsGraphicalCopy(isGraphicalCopy)
	, mMousePosition(mousePosition)
	, mRootDiagramGraphicalId(rootGraphicalId)
	, mIsEmpty(false)
{
	QList<NodeInfo> nodesData;
	QList<EdgeInfo> edgesData;
	pullDataFromClipboard(nodesData, edgesData);

	if (nodesData.isEmpty() && edgesData.isEmpty()) {
		mIsEmpty = true;
		return;
	}

	const QPointF originalPos = nodesData.isEmpty() ? edgesData[0].position() : nodesData[0].position();
	const QPointF offset = mMousePosition - originalPos;

	const QHash<Id, Id> copiedIds = prepareNodes(models.graphicalModelAssistApi(), nodesData, offset);

	QList<ElementInfo> allElements;
	for (const ElementInfo &node : nodesData) {
		allElements << node;
	}

	for (EdgeInfo &edge : edgesData) {
		prepareEdge(edge, offset, copiedIds);
		const ElementInfo elemInfo = edge.convertToSimpleInfo();
		allElements << elemInfo;
	}

	setElements(allElements);
}
Esempio n. 2
0
MultipleRemoveCommand::MultipleRemoveCommand(const models::Models &models)
	: mLogicalApi(models.logicalModelAssistApi())
	, mGraphicalApi(models.graphicalModelAssistApi())
	, mExploser(models.exploser())
{
}
Esempio n. 3
0
CreatePatternCommand::CreatePatternCommand(const models::Models &models, const ElementInfo &pattern)
	: CreateElementsCommand(models, {})
{
	setElements(parse(models.logicalModelAssistApi(), models.graphicalModelAssistApi(), pattern));
}