This package provides an example of a model type GraphRep showing a background image. The image (in our case a cyan background) can be selected and scaled via the notebook of the model type:
![](http://www.adoxx.org/live/documents/10157/86510/Background_image_preview.png/bba71e08-c74b-49a0-aa07-aaec30a456a7?t=1395133675063)
DownloadsThe files below contain an example library (Background Image.abl) and an example model (Background Image example model.adl). A step-by-step configuration guide is presented in the Hands-On section below. It completely describes how to build this example library.
Background Image.abl Background Image example model.adl Hands-On1) 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: Background Image GraphRep, type: Longstring (2) name: Background Image AttrRep, type: Longstring.
Add further attributes to class __ModelTypeMetaData__:![](http://www.adoxx.org/live/documents/10157/86510/04_further_attributes_for_MTMD.png/315ac548-2243-44cb-8a3b-9bd4e288c407?t=1395397528063)
- name: File selection, type: Programcall
- name: Image height, type: Floating number
- name: Image width, type: Floating number
- name: Load image, type: String
3) Configure Background image AttrRep attribute:
![](http://www.adoxx.org/live/documents/10157/86510/05_configure_background_image_attrrep.png/446e9b12-e665-431e-8613-8f912a3f2a7a?t=1395398004902)
- Double click Background image AttrRep attribute, set Standard value to:
1CHAPTER "Background image"
2ATTR "File selection" no-param push-button
3ATTR "Load image"
4
5GROUP "Scaling"
6ATTR "Image height"
7ATTR "Image width"
8ENDGROUP
4) Configure Configure Background image GraphRep attribute:![](http://www.adoxx.org/live/documents/10157/86510/05_conf_background_image_graphrep.png/49a1071c-13db-4cce-a33d-d178fc50b1ec?t=1395401263057)
- Double click Background image GraphRep attribute, set Standard value to:
1GRAPHREP layer:-3
2AVAL filename: ("Load image")
3AVAL sHeight: ("Image height")
4SET mHeight: ( VAL sHeight)
5AVAL sWidth: ("Image width")
6SET mWidth: ( VAL sWidth)
7BITMAPINFO (filename)
8BITMAP (filename) x:0cm y:0cm w: (bmpwidth / (100 - mWidth) * 1.0cm) h: (bmpheight / (100 - mHeight) * 1.0cm)
5) Configure File selection attribute:![](http://www.adoxx.org/live/documents/10157/86510/06_conf_file_selection_attribute.png/9075ac58-0c9a-4f97-be35-15080408cf94?t=1395398438057)
- Double click File selection attribute, set Standard value to: Select file.
- Click Facets and set EnumerationDomain to:
1ITEM "Select file"
2CC "AdoScript" FILE_DIALOG open
3 filter1:"BMP files" type1:"*.bmp"
4 filter2:"JPEG files" type2:"*.jpg"
5 filter3:"PNG files" type3:"*.png"
6CC "Core" SET_ATTR_VAL objid: (objid) attrname: "Load image" val: (path)
6) Configure remaining new attributes- Attribute Image height: set Standard value 11
- Attribute Image width: set Standard value 11
- Attribute Load image: set Standard value db:\Background.png.
- make sure that the file db:\Background.png is contained in the database of the current library (close the Library management and go to Extras --> File management…).
7) Define Model type![](http://www.adoxx.org/live/documents/10157/86510/08_define_MT.png/a6552937-573c-46a9-91eb-83b027721398?t=1395399240113)
- Go back to the Library management and select your current Dynamic Library.
- Click Library attributes… --> Add-ons and define the following model type according the figure above:
1MODELTYPE "Background Image Sample" from:none plural:"Background Image Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "Background Image GraphRep" attrrep: "Background Image AttrRep"
ResultIn order to see the result, open
Background Image example model.adl in the ADOxx Modeling Toolkit.
How to open the model type's notebook: - Right click on modelling area and click Model attributes
- alternatively press Alt+Enter.
![](http://www.adoxx.org/live/documents/10157/86510/09_open_MT_notebook.png/31ad8b95-7e6a-4bf5-9522-4b080e9d98d2?t=1395400316035)
![](http://www.adoxx.org/live/documents/10157/86510/10_MT_notebook.png/2b3ded58-64d0-42bd-9ab6-03daa6dc01a3?t=1395400587530)
- In order to set a background image, enter corresponding file path (file system or ADOxx database) directly into the Load image attribute, or click the Select file button, which opens a dialog for file selection and writes the selected file path into the Load image attribute.
Possible formats: BMP, PNG, JPEG. - Images can be stretched in height and width. Enter values from 0 to 99.
- Hint: the correct aspect ratio of DIN A4 paper is 1 :√2 . Choose some image with ratio 1 :1.43 in order to fully cover one A4 sector on the drawing area.