CreateRemoveCommandImplementation::CreateRemoveCommandImplementation(const models::Models &models
		, const QList<ElementInfo> &elements)
	: mLogicalApi(models.logicalModelAssistApi())
	, mGraphicalApi(models.graphicalModelAssistApi())
	, mExploser(models.exploser())
	, mElements(elements)
{
}
Exemplo n.º 2
0
ExploserView::ExploserView(const models::Models &models
		, Controller &controller
		, const SceneCustomizer &customizer
		, QObject *parent)
	: QObject(parent)
	, mLogicalApi(models.logicalModelAssistApi())
	, mGraphicalApi(models.graphicalModelAssistApi())
	, mExploser(models.exploser())
	, mController(controller)
	, mCustomizer(customizer)
{
}
Exemplo n.º 3
0
NodeElement::NodeElement(ElementImpl *impl, const Id &id, const models::Models &models)
	: Element(impl, id, models)
	, mSwitchGridAction(tr("Switch on grid"), this)
	, mDragState(None)
	, mResizeCommand(nullptr)
	, mIsExpanded(false)
	, mIsFolded(false)
	, mLeftPressed(false)
	, mPos(QPointF(0,0))
	, mSelectionNeeded(false)
	, mConnectionInProgress(false)
	, mPlaceholder(nullptr)
	, mHighlightedNode(nullptr)
	, mRenderTimer(this)
{
	setAcceptHoverEvents(true);
	setFlag(ItemClipsChildrenToShape, false);
	setFlag(QGraphicsItem::ItemDoesntPropagateOpacityToChildren);

	LabelFactory labelFactory(models.graphicalModelAssistApi(), mId);
	QList<LabelInterface*> titles;

	QList<PortInterface *> ports;
	PortFactory portFactory;
	mElementImpl->init(mContents, portFactory, ports, labelFactory, titles, &mRenderer, this);
	mPortHandler = new PortHandler(this, mGraphicalAssistApi, ports);

	for (LabelInterface * const labelInterface : titles) {
		Label * const label = dynamic_cast<Label *>(labelInterface);
		if (!label) {
			continue;
		}

		label->init(mContents);
		label->setParentItem(this);
		mLabels.append(label);
	}

	mFoldedContents = mContents;

	mSwitchGridAction.setCheckable(true);
	connect(&mSwitchGridAction, SIGNAL(toggled(bool)), this, SLOT(switchGrid(bool)));

	mGrid = new SceneGridHandler(this);
	switchGrid(SettingsManager::value("ActivateGrid").toBool());

	initPortsVisibility();

	connect(&mRenderTimer, SIGNAL(timeout()), this, SLOT(initRenderedDiagram()));
}
Exemplo n.º 4
0
Element::Element(ElementImpl *elementImpl, const Id &id, const models::Models &models)
	: mMoving(false)
	, mEnabled(true)
	, mId(id)
	, mElementImpl(elementImpl)
	, mModels(models)
	, mLogicalAssistApi(models.logicalModelAssistApi())
	, mGraphicalAssistApi(models.graphicalModelAssistApi())
	, mController(nullptr)
{
	setFlags(ItemIsSelectable | ItemIsMovable | ItemIsFocusable | ItemClipsChildrenToShape |
			ItemClipsToShape | ItemSendsGeometryChanges);

	setAcceptDrops(true);
	setCursor(Qt::PointingHandCursor);

	updateEnabledState();
	setHideNonHardLabels(SettingsManager::value("hideNonHardLabels").toBool());
	SettingsListener::listen("hideNonHardLabels", this, &Element::setHideNonHardLabels);
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
MultipleRemoveCommand::MultipleRemoveCommand(const models::Models &models)
	: mLogicalApi(models.logicalModelAssistApi())
	, mGraphicalApi(models.graphicalModelAssistApi())
	, mExploser(models.exploser())
{
}
Exemplo n.º 7
0
CreatePatternCommand::CreatePatternCommand(const models::Models &models, const ElementInfo &pattern)
	: CreateElementsCommand(models, {})
{
	setElements(parse(models.logicalModelAssistApi(), models.graphicalModelAssistApi(), pattern));
}