Changeset 9770cc8 in OpenModelica
- Timestamp:
- 2021-06-08T14:07:16+02:00 (3 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- 5dd217b, c162e1ab
- Parents:
- 41f9a35e
- git-author:
- Adeel Asghar <adeel.asghar@…> (06/08/21 14:07:16)
- git-committer:
- GitHub <noreply@…> (06/08/21 14:07:16)
- Location:
- OMEdit/OMEditLIB/Annotations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditLIB/Annotations/LineAnnotation.cpp
r16b10d40 r9770cc8 962 962 if (mPoints.size() == 2 && mpEndComponent) { 963 963 // just check if additional points are really needed or not. 964 if ( (mGeometries[secondLastIndex] == ShapeAnnotation::HorizontalLine && mPoints[lastIndex].y() != point.y()) ||965 (mGeometries[secondLastIndex] == ShapeAnnotation::VerticalLine && mPoints[lastIndex].x() != point.x())) {964 if (secondLastIndex < mGeometries.size() && ((mGeometries.at(secondLastIndex) == ShapeAnnotation::HorizontalLine && mPoints.at(lastIndex).y() != point.y()) || 965 (mGeometries.at(secondLastIndex) == ShapeAnnotation::VerticalLine && mPoints.at(lastIndex).x() != point.x()))) { 966 966 insertPointsGeometriesAndCornerItems(lastIndex); 967 967 setCornerItemsActiveOrPassive(); … … 975 975 updateCornerItem(lastIndex); 976 976 /* update the 2nd point */ 977 assert(secondLastIndex < mGeometries.size()); 978 if (mGeometries[secondLastIndex] == ShapeAnnotation::HorizontalLine) { 979 mPoints[secondLastIndex] = QPointF(mPoints[secondLastIndex].x(), mPoints[secondLastIndex].y() + dy); 980 } else if (mGeometries[secondLastIndex] == ShapeAnnotation::VerticalLine) { 981 mPoints[secondLastIndex] = QPointF(mPoints[secondLastIndex].x() + dx, mPoints[secondLastIndex].y()); 982 } 983 updateCornerItem(secondLastIndex); 977 if (secondLastIndex < mGeometries.size()) { 978 if (mGeometries.at(secondLastIndex) == ShapeAnnotation::HorizontalLine) { 979 mPoints[secondLastIndex] = QPointF(mPoints.at(secondLastIndex).x(), mPoints.at(secondLastIndex).y() + dy); 980 } else if (mGeometries.at(secondLastIndex) == ShapeAnnotation::VerticalLine) { 981 mPoints[secondLastIndex] = QPointF(mPoints.at(secondLastIndex).x() + dx, mPoints.at(secondLastIndex).y()); 982 } 983 updateCornerItem(secondLastIndex); 984 } 984 985 } 985 986 if (!mpGraphicsView->isCreatingConnection() && !mpGraphicsView->isCreatingTransition()) { … … 1282 1283 updateOMSConnection(); 1283 1284 } else { 1284 assert(!mOldAnnotation.isEmpty()); 1285 if (mLineType == LineAnnotation::ConnectionType) { 1286 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateConnectionCommand(this, mOldAnnotation, getOMCShapeAnnotation())); 1287 } else if (mLineType == LineAnnotation::TransitionType) { 1288 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateTransitionCommand(this, mCondition, mImmediate, mReset, 1289 mSynchronize, mPriority, mOldAnnotation, 1290 mCondition, mImmediate, mReset, mSynchronize, 1291 mPriority, getOMCShapeAnnotation())); 1292 } else if (mLineType == LineAnnotation::InitialStateType) { 1293 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateInitialStateCommand(this, mOldAnnotation, getOMCShapeAnnotation())); 1285 if (!mOldAnnotation.isEmpty()) { 1286 if (mLineType == LineAnnotation::ConnectionType) { 1287 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateConnectionCommand(this, mOldAnnotation, getOMCShapeAnnotation())); 1288 } else if (mLineType == LineAnnotation::TransitionType) { 1289 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateTransitionCommand(this, mCondition, mImmediate, mReset, 1290 mSynchronize, mPriority, mOldAnnotation, 1291 mCondition, mImmediate, mReset, mSynchronize, 1292 mPriority, getOMCShapeAnnotation())); 1293 } else if (mLineType == LineAnnotation::InitialStateType) { 1294 mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateInitialStateCommand(this, mOldAnnotation, getOMCShapeAnnotation())); 1295 } 1294 1296 } 1295 1297 } -
OMEdit/OMEditLIB/Annotations/ShapeAnnotation.cpp
r8e569a04 r9770cc8 770 770 if (dynamic_cast<LineAnnotation*>(this) || dynamic_cast<PolygonAnnotation*>(this)) { 771 771 for (int i = 0 ; i < mCornerItemsList.size() ; i++) { 772 assert(mPoints.size() > i); 773 mCornerItemsList.at(i)->setPos(QPointF(mPoints.at(i).x(), mPoints.at(i).y())); 772 if (mPoints.size() > i) { 773 mCornerItemsList.at(i)->setPos(QPointF(mPoints.at(i).x(), mPoints.at(i).y())); 774 } 774 775 } 775 776 } else { 776 assert(mExtents.size() > 1); 777 QPointF extent1 = QPointF(qMin(mExtents.at(0).x(), mExtents.at(1).x()), qMin(mExtents.at(0).y(), mExtents.at(1).y())); 778 QPointF extent2 = QPointF(qMax(mExtents.at(0).x(), mExtents.at(1).x()), qMax(mExtents.at(0).y(), mExtents.at(1).y())); 779 if (mCornerItemsList.size() > 1) { 780 mCornerItemsList.at(0)->setPos(QPointF(extent1.x(), extent1.y())); 781 mCornerItemsList.at(1)->setPos(QPointF(extent2.x(), extent2.y())); 777 if (mExtents.size() > 1) { 778 QPointF extent1 = QPointF(qMin(mExtents.at(0).x(), mExtents.at(1).x()), qMin(mExtents.at(0).y(), mExtents.at(1).y())); 779 QPointF extent2 = QPointF(qMax(mExtents.at(0).x(), mExtents.at(1).x()), qMax(mExtents.at(0).y(), mExtents.at(1).y())); 780 if (mCornerItemsList.size() > 1) { 781 mCornerItemsList.at(0)->setPos(QPointF(extent1.x(), extent1.y())); 782 mCornerItemsList.at(1)->setPos(QPointF(extent2.x(), extent2.y())); 783 } 782 784 } 783 785 } … … 804 806 void ShapeAnnotation::replaceExtent(const int index, const QPointF point) 805 807 { 806 assert(mExtents.size() > 1); 807 assert(index >= 0 && index <= 1); 808 809 prepareGeometryChange(); 810 mExtents.replace(index, point); 808 if (mExtents.size() > 1 && index >= 0 && index <= 1) { 809 prepareGeometryChange(); 810 mExtents.replace(index, point); 811 } 811 812 } 812 813 … … 819 820 void ShapeAnnotation::updateExtent(const int index, const QPointF point) 820 821 { 821 assert(mExtents.size() > 1); 822 assert(index >= 0 && index <= 1); 823 824 prepareGeometryChange(); 825 mExtents.replace(index, point); 826 822 if (mExtents.size() > 1 && index >= 0 && index <= 1) { 823 prepareGeometryChange(); 824 mExtents.replace(index, point); 825 } 827 826 applyTransformation(); 828 827 } … … 1550 1549 void ShapeAnnotation::cornerItemReleased(const bool changed) 1551 1550 { 1552 assert(!mOldAnnotation.isEmpty()); 1553 1554 if (changed) { 1555 ModelWidget *pModelWidget = mpGraphicsView->getModelWidget(); 1556 LineAnnotation *pLineAnnotation = dynamic_cast<LineAnnotation*>(this); 1557 1558 if (pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::OMS) { 1559 if (pLineAnnotation) { 1560 pLineAnnotation->updateOMSConnection(); 1561 pModelWidget->createOMSimulatorUndoCommand(QString("Update OMS Connection connect(%1, %2)").arg(pLineAnnotation->getStartComponentName(), pLineAnnotation->getEndComponentName())); 1551 if (!mOldAnnotation.isEmpty()) { 1552 if (changed) { 1553 ModelWidget *pModelWidget = mpGraphicsView->getModelWidget(); 1554 LineAnnotation *pLineAnnotation = dynamic_cast<LineAnnotation*>(this); 1555 1556 if (pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::OMS) { 1557 if (pLineAnnotation) { 1558 pLineAnnotation->updateOMSConnection(); 1559 pModelWidget->createOMSimulatorUndoCommand(QString("Update OMS Connection connect(%1, %2)").arg(pLineAnnotation->getStartComponentName(), pLineAnnotation->getEndComponentName())); 1560 pModelWidget->updateModelText(); 1561 return; 1562 } 1563 } else { 1564 if (pLineAnnotation && pLineAnnotation->getLineType() == LineAnnotation::ConnectionType) { 1565 manhattanizeShape(false); 1566 removeRedundantPointsGeometriesAndCornerItems(); 1567 // Call getOMCShapeAnnotation() after manhattanizeShape() and removeRedundantPointsGeometriesAndCornerItems() to get a correct new annotation 1568 QString newAnnotation = getOMCShapeAnnotation(); 1569 pModelWidget->getUndoStack()->push(new UpdateConnectionCommand(pLineAnnotation, mOldAnnotation, newAnnotation)); 1570 } else if (pLineAnnotation && pLineAnnotation->getLineType() == LineAnnotation::TransitionType) { 1571 manhattanizeShape(false); 1572 removeRedundantPointsGeometriesAndCornerItems(); 1573 QString newAnnotation = getOMCShapeAnnotation(); 1574 pModelWidget->getUndoStack()->push(new UpdateTransitionCommand(pLineAnnotation, pLineAnnotation->getCondition(), pLineAnnotation->getImmediate(), 1575 pLineAnnotation->getReset(), pLineAnnotation->getSynchronize(), pLineAnnotation->getPriority(), 1576 mOldAnnotation, pLineAnnotation->getCondition(), pLineAnnotation->getImmediate(), 1577 pLineAnnotation->getReset(), pLineAnnotation->getSynchronize(), pLineAnnotation->getPriority(), newAnnotation)); 1578 } else { 1579 QString newAnnotation = getOMCShapeAnnotation(); 1580 pModelWidget->getUndoStack()->push(new UpdateShapeCommand(this, mOldAnnotation, newAnnotation)); 1581 pModelWidget->updateClassAnnotationIfNeeded(); 1582 } 1562 1583 pModelWidget->updateModelText(); 1563 return;1564 1584 } 1565 1585 } else { 1566 if (pLineAnnotation && pLineAnnotation->getLineType() == LineAnnotation::ConnectionType) { 1567 manhattanizeShape(false); 1568 removeRedundantPointsGeometriesAndCornerItems(); 1569 // Call getOMCShapeAnnotation() after manhattanizeShape() and removeRedundantPointsGeometriesAndCornerItems() to get a correct new annotation 1570 QString newAnnotation = getOMCShapeAnnotation(); 1571 pModelWidget->getUndoStack()->push(new UpdateConnectionCommand(pLineAnnotation, mOldAnnotation, newAnnotation)); 1572 } else if (pLineAnnotation && pLineAnnotation->getLineType() == LineAnnotation::TransitionType) { 1573 manhattanizeShape(false); 1574 removeRedundantPointsGeometriesAndCornerItems(); 1575 QString newAnnotation = getOMCShapeAnnotation(); 1576 pModelWidget->getUndoStack()->push(new UpdateTransitionCommand(pLineAnnotation, pLineAnnotation->getCondition(), pLineAnnotation->getImmediate(), 1577 pLineAnnotation->getReset(), pLineAnnotation->getSynchronize(), pLineAnnotation->getPriority(), 1578 mOldAnnotation, pLineAnnotation->getCondition(), pLineAnnotation->getImmediate(), 1579 pLineAnnotation->getReset(), pLineAnnotation->getSynchronize(), pLineAnnotation->getPriority(), newAnnotation)); 1580 } else { 1581 QString newAnnotation = getOMCShapeAnnotation(); 1582 pModelWidget->getUndoStack()->push(new UpdateShapeCommand(this, mOldAnnotation, newAnnotation)); 1583 pModelWidget->updateClassAnnotationIfNeeded(); 1584 } 1585 pModelWidget->updateModelText(); 1586 } 1587 } else { 1588 parseShapeAnnotation(mOldAnnotation); 1589 applyTransformation(); 1586 parseShapeAnnotation(mOldAnnotation); 1587 applyTransformation(); 1588 } 1590 1589 } 1591 1590
Note: See TracChangeset
for help on using the changeset viewer.