Skip to content

Commit

Permalink
- Do not allow selecting or moving the shapes when user is making a c…
Browse files Browse the repository at this point in the history
…onnection.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21076 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jun 12, 2014
1 parent 0e62f93 commit 5f52cbd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Annotations/EllipseAnnotation.cpp
Expand Up @@ -38,7 +38,6 @@

#include "EllipseAnnotation.h"


EllipseAnnotation::EllipseAnnotation(QString annotation, Component *pParent)
: ShapeAnnotation(pParent)
{
Expand Down
26 changes: 26 additions & 0 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -684,6 +684,32 @@ void LineAnnotation::duplicate()
mpGraphicsView->setCanAddClassAnnotation(true);
}

/*!
Reimplementation of mousePressEvent.\n
Checks if user is making a connection then makes the Line unselectable.\n
\param event - QGraphicsSceneMouseEvent
\see ShapeAnnotation::mousePressEvent
*/
void LineAnnotation::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if ((mLineType == LineAnnotation::ConnectionType || mLineType == LineAnnotation::ShapeType) && mpGraphicsView)
{
if (mpGraphicsView->isCreatingConnection())
{
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
else
{
setFlag(QGraphicsItem::ItemIsSelectable, true);
/* Only set the ItemIsMovable flag on shape if the class is not a system library class OR shape is not an inherited shape. */
if (!mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() && !isInheritedShape())
setFlag(QGraphicsItem::ItemIsMovable, true);
}
}
QGraphicsItem::mousePressEvent(event);
}

ConnectionArray::ConnectionArray(GraphicsView *pGraphicsView, LineAnnotation *pConnectionLineAnnotation, QWidget *pParent)
: QDialog(pParent, Qt::WindowTitleHint), mpGraphicsView(pGraphicsView), mpConnectionLineAnnotation(pConnectionLineAnnotation)
{
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.h
Expand Up @@ -91,6 +91,8 @@ public slots:
void handleComponentRotation();
void updateConnectionAnnotation();
void duplicate();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
};

class ConnectionArray : public QDialog
Expand Down
27 changes: 27 additions & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -1625,3 +1625,30 @@ QVariant ShapeAnnotation::itemChange(GraphicsItemChange change, const QVariant &
}
return value;
}

/*!
Reimplementation of mousePressEvent.\n
Checks if user is making a connection then makes all the shapes unselectable except Line.\n
Line shape is bit different so it is handled in its own class LineAnnotation.
\param event - QGraphicsSceneMouseEvent
\see LineAnnotation::mousePressEvent
*/
void ShapeAnnotation::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mpGraphicsView)
{
if (mpGraphicsView->isCreatingConnection())
{
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
else
{
setFlag(QGraphicsItem::ItemIsSelectable, true);
/* Only set the ItemIsMovable flag on shape if the class is not a system library class OR shape is not an inherited shape. */
if (!mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() && !isInheritedShape())
setFlag(QGraphicsItem::ItemIsMovable, true);
}
}
QGraphicsItem::mousePressEvent(event);
}
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h
Expand Up @@ -222,6 +222,7 @@ public slots:
QList<CornerItem*> mCornerItemsList;
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
};

#endif // SHAPEANNOTATION_H

0 comments on commit 5f52cbd

Please sign in to comment.