Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 3dviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jan 16, 2017
2 parents 089a78b + 3d9d102 commit 37eea69
Show file tree
Hide file tree
Showing 15 changed files with 385 additions and 81 deletions.
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Animation/AnimationWindow.h
Expand Up @@ -43,6 +43,7 @@ class AnimationWindow : public AbstractAnimationWindow
public:
AnimationWindow(QWidget *pParent);
~AnimationWindow();

void createActions() override;
};

Expand Down
14 changes: 12 additions & 2 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -1589,8 +1589,18 @@ void ShapeAnnotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)
QMenu menu(mpGraphicsView);
if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getLibraryType()== LibraryTreeItem::MetaModel) {
menu.addAction(mpShapeAttributesAction);
menu.addSeparator();
menu.addAction(mpAlignInterfacesAction);

//Only show align interfaces action for bidirectional connections
LineAnnotation *pConnectionLineAnnotation = dynamic_cast<LineAnnotation*>(this);
QString startName = pConnectionLineAnnotation->getStartComponentName();
QString endName = pConnectionLineAnnotation->getEndComponentName();
MetaModelEditor *pEditor = dynamic_cast<MetaModelEditor*>(mpGraphicsView->getModelWidget()->getEditor());
if(pEditor->getInterfaceCausality(startName) == StringHandler::getTLMCausality(StringHandler::TLMBidirectional) &&
pEditor->getInterfaceCausality(endName) == StringHandler::getTLMCausality(StringHandler::TLMBidirectional)) {
menu.addSeparator();
menu.addAction(mpAlignInterfacesAction);
}

menu.addSeparator();
menu.addAction(mpGraphicsView->getDeleteAction());
} else {
Expand Down
49 changes: 46 additions & 3 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -623,10 +623,44 @@ Component::Component(ComponentInfo *pComponentInfo, Component *pParentComponent)
mpResizerRectangle = 0;
createNonExistingComponent();
createDefaultComponent();
mpDefaultComponentRectangle->setVisible(true);

if(mpComponentInfo->getTLMCausality() == StringHandler::getTLMCausality(StringHandler::TLMBidirectional)) {
if(mpComponentInfo->getDomain() == StringHandler::getTLMDomain(StringHandler::Mechanical)) {
mpDefaultComponentRectangle->setFillColor(QColor(100, 100, 255)); //Mechanical = blue
}
else if(mpComponentInfo->getDomain() == StringHandler::getTLMDomain(StringHandler::Electric)) {
mpDefaultComponentRectangle->setFillColor(QColor(255, 255, 100)); //Hydraulic = yellow
}
else if(mpComponentInfo->getDomain() == StringHandler::getTLMDomain(StringHandler::Hydraulic)) {
mpDefaultComponentRectangle->setFillColor(QColor(100, 255, 100)); //Hydraulic = green
}
else if(mpComponentInfo->getDomain() == StringHandler::getTLMDomain(StringHandler::Pneumatic)) {
mpDefaultComponentRectangle->setFillColor(QColor(100, 255, 255)); //Pneumatic = turquoise
}
else if(mpComponentInfo->getDomain() == StringHandler::getTLMDomain(StringHandler::Magnetic)) {
mpDefaultComponentRectangle->setFillColor(QColor(255, 100, 255)); //Magnetic = purple
}
mpDefaultComponentText->setTextString(QString::number(mpComponentInfo->getDimensions())+"D");
}
else if((mpComponentInfo->getTLMCausality() == StringHandler::getTLMCausality(StringHandler::TLMInput)) |
(mpComponentInfo->getTLMCausality() == StringHandler::getTLMCausality(StringHandler::TLMOutput))) {
mpDefaultComponentRectangle->setFillColor(QColor(255, 100, 100)); //Signal = red
if(mpComponentInfo->getTLMCausality() == StringHandler::getTLMCausality(StringHandler::TLMInput)) {
mpDefaultComponentText->setTextString("in");
}
else {
mpDefaultComponentText->setTextString("out");
}
}
mpDefaultComponentRectangle->setLineColor(QColor(0, 0, 0));
mpDefaultComponentRectangle->setLineColor(QColor(0, 0, 0));
mpDefaultComponentRectangle->setFillColor(QColor(110, 214, 0));
mpDefaultComponentRectangle->setFillPattern(StringHandler::FillSolid);
mpDefaultComponentRectangle->setFillPattern(StringHandler::FillSolid);
mpDefaultComponentRectangle->setVisible(true);
mpDefaultComponentText->setFontSize(300);
mpDefaultComponentText->setVisible(true);


// transformation
qreal yPosition = 80 - mpParentComponent->getComponentsList().size() * 40;
QString transformation = QString("Placement(true,110.0,%1,-15.0,-15.0,15.0,15.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0)").arg(yPosition);
Expand Down Expand Up @@ -1219,12 +1253,15 @@ void Component::renameComponentInConnections(QString newName)
* Inserts a new interface point.
* \param interfaceName
*/
void Component::insertInterfacePoint(QString interfaceName, QString position, QString angle321)
void Component::insertInterfacePoint(QString interfaceName, QString position, QString angle321, int dimensions, QString causality, QString domain)
{
ComponentInfo *pComponentInfo = new ComponentInfo;
pComponentInfo->setName(interfaceName);
pComponentInfo->setPosition(position);
pComponentInfo->setAngle321(angle321);
pComponentInfo->setDimensions(dimensions);
pComponentInfo->setTLMCausality(causality);
pComponentInfo->setDomain(domain);
mComponentsList.append(new Component(pComponentInfo, this));
}

Expand Down Expand Up @@ -1280,7 +1317,13 @@ void Component::drawInterfacePoints()
pComponentInfo->setName(interfacePoint.attribute("Name"));
pComponentInfo->setPosition(interfacePoint.attribute("Position", "0,0,0"));
pComponentInfo->setAngle321(interfacePoint.attribute("Angle321", "0,0,0"));
pComponentInfo->setDimensions(interfacePoint.attribute("Dimensions", "3").toInt());
pComponentInfo->setTLMCausality(interfacePoint.attribute("Causality",
StringHandler::getTLMCausality(StringHandler::TLMBidirectional)));
pComponentInfo->setDomain(interfacePoint.attribute("Domain",
StringHandler::getTLMDomain(StringHandler::Mechanical)));
mComponentsList.append(new Component(pComponentInfo, this));
mComponentsList.last();
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion OMEdit/OMEditGUI/Component/Component.h
Expand Up @@ -117,6 +117,12 @@ class ComponentInfo : public QObject
QString getPosition() const {return mPosition;}
void setAngle321(QString angle321) {mAngle321 = angle321;}
QString getAngle321() const {return mAngle321;}
void setDimensions(int dimensions) {mDimensions = dimensions;}
int getDimensions() const {return mDimensions;}
void setTLMCausality(QString causality) {mTLMCausality = causality;}
QString getTLMCausality() const {return mTLMCausality;}
void setDomain(QString domain) {mDomain = domain;}
QString getDomain() const {return mDomain;}
// operator overloading
bool operator==(const ComponentInfo &componentInfo) const;
bool operator!=(const ComponentInfo &componentInfo) const;
Expand Down Expand Up @@ -148,6 +154,9 @@ class ComponentInfo : public QObject
QString mGeometryFile;
QString mPosition;
QString mAngle321;
int mDimensions;
QString mTLMCausality;
QString mDomain;

bool isModiferClassRecord(QString modifierName, Component *pComponent);
};
Expand Down Expand Up @@ -223,7 +232,7 @@ class Component : public QObject, public QGraphicsItem
void shapeUpdated();
void shapeDeleted();
void renameComponentInConnections(QString newName);
void insertInterfacePoint(QString interfaceName, QString position, QString angle321);
void insertInterfacePoint(QString interfaceName, QString position, QString angle321, int dimensions, QString causality, QString domain);
void removeInterfacePoint(QString interfaceName);

