Skip to content

Commit

Permalink
Added the custom sendExpression in OMCProxy.cpp
Browse files Browse the repository at this point in the history
Updated the delete feature of tree.
Updated the rename feature of tree.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6665 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Oct 27, 2010
1 parent e0454fa commit 1b0d433
Show file tree
Hide file tree
Showing 40 changed files with 1,243 additions and 314 deletions.
12 changes: 12 additions & 0 deletions OMEdit/OMEditGUI/ComponentAnnotation.cpp
Expand Up @@ -58,6 +58,18 @@ ComponentAnnotation::ComponentAnnotation(QString value, QString className, QStri
parseTransformationString(transformationStr);
}

void ComponentAnnotation::setDefaultValues()
{
mVisible = true;
mPositionX = 0;
mPositionY = 0;
mFlipHorizontal = false;
mFlipVertical = false;
mRotateAngle = 0;
mScale = 0;
mAspectRatio = 1;
}

void ComponentAnnotation::parseTransformationString(QString value)
{
value = StringHandler::removeFirstLastCurlBrackets(value);
Expand Down
6 changes: 5 additions & 1 deletion OMEdit/OMEditGUI/ComponentAnnotation.h
Expand Up @@ -62,6 +62,7 @@ class ComponentAnnotation : public ShapeAnnotation
ComponentsProperties *pComponentProperties, IconAnnotation *pParent);
ComponentAnnotation(QString value, QString className, QString transformationStr,
ComponentsProperties *pComponentProperties, IconAnnotation *pParent, bool libraryIcon);
void setDefaultValues();
void parseTransformationString(QString value);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
Expand All @@ -71,7 +72,10 @@ class ComponentAnnotation : public ShapeAnnotation
QString mClassName;
QString mIconAnnotationString;
QString mTransformationString;
QRectF mRectangle;
QRectF mRectangle; // stores the extent points
bool mPreserveAspectRatio;
qreal mInitialScale;
QList<qreal> mGrid;
qreal mPositionX;
qreal mPositionY;
ComponentsProperties *mpComponentProperties;
Expand Down
14 changes: 10 additions & 4 deletions OMEdit/OMEditGUI/ConnectorWidget.cpp
Expand Up @@ -146,7 +146,7 @@ bool Connector::isActive()
return mIsActive;
}

