The problem type developer can change the way a QUESTION is displayed and if he wishes he can also change the whole contents of a window, while maintaining the basic behavior of the data set, i.e. in the Condition window: assign, unassign, draw; in the Material window: create material, delete material; and so on.

With the default layout for the data windows, the questions are placed one after another in one column inside a container frame, the QUESTION's label in column zero and the VALUE in column one. For an example see picture below.

CONDITION: Steel_section

CONDTYPE: over lines

CONDMESHTYPE: over body elements

QUESTION: Local_Axes#LA#(-Default-,-Automatic-)

VALUE: -Default-

QUESTION: SteelName

VALUE: IPN-80

QUESTION: SteelType

VALUE: A37

END CONDITION

The developer can override this behavior using TKWIDGET. TKWIDGET is defined as an attribute of a QUESTION and the value associated with it must be the name of a Tcl procedure, normally implemented in a Tcl file for the problem type. This procedure will take care of drawing the QUESTION. A TKWIDGET may also draw the entire contents of the window and deal with some events related to the window and its data.

The prototype of a TKWIDGET procedure is as follow:

proc TKWidgetProc {event args} {

switch $event {

INIT {

...

}

SYNC {

...

}

DEPEND {

...

}

CLOSE {

...

}

}

}

Note: It is also allowed to add extra arguments before the 'event' argument, and provide its values in theTKWIDGET field

e.g. declare this tkwidget procedure with a first argument "-width 20"

TKWIDGET: GidUtils::TkwidgetEntryConfigure {-width 20}

and then define the Tcl procedure ready to get the first extra argument 'configure_options' before 'events':

proc GidUtils::TkwidgetEntryConfigure { configure_options event args } {

...

}

The argument event is the type of event and args is the list of arguments depending on the event type. The possible events are: INIT, SYNC, CLOSE and DEPEND. Below is a description of each event.

  • INIT: this event is triggered when GiD needs to display the corresponding QUESTION and the list of arguments is {frame row-var GDN STRUCT QUESTION}: frame is the container frame where the widget should be placed; row-var is the name of the variable, used by GiD, with the current row in the frame; GDN and STRUCT are the names of internal variables needed to access the values of the data; QUESTION is the QUESTION's name for which the TKWIDGET procedure was invoked. Normally the code for this event should initialize some variables and draw the widget.
  • SYNC: this is triggered when GiD requires a synchronization of the data. Normally it involves updating some of the QUESTIONs of the data set. The argument list is {GDN STRUCT QUESTION}.
  • CLOSE: this is triggered before closing the window, as mentioned this can be canceled if an ERROR is returned from the procedure.
  • DEPEND: this event is triggered when a dependence is executed over the QUESTION for which the TKWIDGET is defined, ie. that QUESTION is an lvalue of the dependence. The list of arguments is {GDN STRUCT QUESTION ACTION value} where GDN, STRUCT and QUESTION are as before, ACTION could be SET, HIDE or RESTORE and value is the value assigned in the dependence.

The argument args is a variable amount of arguments, provided here as a list. Its content depends on the 'event' argument.

e.g.

INIT args: PARENT CURRENT_ROW_VARIABLE GDN STRUCT QUESTION

SYNC args: GDN STRUCT QUESTION

DEPEND args: GDN STRUCT QUESTION ACTION VALUE

CLOSE args: GDN STRUCT QUESTION

and its meaning is:

CURRENT_ROW_VARIABLE: store a name of variable that provide the integer row number of the current field

GDN and STRUCT: identify the data (e.g set value [DWLocalGetValue $GDN $STRUCT $QUESTION])

QUESTION is the name of the question that identify the field

ACTION could be "HIDE", "SET" or "RESTORE"

The procedure should return:

  • an empty string "" meaning that every thing was OK;
  • a two-list element {ERROR-TYPE Description} where ERROR-TYPE could be ERROR or WARNING. ERROR means that something is wrong and the action should be aborted. If ERROR-TYPE is the WARNING then the action is not aborted but Description is shown as a message. In any case, if Description is not empty a message is displayed.

The picture below shows a fragment of the data definition file and the GUI obtained. This sample is taken from the problem type RamSeries/rambshell and in this case the TKWIDGET is used to create the whole contents of the condition windows. For a full implementation, please download the problem type and check it.

CONDITION: Steel_section

CONDTYPE: over lines

CONDMESHTYPE: over body elements

QUESTION: Local_Axes#LA#(-Default-,-Automatic-)

VALUE: -Default-

QUESTION: SteelName

VALUE: -

QUESTION: SteelType

VALUE: -

TKWIDGET: SteelSections

END CONDITION

TkWidget

Predefined TKWIDGET procedures:

There are some useful features that have been implemented in tcl procedures provided by default in GiD, inside the dev_kit.tcl file,

specially to replace the standard entry of a question by some specialized widget.

  • GidUtils::TkwidgetGetFilenameButton

To show an entry and a select file button that open the dialog window to select an existent file.

  • GidUtils::TkwidgetPickPointOrNode

To show an entry and a button to pick in screen the id number of a point in geometry mode or a node in mesh mode

  • GidUtils::TkwidgetGetLayername

To show a combobox with the current layers

  • GidUtils::TkwidgetGetGroupname

To show a combobox with the current groups

  • GidUtils::TkwidgetGetVector3D

To show in a single row three entries for x, y, z real coordinates of points or directions.