Esempio n. 1
0
Id ModelsAssistApi::createElement(Id const &parent, Id const &id, Id const &logicalId
		, bool isFromLogicalModel, QString const &name, QPointF const &position)
{
	Q_ASSERT(parent.idSize() == 4);
	Id newId = id;
	Id realLogicalId = logicalId;
	if (isFromLogicalModel) {
		realLogicalId = id;
		newId = Id(id.editor(), id.diagram(), id.element(), QUuid::createUuid().toString());
	}
	mModel.addElementToModel(parent, newId, realLogicalId, name, position);
	return newId;
}
IdList BaseGraphTransformationUnit::elementsFromActiveDiagram() const
{
	unsigned const validIdSize = 4;
	Id const activeDiagram = mInterpretersInterface.activeDiagram();
	if (activeDiagram.idSize() < validIdSize) {
		mInterpretersInterface.errorReporter()->addError(tr("no current diagram"));
		return IdList();
	}
	IdList const activeDiagramElements = children(activeDiagram);
	IdList activeDiagramGraphicalElements;
	foreach (Id const &id, activeDiagramElements) {
		if (mGraphicalModelApi.isGraphicalId(id)) {
			activeDiagramGraphicalElements.append(id);
		}
	}
	return activeDiagramGraphicalElements;
}
Esempio n. 3
0
void PaletteToolbox::addDiagramType(Id const &id, QString const &name)
{
	QWidget *tab = new QWidget;
	QVBoxLayout *layout = new QVBoxLayout(tab);

	layout->setSpacing(0);
	layout->setContentsMargins(0, 0, 0, 0);

	tab->setLayout(layout);

	mTabs.append(tab);
	mTabNames.append(name);

	Q_ASSERT(id.idSize() == 2);  // it should be diagram
	mCategories[id] = mTabs.size() - 1;

	mComboBox->addItem(name);

	Q_ASSERT(mTabNames.size() == mTabs.size());
}
Esempio n. 4
0
Id::Id(Id const &base, QString const &additional)
	: mEditor(base.mEditor), mDiagram(base.mDiagram), mElement(base.mElement), mId(base.mId)
{
	unsigned baseSize = base.idSize();
	switch (baseSize) {
		case 0:
			mEditor = additional;
			break;
		case 1:
			mDiagram = additional;
			break;
		case 2:
			mElement = additional;
			break;
		case 3:
			mId = additional;
			break;
		default:
			Q_ASSERT(!"Can not add a part to Id, it will be too long");
	}
	Q_ASSERT(checkIntegrity());
}