예제 #1
0
Id QrsMetamodelSaver::saveEdge(qrRepo::RepoApi &repo, const EdgeElementType &edge, const Id &diagram)
{
	const Id edgeId = metamodelEdgeType.sameTypeId();
	repo.addChild(diagram, edgeId);
	repo.setName(edgeId, edge.name());
	repo.setProperty(edgeId, "displayedName", edge.friendlyName());
	repo.setProperty(edgeId, "description", edge.description());
	repo.setProperty(edgeId, "isDividable", edge.isDividable());
	repo.setProperty(edgeId, "lineType", penStyleToString(edge.penStyle()));
	repo.setProperty(edgeId, "shape", linkShapeToString(edge.shapeType()));

	const QList<LabelProperties> &labels = edge.labels();
	if (!labels.isEmpty()) {
		const LabelProperties &label = labels.first();
		repo.setProperty(edgeId, "labelText", label.isStatic() ? label.text() : label.binding());
		repo.setProperty(edgeId, "labelType", label.isStatic() ? "staticText" : "dynamicText");
		repo.setProperty(edgeId, "hardLabel", label.isHard());
	}

	saveAssociations(repo, edge, edgeId);
	saveProperties(repo, edge, edgeId);
	savePorts(repo, edge, edgeId, "from");
	savePorts(repo, edge, edgeId, "to");
	return edgeId;
}
예제 #2
0
Id LogicalModelAssistApi::createElement(const Id &parent, const Id &type)
{
	Q_ASSERT(type.idSize() == 3);
	Q_ASSERT(parent.idSize() == 4);

	const Id newElementId = type.sameTypeId();
	const QString elementFriendlyName = mModelsAssistApi.editorManagerInterface().friendlyName(type);
	const bool isEdge = mModelsAssistApi.editorManagerInterface().isNodeOrEdge(newElementId.type()) == -1;
	ElementInfo newElement(newElementId, Id(), parent, Id(), {{"name", elementFriendlyName}}, {}, Id(), isEdge);
	mLogicalModel.addElementToModel(newElement);
	return newElementId;
}
예제 #3
0
void QrsMetamodelSaver::saveDiagram(qrRepo::RepoApi &repo, const Metamodel &metamodel
		, const QString &diagramName, const Id &metamodelId, Id &resultingId)
{
	const Id diagramId = metamodelDiagramType.sameTypeId();
	resultingId = diagramId;
	repo.addChild(metamodelId, diagramId);
	repo.setName(diagramId, diagramName);
	repo.setProperty(diagramId, "displayedName", metamodel.diagramFriendlyName(diagramName));
	if (const ElementType *node = metamodel.diagramNode(diagramName)) {
		repo.setProperty(diagramId, "nodeName", node->name());
	}

	QMap<const ElementType *, Id> elements;
	saveObjectsOnDiagram(repo, metamodel, diagramName, diagramId, elements);
	saveLinksInMetamodel(repo, metamodel, diagramName, diagramId, elements);
}
예제 #4
0
Id QrsMetamodelSaver::saveNode(qrRepo::RepoApi &repo, const NodeElementType &node, const Id &diagram)
{
	const Id nodeId = metamodelNodeType.sameTypeId();
	repo.addChild(diagram, nodeId);
	repo.setName(nodeId, node.name());
	repo.setProperty(nodeId, "displayedName", node.friendlyName());
	repo.setProperty(nodeId, "description", node.description());
	repo.setProperty(nodeId, "path", node.mouseGesture());
	repo.setProperty(nodeId, "abstract", node.isHidden());
	repo.setProperty(nodeId, "isResizeable", node.isResizable());
	repo.setProperty(nodeId, "createChildrenFromMenu", node.createChildrenFromMenu());

	saveSdfGraphics(repo, node, nodeId);
	saveContainerProperties(repo, node, nodeId);
	saveProperties(repo, node, nodeId);
	return nodeId;
}
예제 #5
0
void QrsMetamodelSaver::saveMetamodel(qrRepo::RepoApi &repo, const Metamodel &metamodel)
{
	const Id metamodelId = metamodelRootDiagramType.sameTypeId();
	repo.addChild(Id::rootId(), metamodelId);
	repo.setName(metamodelId, metamodel.id());
	repo.setProperty(metamodelId, "displayedName", metamodel.friendlyName());
	repo.setProperty(metamodelId, "version", metamodel.version());

	Id lastDiagramId;
	for (const QString &diagram : metamodel.diagrams()) {
		saveDiagram(repo, metamodel, diagram, metamodelId, lastDiagramId);
	}

	if (lastDiagramId.isNull()) {
		// Metamodel contained no diagrams, nowhere to save enums and ports, giving up.
		return;
	}

	for (const QString &enumName : metamodel.enumNames()) {
		saveEnum(repo, metamodel, enumName, lastDiagramId);
	}
}
예제 #6
0
파일: idsTest.cpp 프로젝트: Antropovi/qreal
TEST(IdsTest, sameTypeIdTest) {
	Id const id = Id::loadFromString("qrm:/editor/diagram/element/id");
	EXPECT_EQ(id.sameTypeId().type(), id.type());
}