forked from qt-creator/qt-creator
ModelEditor: move 3rd_party/modeling into libs/modelinglib
Only moved the files and adapted .pro and .qbs files accordingly. Change-Id: I7c17c2ebf246595c104edf60013bf78379955aa7 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
161
src/libs/modelinglib/qmt/tasks/alignonrastervisitor.cpp
Normal file
161
src/libs/modelinglib/qmt/tasks/alignonrastervisitor.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "alignonrastervisitor.h"
|
||||
|
||||
#include "qmt/diagram_controller/diagramcontroller.h"
|
||||
#include "qmt/diagram/dannotation.h"
|
||||
#include "qmt/diagram/dassociation.h"
|
||||
#include "qmt/diagram/dboundary.h"
|
||||
#include "qmt/diagram/dclass.h"
|
||||
#include "qmt/diagram/dcomponent.h"
|
||||
#include "qmt/diagram/ddependency.h"
|
||||
#include "qmt/diagram/ddiagram.h"
|
||||
#include "qmt/diagram/ditem.h"
|
||||
#include "qmt/diagram/delement.h"
|
||||
#include "qmt/diagram/dinheritance.h"
|
||||
#include "qmt/diagram/dobject.h"
|
||||
#include "qmt/diagram/dpackage.h"
|
||||
#include "qmt/diagram/drelation.h"
|
||||
#include "qmt/diagram_scene/capabilities/moveable.h"
|
||||
#include "qmt/diagram_scene/capabilities/resizable.h"
|
||||
#include "qmt/diagram_scene/diagramsceneconstants.h"
|
||||
#include "qmt/tasks/isceneinspector.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
AlignOnRasterVisitor::AlignOnRasterVisitor()
|
||||
: m_diagramController(0),
|
||||
m_sceneInspector(0),
|
||||
m_diagram(0)
|
||||
{
|
||||
}
|
||||
|
||||
AlignOnRasterVisitor::~AlignOnRasterVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::setDiagramController(DiagramController *diagramController)
|
||||
{
|
||||
m_diagramController = diagramController;
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::setSceneInspector(ISceneInspector *sceneInspector)
|
||||
{
|
||||
m_sceneInspector = sceneInspector;
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::setDiagram(MDiagram *diagram)
|
||||
{
|
||||
m_diagram = diagram;
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDElement(DElement *element)
|
||||
{
|
||||
Q_UNUSED(element);
|
||||
|
||||
QMT_CHECK(false);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDObject(DObject *object)
|
||||
{
|
||||
IResizable *resizable = m_sceneInspector->resizable(object, m_diagram);
|
||||
if (resizable)
|
||||
resizable->alignItemSizeToRaster(IResizable::SideRightOrBottom, IResizable::SideRightOrBottom,
|
||||
2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
||||
IMoveable *moveable = m_sceneInspector->moveable(object, m_diagram);
|
||||
if (moveable)
|
||||
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDPackage(DPackage *package)
|
||||
{
|
||||
visitDObject(package);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDClass(DClass *klass)
|
||||
{
|
||||
visitDObject(klass);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDComponent(DComponent *component)
|
||||
{
|
||||
visitDObject(component);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDDiagram(DDiagram *diagram)
|
||||
{
|
||||
visitDObject(diagram);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDItem(DItem *item)
|
||||
{
|
||||
visitDObject(item);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDRelation(DRelation *relation)
|
||||
{
|
||||
Q_UNUSED(relation);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDInheritance(DInheritance *inheritance)
|
||||
{
|
||||
visitDRelation(inheritance);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDDependency(DDependency *dependency)
|
||||
{
|
||||
visitDRelation(dependency);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDAssociation(DAssociation *association)
|
||||
{
|
||||
visitDRelation(association);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDAnnotation(DAnnotation *annotation)
|
||||
{
|
||||
IMoveable *moveable = m_sceneInspector->moveable(annotation, m_diagram);
|
||||
if (moveable)
|
||||
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
||||
}
|
||||
|
||||
void AlignOnRasterVisitor::visitDBoundary(DBoundary *boundary)
|
||||
{
|
||||
IResizable *resizable = m_sceneInspector->resizable(boundary, m_diagram);
|
||||
if (resizable)
|
||||
resizable->alignItemSizeToRaster(IResizable::SideRightOrBottom, IResizable::SideRightOrBottom,
|
||||
2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
|
||||
IMoveable *moveable = m_sceneInspector->moveable(boundary, m_diagram);
|
||||
if (moveable)
|
||||
moveable->alignItemPositionToRaster(RASTER_WIDTH, RASTER_HEIGHT);
|
||||
}
|
||||
|
||||
} // namespace qmt
|
||||
75
src/libs/modelinglib/qmt/tasks/alignonrastervisitor.h
Normal file
75
src/libs/modelinglib/qmt/tasks/alignonrastervisitor.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_ALIGNONRASTERVISITOR_H
|
||||
#define QMT_ALIGNONRASTERVISITOR_H
|
||||
|
||||
#include "qmt/diagram/dvisitor.h"
|
||||
#include "qmt/infrastructure/qmt_global.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class DiagramController;
|
||||
class ISceneInspector;
|
||||
class MDiagram;
|
||||
|
||||
class QMT_EXPORT AlignOnRasterVisitor : public DVisitor
|
||||
{
|
||||
public:
|
||||
AlignOnRasterVisitor();
|
||||
~AlignOnRasterVisitor();
|
||||
|
||||
void setDiagramController(DiagramController *diagramController);
|
||||
void setSceneInspector(ISceneInspector *sceneInspector);
|
||||
void setDiagram(MDiagram *diagram);
|
||||
|
||||
void visitDElement(DElement *element) override;
|
||||
void visitDObject(DObject *object) override;
|
||||
void visitDPackage(DPackage *package) override;
|
||||
void visitDClass(DClass *klass) override;
|
||||
void visitDComponent(DComponent *component) override;
|
||||
void visitDDiagram(DDiagram *diagram) override;
|
||||
void visitDItem(DItem *item) override;
|
||||
void visitDRelation(DRelation *relation) override;
|
||||
void visitDInheritance(DInheritance *inheritance) override;
|
||||
void visitDDependency(DDependency *dependency) override;
|
||||
void visitDAssociation(DAssociation *association) override;
|
||||
void visitDAnnotation(DAnnotation *annotation) override;
|
||||
void visitDBoundary(DBoundary *boundary) override;
|
||||
|
||||
private:
|
||||
DiagramController *m_diagramController;
|
||||
ISceneInspector *m_sceneInspector;
|
||||
MDiagram *m_diagram;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_ALIGNONRASTERVISITOR_H
|
||||
744
src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp
Normal file
744
src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp
Normal file
@@ -0,0 +1,744 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "diagramscenecontroller.h"
|
||||
|
||||
#include "qmt/controller/namecontroller.h"
|
||||
#include "qmt/controller/undocontroller.h"
|
||||
#include "qmt/diagram_controller/dfactory.h"
|
||||
#include "qmt/diagram_controller/diagramcontroller.h"
|
||||
#include "qmt/diagram_controller/dselection.h"
|
||||
#include "qmt/diagram/dannotation.h"
|
||||
#include "qmt/diagram/dboundary.h"
|
||||
#include "qmt/diagram/dclass.h"
|
||||
#include "qmt/diagram/dpackage.h"
|
||||
#include "qmt/diagram/ditem.h"
|
||||
#include "qmt/diagram/drelation.h"
|
||||
#include "qmt/diagram_ui/diagram_mime_types.h"
|
||||
#include "qmt/model_controller/modelcontroller.h"
|
||||
#include "qmt/model_controller/mselection.h"
|
||||
#include "qmt/model_controller/mvoidvisitor.h"
|
||||
#include "qmt/model/massociation.h"
|
||||
#include "qmt/model/mcanvasdiagram.h"
|
||||
#include "qmt/model/mclass.h"
|
||||
#include "qmt/model/mcomponent.h"
|
||||
#include "qmt/model/mdependency.h"
|
||||
#include "qmt/model/mdiagram.h"
|
||||
#include "qmt/model/minheritance.h"
|
||||
#include "qmt/model/mitem.h"
|
||||
#include "qmt/model/mobject.h"
|
||||
#include "qmt/model/mpackage.h"
|
||||
#include "qmt/model/msourceexpansion.h"
|
||||
#include "qmt/tasks/alignonrastervisitor.h"
|
||||
#include "qmt/tasks/isceneinspector.h"
|
||||
#include "qmt/tasks/voidelementtasks.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QQueue>
|
||||
#include <QPair>
|
||||
|
||||
namespace qmt {
|
||||
|
||||
namespace {
|
||||
static VoidElementTasks dummyElementTasks;
|
||||
}
|
||||
|
||||
class DiagramSceneController::AcceptRelationVisitor : public MVoidConstVisitor
|
||||
{
|
||||
public:
|
||||
AcceptRelationVisitor(const MRelation *relation)
|
||||
: m_relation(relation)
|
||||
{
|
||||
}
|
||||
|
||||
bool isAccepted() const { return m_accepted; }
|
||||
|
||||
void visitMObject(const MObject *object) override
|
||||
{
|
||||
Q_UNUSED(object);
|
||||
m_accepted = dynamic_cast<const MDependency *>(m_relation) != 0;
|
||||
}
|
||||
|
||||
void visitMClass(const MClass *klass) override
|
||||
{
|
||||
Q_UNUSED(klass);
|
||||
m_accepted = dynamic_cast<const MDependency *>(m_relation) != 0
|
||||
|| dynamic_cast<const MInheritance *>(m_relation) != 0
|
||||
|| dynamic_cast<const MAssociation *>(m_relation) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const MRelation *m_relation = 0;
|
||||
bool m_accepted = false;
|
||||
};
|
||||
|
||||
DiagramSceneController::DiagramSceneController(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_modelController(0),
|
||||
m_diagramController(0),
|
||||
m_elementTasks(&dummyElementTasks),
|
||||
m_sceneInspector(0)
|
||||
{
|
||||
}
|
||||
|
||||
DiagramSceneController::~DiagramSceneController()
|
||||
{
|
||||
}
|
||||
|
||||
void DiagramSceneController::setModelController(ModelController *modelController)
|
||||
{
|
||||
if (m_modelController == modelController)
|
||||
return;
|
||||
if (m_modelController) {
|
||||
disconnect(m_modelController, 0, this, 0);
|
||||
m_modelController = 0;
|
||||
}
|
||||
if (modelController)
|
||||
m_modelController = modelController;
|
||||
}
|
||||
|
||||
void DiagramSceneController::setDiagramController(DiagramController *diagramController)
|
||||
{
|
||||
if (m_diagramController == diagramController)
|
||||
return;
|
||||
if (m_diagramController) {
|
||||
disconnect(m_diagramController, 0, this, 0);
|
||||
m_diagramController = 0;
|
||||
}
|
||||
if (diagramController)
|
||||
m_diagramController = diagramController;
|
||||
}
|
||||
|
||||
void DiagramSceneController::setElementTasks(IElementTasks *elementTasks)
|
||||
{
|
||||
m_elementTasks = elementTasks;
|
||||
}
|
||||
|
||||
void DiagramSceneController::setSceneInspector(ISceneInspector *sceneInspector)
|
||||
{
|
||||
m_sceneInspector = sceneInspector;
|
||||
}
|
||||
|
||||
void DiagramSceneController::deleteFromDiagram(const DSelection &dselection, MDiagram *diagram)
|
||||
{
|
||||
if (!dselection.isEmpty()) {
|
||||
MSelection mselection;
|
||||
DSelection remainingDselection;
|
||||
foreach (const DSelection::Index &index, dselection.indices()) {
|
||||
DElement *delement = m_diagramController->findElement(index.elementKey(), diagram);
|
||||
QMT_CHECK(delement);
|
||||
if (delement->modelUid().isValid()) {
|
||||
MElement *melement = m_modelController->findElement(delement->modelUid());
|
||||
QMT_CHECK(melement);
|
||||
if (melement->owner())
|
||||
mselection.append(melement->uid(), melement->owner()->uid());
|
||||
} else {
|
||||
remainingDselection.append(index);
|
||||
}
|
||||
}
|
||||
if (!remainingDselection.isEmpty())
|
||||
m_diagramController->deleteElements(remainingDselection, diagram);
|
||||
if (!mselection.isEmpty())
|
||||
m_modelController->deleteElements(mselection);
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramSceneController::createDependency(DObject *endAObject, DObject *endBObject,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram)
|
||||
{
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Dependency"));
|
||||
|
||||
MObject *endAModelObject = m_modelController->findObject<MObject>(endAObject->modelUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
MObject *endBModelObject = m_modelController->findObject<MObject>(endBObject->modelUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
|
||||
if (endAModelObject == endBModelObject)
|
||||
return;
|
||||
|
||||
auto modelDependency = new MDependency();
|
||||
modelDependency->setEndAUid(endAModelObject->uid());
|
||||
modelDependency->setEndBUid(endBModelObject->uid());
|
||||
modelDependency->setDirection(MDependency::AToB);
|
||||
m_modelController->addRelation(endAModelObject, modelDependency);
|
||||
|
||||
DRelation *relation = addRelation(modelDependency, intermediatePoints, diagram);
|
||||
|
||||
m_diagramController->undoController()->endMergeSequence();
|
||||
|
||||
if (relation)
|
||||
emit newElementCreated(relation, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::createInheritance(DClass *derivedClass, DClass *baseClass,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram)
|
||||
{
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Inheritance"));
|
||||
|
||||
MClass *derivedModelClass = m_modelController->findObject<MClass>(derivedClass->modelUid());
|
||||
QMT_CHECK(derivedModelClass);
|
||||
MClass *baseModelClass = m_modelController->findObject<MClass>(baseClass->modelUid());
|
||||
QMT_CHECK(baseModelClass);
|
||||
|
||||
if (derivedModelClass == baseModelClass)
|
||||
return;
|
||||
|
||||
auto modelInheritance = new MInheritance();
|
||||
modelInheritance->setDerived(derivedModelClass->uid());
|
||||
modelInheritance->setBase(baseModelClass->uid());
|
||||
m_modelController->addRelation(derivedModelClass, modelInheritance);
|
||||
|
||||
DRelation *relation = addRelation(modelInheritance, intermediatePoints, diagram);
|
||||
|
||||
m_diagramController->undoController()->endMergeSequence();
|
||||
|
||||
if (relation)
|
||||
emit newElementCreated(relation, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::createAssociation(DClass *endAClass, DClass *endBClass,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram)
|
||||
{
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Create Association"));
|
||||
|
||||
MClass *endAModelObject = m_modelController->findObject<MClass>(endAClass->modelUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
MClass *endBModelObject = m_modelController->findObject<MClass>(endBClass->modelUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
|
||||
// TODO allow self assignment with just one intermediate point and a nice round arrow
|
||||
if (endAModelObject == endBModelObject && intermediatePoints.count() < 2)
|
||||
return;
|
||||
|
||||
auto modelAssociation = new MAssociation();
|
||||
modelAssociation->setEndAUid(endAModelObject->uid());
|
||||
MAssociationEnd endA = modelAssociation->endA();
|
||||
endA.setNavigable(true);
|
||||
modelAssociation->setEndA(endA);
|
||||
modelAssociation->setEndBUid(endBModelObject->uid());
|
||||
m_modelController->addRelation(endAModelObject, modelAssociation);
|
||||
|
||||
DRelation *relation = addRelation(modelAssociation, intermediatePoints, diagram);
|
||||
|
||||
m_diagramController->undoController()->endMergeSequence();
|
||||
|
||||
if (relation)
|
||||
emit newElementCreated(relation, diagram);
|
||||
}
|
||||
|
||||
bool DiagramSceneController::relocateRelationEndA(DRelation *relation, DObject *targetObject)
|
||||
{
|
||||
return relocateRelationEnd(relation, targetObject, &MRelation::endAUid, &MRelation::setEndAUid);
|
||||
}
|
||||
|
||||
bool DiagramSceneController::relocateRelationEndB(DRelation *relation, DObject *targetObject)
|
||||
{
|
||||
return relocateRelationEnd(relation, targetObject, &MRelation::endBUid, &MRelation::setEndBUid);
|
||||
}
|
||||
|
||||
bool DiagramSceneController::isAddingAllowed(const Uid &modelElementKey, MDiagram *diagram)
|
||||
{
|
||||
MElement *modelElement = m_modelController->findElement(modelElementKey);
|
||||
QMT_CHECK(modelElement);
|
||||
if (m_diagramController->hasDelegate(modelElement, diagram))
|
||||
return false;
|
||||
if (auto modelRelation = dynamic_cast<MRelation *>(modelElement)) {
|
||||
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
|
||||
if (!endADiagramObject)
|
||||
return false;
|
||||
|
||||
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
|
||||
if (!endBDiagramObject)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DiagramSceneController::addExistingModelElement(const Uid &modelElementKey, const QPointF &pos, MDiagram *diagram)
|
||||
{
|
||||
DElement *element = addModelElement(modelElementKey, pos, diagram);
|
||||
if (element)
|
||||
emit elementAdded(element, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::dropNewElement(const QString &newElementId, const QString &name, const QString &stereotype,
|
||||
DElement *topMostElementAtPos, const QPointF &pos, MDiagram *diagram)
|
||||
{
|
||||
if (newElementId == QLatin1String(ELEMENT_TYPE_ANNOTATION)) {
|
||||
auto annotation = new DAnnotation();
|
||||
annotation->setText(QStringLiteral(""));
|
||||
annotation->setPos(pos - QPointF(10.0, 10.0));
|
||||
m_diagramController->addElement(annotation, diagram);
|
||||
alignOnRaster(annotation, diagram);
|
||||
emit newElementCreated(annotation, diagram);
|
||||
} else if (newElementId == QLatin1String(ELEMENT_TYPE_BOUNDARY)) {
|
||||
auto boundary = new DBoundary();
|
||||
boundary->setPos(pos);
|
||||
m_diagramController->addElement(boundary, diagram);
|
||||
alignOnRaster(boundary, diagram);
|
||||
emit newElementCreated(boundary, diagram);
|
||||
} else {
|
||||
MPackage *parentPackage = findSuitableParentPackage(topMostElementAtPos, diagram);
|
||||
MObject *newObject = 0;
|
||||
QString newName;
|
||||
if (newElementId == QLatin1String(ELEMENT_TYPE_PACKAGE)) {
|
||||
auto package = new MPackage();
|
||||
newName = tr("New Package");
|
||||
if (!stereotype.isEmpty())
|
||||
package->setStereotypes(QStringList() << stereotype);
|
||||
newObject = package;
|
||||
} else if (newElementId == QLatin1String(ELEMENT_TYPE_COMPONENT)) {
|
||||
auto component = new MComponent();
|
||||
newName = tr("New Component");
|
||||
if (!stereotype.isEmpty())
|
||||
component->setStereotypes(QStringList() << stereotype);
|
||||
newObject = component;
|
||||
} else if (newElementId == QLatin1String(ELEMENT_TYPE_CLASS)) {
|
||||
auto klass = new MClass();
|
||||
newName = tr("New Class");
|
||||
if (!stereotype.isEmpty())
|
||||
klass->setStereotypes(QStringList() << stereotype);
|
||||
newObject = klass;
|
||||
} else if (newElementId == QLatin1String(ELEMENT_TYPE_ITEM)) {
|
||||
auto item = new MItem();
|
||||
newName = tr("New Item");
|
||||
if (!stereotype.isEmpty()) {
|
||||
item->setVariety(stereotype);
|
||||
item->setVarietyEditable(false);
|
||||
}
|
||||
newObject = item;
|
||||
}
|
||||
if (newObject) {
|
||||
if (!name.isEmpty())
|
||||
newName = tr("New %1").arg(name);
|
||||
newObject->setName(newName);
|
||||
dropNewModelElement(newObject, parentPackage, pos, diagram);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramSceneController::dropNewModelElement(MObject *modelObject, MPackage *parentPackage, const QPointF &pos,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
m_modelController->undoController()->beginMergeSequence(tr("Drop Element"));
|
||||
m_modelController->addObject(parentPackage, modelObject);
|
||||
DElement *element = addObject(modelObject, pos, diagram);
|
||||
m_modelController->undoController()->endMergeSequence();
|
||||
if (element)
|
||||
emit newElementCreated(element, diagram);
|
||||
}
|
||||
|
||||
MPackage *DiagramSceneController::findSuitableParentPackage(DElement *topmostDiagramElement, MDiagram *diagram)
|
||||
{
|
||||
MPackage *parentPackage = 0;
|
||||
if (auto diagramPackage = dynamic_cast<DPackage *>(topmostDiagramElement)) {
|
||||
parentPackage = m_modelController->findObject<MPackage>(diagramPackage->modelUid());
|
||||
} else if (auto diagramObject = dynamic_cast<DObject *>(topmostDiagramElement)) {
|
||||
MObject *modelObject = m_modelController->findObject(diagramObject->modelUid());
|
||||
if (modelObject)
|
||||
parentPackage = dynamic_cast<MPackage *>(modelObject->owner());
|
||||
}
|
||||
if (parentPackage == 0 && diagram != 0)
|
||||
parentPackage = dynamic_cast<MPackage *>(diagram->owner());
|
||||
if (parentPackage == 0)
|
||||
parentPackage = m_modelController->rootPackage();
|
||||
return parentPackage;
|
||||
}
|
||||
|
||||
MDiagram *DiagramSceneController::findDiagramBySearchId(MPackage *package, const QString &diagramName)
|
||||
{
|
||||
QString diagramSearchId = NameController::calcElementNameSearchId(diagramName);
|
||||
foreach (const Handle<MObject> &handle, package->children()) {
|
||||
if (handle.hasTarget()) {
|
||||
if (auto diagram = dynamic_cast<MDiagram *>(handle.target())) {
|
||||
if (NameController::calcElementNameSearchId(diagram->name()) == diagramSearchId)
|
||||
return diagram;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
static QPointF alignObjectLeft(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal left = object->pos().x() + object->rect().left();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherLeft = pos.x() + otherObject->rect().left();
|
||||
qreal delta = otherLeft - left;
|
||||
pos.setX(pos.x() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QPointF alignObjectRight(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal right = object->pos().x() + object->rect().right();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherRight = pos.x() + otherObject->rect().right();
|
||||
qreal delta = otherRight - right;
|
||||
pos.setX(pos.x() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QPointF alignObjectHCenter(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal center = object->pos().x();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherCenter = pos.x();
|
||||
qreal delta = otherCenter - center;
|
||||
pos.setX(pos.x() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QPointF alignObjectTop(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal top = object->pos().y() + object->rect().top();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherTop = pos.y() + otherObject->rect().top();
|
||||
qreal delta = otherTop - top;
|
||||
pos.setY(pos.y() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QPointF alignObjectBottom(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal bottom = object->pos().y() + object->rect().bottom();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherBottom = pos.y() + otherObject->rect().bottom();
|
||||
qreal delta = otherBottom - bottom;
|
||||
pos.setY(pos.y() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QPointF alignObjectVCenter(DObject *object, DObject *otherObject)
|
||||
{
|
||||
qreal center = object->pos().y();
|
||||
QPointF pos = otherObject->pos();
|
||||
qreal otherCenter = pos.y();
|
||||
qreal delta = otherCenter - center;
|
||||
pos.setY(pos.y() - delta);
|
||||
return pos;
|
||||
}
|
||||
|
||||
static QRectF alignObjectWidth(DObject *object, const QSizeF &size)
|
||||
{
|
||||
QRectF rect = object->rect();
|
||||
rect.setX(-size.width() / 2.0);
|
||||
rect.setWidth(size.width());
|
||||
return rect;
|
||||
}
|
||||
|
||||
static QRectF alignObjectHeight(DObject *object, const QSizeF &size)
|
||||
{
|
||||
QRectF rect = object->rect();
|
||||
rect.setY(-size.height() / 2.0);
|
||||
rect.setHeight(size.height());
|
||||
return rect;
|
||||
}
|
||||
|
||||
static QRectF alignObjectSize(DObject *object, const QSizeF &size)
|
||||
{
|
||||
Q_UNUSED(object);
|
||||
|
||||
QRectF rect;
|
||||
rect.setX(-size.width() / 2.0);
|
||||
rect.setY(-size.height() / 2.0);
|
||||
rect.setWidth(size.width());
|
||||
rect.setHeight(size.height());
|
||||
return rect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignLeft(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectLeft, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignRight(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectRight, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignHCenter(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectHCenter, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignTop(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectTop, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignBottom(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectBottom, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignVCenter(DObject *object, const DSelection &selection, MDiagram *diagram)
|
||||
{
|
||||
alignPosition(object, selection, alignObjectVCenter, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignWidth(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
alignSize(object, selection, minimumSize, alignObjectWidth, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignHeight(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
alignSize(object, selection, minimumSize, alignObjectHeight, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignSize(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
alignSize(object, selection, minimumSize, alignObjectSize, diagram);
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignPosition(DObject *object, const DSelection &selection,
|
||||
QPointF (*aligner)(DObject *, DObject *), MDiagram *diagram)
|
||||
{
|
||||
foreach (const DSelection::Index &index, selection.indices()) {
|
||||
DElement *element = m_diagramController->findElement(index.elementKey(), diagram);
|
||||
if (auto selectedObject = dynamic_cast<DObject *>(element)) {
|
||||
if (selectedObject != object) {
|
||||
QPointF newPos = aligner(object, selectedObject);
|
||||
if (newPos != selectedObject->pos()) {
|
||||
m_diagramController->startUpdateElement(selectedObject, diagram, DiagramController::UpdateGeometry);
|
||||
selectedObject->setPos(newPos);
|
||||
m_diagramController->finishUpdateElement(selectedObject, diagram, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignSize(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
QRectF (*aligner)(DObject *, const QSizeF &), MDiagram *diagram)
|
||||
{
|
||||
QSizeF size;
|
||||
if (object->rect().width() < minimumSize.width())
|
||||
size.setWidth(minimumSize.width());
|
||||
else
|
||||
size.setWidth(object->rect().width());
|
||||
if (object->rect().height() < minimumSize.height())
|
||||
size.setHeight(minimumSize.height());
|
||||
else
|
||||
size.setHeight(object->rect().height());
|
||||
foreach (const DSelection::Index &index, selection.indices()) {
|
||||
DElement *element = m_diagramController->findElement(index.elementKey(), diagram);
|
||||
if (auto selectedObject = dynamic_cast<DObject *>(element)) {
|
||||
QRectF newRect = aligner(selectedObject, size);
|
||||
if (newRect != selectedObject->rect()) {
|
||||
m_diagramController->startUpdateElement(selectedObject, diagram, DiagramController::UpdateGeometry);
|
||||
selectedObject->setAutoSized(false);
|
||||
selectedObject->setRect(newRect);
|
||||
m_diagramController->finishUpdateElement(selectedObject, diagram, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramSceneController::alignOnRaster(DElement *element, MDiagram *diagram)
|
||||
{
|
||||
AlignOnRasterVisitor visitor;
|
||||
visitor.setDiagramController(m_diagramController);
|
||||
visitor.setSceneInspector(m_sceneInspector);
|
||||
visitor.setDiagram(diagram);
|
||||
element->accept(&visitor);
|
||||
}
|
||||
|
||||
DElement *DiagramSceneController::addModelElement(const Uid &modelElementKey, const QPointF &pos, MDiagram *diagram)
|
||||
{
|
||||
DElement *element = 0;
|
||||
if (MObject *modelObject = m_modelController->findObject(modelElementKey)) {
|
||||
element = addObject(modelObject, pos, diagram);
|
||||
} else if (MRelation *modelRelation = m_modelController->findRelation(modelElementKey)) {
|
||||
element = addRelation(modelRelation, QList<QPointF>(), diagram);
|
||||
} else {
|
||||
QMT_CHECK(false);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
DObject *DiagramSceneController::addObject(MObject *modelObject, const QPointF &pos, MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(modelObject);
|
||||
|
||||
if (m_diagramController->hasDelegate(modelObject, diagram))
|
||||
return 0;
|
||||
|
||||
m_diagramController->undoController()->beginMergeSequence(tr("Add Element"));
|
||||
|
||||
DFactory factory;
|
||||
modelObject->accept(&factory);
|
||||
auto diagramObject = dynamic_cast<DObject *>(factory.product());
|
||||
QMT_CHECK(diagramObject);
|
||||
diagramObject->setPos(pos);
|
||||
m_diagramController->addElement(diagramObject, diagram);
|
||||
alignOnRaster(diagramObject, diagram);
|
||||
|
||||
// add all relations between any other element on diagram and new element
|
||||
foreach (DElement *delement, diagram->diagramElements()) {
|
||||
if (delement != diagramObject) {
|
||||
auto dobject = dynamic_cast<DObject *>(delement);
|
||||
if (dobject) {
|
||||
MObject *mobject = m_modelController->findObject(dobject->modelUid());
|
||||
if (mobject) {
|
||||
foreach (const Handle<MRelation> &handle, mobject->relations()) {
|
||||
if (handle.hasTarget()
|
||||
&& ((handle.target()->endAUid() == modelObject->uid()
|
||||
&& handle.target()->endBUid() == mobject->uid())
|
||||
|| (handle.target()->endAUid() == mobject->uid()
|
||||
&& handle.target()->endBUid() == modelObject->uid()))) {
|
||||
addRelation(handle.target(), QList<QPointF>(), diagram);
|
||||
}
|
||||
}
|
||||
foreach (const Handle<MRelation> &handle, modelObject->relations()) {
|
||||
if (handle.hasTarget()
|
||||
&& ((handle.target()->endAUid() == modelObject->uid()
|
||||
&& handle.target()->endBUid() == mobject->uid())
|
||||
|| (handle.target()->endAUid() == mobject->uid()
|
||||
&& handle.target()->endBUid() == modelObject->uid()))) {
|
||||
addRelation(handle.target(), QList<QPointF>(), diagram);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add all self relations
|
||||
foreach (const Handle<MRelation> &handle, modelObject->relations()) {
|
||||
if (handle.hasTarget ()
|
||||
&& handle.target()->endAUid() == modelObject->uid()
|
||||
&& handle.target()->endBUid() == modelObject->uid()) {
|
||||
addRelation(handle.target(), QList<QPointF>(), diagram);
|
||||
}
|
||||
}
|
||||
|
||||
m_diagramController->undoController()->endMergeSequence();
|
||||
|
||||
return diagramObject;
|
||||
}
|
||||
|
||||
DRelation *DiagramSceneController::addRelation(MRelation *modelRelation, const QList<QPointF> &intermediatePoints,
|
||||
MDiagram *diagram)
|
||||
{
|
||||
QMT_CHECK(modelRelation);
|
||||
|
||||
if (m_diagramController->hasDelegate(modelRelation, diagram))
|
||||
return 0;
|
||||
|
||||
DFactory factory;
|
||||
modelRelation->accept(&factory);
|
||||
auto diagramRelation = dynamic_cast<DRelation *>(factory.product());
|
||||
QMT_CHECK(diagramRelation);
|
||||
|
||||
MObject *endAModelObject = m_modelController->findObject(modelRelation->endAUid());
|
||||
QMT_CHECK(endAModelObject);
|
||||
DObject *endADiagramObject = m_diagramController->findDelegate<DObject>(endAModelObject, diagram);
|
||||
QMT_CHECK(endADiagramObject);
|
||||
diagramRelation->setEndAUid(endADiagramObject->uid());
|
||||
|
||||
MObject *endBModelObject = m_modelController->findObject(modelRelation->endBUid());
|
||||
QMT_CHECK(endBModelObject);
|
||||
DObject *endBDiagramObject = m_diagramController->findDelegate<DObject>(endBModelObject, diagram);
|
||||
QMT_CHECK(endBDiagramObject);
|
||||
diagramRelation->setEndBUid(endBDiagramObject->uid());
|
||||
|
||||
QList<DRelation::IntermediatePoint> relationPoints;
|
||||
if (endADiagramObject->uid() == endBDiagramObject->uid() && intermediatePoints.isEmpty()) {
|
||||
// create some intermediate points for self-relation
|
||||
QRectF rect = endADiagramObject->rect().translated(endADiagramObject->pos());
|
||||
static const qreal EDGE_RADIUS = 30.0;
|
||||
qreal w = rect.width() * 0.25;
|
||||
if (w > EDGE_RADIUS)
|
||||
w = EDGE_RADIUS;
|
||||
qreal h = rect.height() * 0.25;
|
||||
if (h > EDGE_RADIUS)
|
||||
h = EDGE_RADIUS;
|
||||
QPointF i1(rect.x() - EDGE_RADIUS, rect.bottom() - h);
|
||||
QPointF i2(rect.x() - EDGE_RADIUS, rect.bottom() + EDGE_RADIUS);
|
||||
QPointF i3(rect.x() + w, rect.bottom() + EDGE_RADIUS);
|
||||
relationPoints.append(DRelation::IntermediatePoint(i1));
|
||||
relationPoints.append(DRelation::IntermediatePoint(i2));
|
||||
relationPoints.append(DRelation::IntermediatePoint(i3));
|
||||
} else {
|
||||
foreach (const QPointF &intermediatePoint, intermediatePoints)
|
||||
relationPoints.append(DRelation::IntermediatePoint(intermediatePoint));
|
||||
}
|
||||
diagramRelation->setIntermediatePoints(relationPoints);
|
||||
|
||||
m_diagramController->addElement(diagramRelation, diagram);
|
||||
alignOnRaster(diagramRelation, diagram);
|
||||
|
||||
return diagramRelation;
|
||||
}
|
||||
|
||||
bool DiagramSceneController::relocateRelationEnd(DRelation *relation, DObject *targetObject,
|
||||
Uid (MRelation::*endUid)() const,
|
||||
void (MRelation::*setEndUid)(const Uid &))
|
||||
{
|
||||
QMT_CHECK(relation);
|
||||
if (targetObject && targetObject->uid() != relation->endAUid()) {
|
||||
MRelation *modelRelation = m_modelController->findRelation(relation->modelUid());
|
||||
QMT_CHECK(modelRelation);
|
||||
MObject *targetMObject = m_modelController->findObject(targetObject->modelUid());
|
||||
QMT_CHECK(targetMObject);
|
||||
AcceptRelationVisitor visitor(modelRelation);
|
||||
targetMObject->accept(&visitor);
|
||||
if (visitor.isAccepted()) {
|
||||
MObject *currentTargetMObject = m_modelController->findObject((modelRelation->*endUid)());
|
||||
QMT_CHECK(currentTargetMObject);
|
||||
m_modelController->undoController()->beginMergeSequence(tr("Relocate Relation"));
|
||||
if (currentTargetMObject == modelRelation->owner())
|
||||
m_modelController->moveRelation(targetMObject, modelRelation);
|
||||
m_modelController->startUpdateRelation(modelRelation);
|
||||
(modelRelation->*setEndUid)(targetMObject->uid());
|
||||
m_modelController->finishUpdateRelation(modelRelation, false);
|
||||
m_modelController->undoController()->endMergeSequence();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace qmt
|
||||
142
src/libs/modelinglib/qmt/tasks/diagramscenecontroller.h
Normal file
142
src/libs/modelinglib/qmt/tasks/diagramscenecontroller.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_DIAGRAMSCENECONTROLLER_H
|
||||
#define QMT_DIAGRAMSCENECONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qmt/infrastructure/qmt_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPointF;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class Uid;
|
||||
class ModelController;
|
||||
class DiagramController;
|
||||
class MObject;
|
||||
class MPackage;
|
||||
class MDiagram;
|
||||
class MRelation;
|
||||
class DElement;
|
||||
class DObject;
|
||||
class DClass;
|
||||
class DRelation;
|
||||
class DSelection;
|
||||
class IElementTasks;
|
||||
class ISceneInspector;
|
||||
|
||||
class QMT_EXPORT DiagramSceneController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class AcceptRelationVisitor;
|
||||
|
||||
public:
|
||||
explicit DiagramSceneController(QObject *parent = 0);
|
||||
~DiagramSceneController() override;
|
||||
|
||||
signals:
|
||||
void newElementCreated(DElement *element, MDiagram *diagram);
|
||||
void elementAdded(DElement *element, MDiagram *diagram);
|
||||
|
||||
public:
|
||||
ModelController *modelController() const { return m_modelController; }
|
||||
void setModelController(ModelController *modelController);
|
||||
DiagramController *diagramController() const { return m_diagramController; }
|
||||
void setDiagramController(DiagramController *diagramController);
|
||||
IElementTasks *elementTasks() const { return m_elementTasks; }
|
||||
void setElementTasks(IElementTasks *elementTasks);
|
||||
ISceneInspector *sceneInspector() const { return m_sceneInspector; }
|
||||
void setSceneInspector(ISceneInspector *sceneInspector);
|
||||
|
||||
void deleteFromDiagram(const DSelection &dselection, MDiagram *diagram);
|
||||
|
||||
void createDependency(DObject *endAObject, DObject *endBObject,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram);
|
||||
void createInheritance(DClass *derivedClass, DClass *baseClass,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram);
|
||||
void createAssociation(DClass *endAClass, DClass *endBClass,
|
||||
const QList<QPointF> &intermediatePoints, MDiagram *diagram);
|
||||
bool relocateRelationEndA(DRelation *relation, DObject *targetObject);
|
||||
bool relocateRelationEndB(DRelation *relation, DObject *targetObject);
|
||||
|
||||
bool isAddingAllowed(const Uid &modelElementKey, MDiagram *diagram);
|
||||
void addExistingModelElement(const Uid &modelElementKey, const QPointF &pos, MDiagram *diagram);
|
||||
void dropNewElement(const QString &newElementId, const QString &name, const QString &stereotype,
|
||||
DElement *topMostElementAtPos, const QPointF &pos, MDiagram *diagram);
|
||||
void dropNewModelElement(MObject *modelObject, MPackage *parentPackage, const QPointF &pos,
|
||||
MDiagram *diagram);
|
||||
|
||||
MPackage *findSuitableParentPackage(DElement *topmostDiagramElement, MDiagram *diagram);
|
||||
MDiagram *findDiagramBySearchId(MPackage *package, const QString &diagramName);
|
||||
|
||||
void alignLeft(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignRight(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignHCenter(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignTop(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignBottom(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignVCenter(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void alignWidth(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram);
|
||||
void alignHeight(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram);
|
||||
void alignSize(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
MDiagram *diagram);
|
||||
void distributeHorizontal(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void distributeVertical(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
void distributeField(DObject *object, const DSelection &selection, MDiagram *diagram);
|
||||
|
||||
private:
|
||||
void alignPosition(DObject *object, const DSelection &selection,
|
||||
QPointF (*aligner)(DObject *object, DObject *otherObject),
|
||||
MDiagram *diagram);
|
||||
void alignSize(DObject *object, const DSelection &selection, const QSizeF &minimumSize,
|
||||
QRectF (*aligner)(DObject *, const QSizeF &), MDiagram *diagram);
|
||||
void alignOnRaster(DElement *element, MDiagram *diagram);
|
||||
|
||||
DElement *addModelElement(const Uid &modelElementKey, const QPointF &pos, MDiagram *diagram);
|
||||
DObject *addObject(MObject *modelObject, const QPointF &pos, MDiagram *diagram);
|
||||
DRelation *addRelation(MRelation *modelRelation, const QList<QPointF> &intermediatePoints,
|
||||
MDiagram *diagram);
|
||||
bool relocateRelationEnd(DRelation *relation, DObject *targetObject, Uid (MRelation::*endUid)() const,
|
||||
void (MRelation::*setEndUid)(const Uid &));
|
||||
|
||||
ModelController *m_modelController;
|
||||
DiagramController *m_diagramController;
|
||||
IElementTasks *m_elementTasks;
|
||||
ISceneInspector *m_sceneInspector;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_DIAGRAMSCENECONTROLLER_H
|
||||
65
src/libs/modelinglib/qmt/tasks/finddiagramvisitor.cpp
Normal file
65
src/libs/modelinglib/qmt/tasks/finddiagramvisitor.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "finddiagramvisitor.h"
|
||||
|
||||
#include "qmt/model/mobject.h"
|
||||
#include "qmt/model/mdiagram.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
FindDiagramVisitor::FindDiagramVisitor()
|
||||
: MVoidConstVisitor(),
|
||||
m_diagram(0)
|
||||
{
|
||||
}
|
||||
|
||||
FindDiagramVisitor::~FindDiagramVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
void FindDiagramVisitor::visitMObject(const MObject *object)
|
||||
{
|
||||
foreach (const Handle<MObject> &child, object->children()) {
|
||||
if (child.hasTarget()) {
|
||||
if (auto diagram = dynamic_cast<MDiagram *>(child.target())) {
|
||||
m_diagram = diagram;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FindDiagramVisitor::visitMDiagram(const MDiagram *diagram)
|
||||
{
|
||||
m_diagram = diagram;
|
||||
}
|
||||
|
||||
} // namespace qmt
|
||||
55
src/libs/modelinglib/qmt/tasks/finddiagramvisitor.h
Normal file
55
src/libs/modelinglib/qmt/tasks/finddiagramvisitor.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_FINDDIAGRAMVISITOR_H
|
||||
#define QMT_FINDDIAGRAMVISITOR_H
|
||||
|
||||
#include "qmt/model_controller/mvoidvisitor.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class QMT_EXPORT FindDiagramVisitor : public MVoidConstVisitor
|
||||
{
|
||||
public:
|
||||
FindDiagramVisitor();
|
||||
~FindDiagramVisitor() override;
|
||||
|
||||
const MDiagram *diagram() const { return m_diagram; }
|
||||
|
||||
void visitMObject(const MObject *object) override;
|
||||
void visitMDiagram(const MDiagram *diagram) override;
|
||||
|
||||
private:
|
||||
const MDiagram *m_diagram;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_FINDDIAGRAMVISITOR_H
|
||||
70
src/libs/modelinglib/qmt/tasks/findrootdiagramvisitor.cpp
Normal file
70
src/libs/modelinglib/qmt/tasks/findrootdiagramvisitor.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "findrootdiagramvisitor.h"
|
||||
|
||||
#include "qmt/model/mdiagram.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
FindRootDiagramVisitor::FindRootDiagramVisitor()
|
||||
: MVoidVisitor(),
|
||||
m_diagram(0)
|
||||
{
|
||||
}
|
||||
|
||||
FindRootDiagramVisitor::~FindRootDiagramVisitor()
|
||||
{
|
||||
}
|
||||
|
||||
void FindRootDiagramVisitor::visitMObject(MObject *object)
|
||||
{
|
||||
// first search flat
|
||||
foreach(const Handle<MObject> &child, object->children()) {
|
||||
if (child.hasTarget()) {
|
||||
auto diagram = dynamic_cast<MDiagram *>(child.target());
|
||||
if (diagram) {
|
||||
m_diagram = diagram;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// then search in children
|
||||
foreach(const Handle<MObject> &child, object->children()) {
|
||||
if (child.hasTarget()) {
|
||||
child.target()->accept(this);
|
||||
if (m_diagram)
|
||||
return;
|
||||
}
|
||||
}
|
||||
visitMElement(object);
|
||||
}
|
||||
|
||||
} // namespace qmt
|
||||
56
src/libs/modelinglib/qmt/tasks/findrootdiagramvisitor.h
Normal file
56
src/libs/modelinglib/qmt/tasks/findrootdiagramvisitor.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_FINDROOTDIAGRAMVISITOR_H
|
||||
#define QMT_FINDROOTDIAGRAMVISITOR_H
|
||||
|
||||
#include "qmt/model_controller/mvoidvisitor.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class MDiagram;
|
||||
|
||||
class QMT_EXPORT FindRootDiagramVisitor : public MVoidVisitor
|
||||
{
|
||||
public:
|
||||
FindRootDiagramVisitor();
|
||||
~FindRootDiagramVisitor() override;
|
||||
|
||||
MDiagram *diagram() const { return m_diagram; }
|
||||
|
||||
void visitMObject(MObject *object) override;
|
||||
|
||||
private:
|
||||
MDiagram *m_diagram;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_FINDROOTDIAGRAMVISITOR_H
|
||||
86
src/libs/modelinglib/qmt/tasks/ielementtasks.h
Normal file
86
src/libs/modelinglib/qmt/tasks/ielementtasks.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_IELEMENTTASKS_H
|
||||
#define QMT_IELEMENTTASKS_H
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class MElement;
|
||||
class DElement;
|
||||
class MDiagram;
|
||||
|
||||
class IElementTasks
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~IElementTasks() { }
|
||||
|
||||
virtual void openElement(const MElement *) = 0;
|
||||
virtual void openElement(const DElement *, const MDiagram *) = 0;
|
||||
|
||||
virtual bool hasClassDefinition(const MElement *) const = 0;
|
||||
virtual bool hasClassDefinition(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void openClassDefinition(const MElement *) = 0;
|
||||
virtual void openClassDefinition(const DElement *, const MDiagram *) = 0;
|
||||
|
||||
virtual bool hasHeaderFile(const MElement *) const = 0;
|
||||
virtual bool hasHeaderFile(const DElement *, const MDiagram *) const = 0;
|
||||
virtual bool hasSourceFile(const MElement *) const = 0;
|
||||
virtual bool hasSourceFile(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void openHeaderFile(const MElement *) = 0;
|
||||
virtual void openHeaderFile(const DElement *, const MDiagram *) = 0;
|
||||
virtual void openSourceFile(const MElement *) = 0;
|
||||
virtual void openSourceFile(const DElement *, const MDiagram *) = 0;
|
||||
|
||||
virtual bool hasFolder(const MElement *) const = 0;
|
||||
virtual bool hasFolder(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void showFolder(const MElement *) = 0;
|
||||
virtual void showFolder(const DElement *, const MDiagram *) = 0;
|
||||
|
||||
virtual bool hasDiagram(const MElement *) const = 0;
|
||||
virtual bool hasDiagram(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void openDiagram(const MElement *) = 0;
|
||||
virtual void openDiagram(const DElement *, const MDiagram *) = 0;
|
||||
|
||||
virtual bool hasParentDiagram(const MElement *) const = 0;
|
||||
virtual bool hasParentDiagram(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void openParentDiagram(const MElement *) = 0;
|
||||
virtual void openParentDiagram(const DElement *, const MElement *) = 0;
|
||||
|
||||
virtual bool mayCreateDiagram(const MElement *) const = 0;
|
||||
virtual bool mayCreateDiagram(const DElement *, const MDiagram *) const = 0;
|
||||
virtual void createAndOpenDiagram(const MElement *) = 0;
|
||||
virtual void createAndOpenDiagram(const DElement *, const MDiagram *) = 0;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_IELEMENTTASKS_H
|
||||
60
src/libs/modelinglib/qmt/tasks/isceneinspector.h
Normal file
60
src/libs/modelinglib/qmt/tasks/isceneinspector.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_ISCENEINSPECTOR_H
|
||||
#define QMT_ISCENEINSPECTOR_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSizeF;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class MDiagram;
|
||||
class DElement;
|
||||
class IMoveable;
|
||||
class IResizable;
|
||||
|
||||
class ISceneInspector
|
||||
{
|
||||
public:
|
||||
virtual ~ISceneInspector() { }
|
||||
|
||||
virtual QSizeF rasterSize() const = 0;
|
||||
virtual QSizeF minimalSize(const DElement *element, const MDiagram *diagram) const = 0;
|
||||
virtual IMoveable *moveable(const DElement *element, const MDiagram *diagram) const = 0;
|
||||
virtual IResizable *resizable(const DElement *element, const MDiagram *diagram) const = 0;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_ISCENEINSPECTOR_H
|
||||
177
src/libs/modelinglib/qmt/tasks/voidelementtasks.cpp
Normal file
177
src/libs/modelinglib/qmt/tasks/voidelementtasks.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "voidelementtasks.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
VoidElementTasks::VoidElementTasks()
|
||||
{
|
||||
}
|
||||
|
||||
VoidElementTasks::~VoidElementTasks()
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openElement(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openElement(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasClassDefinition(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasClassDefinition(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::openClassDefinition(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openClassDefinition(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasHeaderFile(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasHeaderFile(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasSourceFile(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasSourceFile(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::openHeaderFile(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openHeaderFile(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openSourceFile(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openSourceFile(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasFolder(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasFolder(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::showFolder(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::showFolder(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasDiagram(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasDiagram(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::openDiagram(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openDiagram(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasParentDiagram(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::hasParentDiagram(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::openParentDiagram(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::openParentDiagram(const DElement *, const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidElementTasks::mayCreateDiagram(const MElement *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidElementTasks::mayCreateDiagram(const DElement *, const MDiagram *) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VoidElementTasks::createAndOpenDiagram(const MElement *)
|
||||
{
|
||||
}
|
||||
|
||||
void VoidElementTasks::createAndOpenDiagram(const DElement *, const MDiagram *)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace qmt
|
||||
85
src/libs/modelinglib/qmt/tasks/voidelementtasks.h
Normal file
85
src/libs/modelinglib/qmt/tasks/voidelementtasks.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Jochen Becher
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMT_VOIDELEMENTTASKS_H
|
||||
#define QMT_VOIDELEMENTTASKS_H
|
||||
|
||||
#include "ielementtasks.h"
|
||||
#include "qmt/infrastructure/qmt_global.h"
|
||||
|
||||
namespace qmt {
|
||||
|
||||
class QMT_EXPORT VoidElementTasks : public IElementTasks
|
||||
{
|
||||
public:
|
||||
VoidElementTasks();
|
||||
~VoidElementTasks() override;
|
||||
|
||||
void openElement(const MElement *) override;
|
||||
void openElement(const DElement *, const MDiagram *) override;
|
||||
|
||||
bool hasClassDefinition(const MElement *) const override;
|
||||
bool hasClassDefinition(const DElement *, const MDiagram *) const override;
|
||||
void openClassDefinition(const MElement *) override;
|
||||
void openClassDefinition(const DElement *, const MDiagram *) override;
|
||||
|
||||
bool hasHeaderFile(const MElement *) const override;
|
||||
bool hasHeaderFile(const DElement *, const MDiagram *) const override;
|
||||
bool hasSourceFile(const MElement *) const override;
|
||||
bool hasSourceFile(const DElement *, const MDiagram *) const override;
|
||||
void openHeaderFile(const MElement *) override;
|
||||
void openHeaderFile(const DElement *, const MDiagram *) override;
|
||||
void openSourceFile(const MElement *) override;
|
||||
void openSourceFile(const DElement *, const MDiagram *) override;
|
||||
|
||||
bool hasFolder(const MElement *) const override;
|
||||
bool hasFolder(const DElement *, const MDiagram *) const override;
|
||||
void showFolder(const MElement *) override;
|
||||
void showFolder(const DElement *, const MDiagram *) override;
|
||||
|
||||
bool hasDiagram(const MElement *) const override;
|
||||
bool hasDiagram(const DElement *, const MDiagram *) const override;
|
||||
void openDiagram(const MElement *) override;
|
||||
void openDiagram(const DElement *, const MDiagram *) override;
|
||||
|
||||
bool hasParentDiagram(const MElement *) const override;
|
||||
bool hasParentDiagram(const DElement *, const MDiagram *) const override;
|
||||
void openParentDiagram(const MElement *) override;
|
||||
void openParentDiagram(const DElement *, const MElement *) override;
|
||||
|
||||
bool mayCreateDiagram(const qmt::MElement *) const override;
|
||||
bool mayCreateDiagram(const qmt::DElement *, const qmt::MDiagram *) const override;
|
||||
void createAndOpenDiagram(const qmt::MElement *) override;
|
||||
void createAndOpenDiagram(const qmt::DElement *, const qmt::MDiagram *) override;
|
||||
};
|
||||
|
||||
} // namespace qmt
|
||||
|
||||
#endif // QMT_VOIDELEMENTTASKS_H
|
||||
Reference in New Issue
Block a user