Skip to content

Commit 006079e

Browse files
committed
Use the correct CoordinateSystem for Component boundingRect.
1 parent 24159a7 commit 006079e

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

OMEdit/OMEditGUI/Component/Component.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,14 @@ CoOrdinateSystem Component::getCoOrdinateSystem() const
582582
{
583583
CoOrdinateSystem coOrdinateSystem;
584584
if (mpLibraryTreeItem && !mpLibraryTreeItem->isNonExisting()) {
585-
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
586-
coOrdinateSystem = mpLibraryTreeItem->getModelWidget()->getIconGraphicsView()->mCoOrdinateSystem;
585+
if (mpLibraryTreeItem->isConnector()) {
586+
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
587+
coOrdinateSystem = mpLibraryTreeItem->getModelWidget()->getIconGraphicsView()->mCoOrdinateSystem;
588+
} else {
589+
coOrdinateSystem = mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->mCoOrdinateSystem;
590+
}
587591
} else {
588-
coOrdinateSystem = mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->mCoOrdinateSystem;
592+
coOrdinateSystem = mpLibraryTreeItem->getModelWidget()->getIconGraphicsView()->mCoOrdinateSystem;
589593
}
590594
}
591595
return coOrdinateSystem;
@@ -849,9 +853,10 @@ QString Component::getParameterDisplayString(QString parameterName)
849853
/* case 2 */
850854
if (displayString.isEmpty()) {
851855
if (mpLibraryTreeItem) {
856+
mpLibraryTreeItem->getModelWidget()->loadDiagramView();
852857
foreach (Component *pComponent, mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->getComponentsList()) {
853858
if (pComponent->getComponentInfo()->getName().compare(parameterName) == 0) {
854-
displayString = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, className);
859+
displayString = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, mpLibraryTreeItem->getNameStructure());
855860
break;
856861
}
857862
}
@@ -1063,6 +1068,7 @@ void Component::createClassComponents()
10631068
foreach (Component *pComponent, mpLibraryTreeItem->getModelWidget()->getIconGraphicsView()->getComponentsList()) {
10641069
mComponentsList.append(new Component(pComponent, this));
10651070
}
1071+
mpLibraryTreeItem->getModelWidget()->loadDiagramView();
10661072
foreach (Component *pComponent, mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->getComponentsList()) {
10671073
if (pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->isConnector()) {
10681074
continue;
@@ -1340,11 +1346,11 @@ QString Component::getParameterDisplayStringFromExtendsParameters(QString parame
13401346
QString displayString = "";
13411347
foreach (Component *pInheritedComponent, mInheritedComponentsList) {
13421348
if (pInheritedComponent->getLibraryTreeItem()) {
1349+
pInheritedComponent->getLibraryTreeItem()->getModelWidget()->loadDiagramView();
13431350
foreach (Component *pComponent, pInheritedComponent->getLibraryTreeItem()->getModelWidget()->getDiagramGraphicsView()->getComponentsList()) {
13441351
if (pComponent->getComponentInfo()->getName().compare(parameterName) == 0) {
13451352
OMCProxy *pOMCProxy = pComponent->getGraphicsView()->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getOMCProxy();
1346-
QString className = pComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure();
1347-
displayString = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, className);
1353+
displayString = pComponent->getComponentInfo()->getParameterValue(pOMCProxy, pComponent->getLibraryTreeItem()->getNameStructure());
13481354
if (!displayString.isEmpty()) {
13491355
return displayString;
13501356
}

OMEdit/OMEditGUI/Component/Transformation.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,45 @@
3838

3939
#include "Transformation.h"
4040

41+
Transformation::Transformation()
42+
{
43+
mValid = false;
44+
initialize(StringHandler::Diagram);
45+
}
46+
4147
Transformation::Transformation(StringHandler::ViewType viewType)
4248
{
4349
mValid = true;
50+
initialize(viewType);
51+
}
52+
53+
Transformation::Transformation(const Transformation &transformation)
54+
{
55+
updateTransformation(transformation);
56+
}
57+
58+
void Transformation::initialize(StringHandler::ViewType viewType)
59+
{
4460
mViewType = viewType;
4561
mWidth = 200.0;
4662
mHeight = 200.0;
4763
mVisible = true;
4864
mOriginDiagram = QPointF(0.0, 0.0);
4965
mHasOriginDiagramX = true;
5066
mHasOriginDiagramY = true;
51-
mExtent1Diagram = QPointF(0.0, 0.0);
52-
mExtent2Diagram = QPointF(0.0, 0.0);
67+
mExtent1Diagram = QPointF(-100.0, -100.0);
68+
mExtent2Diagram = QPointF(100.0, 100.0);
5369
mRotateAngleDiagram = 0.0;
5470
mPositionDiagram = QPointF(0.0, 0.0);
5571
mOriginIcon = QPointF(0.0, 0.0);
5672
mHasOriginIconX = true;
5773
mHasOriginIconY = true;
58-
mExtent1Icon = QPointF(0.0, 0.0);
59-
mExtent2Icon = QPointF(0.0, 0.0);
74+
mExtent1Icon = QPointF(-100.0, -100.0);
75+
mExtent2Icon = QPointF(100.0, 100.0);
6076
mRotateAngleIcon = 0.0;
6177
mPositionIcon = QPointF(0.0, 0.0);
6278
}
6379

64-
Transformation::Transformation(const Transformation &transformation)
65-
{
66-
updateTransformation(transformation);
67-
}
68-
6980
void Transformation::parseTransformationString(QString value, qreal width, qreal height)
7081
{
7182
/*
@@ -261,7 +272,7 @@ void Transformation::setExtent1(QPointF extent)
261272
}
262273
}
263274

264-
QPointF Transformation::getExtent1()
275+
QPointF Transformation::getExtent1() const
265276
{
266277
switch (mViewType) {
267278
case StringHandler::Icon:
@@ -287,7 +298,7 @@ void Transformation::setExtent2(QPointF extent)
287298
}
288299
}
289300

290-
QPointF Transformation::getExtent2()
301+
QPointF Transformation::getExtent2() const
291302
{
292303
switch (mViewType) {
293304
case StringHandler::Icon:

OMEdit/OMEditGUI/Component/Transformation.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ class Component;
4848
class Transformation
4949
{
5050
public:
51-
Transformation() {mValid = false;}
51+
Transformation();
5252
Transformation(StringHandler::ViewType viewType);
5353
Transformation(const Transformation &transformation);
54+
void initialize(StringHandler::ViewType viewType);
5455
void parseTransformationString(QString value, qreal width, qreal height);
5556
void updateTransformation(const Transformation &transformation);
5657
QTransform getTransformationMatrix();
@@ -61,9 +62,9 @@ class Transformation
6162
void setOrigin(QPointF origin);
6263
QPointF getOrigin();
6364
void setExtent1(QPointF extent);
64-
QPointF getExtent1();
65+
QPointF getExtent1() const;
6566
void setExtent2(QPointF extent);
66-
QPointF getExtent2();
67+
QPointF getExtent2() const;
6768
void setRotateAngle(qreal rotateAngle);
6869
qreal getRotateAngle();
6970
QPointF getPosition();

0 commit comments

Comments
 (0)