void Connector::drawConnector()
void Connector::drawConnector(bool isRotated)
{
if (!mEndComponentConnected)
{
Expand Down Expand Up @@ -182,7 +182,13 @@ void Connector::drawConnector()
}
else
{
if (mpStartComponent->getParentIcon()->isSelected() && mpEndComponent->getParentIcon()->isSelected())
if (isRotated)
{
//Retrieve start and end points from ports in case components have moved
updateStartPoint(getStartComponent()->mapToScene(getStartComponent()->boundingRect().center()));
updateEndPoint(getEndComponent()->mapToScene(getEndComponent()->boundingRect().center()));
}
else if (mpStartComponent->getParentIcon()->isSelected() && mpEndComponent->getParentIcon()->isSelected())
{
//Both components and connector are selected, so move whole connector along with components
moveAllPoints(getStartComponent()->mapToScene(getStartComponent()->boundingRect().center()).x()-mPoints[0].x(),
Expand Down Expand Up @@ -378,8 +384,8 @@ ConnectorLine::ConnectorLine(qreal x1, qreal y1, qreal x2, qreal y2, int lineNum
this->endPos = QPointF(x2,y2);
this->mLineNumber = lineNumber;
this->mParentConnectorEndComponentConnected = false;
this->mActivePen = QPen(Qt::red, 1.0);
this->mPassivePen = QPen(Qt::black, 1.0);
this->mActivePen = QPen(Qt::red);
this->mPassivePen = QPen(Qt::black);
this->mHoverPen = QPen(Qt::darkRed, 6.9);
}

Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/ConnectorWidget.h
Expand Up @@ -79,7 +79,7 @@ class Connector : public QGraphicsWidget
signals:
void endComponentConnected();
public slots:
void drawConnector();
void drawConnector(bool isRotated = false);
void updateStartPoint(QPointF point);
void updateEndPoint(QPointF point);
void moveAllPoints(qreal offsetX, qreal offsetY);
Expand Down
19 changes: 9 additions & 10 deletions OMEdit/OMEditGUI/CornerItem.cpp
Expand Up @@ -33,13 +33,11 @@

#include "CornerItem.h"

CornerItem::CornerItem(qreal x, qreal y, Qt::Corner corner, GraphicsScene *graphicsScene, GraphicsView *graphicsView, QGraphicsItem *parent)
: QGraphicsItem(parent), mpGraphicsScene(graphicsScene), mpGraphicsView(graphicsView),
mItemClicked(false), mCorner(corner), mScaleIncrementBy(1.02), mScaleDecrementBy(1/1.02)
CornerItem::CornerItem(qreal x, qreal y, Qt::Corner corner, QGraphicsItem *parent)
: QGraphicsItem(parent), mItemClicked(false), mCorner(corner), mScaleIncrementBy(1.10), mScaleDecrementBy(1/1.10)
{
setFlags(QGraphicsItem::ItemIgnoresTransformations);
this->scale(1.0, -1.0);
this->mpGraphicsScene->addItem(this);
this->mActivePen = QPen(Qt::red, 3);
this->mHoverPen = QPen(Qt::darkRed, 3);
updateCornerItem(x, y, corner);
Expand Down Expand Up @@ -162,15 +160,16 @@ void CornerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
case Qt::TopLeftCorner:
{
if (this->mClickPos.x() < event->pos().x())
if ((this->mClickPos.x() < event->pos().x()) or (this->mClickPos.y() > event->pos().y()))
{
resizeFactorX = this->mScaleDecrementBy;
else if (this->mClickPos.x() > event->pos().x())
resizeFactorY = this->mScaleDecrementBy;
}
else if ((this->mClickPos.x() > event->pos().x()) or (this->mClickPos.y() < event->pos().y()))
{
resizeFactorX = this->mScaleIncrementBy;

if (this->mClickPos.y() < event->pos().y())
resizeFactorY = this->mScaleIncrementBy;
else if (this->mClickPos.y() > event->pos().y())
resizeFactorY = this->mScaleDecrementBy;
}
break;
}
case Qt::TopRightCorner:
Expand Down
4 changes: 1 addition & 3 deletions OMEdit/OMEditGUI/CornerItem.h
Expand Up @@ -47,8 +47,6 @@ class CornerItem : public QObject, public QGraphicsItem
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
GraphicsScene *mpGraphicsScene;
GraphicsView *mpGraphicsView;
QVector<QPointF> mLines;
QRectF mRectangle;
QPen mPen;
Expand All @@ -60,7 +58,7 @@ class CornerItem : public QObject, public QGraphicsItem
qreal mScaleIncrementBy;
qreal mScaleDecrementBy;
public:
CornerItem(qreal x, qreal y, Qt::Corner corner, GraphicsScene *graphicsScene, GraphicsView *graphicsView, QGraphicsItem *parent = 0);
CornerItem(qreal x, qreal y, Qt::Corner corner, QGraphicsItem *parent = 0);
void updateCornerItem(qreal x, qreal y, Qt::Corner corner);
void setActive();
void setPassive();
Expand Down
51 changes: 37 additions & 14 deletions OMEdit/OMEditGUI/EllipseAnnotation.cpp
Expand Up @@ -33,7 +33,7 @@

#include "EllipseAnnotation.h"

EllipseAnnotation::EllipseAnnotation(QString shape, QGraphicsItem *parent)
EllipseAnnotation::EllipseAnnotation(QString shape, OMCProxy *omc, QGraphicsItem *parent)
: ShapeAnnotation(parent)
{
// initialize the Line Patterns map.
Expand Down Expand Up @@ -72,22 +72,39 @@ EllipseAnnotation::EllipseAnnotation(QString shape, QGraphicsItem *parent)
// if first item of list is true then the Ellipse should be visible.
this->mVisible = static_cast<QString>(list.at(0)).contains("true");

int index = 0;
if (omc->mAnnotationVersion == OMCProxy::ANNOTATION_VERSION3X)
{
mOrigin.setX(static_cast<QString>(list.at(1)).toFloat());
mOrigin.setY(static_cast<QString>(list.at(2)).toFloat());

mRotation = static_cast<QString>(list.at(3)).toFloat();
index = 3;
}

// 2,3,4 items of list contains the line color.
index = index + 1;
int red, green, blue;

red = static_cast<QString>(list.at(1)).toInt();
green = static_cast<QString>(list.at(2)).toInt();
blue = static_cast<QString>(list.at(3)).toInt();
red = static_cast<QString>(list.at(index)).toInt();
index = index + 1;
green = static_cast<QString>(list.at(index)).toInt();
index = index + 1;
blue = static_cast<QString>(list.at(index)).toInt();
this->mLineColor = QColor (red, green, blue);

// 5,6,7 items of list contains the fill color.
red = static_cast<QString>(list.at(4)).toInt();
green = static_cast<QString>(list.at(5)).toInt();
blue = static_cast<QString>(list.at(6)).toInt();
index = index + 1;
red = static_cast<QString>(list.at(index)).toInt();
index = index + 1;
green = static_cast<QString>(list.at(index)).toInt();
index = index + 1;
blue = static_cast<QString>(list.at(index)).toInt();
this->mFillColor = QColor (red, green, blue);

// 8 item of the list contains the line pattern.
QString linePattern = StringHandler::getLastWordAfterDot(list.at(7));
index = index + 1;
QString linePattern = StringHandler::getLastWordAfterDot(list.at(index));
QMap<QString, Qt::PenStyle>::iterator it;
for (it = this->mLinePatternsMap.begin(); it != this->mLinePatternsMap.end(); ++it)
{
Expand All @@ -99,7 +116,8 @@ EllipseAnnotation::EllipseAnnotation(QString shape, QGraphicsItem *parent)
}

// 9 item of the list contains the fill pattern.
QString fillPattern = StringHandler::getLastWordAfterDot(list.at(8));
index = index + 1;
QString fillPattern = StringHandler::getLastWordAfterDot(list.at(index));
QMap<QString, Qt::BrushStyle>::iterator fill_it;
for (fill_it = this->mFillPatternsMap.begin(); fill_it != this->mFillPatternsMap.end(); ++fill_it)
{
Expand All @@ -111,14 +129,19 @@ EllipseAnnotation::EllipseAnnotation(QString shape, QGraphicsItem *parent)
}

// 10 item of the list contains the thickness.
this->mThickness = static_cast<QString>(list.at(9)).toFloat();
index = index + 1;
this->mThickness = static_cast<QString>(list.at(index)).toFloat();

// 11, 12, 13, 14 items of the list contains the extent points of Ellipse.
qreal x = static_cast<QString>(list.at(10)).toFloat();
qreal y = static_cast<QString>(list.at(11)).toFloat();
index = index + 1;
qreal x = static_cast<QString>(list.at(index)).toFloat();
index = index + 1;
qreal y = static_cast<QString>(list.at(index)).toFloat();
QPointF p1 (x, y);
x = static_cast<QString>(list.at(12)).toFloat();
y = static_cast<QString>(list.at(13)).toFloat();
index = index + 1;
x = static_cast<QString>(list.at(index)).toFloat();
index = index + 1;
y = static_cast<QString>(list.at(index)).toFloat();
QPointF p2 (x, y);

this->mExtent.append(p1);
Expand Down
7 changes: 6 additions & 1 deletion OMEdit/OMEditGUI/EllipseAnnotation.h
Expand Up @@ -35,11 +35,16 @@
#define ELLIPSEANNOTATION_H

#include "ShapeAnnotation.h"
#include "IconAnnotation.h"

class OMCProxy;

class EllipseAnnotation : public ShapeAnnotation
{
private:
bool mVisible;
QPointF mOrigin;
qreal mRotation;
QColor mLineColor;
QColor mFillColor;
QMap<QString, Qt::PenStyle> mLinePatternsMap;
Expand All @@ -49,7 +54,7 @@ class EllipseAnnotation : public ShapeAnnotation
qreal mThickness;
QList<QPointF> mExtent;
public:
EllipseAnnotation(QString shape, QGraphicsItem *parent = 0);
EllipseAnnotation(QString shape, OMCProxy *omc, QGraphicsItem *parent = 0);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void drawEllipseAnnotaion(QPainter *painter);
Expand Down
16 changes: 11 additions & 5 deletions OMEdit/OMEditGUI/Helper.cpp
Expand Up @@ -62,14 +62,20 @@ QString GUIMessages::getMessage(int type)
return "Simulation Stop Time is not defined.";
else if (type == SIMULATION_STARTTIME_LESSTHAN_STOPTIME)
return "Simulation Start Time should be less than Stop Time.";
else if (type == ENTER_PACKAGE_NAME)
return "Please enter Package Name.";
else if (type == ENTER_MODEL_NAME)
return "Please enter Model Name.";
else if (type == ENTER_NAME)
return "Please enter %1 Name.";
else if (type == MODEL_ALREADY_EXISTS)
return "%1 %2 already exits %3.";
else if (type == ITEM_ALREADY_EXISTS)
return "An item with the same name alresady exists. Please try some other name.";
else if (type == OPEN_MODELICA_HOME_NOT_FOUND)
return "Could not find environment variable OPENMODELICAHOME. Please make sure OpenModelica is installed properly.";
else if (type == ERROR_OCCURRED)
return "Following Error has occurred.";
return "Following Error has occurred. \n\n %1.";
else if (type == ERROR_IN_MODELICA_TEXT)
return "Following Errors are found in Modelica Text. \n\n %1.";
else if (type == UNDO_OR_FIX_ERRORS)
return "\n\nFor normal users it is recommended to choose 'Undo changes'. You can also choose 'Let me fix errors' if you want to fix them by your own.";
else if (type == NO_OPEN_MODELICA_KEYWORDS)
return "Please make sure you are not using any Open Modelica Keywords like (model, package, record, class etc.)";
else if (type == INCOMPATIBLE_CONNECTORS)
Expand Down
7 changes: 5 additions & 2 deletions OMEdit/OMEditGUI/Helper.h
Expand Up @@ -67,10 +67,13 @@ class GUIMessages
NO_SIMULATION_STARTTIME,
NO_SIMULATION_STOPTIME,
SIMULATION_STARTTIME_LESSTHAN_STOPTIME,
ENTER_PACKAGE_NAME,
ENTER_MODEL_NAME,
ENTER_NAME,
MODEL_ALREADY_EXISTS,
ITEM_ALREADY_EXISTS,
OPEN_MODELICA_HOME_NOT_FOUND,
ERROR_OCCURRED,
ERROR_IN_MODELICA_TEXT,
UNDO_OR_FIX_ERRORS,
NO_OPEN_MODELICA_KEYWORDS,
INCOMPATIBLE_CONNECTORS,
SAVE_CHANGES,
Expand Down

0 comments on commit 1b0d433

Please sign in to comment.