Dear Christoph,
Sorry for only coming back to you now. Since the changing of the direction of the relation adjusts the values of the ‘x’ and ’y’ coordinates, there will always be the effect for the rectangles at the start- and endpoint of the relation. Therefore I would suggest you to create these information-rectangles as instances of an additional ‘help’ class.
These instances you can create automatically if you create a relation e.g. with the event ‘AfterCreateModelingNode’ for the source and target object. These ‘help’ objects are connected then with an InterRef with the source and target.
With a second event (‘AfterEditAttributevalue’) you can then coordinate the display of the attributes “attrSourceDescription” and “attrTargetDescription” (See below). The Implementation result of this approach would be as follows:
Please find below an example library, and the step by step documentation how the implement the scenario.
1) Create Clas
ses and Attributes:
-) Create Class "A"
· "RelalationCount" type:EXPRESSION
Standard Value:
1EXPR type:integer
2 expr: (set (objName,aval(objid,"Name")),
3 tokcnt(aql("({\""+objName+"\"}-->\"RelationDescription\") ")))
· "RelationDescription" type:INTERREF
Instance Reference to "Description Class"
-) Create Class "Description Class"
· SourceDescription type:STRING
· TargetDescription type:STRING
-) Create Relation Class "relation"
2) Define the event handler "AfterCreateModellingConnector" for creating descriptive rectangles at the source and target object.
1ON_EVENT "AfterCreateModelingConnector" {
2
3 #Define Pregiven Parameters
4 SETG nModelId: (modelid)
5 SETG nObjId: (objid)
6 SETG nClassId: (classid)
7 SETG nFromObjId: (fromobjid)
8 SETG nToObjId: (toobjid)
9
10 CC "Core" GET_CLASS_ID objid: (nFromObjId)
11 SET nFromObjClassId: (classid)
12 CC "Core" GET_CLASS_ID objid: (nToObjId)
13 SET nToObjClassId: (classid)
14CC "Core" GET_CLASS_ID classname:"A"
15SET nAClassId: (classid)
16
17#Trigger Event if the source and target object are of class "A"
18IF (nFromObjClassId=nAClassId AND nToObjClassId=nAClassId) {
19
20 ################################################################
21 #Ceate Object of class "Description" Class with an unique name.#
22 ################################################################
23 CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"RelationCount"
24 SET nCount: (val + 1)
25 CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"Name"
26 SET sSourceObjectName: (val)
27 CC "Core" GET_CLASS_ID classname:"Description Class"
28 SET nDCclassId: (classid)
29 SET sSourceName: (sSourceObjectName + STR nCount)
30 CC "Core" CREATE_OBJ modelid: (nModelId) classid: (nDCclassId) objname: (sSourceName)
31 SET nSourceObjId: (objid)
32
33 #Connect the instance of "A" with the new created object of "Description Class" with an InterRef
34 CC "Core" GET_ATTR_ID classid: (nAClassId) attrname:"RelationDescription"
35 SET nInterId: (attrid)
36 CC "Core" ADD_INTERREF objid: (nFromObjId) attrid: (nInterId) tobjid: (nSourceObjId)
37
38 #Position the Objects and BendPoints
39 CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"Position"
40 SET sFromObjPosition: (val)
41 LEO parse: (sFromObjPosition) get-tmm-value:n_x_fromobj:"x" get-tmm-value:n_y_fromobj:"y"
42 SET n_x_fromobj: (n_x_fromobj )
43 SET n_y_fromobj: (n_y_fromobj+ (CM nCount + CM 0.5))
44 SET mFromEdgeX: (n_x_fromobj + CM 2)
45 SET mFromEdgeY: (n_y_fromobj)
46 CC "Modeling" SET_OBJ_POS objid: (nSourceObjId) x: (n_x_fromobj) y: (n_y_fromobj)
47
48 #################################
49 #Analogous for the target object#
50 #################################
51 CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"RelationCount"
52 SET nToCount: (val + 1)
53 CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"Name"
54 SET sTargetObjectName: (val)
55 SET sTargetName: (sTargetObjectName + STR nToCount)
56 CC "Core" CREATE_OBJ modelid: (nModelId) classid: (nDCclassId) objname: (sTargetName)
57 SET nTargetObjId: (objid)
58 CC "Core" ADD_INTERREF objid: (nToObjId) attrid: (nInterId) tobjid: (nTargetObjId)
59 CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"Position"
60 SET sToObjPosition: (val)
61 LEO parse: (sToObjPosition) get-tmm-value:n_x_toobj:"x" get-tmm-value:n_y_toobj:"y"
62 SET n_x_toobj: (n_x_toobj)
63 SET n_y_toobj: (n_y_toobj+ (CM nToCount)+ CM 0.5)
64 SET mToEdgeX: (n_x_toobj - CM 2)
65 SET mToEdgeY: (n_y_toobj)
66 CC "Modeling" SET_OBJ_POS objid: (nTargetObjId) x: (n_x_toobj) y: (n_y_toobj)
67 CC "Core" DELETE_CONNECTOR modelid: (nModelId) objid: (nObjId)
68 CC "Core" CREATE_CONNECTOR modelid: (nModelId) fromobjid: (nSourceObjId) toobjid: (nTargetObjId) classid: (nClassId)
69
70 #Set bendpoints
71 CC "Core" SET_ATTR_VAL objid: (objid) attrname:"Positions" val: ("EDGE 2 x1:" + (STR mFromEdgeX) + " y1:" + STR(mFromEdgeY) + " x2:" + (STR mToEdgeX) + " y2:" + STR (mToEdgeY)) }}
3) Define the event handler "AfterEditAttributeValue" for displaying the source and target properties of the relation.
1ON_EVENT "AfterEditAttributeValue" {
2 #Define Pregiven Parameters SETG nModelId: (modelid)
3 SETG nObjId: (instid)
4 SETG nAttrId: (attrid)
5
6 ################################
7 #Display the source information#
8 ################################
9 CC "Core" GET_CLASS_ID relation classname:"relation"
10 CC "Core" GET_ATTR_ID classid: (classid) attrname:"attrSourceDescription"
11 SET nSourceAttrId: (attrid)
12
13 IF (nAttrId=nSourceAttrId) {
14 CC "Core" GET_ATTR_VAL objid: (nObjId) attrname:"attrSourceDescription"
15 CC "Core" GET_CONNECTOR_ENDPOINTS objid: (nObjId)
16 CC "Core" SET_ATTR_VAL objid: (fromobjid) attrname:"SourceDescription" val: (val)
17 }
18
19 ################################
20 #Display the source information#
21 ################################
22 CC "Core" GET_ATTR_ID classid: (classid) attrname:"attrTargetDescription"
23 SET nTargetAttrId: (attrid)
24
25 IF (nAttrId=nTargetAttrId) {
26 CC "Core" GET_ATTR_VAL objid: (nObjId) attrname:"attrTargetDescription"
27 CC "Core" GET_CONNECTOR_ENDPOINTS objid: (nObjId)
28 CC "Core" SET_ATTR_VAL objid: (toobjid) attrname:"TargetDescription" val: (val)
29 }
30}
.