Changeset 953d678e in OpenModelica
- Timestamp:
- 2021-11-23T18:26:05+01:00 (2 years ago)
- Branches:
- maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- 7bb55ae
- Parents:
- 9f0cb452
- git-author:
- Adeel Asghar <adeel.asghar@…> (11/23/21 18:26:05)
- git-committer:
- GitHub <noreply@…> (11/23/21 18:26:05)
- Location:
- OMEdit/OMEditLIB
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditLIB/Annotations/TextAnnotation.cpp
rbf6b3cd r953d678e 313 313 QRectF absMappedBoundingRect = QRectF(boundingRect().x() * sx, boundingRect().y() * sy, qAbs(boundingRect().width() * sx), qAbs(boundingRect().height() * sy)); 314 314 // normalize the text for drawing 315 mTextString = StringHandler::removeFirstLastQuotes(mTextString);316 mTextString = StringHandler::unparse(QString("\"").append(mTextString).append("\""));315 QString textString = StringHandler::removeFirstLastQuotes(mTextString); 316 textString = StringHandler::unparse(QString("\"").append(mTextString).append("\"")); 317 317 // Don't create new QFont instead get a font from painter and set the values on it and set it back. 318 318 QFont font = painter->font(); … … 334 334 if (mFontSize <= 0) { 335 335 QFontMetrics fontMetrics(painter->font()); 336 QRect fontBoundRect = fontMetrics.boundingRect(absMappedBoundingRect.toRect(), Qt::TextDontClip, mTextString);336 QRect fontBoundRect = fontMetrics.boundingRect(absMappedBoundingRect.toRect(), Qt::TextDontClip, textString); 337 337 const qreal xFactor = absMappedBoundingRect.width() / fontBoundRect.width(); 338 338 const qreal yFactor = absMappedBoundingRect.height() / fontBoundRect.height(); … … 350 350 * OR if font size is absolute. 351 351 */ 352 QString textToDraw = mTextString;352 QString textToDraw = textString; 353 353 if (absMappedBoundingRect.width() > 1 && ((mFontSize <= 0 && painter->font().pointSizeF() <= Helper::minimumTextFontSize) || mFontSize > 0)) { 354 354 QFontMetrics fontMetrics(painter->font()); 355 textToDraw = fontMetrics.elidedText( mTextString, Qt::ElideRight, absMappedBoundingRect.width());355 textToDraw = fontMetrics.elidedText(textString, Qt::ElideRight, absMappedBoundingRect.width()); 356 356 // if we get "..." i.e., QChar(0x2026) as textToDraw then don't draw anything 357 357 if (textToDraw.compare(QChar(0x2026)) == 0) { -
OMEdit/OMEditLIB/Element/ElementProperties.cpp
rd0b18e70 r953d678e 1388 1388 /*! 1389 1389 * \class ElementAttributes 1390 * \brief A dialog for displaying components attributes like visibility, stream, casuality etc.1390 * \brief A dialog for displaying elements attributes like visibility, stream, casuality etc. 1391 1391 */ 1392 1392 /*! 1393 1393 * \brief ElementAttributes::ElementAttributes 1394 * \param p Component1394 * \param pElement 1395 1395 * \param pParent 1396 1396 */ 1397 ElementAttributes::ElementAttributes(Element *p Component, QWidget *pParent)1397 ElementAttributes::ElementAttributes(Element *pElement, QWidget *pParent) 1398 1398 : QDialog(pParent) 1399 1399 { 1400 QString className = pComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure(); 1401 setWindowTitle(tr("%1 - %2 - %3 in %4").arg(Helper::applicationName).arg(tr("Element Attributes")).arg(pComponent->getName()) 1402 .arg(className)); 1400 QString className = pElement->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure(); 1401 setWindowTitle(tr("%1 - %2 - %3 in %4").arg(Helper::applicationName, tr("Element Attributes"), pElement->getName(), className)); 1403 1402 setAttribute(Qt::WA_DeleteOnClose); 1404 mp Component = pComponent;1403 mpElement = pElement; 1405 1404 setUpDialog(); 1406 1405 initializeDialog(); … … 1491 1490 mpOkButton = new QPushButton(Helper::ok); 1492 1491 mpOkButton->setAutoDefault(true); 1493 connect(mpOkButton, SIGNAL(clicked()), this, SLOT(update ComponentAttributes()));1492 connect(mpOkButton, SIGNAL(clicked()), this, SLOT(updateElementAttributes())); 1494 1493 mpCancelButton = new QPushButton(Helper::cancel); 1495 1494 mpCancelButton->setAutoDefault(false); … … 1497 1496 mpButtonBox = new QDialogButtonBox(Qt::Horizontal); 1498 1497 mpButtonBox->addButton(mpOkButton, QDialogButtonBox::ActionRole); 1499 if (mp Component->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() || mpComponent->isInheritedComponent()) {1498 if (mpElement->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() || mpElement->isInheritedComponent()) { 1500 1499 mpOkButton->setDisabled(true); 1501 1500 } … … 1522 1521 { 1523 1522 // get Class Name 1524 mpNameTextBox->setText(mp Component->getComponentInfo()->getName());1523 mpNameTextBox->setText(mpElement->getComponentInfo()->getName()); 1525 1524 mpNameTextBox->setCursorPosition(0); 1526 1525 // get dimensions 1527 QString dimensions = mp Component->getComponentInfo()->getArrayIndex();1526 QString dimensions = mpElement->getComponentInfo()->getArrayIndex(); 1528 1527 mpDimensionsTextBox->setText(QString("[%1]").arg(dimensions)); 1529 1528 // get Comment 1530 mpCommentTextBox->setText(mp Component->getComponentInfo()->getComment());1529 mpCommentTextBox->setText(mpElement->getComponentInfo()->getComment()); 1531 1530 mpCommentTextBox->setCursorPosition(0); 1532 1531 // get classname 1533 mpPathTextBox->setText(mp Component->getComponentInfo()->getClassName());1532 mpPathTextBox->setText(mpElement->getComponentInfo()->getClassName()); 1534 1533 // get Variability 1535 if (mp Component->getComponentInfo()->getVariablity() == "constant") {1534 if (mpElement->getComponentInfo()->getVariablity() == "constant") { 1536 1535 mpConstantRadio->setChecked(true); 1537 } else if (mp Component->getComponentInfo()->getVariablity() == "parameter") {1536 } else if (mpElement->getComponentInfo()->getVariablity() == "parameter") { 1538 1537 mpParameterRadio->setChecked(true); 1539 } else if (mp Component->getComponentInfo()->getVariablity() == "discrete") {1538 } else if (mpElement->getComponentInfo()->getVariablity() == "discrete") { 1540 1539 mpDiscreteRadio->setChecked(true); 1541 1540 } else { … … 1543 1542 } 1544 1543 // get Properties 1545 mpFinalCheckBox->setChecked(mp Component->getComponentInfo()->getFinal());1546 mpProtectedCheckBox->setChecked(mp Component->getComponentInfo()->getProtected());1547 mpReplaceAbleCheckBox->setChecked(mp Component->getComponentInfo()->getReplaceable());1548 mIsFlow = mp Component->getComponentInfo()->getFlow() ? "true" : "false";1544 mpFinalCheckBox->setChecked(mpElement->getComponentInfo()->getFinal()); 1545 mpProtectedCheckBox->setChecked(mpElement->getComponentInfo()->getProtected()); 1546 mpReplaceAbleCheckBox->setChecked(mpElement->getComponentInfo()->getReplaceable()); 1547 mIsFlow = mpElement->getComponentInfo()->getFlow() ? "true" : "false"; 1549 1548 // get Casuality 1550 if (mp Component->getComponentInfo()->getCausality() == "input") {1549 if (mpElement->getComponentInfo()->getCausality() == "input") { 1551 1550 mpInputRadio->setChecked(true); 1552 } else if (mp Component->getComponentInfo()->getCausality() == "output") {1551 } else if (mpElement->getComponentInfo()->getCausality() == "output") { 1553 1552 mpOutputRadio->setChecked(true); 1554 1553 } else { … … 1556 1555 } 1557 1556 // get InnerOuter 1558 mpInnerCheckBox->setChecked(mp Component->getComponentInfo()->getInner());1559 mpOuterCheckBox->setChecked(mp Component->getComponentInfo()->getOuter());1560 } 1561 1562 /*! 1563 * \brief ElementAttributes::update ComponentAttributes1557 mpInnerCheckBox->setChecked(mpElement->getComponentInfo()->getInner()); 1558 mpOuterCheckBox->setChecked(mpElement->getComponentInfo()->getOuter()); 1559 } 1560 1561 /*! 1562 * \brief ElementAttributes::updateElementAttributes 1564 1563 * Slot activated when mpOkButton clicked signal is raised.\n 1565 * Updates the component attributes.1566 */ 1567 void ElementAttributes::update ComponentAttributes()1568 { 1569 ModelWidget *pModelWidget = mp Component->getGraphicsView()->getModelWidget();1564 * Updates the element attributes. 1565 */ 1566 void ElementAttributes::updateElementAttributes() 1567 { 1568 ModelWidget *pModelWidget = mpElement->getGraphicsView()->getModelWidget(); 1570 1569 /* Check the same component name problem before setting any attributes. */ 1571 if (mp Component->getComponentInfo()->getName().compare(mpNameTextBox->text()) != 0) {1572 if (!mp Component->getGraphicsView()->checkElementName(mpNameTextBox->text())) {1573 QMessageBox::information(MainWindow::instance(), QString( Helper::applicationName).append(" - ").append(Helper::information),1570 if (mpElement->getComponentInfo()->getName().compare(mpNameTextBox->text()) != 0) { 1571 if (!mpElement->getGraphicsView()->checkElementName(mpNameTextBox->text())) { 1572 QMessageBox::information(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::information), 1574 1573 GUIMessages::getMessage(GUIMessages::SAME_COMPONENT_NAME).arg(mpNameTextBox->text()), Helper::ok); 1575 1574 return; … … 1578 1577 // check for spaces 1579 1578 if (StringHandler::containsSpace(mpNameTextBox->text())) { 1580 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName ).arg(Helper::error),1579 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), 1581 1580 tr("A component name should not have spaces. Please choose another name."), Helper::ok); 1582 1581 return; … … 1584 1583 // check for comma 1585 1584 if (mpNameTextBox->text().contains(',')) { 1586 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName ).arg(Helper::error),1585 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), 1587 1586 GUIMessages::getMessage(GUIMessages::INVALID_INSTANCE_NAME).arg(mpNameTextBox->text()), Helper::ok); 1588 1587 return; … … 1590 1589 // check for invalid names 1591 1590 MainWindow::instance()->getOMCProxy()->setLoggingEnabled(false); 1592 QList<QString> result = MainWindow::instance()->getOMCProxy()->parseString(QString("model M N %1; end M;").arg(mpNameTextBox->text()), 1593 "M", false); 1591 QList<QString> result = MainWindow::instance()->getOMCProxy()->parseString(QString("model M N %1; end M;").arg(mpNameTextBox->text()), "M", false); 1594 1592 MainWindow::instance()->getOMCProxy()->setLoggingEnabled(true); 1595 1593 if (result.isEmpty()) { 1596 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName ).arg(Helper::error),1594 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), 1597 1595 GUIMessages::getMessage(GUIMessages::INVALID_INSTANCE_NAME).arg(mpNameTextBox->text()), Helper::ok); 1598 1596 return; … … 1617 1615 } 1618 1616 // save the old ElementInfo 1619 ElementInfo oldComponentInfo(mp Component->getComponentInfo());1617 ElementInfo oldComponentInfo(mpElement->getComponentInfo()); 1620 1618 // Create a new ElementInfo 1621 1619 ElementInfo newComponentInfo; 1622 newComponentInfo.setClassName(mp Component->getComponentInfo()->getClassName());1620 newComponentInfo.setClassName(mpElement->getComponentInfo()->getClassName()); 1623 1621 newComponentInfo.setName(mpNameTextBox->text()); 1624 1622 newComponentInfo.setComment(mpCommentTextBox->text()); 1625 1623 newComponentInfo.setProtected(mpProtectedCheckBox->isChecked()); 1626 1624 newComponentInfo.setFinal(mpFinalCheckBox->isChecked()); 1627 newComponentInfo.setFlow(mp Component->getComponentInfo()->getFlow());1628 newComponentInfo.setStream(mp Component->getComponentInfo()->getStream());1625 newComponentInfo.setFlow(mpElement->getComponentInfo()->getFlow()); 1626 newComponentInfo.setStream(mpElement->getComponentInfo()->getStream()); 1629 1627 newComponentInfo.setReplaceable(mpReplaceAbleCheckBox->isChecked()); 1630 1628 newComponentInfo.setVariablity(variability); … … 1637 1635 */ 1638 1636 if (oldComponentInfo != newComponentInfo) { 1639 UpdateComponentAttributesCommand *pUpdateComponentAttributesCommand = new UpdateComponentAttributesCommand(mp Component, oldComponentInfo, newComponentInfo);1637 UpdateComponentAttributesCommand *pUpdateComponentAttributesCommand = new UpdateComponentAttributesCommand(mpElement, oldComponentInfo, newComponentInfo); 1640 1638 pModelWidget->getUndoStack()->push(pUpdateComponentAttributesCommand); 1641 1639 pModelWidget->updateModelText(); -
OMEdit/OMEditLIB/Element/ElementProperties.h
rc5f80b95 r953d678e 200 200 Q_OBJECT 201 201 public: 202 ElementAttributes(Element *p Component, QWidget *pParent = 0);202 ElementAttributes(Element *pElement, QWidget *pParent = 0); 203 203 void setUpDialog(); 204 204 void initializeDialog(); 205 205 private: 206 Element *mp Component;206 Element *mpElement; 207 207 Label *mpAttributesHeading; 208 208 QFrame *mHorizontalLine; … … 239 239 QDialogButtonBox *mpButtonBox; 240 240 public slots: 241 void update ComponentAttributes();241 void updateElementAttributes(); 242 242 }; 243 243 -
OMEdit/OMEditLIB/Modeling/Commands.cpp
r675fe85 r953d678e 441 441 OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy(); 442 442 // update component attributes 443 if (pOMCProxy->setComponentProperties(modelName, pComponent->getComponentInfo()->getName(), isFinal, flow, isProtected, isReplaceAble, 444 variability, isInner, isOuter, causality)) { 443 if (pOMCProxy->setComponentProperties(modelName, pComponent->getComponentInfo()->getName(), isFinal, flow, isProtected, isReplaceAble, variability, isInner, isOuter, causality)) { 445 444 pComponent->getComponentInfo()->setFinal(componentInfo.getFinal()); 446 445 pComponent->getComponentInfo()->setProtected(componentInfo.getProtected()); … … 472 471 } 473 472 } else { 474 QMessageBox::critical(MainWindow::instance(), 475 QString(Helper::applicationName).append(" - ").append(Helper::error), pOMCProxy->getResult(), Helper::ok); 473 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), pOMCProxy->getResult(), Helper::ok); 476 474 pOMCProxy->printMessagesStringInternal(); 477 475 } … … 484 482 if (pComponent->getLibraryTreeItem()->isConnector()) { 485 483 if (pComponent->getGraphicsView()->getViewType() == StringHandler::Icon) { 486 Element *pDiagramComponent = 0; 487 pDiagramComponent = pComponent->getGraphicsView()->getModelWidget()->getDiagramGraphicsView()->getElementObject(pComponent->getName()); 484 Element *pDiagramComponent = pComponent->getGraphicsView()->getModelWidget()->getDiagramGraphicsView()->getElementObject(pComponent->getName()); 488 485 if (pDiagramComponent) { 489 486 pDiagramComponent->componentCommentHasChanged(); 490 487 } 491 488 } else { 492 Element *pIconComponent = 0; 493 pIconComponent = pComponent->getGraphicsView()->getModelWidget()->getIconGraphicsView()->getElementObject(pComponent->getName()); 489 Element *pIconComponent = pComponent->getGraphicsView()->getModelWidget()->getIconGraphicsView()->getElementObject(pComponent->getName()); 494 490 if (pIconComponent) { 495 491 pIconComponent->componentCommentHasChanged(); … … 498 494 } 499 495 } else { 500 QMessageBox::critical(MainWindow::instance(), 501 QString(Helper::applicationName).append(" - ").append(Helper::error), pOMCProxy->getResult(), Helper::ok); 496 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), pOMCProxy->getResult(), Helper::ok); 502 497 pOMCProxy->printMessagesStringInternal(); 503 498 } … … 512 507 if (pComponent->getLibraryTreeItem()->isConnector()) { 513 508 if (pComponent->getGraphicsView()->getViewType() == StringHandler::Icon) { 514 Element *pDiagramComponent = 0; 515 pDiagramComponent = pComponent->getGraphicsView()->getModelWidget()->getDiagramGraphicsView()->getElementObject(pComponent->getName()); 509 Element *pDiagramComponent = pComponent->getGraphicsView()->getModelWidget()->getDiagramGraphicsView()->getElementObject(pComponent->getName()); 516 510 if (pDiagramComponent) { 517 511 pDiagramComponent->componentNameHasChanged(); 518 512 } 519 513 } else { 520 Element *pIconComponent = 0; 521 pIconComponent = pComponent->getGraphicsView()->getModelWidget()->getIconGraphicsView()->getElementObject(pComponent->getName()); 514 Element *pIconComponent = pComponent->getGraphicsView()->getModelWidget()->getIconGraphicsView()->getElementObject(pComponent->getName()); 522 515 if (pIconComponent) { 523 516 pIconComponent->componentNameHasChanged(); … … 526 519 } 527 520 } else { 528 QMessageBox::critical(MainWindow::instance(), 529 QString(Helper::applicationName).append(" - ").append(Helper::error), pOMCProxy->getResult(), Helper::ok); 521 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), pOMCProxy->getResult(), Helper::ok); 530 522 pOMCProxy->printMessagesStringInternal(); 531 523 } … … 537 529 pComponent->getComponentInfo()->setArrayIndex(arrayIndex); 538 530 } else { 539 QMessageBox::critical(MainWindow::instance(), 540 QString(Helper::applicationName).append(" - ").append(Helper::error), pOMCProxy->getResult(), Helper::ok); 531 QMessageBox::critical(MainWindow::instance(), QString("%1 - %2").arg(Helper::applicationName, Helper::error), pOMCProxy->getResult(), Helper::ok); 541 532 pOMCProxy->printMessagesStringInternal(); 542 533 }
Note: See TracChangeset
for help on using the changeset viewer.