Skip to content

Commit

Permalink
- Display the bitmap is library browser.
Browse files Browse the repository at this point in the history
- Handle the extends class bitmaps.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19610 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 17, 2014
1 parent 2a96d05 commit 9c1e51f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 37 deletions.
8 changes: 5 additions & 3 deletions OMEdit/OMEditGUI/Annotations/BitmapAnnotation.cpp
Expand Up @@ -37,9 +37,10 @@

#include "BitmapAnnotation.h"

BitmapAnnotation::BitmapAnnotation(QString annotation, Component *pParent)
BitmapAnnotation::BitmapAnnotation(QString classFileName, QString annotation, Component *pParent)
: ShapeAnnotation(pParent), mpComponent(pParent)
{
mClassFileName = classFileName;
// set the default values
GraphicItem::setDefaults();
ShapeAnnotation::setDefaults();
Expand All @@ -48,11 +49,12 @@ BitmapAnnotation::BitmapAnnotation(QString annotation, Component *pParent)
setRotation(mRotation);
}

BitmapAnnotation::BitmapAnnotation(QString annotation, bool inheritedShape, GraphicsView *pGraphicsView)
BitmapAnnotation::BitmapAnnotation(QString classFileName, QString annotation, bool inheritedShape, GraphicsView *pGraphicsView)
: ShapeAnnotation(inheritedShape, pGraphicsView, 0)
{
setFlag(QGraphicsItem::ItemIsSelectable);
mpComponent = 0;
mClassFileName = classFileName;
// set the default values
GraphicItem::setDefaults();
ShapeAnnotation::setDefaults();
Expand Down Expand Up @@ -149,7 +151,7 @@ QString BitmapAnnotation::getShapeAnnotation()

void BitmapAnnotation::duplicate()
{
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation("", false, mpGraphicsView);
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(mClassFileName, "", false, mpGraphicsView);
QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
pBitmapAnnotation->setOrigin(mOrigin + gridStep);
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Annotations/BitmapAnnotation.h
Expand Up @@ -47,8 +47,8 @@ class BitmapAnnotation : public ShapeAnnotation
{
Q_OBJECT
public:
BitmapAnnotation(QString annotation, Component *pParent);
BitmapAnnotation(QString annotation, bool inheritedShape, GraphicsView *pGraphicsView);
BitmapAnnotation(QString classFileName, QString annotation, Component *pParent);
BitmapAnnotation(QString classFileName, QString annotation, bool inheritedShape, GraphicsView *pGraphicsView);
void parseShapeAnnotation(QString annotation);
QRectF boundingRect() const;
QPainterPath shape() const;
Expand Down
22 changes: 4 additions & 18 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -992,35 +992,21 @@ void ShapeAnnotation::setFileName(QString fileName, Component *pComponent)
return;
}

GraphicsView *pGraphicsView = 0;
OMCProxy *pOMCProxy = 0;
if (pComponent)
{
pGraphicsView = pComponent->getGraphicsView();
pOMCProxy = pComponent->getOMCProxy();
}
else if (mpGraphicsView)
{
pGraphicsView = mpGraphicsView;
pOMCProxy = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getOMCProxy();
}
pOMCProxy = pGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getOMCProxy();

mOriginalFileName = fileName;
QUrl fileUrl(mOriginalFileName);
QFileInfo fileInfo(mOriginalFileName);
QString classFileName = "";
/* if the bitmap is part of a component then read the component filename. */
if (pComponent)
{
QStringList classInformation = pOMCProxy->getClassInformation(pComponent->getClassName());
if (classInformation.size() > 2)
classFileName = classInformation.at(2);
}
/* if bitmap is part of a icon/diagram of a class then read the class filename. */
else
{
classFileName = pGraphicsView->getModelWidget()->getLibraryTreeNode()->getFileName();
}
QFileInfo classFileInfo(classFileName);
QFileInfo classFileInfo(mClassFileName);

/* if its a modelica:// link then make it absolute path */
if (fileUrl.scheme().toLower().compare("modelica") == 0)
{
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h
Expand Up @@ -215,6 +215,7 @@ public slots:
StringHandler::TextAlignment mHorizontalAlignment;
QString mOriginalFileName;
QString mFileName;
QString mClassFileName; /* Used to find the bitmap relative locations. */
QString mImageSource;
QImage mImage;
QList<CornerItem*> mCornerItemsList;
Expand Down
18 changes: 10 additions & 8 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -327,14 +327,16 @@ void Component::parseAnnotationString(QString annotation)
}
else if (shape.startsWith("Bitmap"))
{
//! @note No Bitmaps for library icons.
if (!isLibraryComponent())
{
shape = shape.mid(QString("Bitmap").length());
shape = StringHandler::removeFirstLastBrackets(shape);
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(shape, this);
mpShapesList.append(pBitmapAnnotation);
}
/* get the class file path */
QString classFileName;
QStringList classInformation = mpOMCProxy->getClassInformation(mClassName);
if (classInformation.size() > 2)
classFileName = classInformation.at(2);
/* create the bitmap shape */
shape = shape.mid(QString("Bitmap").length());
shape = StringHandler::removeFirstLastBrackets(shape);
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(classFileName, shape, this);
mpShapesList.append(pBitmapAnnotation);
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions OMEdit/OMEditGUI/GUI/Containers/ModelWidgetContainer.cpp
Expand Up @@ -775,7 +775,7 @@ void GraphicsView::createBitmapShape(QPointF point)
if (!isCreatingBitmapShape())
{
setIsCreatingBitmapShape(true);
mpBitmapShapeAnnotation = new BitmapAnnotation("", false, this);
mpBitmapShapeAnnotation = new BitmapAnnotation(mpModelWidget->getLibraryTreeNode()->getFileName(), "", false, this);
mpBitmapShapeAnnotation->replaceExtent(0, point);
mpBitmapShapeAnnotation->replaceExtent(1, point);
}
Expand Down Expand Up @@ -2206,12 +2206,12 @@ void ModelWidget::getModelIconDiagramShapes(QString className, bool inheritedCyc
}
OMCProxy *pOMCProxy = mpModelWidgetContainer->getMainWindow()->getOMCProxy();
QString iconAnnotationString = pOMCProxy->getIconAnnotation(className);
getModelIconDiagramShapes(iconAnnotationString, StringHandler::Icon, inheritedCycle);
getModelIconDiagramShapes(className, iconAnnotationString, StringHandler::Icon, inheritedCycle);
QString diagramAnnotationString = pOMCProxy->getDiagramAnnotation(className);
getModelIconDiagramShapes(diagramAnnotationString, StringHandler::Diagram, inheritedCycle);
getModelIconDiagramShapes(className, diagramAnnotationString, StringHandler::Diagram, inheritedCycle);
}

void ModelWidget::getModelIconDiagramShapes(QString annotationString, StringHandler::ViewType viewType, bool inheritedCycle)
void ModelWidget::getModelIconDiagramShapes(QString className, QString annotationString, StringHandler::ViewType viewType, bool inheritedCycle)
{
annotationString = StringHandler::removeFirstLastCurlBrackets(annotationString);
if (annotationString.isEmpty())
Expand Down Expand Up @@ -2308,9 +2308,15 @@ void ModelWidget::getModelIconDiagramShapes(QString annotationString, StringHand
}
else if (shape.startsWith("Bitmap"))
{
/* get the class file path */
QString classFileName;
QStringList classInformation = mpModelWidgetContainer->getMainWindow()->getOMCProxy()->getClassInformation(className);
if (classInformation.size() > 2)
classFileName = classInformation.at(2);
/* create the bitmap shape */
shape = shape.mid(QString("Bitmap").length());
shape = StringHandler::removeFirstLastBrackets(shape);
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(shape, inheritedCycle, pGraphicsView);
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(classFileName, shape, inheritedCycle, pGraphicsView);
pBitmapAnnotation->initializeTransformation();
pBitmapAnnotation->drawCornerItems();
pBitmapAnnotation->setCornerItemsPassive();
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/GUI/Containers/ModelWidgetContainer.h
Expand Up @@ -300,7 +300,7 @@ class ModelWidget : public QWidget
void updateParentModelsText(QString className);
void getModelComponents(QString className, bool inheritedCycle = false);
void getModelIconDiagramShapes(QString className, bool inheritedCycle = false);
void getModelIconDiagramShapes(QString annotationString, StringHandler::ViewType viewType, bool inheritedCycle = false);
void getModelIconDiagramShapes(QString className, QString annotationString, StringHandler::ViewType viewType, bool inheritedCycle = false);
void getModelConnections(QString className, bool inheritedCycle = false);
Component* getConnectorComponent(Component *pConnectorComponent, QString connectorName);
void refresh();
Expand Down

0 comments on commit 9c1e51f

Please sign in to comment.