Skip to content

Commit

Permalink
Update Component instances when new shapes are added to the class.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Oct 25, 2015
1 parent 6b87f1e commit 2176a3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp
Expand Up @@ -403,7 +403,7 @@ void TextAnnotation::initUpdateTextString()
if (mpComponent) {
if (mOriginalTextString.contains("%")) {
updateTextString();
connect(mpComponent->getRootParentComponent(), SIGNAL(displayTextChanged()), SLOT(updateTextString()), Qt::UniqueConnection);
connect(mpComponent, SIGNAL(displayTextChanged()), SLOT(updateTextString()), Qt::UniqueConnection);
}
}
}
Expand Down Expand Up @@ -458,10 +458,10 @@ void TextAnnotation::updateTextString()
return;
}
if (mOriginalTextString.toLower().contains("%name")) {
mTextString.replace(QRegExp("%name"), mpComponent->getRootParentComponent()->getName());
mTextString.replace(QRegExp("%name"), mpComponent->getName());
}
if (mOriginalTextString.toLower().contains("%class")) {
mTextString.replace(QRegExp("%class"), mpComponent->getRootParentComponent()->getLibraryTreeItem()->getNameStructure());
mTextString.replace(QRegExp("%class"), mpComponent->getLibraryTreeItem()->getNameStructure());
}
if (!mTextString.contains("%")) {
return;
Expand Down
8 changes: 5 additions & 3 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -1005,9 +1005,11 @@ void Component::removeShapes()
delete pShapeAnnotation;
}
mShapesList.clear();
mpNonExistingComponentLine->setVisible(false);
mpDefaultComponentRectangle->setVisible(false);
mpDefaultComponentText->setVisible(false);
if (mComponentType == Component::Root) {
mpNonExistingComponentLine->setVisible(false);
mpDefaultComponentRectangle->setVisible(false);
mpDefaultComponentText->setVisible(false);
}
}

void Component::removeComponents()
Expand Down
12 changes: 6 additions & 6 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -752,9 +752,9 @@ void GraphicsView::createRectangleShape(QPointF point)
// make the toolbar button of rectangle unchecked
pMainWindow->getRectangleShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpRectangleShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpRectangleShapeAnnotation, this);
}
}

Expand Down Expand Up @@ -785,9 +785,9 @@ void GraphicsView::createEllipseShape(QPointF point)
// make the toolbar button of ellipse unchecked
pMainWindow->getEllipseShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpEllipseShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpEllipseShapeAnnotation, this);
}
}

Expand Down Expand Up @@ -818,11 +818,11 @@ void GraphicsView::createTextShape(QPointF point)
// make the toolbar button of text unchecked
pMainWindow->getTextShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpTextShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpTextShapeAnnotation->showShapeProperties();
mpTextShapeAnnotation->setSelected(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpTextShapeAnnotation, this);
}
}

Expand Down Expand Up @@ -852,11 +852,11 @@ void GraphicsView::createBitmapShape(QPointF point)
// make the toolbar button of text unchecked
pMainWindow->getBitmapShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpBitmapShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpBitmapShapeAnnotation->showShapeProperties();
mpBitmapShapeAnnotation->setSelected(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpBitmapShapeAnnotation, this);
}
}

Expand Down Expand Up @@ -1718,9 +1718,9 @@ void GraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
// make the toolbar button of line unchecked
pMainWindow->getLineShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpLineShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpLineShapeAnnotation, this);
return;
} else if (isCreatingPolygonShape()) {
// finish creating the polygon
Expand All @@ -1736,9 +1736,9 @@ void GraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
// make the toolbar button of polygon unchecked
pMainWindow->getPolygonShapeAction()->setChecked(false);
pMainWindow->getConnectModeAction()->setChecked(true);
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpPolygonShapeAnnotation, this);
mpModelWidget->updateClassAnnotationIfNeeded();
mpModelWidget->updateModelicaText();
mpModelWidget->getLibraryTreeItem()->emitShapeAdded(mpPolygonShapeAnnotation, this);
return;
}
ShapeAnnotation *pShapeAnnotation = dynamic_cast<ShapeAnnotation*>(itemAt(event->pos()));
Expand Down

0 comments on commit 2176a3c

Please sign in to comment.