Background Image Model Type GraphRepBackground Image Model Type GraphRepBackground Image Model Type GraphRepSabin Popescuhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=871112014-03-27T08:40:09Z2014-03-17T13:36:31Z<strong></strong>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:<br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/Background_image_preview.png/bba71e08-c74b-49a0-aa07-aaec30a456a7?t=1395133675063" /><br /><br /><span style="font-size: 18px"><br /><strong>Downloads</strong></span><br /><br />The 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.<br /><br /><a href="http://www.adoxx.org/live/documents/10157/86510/Background+Image.abl/a629ed15-b462-45ff-b8f5-cc1653183069">Background Image.abl </a><br /><a href="http://www.adoxx.org/live/documents/10157/86510/Background+Image+example+model.adl/295906e2-77b9-4461-bbf9-64fae6ef4cbf">Background Image example model.adl </a><br /><br /><br /><span style="font-size: 18px"><strong>Hands-On</strong></span><br /><br /><strong>1) Create new class <em>_</em>_ModelTypeMetaData__</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/02_new_class_modeltypemetadata.png/6033c3c3-b987-47d3-af88-a18dfa268e7c?t=1395396294163" /><br /><br /><strong>Steps to create class <em>__ModelTypeMetaData__</em></strong><ul style="list-style: disc inside;"><li>Go to the Library management, select a dynamic library and click <em>Class hierarchy</em>.</li><li>Click <em>View</em> and select <em>Metamodel</em>.</li><li>Select <em>__D-construct__ (Metamodel)</em></li><li>Click <em>New</em> --> <em>New class</em>; name it <em>__ModelTypeMetaData__</em> (two underscore signs!).</li></ul style="list-style: disc inside;"><strong>2) Add new attributes to class __ModelTypeMetaData__</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/03_new_attributes_to_class_MTMD.png/4955c105-78d4-4eb4-b1b7-989a2d02b383?t=1395396794710" /><br /><br /><strong>Steps to add attributes to class __ModelTypeMetaData__:</strong><br /><ul style="list-style: disc inside;"><li>Select class <em>__ModelTypeMetaData__</em></li><li>Click <em>New</em> --> <em>New attribute...</em></li><li>Name new attributes and select type according figure above: (1) name: <em>Background Image GraphRep</em>, type: <em>Longstring</em> (2) name: <em>Background Image AttrRep</em>, type: <em>Longstring</em>.</li></ul style="list-style: disc inside;"><strong>Add further attributes <strong>to class __ModelTypeMetaData__</strong>:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/04_further_attributes_for_MTMD.png/315ac548-2243-44cb-8a3b-9bd4e288c407?t=1395397528063" /><br /><ul style="list-style: disc inside;"><li>name: <em>File selection</em>, type: <em>Programcall</em></li><li>name: <em>Image height</em>, type: <em>Floating number</em></li><li>name: <em>Image width</em>, type: <em>Floating number</em></li><li>name: <em>Load image</em>, type: <em>String</em></li></ul style="list-style: disc inside;"><strong>3) Configure Background image AttrRep attribute</strong>:<br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/05_configure_background_image_attrrep.png/446e9b12-e665-431e-8613-8f912a3f2a7a?t=1395398004902" /><br /><ul style="list-style: disc inside;"><li>Double click <em>Background image AttrRep</em> attribute, set <em>Standard value</em> to:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>CHAPTER "Background image"<br /><span class="code-lines">2</span>ATTR "File selection" no-param push-button<br /><span class="code-lines">3</span>ATTR "Load image"<br /><span class="code-lines">4</span><br /><span class="code-lines">5</span>GROUP "Scaling"<br /><span class="code-lines">6</span>ATTR "Image height"<br /><span class="code-lines">7</span>ATTR "Image width"<br /><span class="code-lines">8</span>ENDGROUP<br /></div><strong><br />4) Configure Configure Background image GraphRep attribute:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/05_conf_background_image_graphrep.png/49a1071c-13db-4cce-a33d-d178fc50b1ec?t=1395401263057" /><br /><ul style="list-style: disc inside;"><li>Double click <em>Background image GraphRep</em> attribute, set <em>Standard value</em> to:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>GRAPHREP layer:-3<br /><span class="code-lines">2</span>AVAL filename: ("Load image")<br /><span class="code-lines">3</span>AVAL sHeight: ("Image height")<br /><span class="code-lines">4</span>SET mHeight: ( VAL sHeight)<br /><span class="code-lines">5</span>AVAL sWidth: ("Image width")<br /><span class="code-lines">6</span>SET mWidth: ( VAL sWidth)<br /><span class="code-lines">7</span>BITMAPINFO (filename)<br /><span class="code-lines">8</span>BITMAP (filename) x:0cm y:0cm w: (bmpwidth / (100 - mWidth) * 1.0cm) h: (bmpheight / (100 - mHeight) * 1.0cm)<br /></div><br /><strong>5) Configure File selection attribute:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/06_conf_file_selection_attribute.png/9075ac58-0c9a-4f97-be35-15080408cf94?t=1395398438057" /><ul style="list-style: disc inside;"><li>Double click <em>File selection</em> attribute, set <em>Standard value</em> to: <em>Select file</em>.</li><li>Click <em>Facets</em> and set <em>EnumerationDomain</em> to:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>ITEM "Select file"<br /><span class="code-lines">2</span>CC "AdoScript" FILE_DIALOG open<br /><span class="code-lines">3</span> filter1:"BMP files" type1:"*.bmp"<br /><span class="code-lines">4</span> filter2:"JPEG files" type2:"*.jpg"<br /><span class="code-lines">5</span> filter3:"PNG files" type3:"*.png"<br /><span class="code-lines">6</span>CC "Core" SET_ATTR_VAL objid: (objid) attrname: "Load image" val: (path)<br /></div><br /><strong>6) Configure remaining new attributes</strong><br /><ul style="list-style: disc inside;"><li>Attribute <em>Image height</em>: set <em>Standard value</em> 11</li><li>Attribute <em>Image width</em>: set <em>Standard value</em> 11</li><li>Attribute <em>Load image</em>: set <em>Standard value</em> db:\Background.png.</li><li>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…).</li></ul style="list-style: disc inside;"><img src="http://www.adoxx.org/live/documents/10157/86510/07_file_management.png/86d4d23e-4d6b-4bf4-b797-acf2fd740005?t=1395399041607" /><br /><br /><strong>7) Define Model type</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/08_define_MT.png/a6552937-573c-46a9-91eb-83b027721398?t=1395399240113" /><br /><ul style="list-style: disc inside;"><li>Go back to the <em>Library management</em> and select your current <em>Dynamic Library</em>.</li><li>Click <em>Library attributes…</em> --> <em>Add-ons</em> and define the following model type according the figure above:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>MODELTYPE "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"</div><br /><br /><strong><span style="font-size: 18px">Result</span></strong><br /><br />In order to see the result, open <a href="http://www.adoxx.org/live/documents/10157/86510/Background+Image+example+model.adl/295906e2-77b9-4461-bbf9-64fae6ef4cbf">Background Image example model.adl </a>in the ADOxx Modeling Toolkit. <br /><br /><strong>How to open the model type's notebook: </strong><ul style="list-style: disc inside;"><li>Right click on modelling area and click Model attributes</li><li>alternatively press Alt+Enter.</li></ul style="list-style: disc inside;"><img src="http://www.adoxx.org/live/documents/10157/86510/09_open_MT_notebook.png/31ad8b95-7e6a-4bf5-9522-4b080e9d98d2?t=1395400316035" /><br /><br /><img src="http://www.adoxx.org/live/documents/10157/86510/10_MT_notebook.png/2b3ded58-64d0-42bd-9ab6-03daa6dc01a3?t=1395400587530" /><br /><ul style="list-style: disc inside;"><li>In order to set a background image, enter corresponding file path (file system or ADOxx database) directly into the <em>Load image</em> attribute, or click the <em>Select file </em>button, which opens a dialog for file selection and writes the selected file path into the <em>Load image</em> attribute.<br />Possible formats: BMP, PNG, JPEG.</li><li>Images can be stretched in height and width. Enter values from 0 to 99. </li><li>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. </li></ul style="list-style: disc inside;"><a href="http://www.adoxx.org/live/documents/10157/86510/Background+Image+example+model.adl/295906e2-77b9-4461-bbf9-64fae6ef4cbf"></a>Sabin Popescu2014-03-17T13:36:31Z