relation-Class: Draw rectangle and dock to connected objectrelation-Class: Draw rectangle and dock to connected objectRE: relation-Class: Draw rectangle and dock to connected objectMehmet Albayrakhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3506152015-07-27T06:46:49Z2015-07-27T06:44:54ZDear Christoph, <br /><br />You are absolutely right. The calculation for the position of the rectangles would be the same as above. <br /><br />Since the 'Position' is an <strong><u>attribute</u></strong> of each class (inherited from the super class '__D-construct__' ), you can here again use the event 'AfterEditAttributeValue'. Therefore you need only to trigger the event if the attribute 'Position' is changed, like we did above for the attributes '<span style="font-family: monospace">attrSourceDescription</span>' and '<span style="font-family: monospace">attrTargetDescription</span>'. And then you can reposition the objects.Mehmet Albayrak2015-07-27T06:44:54ZRE: relation-Class: Draw rectangle and dock to connected objectchristophhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3505562015-07-26T17:30:52Z2015-07-26T17:30:52ZThank you so much Mehmet! This is an awesome solution for my problem - I just tried it and it works really well. <br /><br />The only thing I still want to add is the position of the rectangle with regard to the object position when I move it around - it should stay docked to the object. Can I use the "Position" attribute for that somehow because I couldn't find any "object-move" event or the like?<br /><br />The calculation for the position of the rectangles would be pretty much the same as you have already shown in your code. <br /><br />Thanks again! christoph2015-07-26T17:30:52ZRE: relation-Class: Draw rectangle and dock to connected objectMehmet Albayrakhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3502182015-07-24T11:56:37Z2015-07-24T10:03:41ZDear Christoph,<br /><br />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. <br />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.<br />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:<br /><img src="http://www.adoxx.org/live/documents/10157/110691/RelationGraph.bmp/ac6d7b58-0bea-452f-88d3-1e7aaa9e864e?t=1437738532868" /> <br />Please find below an example library, and the step by step documentation how the implement the scenario.<br /><br />1) Create Clas<span style="font-size: 16px"><span style="font-size: 12px"></span></span>ses and Attributes: <br /><br /><strong> -) Create Class </strong>"A" <strong> <br /><span style="font-family: sans-serif"><span style="font-size: 16px"><strong> · </strong></span></span></strong><span style="font-size: 12px"><span style="font-family: sans-serif">"RelalationCount" type:EXPRESSION <br /> Standard Value:<br /><br /></span></span><div class="code"><span class="code-lines">1</span>EXPR type:integer <br /><span class="code-lines">2</span> expr: (set (objName,aval(objid,"Name")), <br /><span class="code-lines">3</span> tokcnt(aql("({\""+objName+"\"}-->\"RelationDescription\") ")))<br /></div><br /> <strong><span style="font-family: sans-serif"><span style="font-size: 16px">·</span></span></strong> "RelationDescription" type:INTERREF<br /> Instance Reference to "Description Class"<br /><br /> <strong> -) Create Class </strong>"Description Class"<br /><br /> <strong><span style="font-family: sans-serif"><span style="font-size: 16px">·</span></span></strong> SourceDescription type:STRING<br /> <strong><span style="font-family: sans-serif"><span style="font-size: 16px">·</span></span></strong> TargetDescription type:STRING<br /><br /> <strong>-) Create Relation Class </strong>"relation"<br /><br />2) Define the event handler "AfterCreateModellingConnector" for creating descriptive rectangles at the source and target object.<br /><br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "AfterCreateModelingConnector" {<br /><span class="code-lines"> 2</span> <br /><span class="code-lines"> 3</span> #Define Pregiven Parameters<br /><span class="code-lines"> 4</span> SETG nModelId: (modelid) <br /><span class="code-lines"> 5</span> SETG nObjId: (objid)<br /><span class="code-lines"> 6</span> SETG nClassId: (classid)<br /><span class="code-lines"> 7</span> SETG nFromObjId: (fromobjid)<br /><span class="code-lines"> 8</span> SETG nToObjId: (toobjid)<br /><span class="code-lines"> 9</span><br /><span class="code-lines">10</span> CC "Core" GET_CLASS_ID objid: (nFromObjId)<br /><span class="code-lines">11</span> SET nFromObjClassId: (classid)<br /><span class="code-lines">12</span> CC "Core" GET_CLASS_ID objid: (nToObjId)<br /><span class="code-lines">13</span> SET nToObjClassId: (classid)<br /><span class="code-lines">14</span>CC "Core" GET_CLASS_ID classname:"A"<br /><span class="code-lines">15</span>SET nAClassId: (classid)<br /><span class="code-lines">16</span><br /><span class="code-lines">17</span>#Trigger Event if the source and target object are of class "A"<br /><span class="code-lines">18</span>IF (nFromObjClassId=nAClassId AND nToObjClassId=nAClassId) {<br /><span class="code-lines">19</span> <br /><span class="code-lines">20</span> ################################################################<br /><span class="code-lines">21</span> #Ceate Object of class "Description" Class with an unique name.#<br /><span class="code-lines">22</span> ################################################################<br /><span class="code-lines">23</span> CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"RelationCount"<br /><span class="code-lines">24</span> SET nCount: (val + 1)<br /><span class="code-lines">25</span> CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"Name"<br /><span class="code-lines">26</span> SET sSourceObjectName: (val)<br /><span class="code-lines">27</span> CC "Core" GET_CLASS_ID classname:"Description Class"<br /><span class="code-lines">28</span> SET nDCclassId: (classid)<br /><span class="code-lines">29</span> SET sSourceName: (sSourceObjectName + STR nCount)<br /><span class="code-lines">30</span> CC "Core" CREATE_OBJ modelid: (nModelId) classid: (nDCclassId) objname: (sSourceName)<br /><span class="code-lines">31</span> SET nSourceObjId: (objid)<br /><span class="code-lines">32</span><br /><span class="code-lines">33</span> #Connect the instance of "A" with the new created object of "Description Class" with an InterRef<br /><span class="code-lines">34</span> CC "Core" GET_ATTR_ID classid: (nAClassId) attrname:"RelationDescription"<br /><span class="code-lines">35</span> SET nInterId: (attrid)<br /><span class="code-lines">36</span> CC "Core" ADD_INTERREF objid: (nFromObjId) attrid: (nInterId) tobjid: (nSourceObjId) <br /><span class="code-lines">37</span><br /><span class="code-lines">38</span> #Position the Objects and BendPoints<br /><span class="code-lines">39</span> CC "Core" GET_ATTR_VAL objid: (nFromObjId) attrname:"Position"<br /><span class="code-lines">40</span> SET sFromObjPosition: (val)<br /><span class="code-lines">41</span> LEO parse: (sFromObjPosition) get-tmm-value:n_x_fromobj:"x" get-tmm-value:n_y_fromobj:"y"<br /><span class="code-lines">42</span> SET n_x_fromobj: (n_x_fromobj )<br /><span class="code-lines">43</span> SET n_y_fromobj: (n_y_fromobj+ (CM nCount + CM 0.5))<br /><span class="code-lines">44</span> SET mFromEdgeX: (n_x_fromobj + CM 2)<br /><span class="code-lines">45</span> SET mFromEdgeY: (n_y_fromobj)<br /><span class="code-lines">46</span> CC "Modeling" SET_OBJ_POS objid: (nSourceObjId) x: (n_x_fromobj) y: (n_y_fromobj)<br /><span class="code-lines">47</span><br /><span class="code-lines">48</span> #################################<br /><span class="code-lines">49</span> #Analogous for the target object#<br /><span class="code-lines">50</span> #################################<br /><span class="code-lines">51</span> CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"RelationCount"<br /><span class="code-lines">52</span> SET nToCount: (val + 1)<br /><span class="code-lines">53</span> CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"Name"<br /><span class="code-lines">54</span> SET sTargetObjectName: (val)<br /><span class="code-lines">55</span> SET sTargetName: (sTargetObjectName + STR nToCount)<br /><span class="code-lines">56</span> CC "Core" CREATE_OBJ modelid: (nModelId) classid: (nDCclassId) objname: (sTargetName)<br /><span class="code-lines">57</span> SET nTargetObjId: (objid)<br /><span class="code-lines">58</span> CC "Core" ADD_INTERREF objid: (nToObjId) attrid: (nInterId) tobjid: (nTargetObjId) <br /><span class="code-lines">59</span> CC "Core" GET_ATTR_VAL objid: (nToObjId) attrname:"Position"<br /><span class="code-lines">60</span> SET sToObjPosition: (val)<br /><span class="code-lines">61</span> LEO parse: (sToObjPosition) get-tmm-value:n_x_toobj:"x" get-tmm-value:n_y_toobj:"y"<br /><span class="code-lines">62</span> SET n_x_toobj: (n_x_toobj)<br /><span class="code-lines">63</span> SET n_y_toobj: (n_y_toobj+ (CM nToCount)+ CM 0.5)<br /><span class="code-lines">64</span> SET mToEdgeX: (n_x_toobj - CM 2)<br /><span class="code-lines">65</span> SET mToEdgeY: (n_y_toobj)<br /><span class="code-lines">66</span> CC "Modeling" SET_OBJ_POS objid: (nTargetObjId) x: (n_x_toobj) y: (n_y_toobj)<br /><span class="code-lines">67</span> CC "Core" DELETE_CONNECTOR modelid: (nModelId) objid: (nObjId)<br /><span class="code-lines">68</span> CC "Core" CREATE_CONNECTOR modelid: (nModelId) fromobjid: (nSourceObjId) toobjid: (nTargetObjId) classid: (nClassId)<br /><span class="code-lines">69</span> <br /><span class="code-lines">70</span> #Set bendpoints<br /><span class="code-lines">71</span> CC "Core" SET_ATTR_VAL objid: (objid) attrname:"Positions" val: ("EDGE 2 x1:" + (STR mFromEdgeX) + " y1:" + STR(mFromEdgeY) + " x2:" + (STR mToEdgeX) + " y2:" + STR (mToEdgeY)) }}<br /></div><br />3) Define the event handler "AfterEditAttributeValue" for displaying the source and target properties of the relation.<br /><br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "AfterEditAttributeValue" {<br /><span class="code-lines"> 2</span> #Define Pregiven Parameters SETG nModelId: (modelid)<br /><span class="code-lines"> 3</span> SETG nObjId: (instid)<br /><span class="code-lines"> 4</span> SETG nAttrId: (attrid)<br /><span class="code-lines"> 5</span><br /><span class="code-lines"> 6</span> ################################<br /><span class="code-lines"> 7</span> #Display the source information#<br /><span class="code-lines"> 8</span> ################################<br /><span class="code-lines"> 9</span> CC "Core" GET_CLASS_ID relation classname:"relation" <br /><span class="code-lines">10</span> CC "Core" GET_ATTR_ID classid: (classid) attrname:"attrSourceDescription"<br /><span class="code-lines">11</span> SET nSourceAttrId: (attrid)<br /><span class="code-lines">12</span><br /><span class="code-lines">13</span> IF (nAttrId=nSourceAttrId) {<br /><span class="code-lines">14</span> CC "Core" GET_ATTR_VAL objid: (nObjId) attrname:"attrSourceDescription"<br /><span class="code-lines">15</span> CC "Core" GET_CONNECTOR_ENDPOINTS objid: (nObjId)<br /><span class="code-lines">16</span> CC "Core" SET_ATTR_VAL objid: (fromobjid) attrname:"SourceDescription" val: (val)<br /><span class="code-lines">17</span> }<br /><span class="code-lines">18</span><br /><span class="code-lines">19</span> ################################ <br /><span class="code-lines">20</span> #Display the source information#<br /><span class="code-lines">21</span> ################################ <br /><span class="code-lines">22</span> CC "Core" GET_ATTR_ID classid: (classid) attrname:"attrTargetDescription"<br /><span class="code-lines">23</span> SET nTargetAttrId: (attrid)<br /><span class="code-lines">24</span><br /><span class="code-lines">25</span> IF (nAttrId=nTargetAttrId) {<br /><span class="code-lines">26</span> CC "Core" GET_ATTR_VAL objid: (nObjId) attrname:"attrTargetDescription"<br /><span class="code-lines">27</span> CC "Core" GET_CONNECTOR_ENDPOINTS objid: (nObjId)<br /><span class="code-lines">28</span> CC "Core" SET_ATTR_VAL objid: (toobjid) attrname:"TargetDescription" val: (val)<br /><span class="code-lines">29</span> }<br /><span class="code-lines">30</span>}<br /></div><br />.Mehmet Albayrak2015-07-24T10:03:41ZRE: relation-Class: Draw rectangle and dock to connected objectchristophhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3439102015-07-14T07:37:45Z2015-07-14T07:37:45ZThanks for the info Mehmet. That is strange, I can see them on different devices and browsers. <br />Anyways here they are attached and thanks for reporting back. christoph2015-07-14T07:37:45ZRE: relation-Class: Draw rectangle and dock to connected objectMehmet Albayrakhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3439052015-07-14T07:08:20Z2015-07-14T07:07:35ZDear Christoph,<br />Unfortunately, we cannot see your images in the post. Can you please attach the files by clicking on 'Attach Files' (see Screenshot)?Mehmet Albayrak2015-07-14T07:07:35Zrelation-Class: Draw rectangle and dock to connected objectchristophhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3417882015-07-11T10:15:36Z2015-07-11T10:15:31Z<span style="color: #222222"><span style="font-family: tahoma, sans-serif"><span style="font-size: 10px">Hello, <br /></span></span></span><span style="color: #222222"><span style="font-family: tahoma, sans-serif"><span style="font-size: 10px"><br /></span></span></span><span style="color: #222222"><span style="font-family: tahoma, sans-serif"><span style="font-size: 10px">I have a question regardarding the relation-Class. What I want to achive is the following: </span></span></span><span style="color: #222222"><span style="font-family: arial, sans-serif"><span style="font-size: 10px"><span style="font-family: tahoma, sans-serif"><br /></span><span style="font-family: tahoma, sans-serif"><br /></span><span style="font-family: tahoma, sans-serif"><img src="https://mail.google.com/mail/u/0/?ui=2&ik=3690c98546&view=fimg&th=14e6a3a614183fc3&attid=0.2&disp=emb&realattid=ii_14e6a3069dd8dc56&attbid=ANGjdJ9vjXb2iqPrzS-WfKi1WymLK-3Qm1x6j41Etlu3A3NHT9mG05sIkiiIGjt07f-sqKoeWfzO30uYox05AsBkTP_nTPorROrWldo3NWGq8E0ZaLkLQSgo1Dw5RUU&sz=w944-h400&ats=1436616296945&rm=14e6a3a614183fc3&zw&atsh=1" /><br /></span><span style="font-family: tahoma, sans-serif">I want to show the cardinalety and it's description as a seperate rectangle below the object (e.g book). <br /></span><span style="font-family: tahoma, sans-serif">So far I tried the following: </span><span style="font-family: tahoma, sans-serif"><img src="https://mail.google.com/mail/u/0/?ui=2&ik=3690c98546&view=fimg&th=14e6a3a614183fc3&attid=0.1&disp=emb&realattid=ii_14e6a30335725018&attbid=ANGjdJ_r9VSw92BuwluLKew7ZwDCBVQwAZ6B51OOMEmrF49-Dknh824RVcbrpYVitiNxFYWu6K1-lSkcoibyCDYmVDIHBpykoBRrbwxl56bzqOmlMVXVIuBCRNSwbv8&sz=w944-h412&ats=1436616296945&rm=14e6a3a614183fc3&zw&atsh=1" /><br /></span><span style="font-family: tahoma, sans-serif"><br /></span><span style="font-family: tahoma, sans-serif"><br /></span><span style="font-family: tahoma, sans-serif">The problem is that the rectangle box is not docked to the object and it doesn't adjust it self to the object position and width. The height of the box as well as the orientation should stay the same. If I start to move the e.g "book"-object these boxes the rectangles are always resizing and changing their orientation. </span><span style="font-family: tahoma, sans-serif">My GraphRep for the relation-class: </span><span style="font-family: tahoma, sans-serif"><br /></span></span></span></span><div class="quote"><div class="quote-content"><span style="font-size: 10px">GRAPHRE<span style="font-family: tahoma, sans-serif"></span>P<span style="font-family: tahoma, sans-serif"> </span><span style="font-family: tahoma, sans-serif"> sizing:asymmetrical</span></span></div></div><div class="quote"><div class="quote-content"><span style="font-size: 10px">START<br />FILL color:whitesmoke<br />RECTANGLE x:1.5 y:-.5cm w:-3cm h:1cm<br />ATTR "attrSourceDescription" line-break: words w:c h:c x:-0.5cm<br /><br />END<br />FILL color:black<br />POLYGON 3 x1:-3cm y1:.1cm x2:-2.7cm y2:0cm x3:-3cm y3:-0.1cm<br />FILL color:whitesmoke<br />RECTANGLE x:0 y:-0.5cm w:-2.7cm h:1cm<br />ATTR "attrTargetDescription" line-break: words w:c h:c x:-0.5cm<br /><br />MIDDLE<br />ATTR "attrCardinalety" w:c h:c y:-0.2cm</span></div></div><span style="font-size: 10px"></span><br /><span style="font-family: tahoma, sans-serif">AttrRep for the relation-class: </span><span style="font-family: tahoma, sans-serif"><br /></span><div class="quote"><div class="quote-content"><span style="font-size: 10px"><span style="font-family: monospace, monospace">NOTEBOOK <br /></span><span style="font-family: monospace, monospace">CHAPTER "Description"<br /></span><span style="font-family: monospace, monospace">ATTR "attrSourceDescription"<br /></span><span style="font-family: monospace, monospace">ATTR "attrTargetDescription"<br /></span>ATTR "attrCardinalety"</span></div></div><span style="font-family: tahoma, sans-serif"><br /></span><span style="font-family: tahoma, sans-serif">Whats the best solution to solve this and can you give me some hints. I don't think it is enough to just use the GRAPHREP to solve this problem. Maybe events and some ADOScript could help? <br /></span><span style="font-family: tahoma, sans-serif">Thanks in advance, Christoph</span>christoph2015-07-11T10:15:31Z