Developer Resource: Modelling Language
In this package a model type GraphRep for displaying a model as a set of bars has been implemented.
The model itself can be both a graph or a pool and the objects (modelling instances) are centrally displayed in the Modelling Area.
The values of some selected attributes are displayed on both sides on the modelling area, as defined by the developer.
This solution allows the activation/deactivation of the bar display, selecting the orientation of the modelling area (horizontal/vertical), selection of visible attributes (bars) and much more...
The images below show horizontal and vertical orientation as well as the model type notebook, where the appearance of the model type GraphRep can be configured:
Downloads
The files below contain an example library (Bar_Display_Library) and example models (Bar_Display_Example_Models):
Bar_Display_Library
Bar_Display_Example_Models
Hands-On
1) Create new class __ModelTypeMetaData__
Steps to create class __ModelTypeMetaData__
- Go to the Library management, select a dynamic library and click Class hierarchy.
- Click View and select Metamodel.
- Select __D-construct__ (Metamodel)
- Click New --> New class; name it __ModelTypeMetaData__ (two underscore signs!).
2) Add new attributes to class __ModelTypeMetaData__
Steps to add attributes to class __ModelTypeMetaData__:
- Select class __ModelTypeMetaData__
- Click New --> New attribute...
- Name new attributes and select type according figure above: (1) name: BAR GraphRep, type: Longstring (2) name: BAR AttrRep, type: Longstring (3) name: Reference overview settings, type: Longstring.
3) Add Enumeration attribute BAR Display active to class __ModelTypeMetaData__
Steps to add and configure the Enumeration attribute:
- Select class __ModelTypeMetaData__
- Click New --> New attribute...
- Name new attribute BAR Display active and set type to Enumeration.
- Click OK and add the values Yes and No: type Yes into the New value input bar, click Add and do the same for No.
4) Add further attributes to __ModelTypeMetaData__
Name: Info_color, type: String, value: lightblue
Name: Info_display, type: Enumeration, values: Yes, No.
Name: Info_size, type: Enumeration, values: 1, 2, 3, 4, 6, 8, 10, 14.
Name: Modelling direction, type: Enumeration, values: horizontal, vertical.
Name: Modelling_size, type: Enumeration, values: 4, 6, 8, 10, 14, 18, 22.
Name: References_color, type: String, value: lightblue
Name: References_display, type: Enumeration, values: Yes, No.
Name: References_size, type: Enumeration, values: 1, 2, 3, 4, 6, 8, 10, 14.
5) Configure BAR AttrRep attribute
- Double click BAR AttrRep attribute, set Standard value to:
CHAPTER "BAR Display" ATTR "BAR Display active" ctrltype: check checked-value: "Yes" unchecked-value: "No" AVAL s_Aktiv: "BAR Display active" ATTR "Modelling direction" ctrltype: radio enabled: (s_Aktiv = "Yes") ATTR "Modelling_size" GROUP "References" ATTR "References_display" ctrltype: check checked-value: "Yes" unchecked-value: "No" enabled: (s_Aktiv = "Yes") AVAL s_References_display: "References_display" ATTR "References_color" dialog: color enabled: ((s_Aktiv = "Yes") AND (s_References_display = "Yes")) ATTR "References_size" ENDGROUP GROUP "Info" ATTR "Info_display" ctrltype: check checked-value: "Yes" unchecked-value: "No" enabled: (s_Aktiv = "Yes") AVAL s_Info_display: "Info_display" ATTR "Info_color" dialog: color enabled: ((s_Aktiv = "Yes") AND (s_Info_display = "Yes")) ATTR "Info_size" ENDGROUP CHAPTER "Description" ATTR "Description"
6) Configuring BAR GraphRep attribute
- Double click BAR GraphRep attribute, set Standard value to:
@INCLUDE "db:\\modeltype_graphrep_BAR.leo"
- make sure that the file modeltype_graphrep_BAR.leo is contained in the database of the current library (close the Library management and go to Extras --> File management…).
The file modeltype_graphrep_BAR.leo contains the following code:
GRAPHREP layer:-3 SHADOW off AVAL modDirection:"Modelling direction" AVAL sNav: "BAR Display active" #------------------------------------- # make header with (model) description #------------------------------------- IF (sNav = "Yes") { AVAL name: "Name" IF (modDirection = "vertical") {# vertical case FONT h:12pt bold FILL color:white TEXTBOX (name ) x:1cm y:0.2cm FILL color:whitesmoke RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm) TEXT (name) x:1cm y:0.2cm FONT h:10pt ATTR "Description" x:0.5cm y: (texty2 + 0.3cm) w:l:10cm h:t:2cm } ELSE {# horizontal case FONT h:12pt bold IF (_outdevtype = "printer") {# when printing, description is printed on first A4 page only: SET n_pageNr:0 WHILE (w>= (n_pageNr*20.1cm)) { TEXTBOX (name + " (p." + STR (n_pageNr + 1) + ")") x: (1cm + n_pageNr*20.1cm) y:0.2cm FILL color:whitesmoke RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm) TEXT (name + " (p." + STR (n_pageNr + 1) + ")") x: (1cm + n_pageNr*20.1cm) y:0.2cm SET n_pageNr: (n_pageNr + 1) } } ELSE { TEXTBOX (name ) x:1cm y:0.2cm FILL color:whitesmoke RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm) TEXT (name) x:1cm y:0.2cm } FONT h:10pt ATTR "Description" x:0.5cm y: (texty2 + 0.3cm) w:l:10cm h:t:2cm } #---------- # make BARs #---------- FONT h:9pt bold SET cmDefaultLaneSize:2cm # read "Reference overview settings"-attribute: AVAL sRefOverviewInfo:"Reference overview settings" SET cmX:0.0cm SET cmY: (texty2 + 2.2cm) PEN color:gray w:1pt SET sSepLine:"\n" SET sSepToken:"|" FOR sLaneInfo in: (sRefOverviewInfo) sep: (sSepLine) { SET sLaneDisp: "No" SET sLaneName: (token(sLaneInfo, 0, sSepToken)) SET sHeading: (token(sLaneInfo, 1, sSepToken)) SET sLaneNameDisp: (sLaneName + "_display") # read "..._display"-attribute: AVAL set-default: "No" sLaneDisp: (sLaneNameDisp) SET cmLaneSize: (sLaneName + "_size") # read "..._size"-attribute: AVAL set-default: "2" sLaneSize: ( cmLaneSize) SET laneSize: ( CM VAL sLaneSize) IF (type(laneSize) != "measure") { SET laneSize: (cmDefaultLaneSize) } IF (sLaneName = "Modelling") { SET sLaneDisp: "Yes" } # check if current lane shall be painted IF (sLaneDisp = "Yes") { SET sLaneColorName: (sLaneName + "_color") AVAL set-default: lightblue sLaneColor: (sLaneColorName) FILL color: (sLaneColor) IF (sLaneName = "Modelling") { FILL style:null } IF (modDirection = "vertical") { # create vertical bar RECTANGLE x: (cmX) y: (cmY) w: (laneSize) h: (h) TEXT (sHeading) line-break:rigorous x: (cmX + (laneSize / 2)) y: (cmY + 0.55cm) w:c: (laneSize) h:t SET cmX: (cmX + laneSize) } ELSE { # create horizontal bar SET n_pageNr:0 RECTANGLE x: (cmX) y: (cmY) w: (w) h: (laneSize) WHILE (w>= (n_pageNr*20.1cm)) { TEXT (sHeading) line-break:words x: (cmX + 0.1cm + n_pageNr*20.05cm) y: (cmY + (laneSize / 2)) w:l:2.5cm h:c: (laneSize) SET n_pageNr: (n_pageNr + 1) } SET cmY: (cmY + laneSize) } } } }
7) Configure Reference overview settings attribute
- Double click Reference overview settings attribute, set Standard value to:
References|References Modelling|Drawing Area Info|Info
8) Create new class A; superclass: __D-construct__ (Metamodel)
9) Add new attributes to class A
- name: _disp_Info_, type: Expression.
- name: _disp_Modelling_, type: Expression.
- name: _disp_References_, type: Expression.
- name: _Modelling_direction_, type: Expression.
- name: _REFERENCE_OVERVIEW_SETTINGS_, type: Expression.
- name: _size_Info_, type: Expression.
- name: _size_Modelling_, type: Expression.
- name: _size_References_, type: Expression.
- name: Info, type: Longstring.
10) Configure new Expression attributes in class A
- Double click on _disp_Info_ attribute
- Set Standard value:
EXPR type:string expr: (maval("Info_display"))
- Analogously define values of remaining Expression attributes (thereby the argument in the maval function is always the name of the corresponding attribute in __ModelTypeMetaData__).
11) Configure GraphRep of class A
- Double click GraphRep (Metamodel).
- Click the Dialog button.
- Enter:
GRAPHREP SHADOW off FILL color:blue ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm ATTR "Name" x:0.00cm y:1.0cm w:c @INCLUDE "db:\\class_graphrep_BAR.leo"
- Make sure that the file class_graphrep_BAR.leo is contained in the database.
The file class_graphrep_BAR.leo contains the following code:
#Define amount of space for displaying attribute values: SET cmDisplayHeight:4cm SET cmDisplayHeight2:4cm #read "Modelling direction" and "Reference overview settings" attributes [via corresponding expression attributes]: AVAL modDirection:"_Modelling_direction_" AVAL sREFERENCE_OVERVIEW_SETTINGS:"_REFERENCE_OVERVIEW_SETTINGS_" #define seperators for "Reference overview settings" attribute: SET sSepLine:"\n" SET sSepToken:"|" #------------------------------ # Vertical navigation overview: #------------------------------ IF (modDirection = "vertical") { SET cmX:0.08cm SET cmY:-0.75cm FONT "Arial" h:8pt color:black PEN color:darkgray outline FOR sLaneInfo in: (sREFERENCE_OVERVIEW_SETTINGS) sep: (sSepLine) { SET sLaneName: (token(sLaneInfo, 0, sSepToken)) SET cmLaneSize: ("_size_" + sLaneName + "_") AVAL set-default: "2" sLaneSize: ( cmLaneSize) SET laneSize: ( CM VAL sLaneSize) SET bShowLane: "No" AVAL set-default: "No" bShowLane: ("_disp_" + sLaneName + "_") IF (bShowLane = "Yes") { IF (sLaneName != "Modelling") { ATTR (sLaneName) format:"%o" x:abs: (cmX) y: (cmY) w:l: (laneSize - 0.16cm) h:t: (cmDisplayHeight) line-break:rigorous } SET cmX: (cmX + laneSize) } } } #------------------------------- # Horizontal navigation overview #------------------------------- ELSE { FONT h:12pt bold TEXTBOX "A" x:1cm y:0.2cm SET cmY: (texty2 + 2.3cm) SET cmX:-1.6cm FONT "Arial" h:8pt color:black PEN color:darkgray outline FOR sLaneInfo in: (sREFERENCE_OVERVIEW_SETTINGS) sep: (sSepLine) { SET sLaneName: (token(sLaneInfo, 0, sSepToken)) SET cmLaneSize: ("_size_" + sLaneName + "_") AVAL set-default: "2" sLaneSize: ( cmLaneSize) SET laneSize: ( CM VAL sLaneSize) SET bShowLane: "No" AVAL set-default: "No" bShowLane: ("_disp_" + sLaneName + "_") IF (bShowLane = "Yes") { IF (sLaneName != "Modelling") { ATTR (sLaneName) format:"%o" x: (cmX) y:abs: (cmY) w:l: (cmDisplayHeight2) h:t: (laneSize - 0.16cm) line-break:rigorous } SET cmY: (cmY + laneSize) } } }
12) Create new class B; superclass: __D-construct__ (Metamodel)
13) Configure GraphRep of class B
code:
GRAPHREP SHADOW off FILL color:red ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm ATTR "Name" x:0.00cm y:1.0cm w:c
14) Define Modeltypes
- Go back to the Library management and select your current Dynamic Library.
- Click Library attributes… --> Add-ons and define the following two model types according the figure above
MODELTYPE "Bar Display Sample" from:none plural:"Bar Display Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "BAR GraphRep" attrrep: "BAR AttrRep" INCL "A" MODELTYPE "References Sample" from:none plural:"References Samples" pos:1 not-simulateable bitmap:"db:\\sample-target.bmp" INCL "B"
Steps to add the Interref attribute References to A:
- Select class A
- Click New --> New attribute...
- Name new attribute References and set type to Interref.
- Click OK
- Double click on new attribute Refereces --> click Facets.
- Click the Dialog button of the AttributeInterRefDomain attribute, see figure above.
- Select Instance references, click Add…, select Model type References Sample and Class B and apply (twice).
Result
In order to see the result, import and open Bar_Display_Example_Models in the ADOxx Modeling Toolkit. When importing the example models, one may need to click on the "Import objects from other Library" option.