Transformation mTransformation;
Expand Down
29 changes: 10 additions & 19 deletions OMEdit/OMEditGUI/Component/Transformation.cpp
Expand Up @@ -119,39 +119,30 @@ void Transformation::parseTransformationString(QString value, qreal width, qreal
// origin x position
bool hasExtent1X, hasExtent1Y, hasExtent2X, hasExtent2Y, hasRotation = false;
mOriginIcon.setX(list.at(8).toFloat(&mHasOriginIconX));
if (!mHasOriginIconX) {
mOriginIcon.setX(mOriginDiagram.x());
}
// origin y position
mOriginIcon.setY(list.at(9).toFloat(&mHasOriginIconY));
if (!mHasOriginIconY) {
mOriginIcon.setY(mOriginDiagram.y());
}
// extent1 x
mExtent1Icon.setX(list.at(10).toFloat(&hasExtent1X));
if (!hasExtent1X) {
mExtent1Icon.setX(mExtent1Diagram.x());
}
// extent1 y
mExtent1Icon.setY(list.at(11).toFloat(&hasExtent1Y));
if (!hasExtent1Y) {
mExtent1Icon.setY(mExtent1Diagram.y());
}
// extent1 x
mExtent2Icon.setX(list.at(12).toFloat(&hasExtent2X));
if (!hasExtent2X) {
mExtent2Icon.setX(mExtent2Diagram.x());
}
// extent1 y
mExtent2Icon.setY(list.at(13).toFloat(&hasExtent2Y));
if (!hasExtent2Y) {
mExtent2Icon.setY(mExtent2Diagram.y());
}
// rotate angle
if (list.size() > 14) {
mRotateAngleIcon = list.at(14).toFloat(&hasRotation);
}
if (!hasRotation) {
/* Ticket:4215
* Only use transformation values when no iconTransformation value is available. Don't mix.
*/
if (!mHasOriginIconX && !mHasOriginIconY && !hasExtent1X && !hasExtent1Y && !hasExtent2X && !hasExtent2Y && !hasRotation) {
mOriginIcon.setX(mOriginDiagram.x());
mOriginIcon.setY(mOriginDiagram.y());
mExtent1Icon.setX(mExtent1Diagram.x());
mExtent1Icon.setY(mExtent1Diagram.y());
mExtent2Icon.setX(mExtent2Diagram.x());
mExtent2Icon.setY(mExtent2Diagram.y());
mRotateAngleIcon = mRotateAngleDiagram;
}
}
Expand Down

0 comments on commit 37eea69

Please sign in to comment.