Skip to content

Commit

Permalink
Fixes #2711. Better handling of class components.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Sep 30, 2015
1 parent ea7b44a commit 703263b
Show file tree
Hide file tree
Showing 30 changed files with 1,035 additions and 1,248 deletions.
7 changes: 6 additions & 1 deletion OMEdit/OMEditGUI/Annotations/BitmapAnnotation.cpp
Expand Up @@ -56,6 +56,10 @@ BitmapAnnotation::BitmapAnnotation(ShapeAnnotation *pShapeAnnotation, Component
updateShape(pShapeAnnotation);
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
}

BitmapAnnotation::BitmapAnnotation(QString classFileName, QString annotation, GraphicsView *pGraphicsView)
Expand All @@ -70,6 +74,7 @@ BitmapAnnotation::BitmapAnnotation(QString classFileName, QString annotation, Gr
ShapeAnnotation::setUserDefaults();
parseShapeAnnotation(annotation);
setShapeFlags(true);
connect(this, SIGNAL(updateClassAnnotation()), this, SIGNAL(updateReferenceShapes()));
connect(this, SIGNAL(updateClassAnnotation()), mpGraphicsView, SLOT(addClassAnnotation()));
}

Expand All @@ -80,7 +85,7 @@ BitmapAnnotation::BitmapAnnotation(ShapeAnnotation *pShapeAnnotation, GraphicsVi
updateShape(pShapeAnnotation);
setShapeFlags(true);
mpGraphicsView->scene()->addItem(this);
connect(pShapeAnnotation, SIGNAL(updateClassAnnotation()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
Expand Down
7 changes: 6 additions & 1 deletion OMEdit/OMEditGUI/Annotations/EllipseAnnotation.cpp
Expand Up @@ -56,6 +56,10 @@ EllipseAnnotation::EllipseAnnotation(ShapeAnnotation *pShapeAnnotation, Componen
updateShape(pShapeAnnotation);
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
}

EllipseAnnotation::EllipseAnnotation(QString annotation, GraphicsView *pGraphicsView)
Expand All @@ -69,6 +73,7 @@ EllipseAnnotation::EllipseAnnotation(QString annotation, GraphicsView *pGraphics
ShapeAnnotation::setUserDefaults();
parseShapeAnnotation(annotation);
setShapeFlags(true);
connect(this, SIGNAL(updateClassAnnotation()), this, SIGNAL(updateReferenceShapes()));
connect(this, SIGNAL(updateClassAnnotation()), mpGraphicsView, SLOT(addClassAnnotation()));
}

Expand All @@ -78,7 +83,7 @@ EllipseAnnotation::EllipseAnnotation(ShapeAnnotation *pShapeAnnotation, Graphics
updateShape(pShapeAnnotation);
setShapeFlags(true);
mpGraphicsView->scene()->addItem(this);
connect(pShapeAnnotation, SIGNAL(updateClassAnnotation()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
Expand Down
31 changes: 30 additions & 1 deletion OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -61,6 +61,34 @@ LineAnnotation::LineAnnotation(ShapeAnnotation *pShapeAnnotation, Component *pPa
setEndComponent(0);
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
}

LineAnnotation::LineAnnotation(Component *pParent)
: ShapeAnnotation(pParent)
{
setLineType(LineAnnotation::ComponentType);
setStartComponent(0);
setEndComponent(0);
// set the default values
GraphicItem::setDefaults();
ShapeAnnotation::setDefaults();
// create a red cross
setLineColor(QColor(255, 0, 0));
// create a red cross with points
addPoint(QPointF(-100, -100));
addPoint(QPointF(100, 100));
addPoint(QPointF(-100, 100));
addPoint(QPointF(100, -100));
addPoint(QPointF(-100, -100));
addPoint(QPointF(-100, 100));
addPoint(QPointF(100, 100));
addPoint(QPointF(100, -100));
setPos(mOrigin);
setRotation(mRotation);
}

LineAnnotation::LineAnnotation(QString annotation, GraphicsView *pGraphicsView)
Expand All @@ -76,6 +104,7 @@ LineAnnotation::LineAnnotation(QString annotation, GraphicsView *pGraphicsView)
ShapeAnnotation::setUserDefaults();
parseShapeAnnotation(annotation);
setShapeFlags(true);
connect(this, SIGNAL(updateClassAnnotation()), this, SIGNAL(updateReferenceShapes()));
connect(this, SIGNAL(updateClassAnnotation()), mpGraphicsView, SLOT(addClassAnnotation()));
}

Expand Down Expand Up @@ -111,7 +140,7 @@ LineAnnotation::LineAnnotation(ShapeAnnotation *pShapeAnnotation, GraphicsView *
updateShape(pShapeAnnotation);
setShapeFlags(true);
mpGraphicsView->scene()->addItem(this);
connect(pShapeAnnotation, SIGNAL(updateClassAnnotation()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.h
Expand Up @@ -55,6 +55,7 @@ class LineAnnotation : public ShapeAnnotation
};
LineAnnotation(QString annotation, Component *pParent);
LineAnnotation(ShapeAnnotation *pShapeAnnotation, Component *pParent);
LineAnnotation(Component *pParent);
LineAnnotation(QString annotation, GraphicsView *pGraphicsView);
LineAnnotation(GraphicsView *pGraphicsView);
LineAnnotation(ShapeAnnotation *pShapeAnnotation, GraphicsView *pGraphicsView);
Expand Down
7 changes: 6 additions & 1 deletion OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp
Expand Up @@ -56,6 +56,10 @@ PolygonAnnotation::PolygonAnnotation(ShapeAnnotation *pShapeAnnotation, Componen
updateShape(pShapeAnnotation);
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
}

PolygonAnnotation::PolygonAnnotation(QString annotation, GraphicsView *pGraphicsView)
Expand All @@ -69,6 +73,7 @@ PolygonAnnotation::PolygonAnnotation(QString annotation, GraphicsView *pGraphics
ShapeAnnotation::setUserDefaults();
parseShapeAnnotation(annotation);
setShapeFlags(true);
connect(this, SIGNAL(updateClassAnnotation()), this, SIGNAL(updateReferenceShapes()));
connect(this, SIGNAL(updateClassAnnotation()), mpGraphicsView, SLOT(addClassAnnotation()));
}

Expand All @@ -78,7 +83,7 @@ PolygonAnnotation::PolygonAnnotation(ShapeAnnotation *pShapeAnnotation, Graphics
updateShape(pShapeAnnotation);
setShapeFlags(true);
mpGraphicsView->scene()->addItem(this);
connect(pShapeAnnotation, SIGNAL(updateClassAnnotation()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
Expand Down
25 changes: 24 additions & 1 deletion OMEdit/OMEditGUI/Annotations/RectangleAnnotation.cpp
Expand Up @@ -56,6 +56,28 @@ RectangleAnnotation::RectangleAnnotation(ShapeAnnotation *pShapeAnnotation, Comp
updateShape(pShapeAnnotation);
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
}

RectangleAnnotation::RectangleAnnotation(Component *pParent)
: ShapeAnnotation(pParent)
{
// set the default values
GraphicItem::setDefaults();
FilledShape::setDefaults();
ShapeAnnotation::setDefaults();
// create a grey rectangle
setLineColor(QColor(0, 0, 0));
setFillColor(QColor(240, 240, 240));
setFillPattern(StringHandler::FillSolid);
QList<QPointF> extents;
extents << QPointF(-100, -100) << QPointF(100, 100);
setExtents(extents);
setPos(mOrigin);
setRotation(mRotation);
}

RectangleAnnotation::RectangleAnnotation(QString annotation, GraphicsView *pGraphicsView)
Expand All @@ -69,6 +91,7 @@ RectangleAnnotation::RectangleAnnotation(QString annotation, GraphicsView *pGrap
ShapeAnnotation::setUserDefaults();
parseShapeAnnotation(annotation);
setShapeFlags(true);
connect(this, SIGNAL(updateClassAnnotation()), this, SIGNAL(updateReferenceShapes()));
connect(this, SIGNAL(updateClassAnnotation()), mpGraphicsView, SLOT(addClassAnnotation()));
}

Expand All @@ -78,7 +101,7 @@ RectangleAnnotation::RectangleAnnotation(ShapeAnnotation *pShapeAnnotation, Grap
updateShape(pShapeAnnotation);
setShapeFlags(true);
mpGraphicsView->scene()->addItem(this);
connect(pShapeAnnotation, SIGNAL(updateClassAnnotation()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
connect(pShapeAnnotation, SIGNAL(added()), this, SLOT(referenceShapeAdded()));
connect(pShapeAnnotation, SIGNAL(changed()), this, SLOT(referenceShapeChanged()));
connect(pShapeAnnotation, SIGNAL(deleted()), this, SLOT(referenceShapeDeleted()));
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/RectangleAnnotation.h
Expand Up @@ -50,6 +50,7 @@ class RectangleAnnotation : public ShapeAnnotation
public:
RectangleAnnotation(QString annotation, Component *pParent);
RectangleAnnotation(ShapeAnnotation *pShapeAnnotation, Component *pParent);
RectangleAnnotation(Component *pParent);
RectangleAnnotation(QString annotation, GraphicsView *pGraphicsView);
RectangleAnnotation(ShapeAnnotation *pShapeAnnotation, GraphicsView *pGraphicsView);
void parseShapeAnnotation(QString annotation);
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -1028,7 +1028,7 @@ void ShapeAnnotation::setFileName(QString fileName, Component *pComponent)
OMCProxy *pOMCProxy = 0;
if (pComponent)
{
pOMCProxy = pComponent->getOMCProxy();
pOMCProxy = pComponent->getGraphicsView()->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getOMCProxy();
}
else
{
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h
Expand Up @@ -195,6 +195,7 @@ class ShapeAnnotation : public QObject, public QGraphicsItem, public GraphicItem
void emitDeleted() {emit deleted();}
signals:
void updateClassAnnotation();
void updateReferenceShapes();
void added();
void changed();
void deleted();
Expand Down

0 comments on commit 703263b

Please sign in to comment.