@@ -113,17 +113,17 @@ bool MetaModelEditor::validateText()
113
113
*/
114
114
QDomElement MetaModelEditor::getSubModelElement (QString name)
115
115
{
116
- QDomElement subModelsElement = getSubModelsElement ();
117
- if (!subModelsElement.isNull ()) {
118
- QDomElement subModelElement = subModelsElement.firstChildElement (" SubModel" );
119
- while (!subModelElement.isNull ()) {
120
- if (subModelElement.attribute (" Name" ).compare (name) == 0 ) {
121
- return subModelElement;
122
- }
123
- subModelElement = subModelElement.nextSiblingElement (" SubModel" );
116
+ QDomElement subModelsElement = getSubModelsElement ();
117
+ if (!subModelsElement.isNull ()) {
118
+ QDomElement subModelElement = subModelsElement.firstChildElement (" SubModel" );
119
+ while (!subModelElement.isNull ()) {
120
+ if (subModelElement.attribute (" Name" ).compare (name) == 0 ) {
121
+ return subModelElement;
124
122
}
123
+ subModelElement = subModelElement.nextSiblingElement (" SubModel" );
125
124
}
126
- return QDomElement ();
125
+ }
126
+ return QDomElement ();
127
127
}
128
128
129
129
/* !
@@ -386,21 +386,15 @@ bool MetaModelEditor::createConnection(LineAnnotation *pConnectionLineAnnotation
386
386
bool aligned = interfacesAligned (pConnectionLineAnnotation->getStartComponentName (), pConnectionLineAnnotation->getEndComponentName ());
387
387
pConnectionLineAnnotation->setAligned (aligned);
388
388
389
- if (this ->getInterfaceCausality (pConnectionLineAnnotation->getEndComponentName ()) ==
390
- StringHandler::getTLMCausality (StringHandler::TLMInput)) {
391
- pConnectionLineAnnotation->setLinePattern (StringHandler::LineDash);
392
- pConnectionLineAnnotation->setEndArrow (StringHandler::ArrowFilled);
393
- // pConnectionLineAnnotation->update();
394
- // pConnectionLineAnnotation->handleComponentMoved();
395
- }
396
- else if (this ->getInterfaceCausality (pConnectionLineAnnotation->getEndComponentName ()) ==
397
- StringHandler::getTLMCausality (StringHandler::TLMOutput)) {
398
- pConnectionLineAnnotation->setLinePattern (StringHandler::LineDash);
399
- pConnectionLineAnnotation->setStartArrow (StringHandler::ArrowFilled);
400
- // pConnectionLineAnnotation->update();
401
- // pConnectionLineAnnotation->handleComponentMoved();
389
+ if (this ->getInterfaceCausality (pConnectionLineAnnotation->getEndComponentName ()) ==
390
+ StringHandler::getTLMCausality (StringHandler::TLMInput)) {
391
+ pConnectionLineAnnotation->setLinePattern (StringHandler::LineDash);
392
+ pConnectionLineAnnotation->setEndArrow (StringHandler::ArrowFilled);
393
+ } else if (this ->getInterfaceCausality (pConnectionLineAnnotation->getEndComponentName ()) ==
394
+ StringHandler::getTLMCausality (StringHandler::TLMOutput)) {
395
+ pConnectionLineAnnotation->setLinePattern (StringHandler::LineDash);
396
+ pConnectionLineAnnotation->setStartArrow (StringHandler::ArrowFilled);
402
397
}
403
-
404
398
return true ;
405
399
}
406
400
return false ;
@@ -414,49 +408,41 @@ bool MetaModelEditor::createConnection(LineAnnotation *pConnectionLineAnnotation
414
408
*/
415
409
bool MetaModelEditor::okToConnect (LineAnnotation *pConnectionLineAnnotation)
416
410
{
417
- QString startComp = pConnectionLineAnnotation->getStartComponentName ();
418
- QString endComp = pConnectionLineAnnotation->getEndComponentName ();
411
+ QString startComp = pConnectionLineAnnotation->getStartComponentName ();
412
+ QString endComp = pConnectionLineAnnotation->getEndComponentName ();
419
413
420
- int dimensions1 = getInterfaceDimensions (startComp);
421
- int dimensions2 = getInterfaceDimensions (endComp);
422
- QString causality1 = getInterfaceCausality (startComp);
423
- QString causality2 = getInterfaceCausality (endComp);
424
- QString domain1 = getInterfaceDomain (startComp);
425
- QString domain2 = getInterfaceDomain (endComp);
414
+ int dimensions1 = getInterfaceDimensions (startComp);
415
+ int dimensions2 = getInterfaceDimensions (endComp);
416
+ QString causality1 = getInterfaceCausality (startComp);
417
+ QString causality2 = getInterfaceCausality (endComp);
418
+ QString domain1 = getInterfaceDomain (startComp);
419
+ QString domain2 = getInterfaceDomain (endComp);
426
420
421
+ if (dimensions1 != dimensions2) {
427
422
MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
428
- " Checking connection between " +
429
- startComp+" and " +endComp,
430
- Helper::scriptingKind, Helper::notificationLevel));
431
-
432
- if (dimensions1 != dimensions2) {
433
- MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
434
- " Cannot connect interface points of different dimensions (" +
435
- QString::number (dimensions1)+" to " +
436
- QString::number (dimensions2)+" )" ,
437
- Helper::scriptingKind, Helper::errorLevel));
438
- return false ;
439
- }
440
- if (!(causality1 == StringHandler::getTLMCausality (StringHandler::TLMBidirectional) &&
441
- causality2 == StringHandler::getTLMCausality (StringHandler::TLMBidirectional)) &&
442
- !(causality1 == StringHandler::getTLMCausality (StringHandler::TLMInput) &&
443
- causality2 == StringHandler::getTLMCausality (StringHandler::TLMOutput)) &&
444
- !(causality1 == StringHandler::getTLMCausality (StringHandler::TLMOutput) &&
445
- causality2 == StringHandler::getTLMCausality (StringHandler::TLMInput))) {
446
- MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
447
- " Cannot connect interface points of different causality (" +
448
- causality1+" to " +causality2+" )" ,
449
- Helper::scriptingKind, Helper::errorLevel));
450
- return false ;
451
- }
452
- if (domain1 != domain2) {
453
- MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
454
- " Cannot connect interface points of different domains (" +
455
- domain1+" to " +domain2+" )" ,
456
- Helper::scriptingKind, Helper::errorLevel));
457
- return false ;
458
- }
459
- return true ;
423
+ tr (" Cannot connect interface points of different dimensions (%1 to %2)" )
424
+ .arg (QString::number (dimensions1), QString::number (dimensions2)),
425
+ Helper::scriptingKind, Helper::errorLevel));
426
+ return false ;
427
+ }
428
+ if (!(causality1 == StringHandler::getTLMCausality (StringHandler::TLMBidirectional) &&
429
+ causality2 == StringHandler::getTLMCausality (StringHandler::TLMBidirectional)) &&
430
+ !(causality1 == StringHandler::getTLMCausality (StringHandler::TLMInput) &&
431
+ causality2 == StringHandler::getTLMCausality (StringHandler::TLMOutput)) &&
432
+ !(causality1 == StringHandler::getTLMCausality (StringHandler::TLMOutput) &&
433
+ causality2 == StringHandler::getTLMCausality (StringHandler::TLMInput))) {
434
+ MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
435
+ tr (" Cannot connect interface points of different causality (%1 to %2)" )
436
+ .arg (causality1, causality2), Helper::scriptingKind, Helper::errorLevel));
437
+ return false ;
438
+ }
439
+ if (domain1 != domain2) {
440
+ MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 ,
441
+ tr (" Cannot connect interface points of different domains (%1 to %2)" )
442
+ .arg (domain1, domain2), Helper::scriptingKind, Helper::errorLevel));
443
+ return false ;
444
+ }
445
+ return true ;
460
446
}
461
447
462
448
/* !
@@ -681,8 +667,8 @@ void MetaModelEditor::addInterfacesData(QDomElement interfaces)
681
667
bool MetaModelEditor::interfacesAligned (QString interface1, QString interface2)
682
668
{
683
669
if (getInterfaceCausality (interface1) != StringHandler::getTLMCausality (StringHandler::TLMBidirectional)) {
684
- // Assume interface2 has same causality and dimensions, otherwise they could not be connected)
685
- return true ; // Alignment is not relevant for non-bidirectional connections
670
+ // Assume interface2 has same causality and dimensions, otherwise they could not be connected)
671
+ return true ; // Alignment is not relevant for non-bidirectional connections
686
672
}
687
673
688
674
// Extract rotation and position vectors to Qt matrices
@@ -698,17 +684,16 @@ bool MetaModelEditor::interfacesAligned(QString interface1, QString interface2)
698
684
QGenericMatrix<3 ,1 ,double > X2_C2_PHI_X2; // Rotation of C2 relative to X2 expressed in X2
699
685
QGenericMatrix<3 ,1 ,double > CG_X2_R_CG; // Position of X2 relative to CG expressed in CG
700
686
QGenericMatrix<3 ,1 ,double > X2_C2_R_X2; // Position of C2 relative to X2 expressed in X2
687
+
701
688
if (!getPositionAndRotationVectors (interface2,CG_X2_PHI_CG, X2_C2_PHI_X2,CG_X2_R_CG,X2_C2_R_X2)) {
702
689
return false ;
703
- }
704
-
705
- else if (getInterfaceCausality (interface1) == StringHandler::getTLMCausality (StringHandler::TLMBidirectional) &&
706
- getInterfaceDimensions (interface1) == 1 ) {
707
- // Handle 1D- interfaces
708
- // Assume interface2 has same causality and dimensions, otherwise they could not be connected)
709
- // Only compare first element of interface position relative to external model,
710
- // the model orientation should not matter for 1D connections
711
- return fuzzyCompare (X1_C1_R_X1 (0 ,0 ),X2_C2_R_X2 (0 ,0 ));
690
+ } else if (getInterfaceCausality (interface1) == StringHandler::getTLMCausality (StringHandler::TLMBidirectional) &&
691
+ getInterfaceDimensions (interface1) == 1 ) {
692
+ // Handle 1D- interfaces
693
+ // Assume interface2 has same causality and dimensions, otherwise they could not be connected)
694
+ // Only compare first element of interface position relative to external model,
695
+ // the model orientation should not matter for 1D connections
696
+ return fuzzyCompare (X1_C1_R_X1 (0 ,0 ),X2_C2_R_X2 (0 ,0 ));
712
697
}
713
698
714
699
QGenericMatrix<3 ,1 ,double > CG_C1_R_CG, CG_C1_PHI_CG, CG_C2_R_CG, CG_C2_PHI_CG;
@@ -949,9 +934,9 @@ void MetaModelEditor::alignInterfaces(QString fromInterface, QString toInterface
949
934
950
935
// Extract angles from rotation matrix
951
936
QGenericMatrix<3 ,1 ,double > CG_X1_PHI_CG_new = getRotationVector (R_CG_X1);
952
- // CG_X1_PHI_CG(0,0) = atan2(R_CG_X1(2,1),R_CG_X1(2,2));
953
- // 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)));
954
- // CG_X1_PHI_CG(0,2) = atan2(R_CG_X1(1,0),R_CG_X1(0,0));
937
+ // CG_X1_PHI_CG(0,0) = atan2(R_CG_X1(2,1),R_CG_X1(2,2));
938
+ // 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)));
939
+ // CG_X1_PHI_CG(0,2) = atan2(R_CG_X1(1,0),R_CG_X1(0,0));
955
940
956
941
// New position of X1 relative to CG
957
942
QGenericMatrix<3 ,1 ,double > CG_X1_R_CG_new = CG_X2_R_CG + X2_C2_R_X2*R_CG_X2 - X1_C1_R_X1*R_CG_X1;
@@ -986,38 +971,36 @@ void MetaModelEditor::alignInterfaces(QString fromInterface, QString toInterface
986
971
*/
987
972
int MetaModelEditor::getInterfaceDimensions (QString interfacePoint)
988
973
{
989
- // Extract submodel and interface names
990
- QString modelName = interfacePoint.split (" ." ).at (0 );
991
- QString interfaceName = interfacePoint.split (" ." ).at (1 );
992
-
993
- QDomElement subModelElement = getSubModelElement (modelName);
994
- QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
995
- while (!interfaceElement.isNull ()) {
996
- if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
997
- return interfaceElement.attribute (" Dimensions" , " 3" ).toInt ();
998
- }
999
- interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
974
+ // Extract submodel and interface names
975
+ QString modelName = interfacePoint.split (" ." ).at (0 );
976
+ QString interfaceName = interfacePoint.split (" ." ).at (1 );
977
+
978
+ QDomElement subModelElement = getSubModelElement (modelName);
979
+ QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
980
+ while (!interfaceElement.isNull ()) {
981
+ if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
982
+ return interfaceElement.attribute (" Dimensions" , " 3" ).toInt ();
1000
983
}
1001
- return 3 ; // Backwards compatibility
984
+ interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
985
+ }
986
+ return 3 ; // Backwards compatibility
1002
987
}
1003
988
1004
989
QString MetaModelEditor::getInterfaceCausality (QString interfacePoint)
1005
990
{
1006
- MessagesWidget::instance ()->addGUIMessage (MessageItem (MessageItem::MetaModel, " " , false , 0 , 0 , 0 , 0 , " Checking causality for: " +interfacePoint,
1007
- Helper::scriptingKind, Helper::notificationLevel));
1008
- // Extract submodel and interface names
1009
- QString modelName = interfacePoint.split (" ." ).at (0 );
1010
- QString interfaceName = interfacePoint.split (" ." ).at (1 );
1011
-
1012
- QDomElement subModelElement = getSubModelElement (modelName);
1013
- QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
1014
- while (!interfaceElement.isNull ()) {
1015
- if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
1016
- return interfaceElement.attribute (" Causality" , StringHandler::getTLMCausality (StringHandler::TLMBidirectional));
1017
- }
1018
- interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
991
+ // Extract submodel and interface names
992
+ QString modelName = interfacePoint.split (" ." ).at (0 );
993
+ QString interfaceName = interfacePoint.split (" ." ).at (1 );
994
+
995
+ QDomElement subModelElement = getSubModelElement (modelName);
996
+ QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
997
+ while (!interfaceElement.isNull ()) {
998
+ if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
999
+ return interfaceElement.attribute (" Causality" , StringHandler::getTLMCausality (StringHandler::TLMBidirectional));
1019
1000
}
1020
- return StringHandler::getTLMCausality (StringHandler::TLMBidirectional); // Backwards compatibility
1001
+ interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
1002
+ }
1003
+ return StringHandler::getTLMCausality (StringHandler::TLMBidirectional); // Backwards compatibility
1021
1004
}
1022
1005
1023
1006
/* !
@@ -1028,20 +1011,20 @@ QString MetaModelEditor::getInterfaceCausality(QString interfacePoint)
1028
1011
*/
1029
1012
QString MetaModelEditor::getInterfaceDomain (QString interfacePoint)
1030
1013
{
1031
- // Extract submodel and interface names
1032
- QString modelName = interfacePoint.split (" ." ).at (0 );
1033
- QString interfaceName = interfacePoint.split (" ." ).at (1 );
1034
-
1035
- QDomElement subModelElement = getSubModelElement (modelName);
1036
- QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
1037
- while (!interfaceElement.isNull ()) {
1038
- if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
1039
- // Default to mechanical for backwards compatibility
1040
- return interfaceElement.attribute (" Domain" , StringHandler::getTLMDomain (StringHandler::Mechanical));
1041
- }
1042
- interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
1014
+ // Extract submodel and interface names
1015
+ QString modelName = interfacePoint.split (" ." ).at (0 );
1016
+ QString interfaceName = interfacePoint.split (" ." ).at (1 );
1017
+
1018
+ QDomElement subModelElement = getSubModelElement (modelName);
1019
+ QDomElement interfaceElement = subModelElement.firstChildElement (" InterfacePoint" );
1020
+ while (!interfaceElement.isNull ()) {
1021
+ if (interfaceElement.attribute (" Name" ).compare (interfaceName) == 0 ) {
1022
+ // Default to mechanical for backwards compatibility
1023
+ return interfaceElement.attribute (" Domain" , StringHandler::getTLMDomain (StringHandler::Mechanical));
1043
1024
}
1044
- return StringHandler::getTLMDomain (StringHandler::Mechanical); // Backwards compatibility
1025
+ interfaceElement = interfaceElement.nextSiblingElement (" InterfacePoint" );
1026
+ }
1027
+ return StringHandler::getTLMDomain (StringHandler::Mechanical); // Backwards compatibility
1045
1028
}
1046
1029
1047
1030
/* !
@@ -1123,7 +1106,7 @@ void MetaModelEditor::contentsHasChanged(int position, int charsRemoved, int cha
1123
1106
1124
1107
// ! Constructor
1125
1108
MetaModelHighlighter::MetaModelHighlighter (MetaModelEditorPage *pMetaModelEditorPage, QPlainTextEdit *pPlainTextEdit)
1126
- : QSyntaxHighlighter(pPlainTextEdit->document ())
1109
+ : QSyntaxHighlighter(pPlainTextEdit->document ())
1127
1110
{
1128
1111
mpMetaModelEditorPage = pMetaModelEditorPage;
1129
1112
mpPlainTextEdit = pPlainTextEdit;
@@ -1165,7 +1148,7 @@ void MetaModelHighlighter::initializeSettings()
1165
1148
mHighlightingRules .append (rule);
1166
1149
}
1167
1150
1168
- // MetaModel Elements
1151
+ // MetaModel Elements
1169
1152
QStringList elementPatterns;
1170
1153
elementPatterns << " \\ bxml\\ b"
1171
1154
<< " \\ bModel\\ b"
0 commit comments