Changeset 26abcb97 in OpenModelica
- Timestamp:
- 2016-04-01T15:28:50+02:00 (8 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, master, omlib-staging
- Children:
- d8c46e3, ddb7de2
- Parents:
- fbf65b8c (diff), 29cba5b3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- OMEdit/OMEditGUI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditGUI/Editors/MetaModelEditor.cpp
rfbf65b8c r26abcb97 98 98 } 99 99 100 101 /*! 102 * @\brief MetaModelEditor::getSubModelElement 103 * Returns SubModel element tag by model name 104 * @param name Name of the sub model to search for 105 * @return 106 */ 107 QDomElement MetaModelEditor::getSubModelElement(QString name) 108 { 109 QDomElement subModelsElement = getSubModelsElement(); 110 if(!subModelsElement.isNull()) { 111 QDomElement subModelElement = subModelsElement.firstChildElement("SubModel"); 112 while(!subModelElement.isNull()) { 113 if(subModelElement.attribute("Name").compare(name) == 0) { 114 return subModelElement; 115 } 116 subModelElement = subModelElement.nextSiblingElement("SubModel"); 117 } 118 } 119 return QDomElement(); 120 } 121 100 122 /*! 101 123 * \brief MetaModelEditor::getSubModelsElement … … 479 501 /*! 480 502 * \brief MetaModelEditor::getRotationMatrix 481 * \param rotation 503 * Computes the corresponding rotation matrix for specified rotation vector 504 * \param rotation Rotation vector with Euler angles 482 505 * \return 483 506 */ 484 507 QGenericMatrix<3,3, double> MetaModelEditor::getRotationMatrix(QGenericMatrix<3,1,double> rotation) 485 508 { 486 double alpha = rotation(0,0); 487 double beta = rotation(0,1); 488 double gamma = rotation(0,2); 489 490 //Compute rotational matrix around x-axis 491 double Rx_data[9]; 492 Rx_data[0] = 1; Rx_data[1] = 0; Rx_data[2] = 0; 493 Rx_data[3] = 0; Rx_data[4] = cos(alpha); Rx_data[5] = -sin(alpha); 494 Rx_data[6] = 0; Rx_data[7] = sin(alpha); Rx_data[8] = cos(alpha); 495 QGenericMatrix<3,3,double> Rx(Rx_data); 496 497 //Compute rotational matrix around y-axis 498 double Ry_data[9]; 499 Ry_data[0] = cos(beta); Ry_data[1] = 0; Ry_data[2] = sin(beta); 500 Ry_data[3] = 0; Ry_data[4] = 1; Ry_data[5] = 0; 501 Ry_data[6] = -sin(beta); Ry_data[7] = 0; Ry_data[8] = cos(beta); 502 503 QGenericMatrix<3,3,double> Ry(Ry_data); 504 505 //Compute rotational matrix around z-axis 506 double Rz_data[9]; 507 Rz_data[0] = cos(gamma); Rz_data[1] = -sin(gamma); Rz_data[2] = 0; 508 Rz_data[3] = sin(gamma); Rz_data[4] = cos(gamma); Rz_data[5] = 0; 509 Rz_data[6] = 0; Rz_data[7] = 0; Rz_data[8] = 1; 510 QGenericMatrix<3,3,double> Rz(Rz_data); 511 512 513 //Compute complete rotational matrix 514 QGenericMatrix<3,3,double> R = Rx*Ry*Rz; 509 double c1 = cos(rotation(0,0)); 510 double s1 = sin(rotation(0,0)); 511 double c2 = cos(rotation(0,1)); 512 double s2 = sin(rotation(0,1)); 513 double c3 = cos(rotation(0,2)); 514 double s3 = sin(rotation(0,2)); 515 516 double R_data[9]; 517 R_data[0] = c2*c3; R_data[1] = c2*s3; R_data[2] = -s2; 518 R_data[3] = -c1*s3+s1*s2*c3; R_data[4] = c1*c3+s1*s2*s3; R_data[5] = s1*c2; 519 R_data[6] = s1*s3+c1*s2*c3; R_data[7] = -s1*c3+c1*s2*s3; R_data[8] = c1*c2; 520 521 QGenericMatrix<3,3,double> R(R_data); 515 522 516 523 return R; 517 524 } 518 525 526 527 /*! 528 * \brief MetaModelEditor::getRotationVector 529 * Computes a rotation vector (321) from a rotation matrix 530 * \param R 531 * \return 532 */ 533 QGenericMatrix<3,1,double> MetaModelEditor::getRotationVector(QGenericMatrix<3,3,double> R) 534 { 535 double a11 = R(0,0); 536 double a12 = R(0,1); 537 double a13 = R(0,2); 538 double a23 = R(1,2); 539 double a33 = R(2,2); 540 541 double phi[3]; 542 phi[1] = (fabs(a13) < DBL_MIN)? 0.0 : asin((a13<-1.0) ? 1.0 : ((a13>1.0) ? -1.0 : -a13)); 543 double tmp = cos(phi[2]); 544 double cosphi2 = tmp+sign(tmp)*1.0e-50; 545 546 phi[0] = atan2(a23/cosphi2, a33/cosphi2); 547 phi[2] = atan2(a12/cosphi2, a11/cosphi2); 548 549 return QGenericMatrix<3,1,double>(phi); 550 } 551 552 /*! 553 * \brief MetaModelEditor::getPositionAndRotationVectors 554 * Extracts position and rotation vectors for specified TLM interface, both between CG and model X and between X and interface C 555 * \param interface Interface on the form "submodel.interface" 556 * \param CG_X_PHI_CG Rotation vector between CG abd X 557 * \param X_C_PHI_X Rotation vector between X and C 558 * \param CG_X_R_CG Position vector between CG and X 559 * \param X_C_R_X Position vector between X and C 560 * \return 561 */ 562 bool MetaModelEditor::getPositionAndRotationVectors(QString interface, 563 QGenericMatrix<3,1,double> &CG_X_PHI_CG, 564 QGenericMatrix<3,1,double> &X_C_PHI_X, 565 QGenericMatrix<3,1,double> &CG_X_R_CG, 566 QGenericMatrix<3,1,double> &X_C_R_X) 567 { 568 //Extract submodel and interface names 569 QString modelName = interface.split(".").at(0); 570 QString interfaceName = interface.split(".").at(1); 571 572 //Read positions and rotations from XML 573 QString x_c_r_x_str, x_c_phi_x_str; 574 QString cg_x_phi_cg_str, cg_x_r_cg_str; 575 QDomElement subModelElement = getSubModelElement(modelName); 576 cg_x_r_cg_str = subModelElement.attribute("Position"); 577 cg_x_phi_cg_str = subModelElement.attribute("Angle321"); 578 QDomElement interfaceElement = subModelElement.firstChildElement("InterfacePoint"); 579 while(!interfaceElement.isNull()) { 580 if(interfaceElement.attribute("Name").compare(interfaceName) == 0) { 581 x_c_r_x_str = interfaceElement.attribute("Position"); 582 x_c_phi_x_str = interfaceElement.attribute("Angle321"); 583 } 584 interfaceElement = interfaceElement.nextSiblingElement("InterfacePoint"); 585 } 586 587 //Make sure that all vector strings are found in XML 588 if(cg_x_phi_cg_str.isEmpty() || 589 cg_x_r_cg_str.isEmpty() || 590 x_c_r_x_str.isEmpty() || 591 x_c_phi_x_str.isEmpty()) 592 { 593 QString msg = "Interface coordinates does not exist in xml"; 594 mpMainWindow->getMessagesWidget()->addGUIMessage(MessageItem(MessageItem::MetaModel, "",false,0,0,0,0,msg,Helper::scriptingKind,Helper::errorLevel)); 595 return false; 596 } 597 598 //Convert from strings to arrays 599 double cg_x_phi_cg[3],x_c_phi_x[3]; 600 double cg_x_r_cg[3],x_c_r_x[3]; 601 602 cg_x_phi_cg[0] = cg_x_phi_cg_str.split(",")[0].toDouble(); 603 cg_x_phi_cg[1] = cg_x_phi_cg_str.split(",")[1].toDouble(); 604 cg_x_phi_cg[2] = cg_x_phi_cg_str.split(",")[2].toDouble(); 605 606 x_c_phi_x[0] = x_c_phi_x_str.split(",")[0].toDouble(); 607 x_c_phi_x[1] = x_c_phi_x_str.split(",")[1].toDouble(); 608 x_c_phi_x[2] = x_c_phi_x_str.split(",")[2].toDouble(); 609 610 cg_x_r_cg[0] = cg_x_r_cg_str.split(",")[0].toDouble(); 611 cg_x_r_cg[1] = cg_x_r_cg_str.split(",")[1].toDouble(); 612 cg_x_r_cg[2] = cg_x_r_cg_str.split(",")[2].toDouble(); 613 614 x_c_r_x[0] = x_c_r_x_str.split(",")[0].toDouble(); 615 x_c_r_x[1] = x_c_r_x_str.split(",")[1].toDouble(); 616 x_c_r_x[2] = x_c_r_x_str.split(",")[2].toDouble(); 617 618 //Convert from arrays to Qt matrices 619 CG_X_PHI_CG = QGenericMatrix<3,1,double>(cg_x_phi_cg); //Rotation of X relative to CG expressed in CG 620 X_C_PHI_X = QGenericMatrix<3,1,double>(x_c_phi_x); //Rotation of C relative to X expressed in X 621 CG_X_R_CG = QGenericMatrix<3,1,double>(cg_x_r_cg); //Position of X1 relative to CG expressed in CG 622 X_C_R_X = QGenericMatrix<3,1,double>(x_c_r_x); //Position of C relative to X expressed in X 623 624 return true; 625 } 626 519 627 /*! 520 628 * \brief MetaModelEditor::alignInterfaces 521 * \param fromSubModel 522 * \param toSubModel 523 */ 524 void MetaModelEditor::alignInterfaces(QString fromSubModel, QString toSubModel) 525 { 526 //Extract submodel and interface names 527 QString model1 = fromSubModel.split(".").at(0); 528 QString interface1 = fromSubModel.split(".").at(1); 529 QString model2 = toSubModel.split(".").at(0); 530 QString interface2 = toSubModel.split(".").at(1); 531 532 //Read positions and rotations from XML 533 QDomElement subModelElement1; 534 QString x1_c1_r_x1_str, x1_c1_phi_x1_str, x2_c2_r_x2_str, x2_c2_phi_x2_str; 535 QString cg_x1_phi_cg_str, cg_x2_phi_cg_str, cg_x1_r_cg_str, cg_x2_r_cg_str; 536 QDomElement modelElement = mXmlDocument.firstChildElement("Model"); 537 if(!modelElement.isNull()) { 538 QDomElement subModelsElement = modelElement.firstChildElement("SubModels"); 539 if(!subModelsElement.isNull()) { 540 QDomElement subModelElement = subModelsElement.firstChildElement("SubModel"); 541 while(!subModelElement.isNull()) { 542 if(subModelElement.attribute("Name").compare(model1) == 0) { 543 cg_x1_r_cg_str = subModelElement.attribute("Position"); 544 cg_x1_phi_cg_str = subModelElement.attribute("Angle321"); 545 subModelElement1 = subModelElement; //Store this element for writing back data after transformation 546 } 547 else if(subModelElement.attribute("Name").compare(model2) == 0) { 548 cg_x2_r_cg_str = subModelElement.attribute("Position"); 549 cg_x2_phi_cg_str = subModelElement.attribute("Angle321"); 550 } 551 QDomElement interfaceElement = subModelElement.firstChildElement("InterfacePoint"); 552 while(!interfaceElement.isNull()) { 553 if(subModelElement.attribute("Name").compare(model1) == 0 && 554 interfaceElement.attribute("Name").compare(interface1) == 0) { 555 x1_c1_r_x1_str = interfaceElement.attribute("Position"); 556 x1_c1_phi_x1_str = interfaceElement.attribute("Angle321"); 557 } 558 else if(subModelElement.attribute("Name").compare(model2) == 0 && 559 interfaceElement.attribute("Name").compare(interface2) == 0) { 560 x2_c2_r_x2_str = interfaceElement.attribute("Position"); 561 x2_c2_phi_x2_str = interfaceElement.attribute("Angle321"); 562 } 563 interfaceElement = interfaceElement.nextSiblingElement("InterfacePoint"); 564 } 565 subModelElement = subModelElement.nextSiblingElement("SubModel"); 566 } 567 } 568 } 569 570 //Assert that all rotations and positions were found (do something smarter?) 571 if(cg_x1_phi_cg_str.isEmpty() || 572 cg_x2_phi_cg_str.isEmpty() || 573 cg_x1_r_cg_str.isEmpty() || 574 cg_x2_r_cg_str.isEmpty() || 575 x1_c1_r_x1_str.isEmpty() || 576 x1_c1_phi_x1_str.isEmpty() || 577 x2_c2_r_x2_str.isEmpty() || 578 x2_c2_phi_x2_str.isEmpty()) 579 { 580 QString msg = "Interface coordinates does not exist in xml"; 581 mpMainWindow->getMessagesWidget()->addGUIMessage(MessageItem(MessageItem::MetaModel, "",false,0,0,0,0,msg,Helper::scriptingKind,Helper::errorLevel)); 582 return; 583 } 584 585 //Convert from strings to arrays 586 double cg_x1_phi_cg[3],cg_x2_phi_cg[3],x1_c1_phi_x1[3],x2_c2_phi_x2[3]; 587 double cg_x1_r_cg[3],cg_x2_r_cg[3],x1_c1_r_x1[3],x2_c2_r_x2[3]; 588 589 cg_x1_phi_cg[0] = cg_x1_phi_cg_str.split(",")[0].toDouble(); 590 cg_x1_phi_cg[1] = cg_x1_phi_cg_str.split(",")[1].toDouble(); 591 cg_x1_phi_cg[2] = cg_x1_phi_cg_str.split(",")[2].toDouble(); 592 593 cg_x2_phi_cg[0] = cg_x2_phi_cg_str.split(",")[0].toDouble(); 594 cg_x2_phi_cg[1] = cg_x2_phi_cg_str.split(",")[1].toDouble(); 595 cg_x2_phi_cg[2] = cg_x2_phi_cg_str.split(",")[2].toDouble(); 596 597 x1_c1_phi_x1[0] = x1_c1_phi_x1_str.split(",")[0].toDouble(); 598 x1_c1_phi_x1[1] = x1_c1_phi_x1_str.split(",")[1].toDouble(); 599 x1_c1_phi_x1[2] = x1_c1_phi_x1_str.split(",")[2].toDouble(); 600 601 x2_c2_phi_x2[0] = x2_c2_phi_x2_str.split(",")[0].toDouble(); 602 x2_c2_phi_x2[1] = x2_c2_phi_x2_str.split(",")[1].toDouble(); 603 x2_c2_phi_x2[2] = x2_c2_phi_x2_str.split(",")[2].toDouble(); 604 605 cg_x1_r_cg[0] = cg_x1_r_cg_str.split(",")[0].toDouble(); 606 cg_x1_r_cg[1] = cg_x1_r_cg_str.split(",")[1].toDouble(); 607 cg_x1_r_cg[2] = cg_x1_r_cg_str.split(",")[2].toDouble(); 608 609 cg_x2_r_cg[0] = cg_x2_r_cg_str.split(",")[0].toDouble(); 610 cg_x2_r_cg[1] = cg_x2_r_cg_str.split(",")[1].toDouble(); 611 cg_x2_r_cg[2] = cg_x2_r_cg_str.split(",")[2].toDouble(); 612 613 x1_c1_r_x1[0] = x1_c1_r_x1_str.split(",")[0].toDouble(); 614 x1_c1_r_x1[1] = x1_c1_r_x1_str.split(",")[1].toDouble(); 615 x1_c1_r_x1[2] = x1_c1_r_x1_str.split(",")[2].toDouble(); 616 617 x2_c2_r_x2[0] = x2_c2_r_x2_str.split(",")[0].toDouble(); 618 x2_c2_r_x2[1] = x2_c2_r_x2_str.split(",")[1].toDouble(); 619 x2_c2_r_x2[2] = x2_c2_r_x2_str.split(",")[2].toDouble(); 620 621 //Convert from arrays to Qt matrices 622 QGenericMatrix<3,1,double> CG_X1_PHI_CG(cg_x1_phi_cg); //Rotation of X1 relative to CG expressed in CG 623 QGenericMatrix<3,1,double> CG_X2_PHI_CG(cg_x2_phi_cg); //Rotation of X2 relative to CG expressed in CG 624 QGenericMatrix<3,1,double> X1_C1_PHI_X1(x1_c1_phi_x1); //Rotation of C1 relative to X1 expressed in X1 625 QGenericMatrix<3,1,double> X2_C2_PHI_X2(x2_c2_phi_x2); //Rotation of C2 relative to X2 expressed in X2 626 QGenericMatrix<3,1,double> CG_X1_R_CG(cg_x1_r_cg); //Position of X1 relative to CG expressed in CG 627 QGenericMatrix<3,1,double> CG_X2_R_CG(cg_x2_r_cg); //Position of X2 relative to CG expressed in CG 628 QGenericMatrix<3,1,double> X1_C1_R_X1(x1_c1_r_x1); //Position of C1 relative to X1 expressed in X1 629 QGenericMatrix<3,1,double> X2_C2_R_X2(x2_c2_r_x2); //Position of C2 relative to X2 expressed in X2 629 * Aligns interface C1 in model X1 to interface C2 in model X2 630 * \param fromSubModel Full name of first interfae (X1.C1) 631 * \param toSubModel Full name of second interface (X2.C2) 632 */ 633 void MetaModelEditor::alignInterfaces(QString fromInterface, QString toInterface) 634 { 635 636 //Extract rotation and position vectors to Qt matrices 637 QGenericMatrix<3,1,double> CG_X1_PHI_CG; //Rotation of X1 relative to CG expressed in CG 638 QGenericMatrix<3,1,double> X1_C1_PHI_X1; //Rotation of C1 relative to X1 expressed in X1 639 QGenericMatrix<3,1,double> CG_X1_R_CG; //Position of X1 relative to CG expressed in CG 640 QGenericMatrix<3,1,double> X1_C1_R_X1; //Position of C1 relative to X1 expressed in X1 641 if(!getPositionAndRotationVectors(fromInterface,CG_X1_PHI_CG, X1_C1_PHI_X1,CG_X1_R_CG,X1_C1_R_X1)) return; 642 643 QGenericMatrix<3,1,double> CG_X2_PHI_CG; //Rotation of X2 relative to CG expressed in CG 644 QGenericMatrix<3,1,double> X2_C2_PHI_X2; //Rotation of C2 relative to X2 expressed in X2 645 QGenericMatrix<3,1,double> CG_X2_R_CG; //Position of X2 relative to CG expressed in CG 646 QGenericMatrix<3,1,double> X2_C2_R_X2; //Position of C2 relative to X2 expressed in X2 647 if(!getPositionAndRotationVectors(toInterface,CG_X2_PHI_CG, X2_C2_PHI_X2,CG_X2_R_CG,X2_C2_R_X2)) return; 630 648 631 649 QGenericMatrix<3,3,double> R_X2_C2, R_CG_X1, R_CG_X2, R_CG_C2, R_X1_C1; … … 640 658 641 659 //Extract angles from rotation matrix 642 CG_X1_PHI_CG(0,0) = atan2(R_CG_X1(2,1),R_CG_X1(2,2)); 643 CG_X1_PHI_CG(0,1) = atan2(-R_CG_X1(2,0),sqrt(R_CG_X1(2,1)*R_CG_X1(2,1) + R_CG_X1(2,2)*R_CG_X1(2,2))); 644 CG_X1_PHI_CG(0,2) = atan2(R_CG_X1(1,0),R_CG_X1(0,0)); 660 CG_X1_PHI_CG = getRotationVector(R_CG_X1); 661 // CG_X1_PHI_CG(0,0) = atan2(R_CG_X1(2,1),R_CG_X1(2,2)); 662 // CG_X1_PHI_CG(0,1) = atan2(-R_CG_X1(2,0),sqrt(R_CG_X1(2,1)*R_CG_X1(2,1) + R_CG_X1(2,2)*R_CG_X1(2,2))); 663 // CG_X1_PHI_CG(0,2) = atan2(R_CG_X1(1,0),R_CG_X1(0,0)); 645 664 646 665 //New position of X1 relative to CG … … 648 667 649 668 //Write back new rotation and position to XML 650 cg_x1_r_cg_str = QString("%1,%2,%3").arg(CG_X1_R_CG(0,0)).arg(CG_X1_R_CG(0,1)).arg(CG_X1_R_CG(0,2));651 subModelElement1.setAttribute("Position", cg_x1_r_cg_str);652 cg_x1_phi_cg_str = QString("%1,%2,%3").arg(CG_X1_PHI_CG(0,0)).arg(CG_X1_PHI_CG(0,1)).arg(CG_X1_PHI_CG(0,2));653 subModelElement1.setAttribute("Angle321", cg_x1_phi_cg_str);669 QString cg_x1_r_cg_str = QString("%1,%2,%3").arg(CG_X1_R_CG(0,0)).arg(CG_X1_R_CG(0,1)).arg(CG_X1_R_CG(0,2)); 670 getSubModelElement(fromInterface.split(".").first()).setAttribute("Position", cg_x1_r_cg_str); 671 QString cg_x1_phi_cg_str = QString("%1,%2,%3").arg(CG_X1_PHI_CG(0,0)).arg(CG_X1_PHI_CG(0,1)).arg(CG_X1_PHI_CG(0,2)); 672 getSubModelElement(fromInterface.split(".").first()).setAttribute("Angle321", cg_x1_phi_cg_str); 654 673 setPlainText(mXmlDocument.toString()); 655 } 674 675 //Give error message if alignment failed 676 if(!interfacesAligned(fromInterface, toInterface)) 677 { 678 mpMainWindow->getMessagesWidget()->addGUIMessage(MessageItem(MessageItem::MetaModel, "",false,0,0,0,0,"Alignment operation failed.",Helper::scriptingKind,Helper::errorLevel)); 679 } 680 } 681 682 683 /*! 684 * \brief MetaModelEditor::fuzzyCompare 685 * Special implementation of fuzzyCompare. Uses much larger tolerance than built-in qFuzzyCompare() 686 * \param p1 687 * \param p2 688 * \return 689 */ 690 inline bool MetaModelEditor::fuzzyCompare(double p1, double p2) 691 { 692 //! @todo What tolerance should be used? This is just a random number that seemed to work for some reason. 693 return (qAbs(p1 - p2) <= 0.00001 * qMin(qAbs(p1), qAbs(p2))); 694 } 695 696 697 /*! 698 * \brief MetaModelEditor::interfacesAligned 699 * Checkes whether specified TLM interfaces are aligned 700 * \param interface1 First interface (submodel1.interface1) 701 * \param interface2 Second interface (submodel2.interface2) 702 * \return 703 */ 704 bool MetaModelEditor::interfacesAligned(QString interface1, QString interface2) 705 { 706 //Extract rotation and position vectors to Qt matrices 707 QGenericMatrix<3,1,double> CG_X1_PHI_CG; //Rotation of X1 relative to CG expressed in CG 708 QGenericMatrix<3,1,double> X1_C1_PHI_X1; //Rotation of C1 relative to X1 expressed in X1 709 QGenericMatrix<3,1,double> CG_X1_R_CG; //Position of X1 relative to CG expressed in CG 710 QGenericMatrix<3,1,double> X1_C1_R_X1; //Position of C1 relative to X1 expressed in X1 711 if(!getPositionAndRotationVectors(interface1,CG_X1_PHI_CG, X1_C1_PHI_X1,CG_X1_R_CG,X1_C1_R_X1)) return false; 712 713 QGenericMatrix<3,1,double> CG_X2_PHI_CG; //Rotation of X2 relative to CG expressed in CG 714 QGenericMatrix<3,1,double> X2_C2_PHI_X2; //Rotation of C2 relative to X2 expressed in X2 715 QGenericMatrix<3,1,double> CG_X2_R_CG; //Position of X2 relative to CG expressed in CG 716 QGenericMatrix<3,1,double> X2_C2_R_X2; //Position of C2 relative to X2 expressed in X2 717 if(!getPositionAndRotationVectors(interface2,CG_X2_PHI_CG, X2_C2_PHI_X2,CG_X2_R_CG,X2_C2_R_X2)) return false; 718 719 QGenericMatrix<3,1,double> CG_C1_R_CG, CG_C1_PHI_CG, CG_C2_R_CG, CG_C2_PHI_CG; 720 QGenericMatrix<3,3,double> R_X1_C1, R_CG_X1, R_CG_C1, R_X2_C2, R_CG_X2, R_CG_C2; 721 722 //Compute rotation matrices for both interfaces relative to CG and make sure they are the same 723 R_X1_C1 = getRotationMatrix(X1_C1_PHI_X1); //Rotation matrix between X1 and C1 724 R_CG_X1 = getRotationMatrix(CG_X1_PHI_CG); //Rotation matrix between CG and X1 725 R_CG_C1 = R_X1_C1*R_CG_X1; //Rotation matrix between CG and C1 726 R_X2_C2 = getRotationMatrix(X2_C2_PHI_X2); //Rotation matrix between X2 and C2 727 R_CG_X2 = getRotationMatrix(CG_X2_PHI_CG); //Rotation matrix between CG and X2 728 R_CG_C2 = R_X2_C2*R_CG_X2; //Rotation matrix between CG and C2 729 730 bool success=true; 731 for(int i=0; i<3; ++i) { 732 for(int j=0; j<3; ++j) { 733 if(!fuzzyCompare(R_CG_C1(i,j),R_CG_C2(i,j))) { 734 success=false; 735 } 736 } 737 } 738 739 //Compute positions for both interfaces relative to CG and make sure they are the same 740 CG_C1_R_CG = CG_X1_R_CG + X1_C1_R_X1*R_CG_X1; //Position of C1 relative to CG exressed in CG 741 CG_C2_R_CG = CG_X2_R_CG + X2_C2_R_X2*R_CG_X2; //Position of C2 relative to CG exressed in CG 742 743 for(int i=0; i<3; ++i) { 744 if(!fuzzyCompare(CG_C1_R_CG(0,i),CG_C2_R_CG(0,i))) { 745 success=false; 746 } 747 } 748 749 return success; 750 } 751 656 752 657 753 /*! -
OMEdit/OMEditGUI/Editors/MetaModelEditor.h
rf806cd87 r7368537b 71 71 QDomElement getConnectionsElement(); 72 72 QDomNodeList getConnections(); 73 QDomElement getSubModelElement(QString name); 73 74 bool addSubModel(QString name, QString exactStep, QString modelFile, QString startCommand, QString visible, QString origin, QString extent, 74 75 QString rotation); … … 92 93 XMLDocument mXmlDocument; 93 94 QGenericMatrix<3,3,double> getRotationMatrix(QGenericMatrix<3,1,double> rotation); 95 bool getPositionAndRotationVectors(QString interface, QGenericMatrix<3,1,double> &CG_X_PHI_CG, QGenericMatrix<3,1,double> &X_C_PHI_X, QGenericMatrix<3,1,double> &CG_X_R_CG, QGenericMatrix<3,1,double> &X_C_R_X); 96 bool interfacesAligned(QString interface1, QString interface2); 97 bool fuzzyCompare(double p1, double p2); 98 QGenericMatrix<3, 1, double> getRotationVector(QGenericMatrix<3, 3, double> R); 94 99 private slots: 95 100 virtual void showContextMenu(QPoint point); -
OMEdit/OMEditGUI/TLM/FetchInterfaceDataDialog.cpp
r2ecd6baa rae0b1748 214 214 for (int i = 0; i < connections.size(); i++) { 215 215 QDomElement connection = connections.at(i).toElement(); 216 interfaces << connection.attribute("From")+" to"+connection.attribute("To");217 interfaces << connection.attribute("To")+" to"+connection.attribute("From");216 interfaces << connection.attribute("From")+" -> "+connection.attribute("To"); 217 interfaces << connection.attribute("To")+" -> "+connection.attribute("From"); 218 218 } 219 219 } … … 263 263 QList<QListWidgetItem*> selectedItems = mpInterfaceListWidget->selectedItems(); 264 264 if (!selectedItems.isEmpty()) { 265 QString fromInterface = selectedItems.first()->text().section(" to",0,0);266 QString toInterface = selectedItems.first()->text().section(" to",1,1);265 QString fromInterface = selectedItems.first()->text().section(" -> ",0,0); 266 QString toInterface = selectedItems.first()->text().section(" -> ",1,1); 267 267 pMetaModelEditor->alignInterfaces(fromInterface, toInterface); 268 268 } -
OMEdit/OMEditGUI/TLM/TLMCoSimulationThread.cpp
r66abb94 r29cba5b3 77 77 environment.insert("TLMPluginPath", tlmCoSimulationOptions.getTLMPluginPath()); 78 78 mpManagerProcess->setProcessEnvironment(environment); 79 // start the executable79 // start the executable 80 80 mpManagerProcess->start(fileName, args); 81 81 emit sendManagerOutput(QString("%1 %2").arg(fileName).arg(args.join(" ")), StringHandler::OMEditInfo);
Note: See TracChangeset
for help on using the changeset viewer.