« Back to Scenario Collection

View Switch - dynamic GraphRep

Combination View Flat View Tree View
Threads [ Previous | Next ]
View Switch - dynamic GraphRep
graphrep scenario documentation visualisation configuration
Answer
4/3/14 12:35 PM
This package provides an example for dynamic GraphReps.

The graphical representation of objects depends on the value of two attributes (in our case "People-like view" and "Action type"):






Downloads

The files below contain an example library (View Switch Library.abl) and anexample model (Sample_View Switch.adl). A step-by-step configuration guide is presented in the Hands-On section below. It completely describes how to build this example library.

View Switch Library.abl
Sample_View Switch.adl

Hands-On

1) Create new classes __ModelTypeMetaData__ and Task



Steps to create classes __ModelTypeMetaData__, Task
  • 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!).
  • Click New --> New class; name it Task.
2) Add attributes


  • Select class Task and click New attribute.
  • name: Action type, type: Enumeration
  • Set EnumerationDomain:
1Register@Observe@Plan@Do@Check@Adjust
  • Select class Task and click New attribute.
  • name: People-like view, type: Enumeration
  • Set EnumerationDomain:
1No@Yes
  • Select class __ModelTypeMetaData__ and click New attribute.
  • name: BoolPLV, type: Enumeration
  • Set EnumerationDomain:
1No@Yes
3) Define Model Type “Task Pool”


  • Go to your dynamic library
  • click Library attributes --> Add-ons
  • add the model type Task Pool to the Modi attribute and include class Task:
1MODELTYPE "Task Pool"
2INCL "Task"

4) Configure GraphRep of class Task
  • go to class Task
  • double-click GraphRep (Metamodel) attribute
  • enter the following code to the Standard value attribute:
 1GRAPHREP
 2AVAL plv:"People-like view"
 3FILL r:102 g:153 b:255
 4AVAL actionType:"Action type"
 5IF (plv = "No")
 6RECTANGLE x:-1.4cm y:-.7cm w:2.8cm h:1.4cm
 7ATTR "Name" y:1.2cm w:c:2.8cm h:t
 8ELSE
 9SET filename: ("db:\\plan.jpg")   
10    IF (actionType = "Register")
11    {
12        SET filename:"db:\\register.jpg"
13    }
14    IF (actionType = "Observe")
15    {
16        SET filename:"db:\\observe.jpg"
17    }
18    IF (actionType = "Plan")
19    {
20        SET filename:"db:\\plan.jpg"
21    }
22    IF (actionType = "Do")
23    {
24        SET filename:"db:\\do.jpg"
25    }
26    IF (actionType = "Check")
27    {
28        SET filename:"db:\\check.jpg"
29    }
30    IF (actionType = "Adjust")
31    {
32        SET filename:"db:\\adjust.jpg"
33    }
34SET we:5.6cm
35        SET he:2.8cm
36        PEN w:0.07cm color:black
37        FILL style:null
38        SET bigRectangle: (CM (5.6))
39        RECTANGLE x: ((-1)*(we/2)) y: ((-1)*(he/2)) w: (bigRectangle) h: (CM 3)  # a border marking the object's size
40        TABLE  w: (we/2) h: (he/2) rows:1 cols:1 w1:100% h1:100%  # get the current size of the object
41        BITMAPINFO (filename)  # get the bitmap size
42        STRETCH off
43        IF (bmpwidth / CMS tabw1 < bmpheight / CMS tabh1) {
44            # use maximum height, space left and right
45            SET w: (tabh1 * 2 * (bmpwidth / bmpheight))
46            BITMAP (filename) x: ((-1)*(w)) y: (((-1)*(tabh1)) + (CM 0.05)) w: (w) h: (he)
47        } ELSE {
48            # use maximum width, space at top and bottom
49            SET h: (tabw1  * 2 * (bmpheight / bmpwidth))
50            BITMAP (filename) x: ((-1)*(tabw1 * 2)) y: ((-1)*(h)) w: (tabw1 * 2) h: (h)
51        }
52        FONT bold
53        ATTR "Name" x:0.5cm y: ((((-1)*(he/2))+0.5cm)) w:l:2.0cm h:b:1.5cm line-break:rigorous
54        FONT
55        ATTR "Description" x:0.5cm y: (((-1)*(he/2)+1.5cm)) w:l:2.0cm h:c:2cm line-break:rigorous
56ENDIF

5) Add Images and AdoScript file to the data base
  • click Extras --> File management...
  • select the data base of your library
  • import files (adjust.jpg, check.jpg, do.jpg, observe.jpg, plan.jpg, register.jpg, showHidePeopleLikeView.asc)
6) Code contained in showHidePeopleLikeView.asc:
 1CC "Modeling" GET_ACT_MODEL
 2  #--> RESULT modelid:intValue
 3SETL id_ActModel: (modelid)
 4
 5CC "Core" GET_ATTR_VAL objid: (id_ActModel) attrname: ("BoolPLV")
 6SET s_peoplelikeview_attrval: (val)
 7
 8IF (s_peoplelikeview_attrval = "No")
 9{
10    SET plvOption: ("Yes")
11    CC "Core" SET_ATTR_VAL objid: (id_ActModel) attrname: ("BoolPLV") val: ("Yes")
12}
13ELSE
14{
15    SET plvOption: ("No")
16    CC "Core" SET_ATTR_VAL objid: (id_ActModel) attrname: ("BoolPLV") val: ("No")
17}
18
19CC "AQL"  EVAL_AQL_EXPRESSION modelid: (id_ActModel) expr: ("<\"" + c_CLASS_NAME_1 + "\">")
20SET ocount: (tokcnt (objids, " ")) j:0
21WHILE(j < ocount)
22{
23    SET objid: (VAL token (objids, j, " "))
24    CC "Core"  SET_ATTR_VAL objid: (objid) attrname: (c_ATTR_NAME_SHOW_PEOPLE_LIKE_VIEW) val: (plvOption)
25    SET j: (j + 1)
26}
27
28IF (plvOption = "No")
29{
30    CC "AdoScript" INFOBOX (c_str_SHOW_PEOPLE_LIKE_TEXT_SHOW)
31}
32
33IF (plvOption = "Yes")
34{
35    CC "AdoScript" INFOBOX (c_str_SHOW_PEOPLE_LIKE_TEXT_HIDE)
36}

7) Add new menu item to the Modelling Toolkit
  • Select your dynamic library
  • click Library attributes --> Add-ons
  • add the following lines to the External coupling attribute:
1ITEM "Show/Hide People-like view"
2      modeling:"Extras"
3EXECUTE file: ("db:\\showHidePeopleLikeView.asc")