« Back to Scenario Collection

Buttons on the Drawing Area

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Buttons on the Drawing Area
external coupling scenario documentation modeltype graphrep
Answer
27/03/14 09:13
In this package we provide an example of a model type GraphRep which contains a Button that triggers some event. In our case it is a print-button which opens a print dialogue when ckicking on it:




Downloads


The files below contain an example library (Print Button.abl) and an example model (Print Button demo 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.

Print Button.abl
Print Button demo model.adl


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 attribute 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: Print Button GraphRep, type: Longstring.
3) Configure Print Button GraphRep attribute


  • Double click Print Button GraphRep attribute, set Standard value to:
1GRAPHREP layer:-3
2IF (_outdevtype = "drawingarea") {
3SET printIcon:"db:\\btn_print.png"
4BITMAPINFO (printIcon)
5BITMAP (printIcon) x:1cm y:0.5cm w:1.5cm h:1.5cm
6HOTSPOT "_PrintModel_" text:"Print Model" x:1cm y:0.5cm w:1.5cm h:1.5cm
7}
  • Make sure that the file btn_print.png is contained in the database (close the Library management and go to Extras --> File management…).
4) Creating _PrintModel_ attribute (Programcall)


  • Select class __ModelTypeMetaData__
  • Click New --> New attribute...
  • Name new attributes and select type according figure above: (1) name: _PrintModel_, type: Programcall.
5) Configure _PrintModel_ attribute (Programcall)


  • Double click _PrintModel_ attribute
  • Set Standard value to: Print Model
  • •Click Facets and set EnumerationDomain to:
1ITEM "Print Model"
2EXECUTE file: ("db:\\PrintModel.asc")
  • Make sure that the file PrintModel.asc is contained in the database.
6) Define Model type



  • 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 "Print Button Sample" from:none plural:"Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "Print Button GraphRep"


Result


In order to see the result, open Print Button demo model.adl in the ADOxx Modeling Toolkit.


  • Clicking the Print Model button triggers (via HOTSPOT command) the Programcall _PrintModel_, which executes the file PrintModel.asc.
  • Note, that the print icon (btn_print.png) is represented on the drawing area only.

RE: Buttons on the Drawing Area
Answer
14/11/19 11:29 as a reply to Sabin Popescu.
Hello!

I am trying to have two different Buttons in the same drawing area. I already created the second button, however, it is not shown in the drawing area. 
I am pretty sure that I have to do this in Add-ons but unfortunately it is not working.
1MODELTYPE "Role Model" from:none plural:"Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "First Button GraphRep"from:none plural:"Samples" pos:3 not-simulateable graphrep: "Second Button GraphRep"

The button with the GraphRep "Second Button GraphRep" is not shown. 

Best regards,

Benedikt Kaiser

RE: Buttons on the Drawing Area
modeltype graphrep if attribute modeltype graphrep
Answer
09/12/19 11:42 as a reply to Benedikt Kaiser.
Dear Benedikt,
A model type can have only one graphical representation. To display two buttons in a model type you must do this via the GraphRep attribute. The GraphRep code for two different buttons in a model type could look like this:

GRAPHREP layer:-3

IF (_outdevtype = "drawingarea") {
SET printIcon:"db:\\btn_print.png"
BITMAPINFO (printIcon)
BITMAP (printIcon) x:1cm y:0.5cm w:1.5cm h:1.5cm
HOTSPOT "_PrintModel_" text:"Print Model" x:1cm y:0.5cm w:1.5cm h:1.5cm
SET printIcon2:"db:\\btn_print.png"
BITMAPINFO (printIcon2)
BITMAP (printIcon2) x:3cm y:0.5cm w:1.5cm h:1.5cm
HOTSPOT "_PrintModel_" text:"Print Model" x:3cm y:0.5cm w:1.5cm h:1.5cm
}