Appendix A1: Standard predicates for visualization control
|
InferenceOn |
|||||
|
Description |
The visualization system calls InferenceOn to know if the visual world must be automatically maintained consistent with the value of variables of the underlying C program. If InferenceOn is true, standard predicates are recomputed as necessary to reflect significant changes of C variables. Note computations for building visual objects are worked out if and only if the predicate InferenceOn is true. If InferenceOn is false or is not declared, no predicate will ever be recomputed and the screen will never be updated. Observe that the old name of this predicate was Inference. Its usage is still possible in the current version of Leonardo, but it is deprecated. |
||||
| Default |
unless explicitly stated with the /** Not InferenceOn; **/ directive, InferenceOn is always true since it is automatically inserted into the knowledge base at process start up. |
||||
| Type | standard boolean | ||||
|
Parameters |
none |
||||
|
Usage |
/** InferenceOn; **/ puts the predicate InferenceOn into the current knowledge base, activating the visualization system if it was not active. This declaration forces the immediate reconstruction of all visual objects, too. /** Not InferenceOn; **/ removes the predicate InferenceOn from the current knowledge base, deactivating the visualization system if it was active. This implies a total paralysis of the mechanism of inference of visual data until the declaration /** InferenceOn; **/ is encountered again. Note: the visualization system should be deactivated where the content of data structures is not consistent, in order to avoid to compute predicates referring to totally or partially wrong data. This problem usually arises during initializations, and particular care must be taken while working with pointers. |
||||
|
Example |
[declaration of data structures] /** [predicates that refer to data structures] **/ void main(){
} Visual objects are built and shown only after the data structures have been fully initialized. No visualization occurs between /** Not InferenceOn; **/ and /** InferenceOn; **/. |
||||
|
Tip |
It is not convenient to deactivate and then activate the visualization system too frequently (for example on small code areas often iterated), since the complete rebuilding of visual data forced by the declaration /** InferenceOn; **/ may cause a light slowdown of the computation. |
||||
|
VisualUpdateOn |
|||||
|
Description |
The visualization system calls VisualUpdateOn to know if the screen must be automatically refreshed when the values of variables of the underlying C program have significantly changed. If VisualUpdateOn is false or is not declared, the screen will never be updated. Note VisualUpdateOn differs from InferenceOn for it affects only the drawing session of the visualization and not the computation of predicates that yields visual objects. Observe that the old name of this predicate was VisualUpdate. Its usage is still possible in the current version of Leonardo, but it is deprecated. |
||||
| Default |
Unless explicitly stated with the /** Not VisualUpdateOn; **/ directive, VisualUpdateOn is always true since it is automatically inserted into the knowledge base at process start up. |
||||
| Predicate type | standard boolean | ||||
|
Parameters |
none |
||||
|
Usage |
/** VisualUpdateOn; **/ puts the predicate VisualUpdateOn into the current knowledge base, allowing the update of the screen each time it is necessary. This declaration forces the immediate refresh of the screen, too. /** Not VisualUpdateOn; **/ removes the predicate VisualUpdateOn from the current knowledge base. This implies the screen will not be refreshed until the declaration /** VisualUpdateOn; **/ is encountered again. Note: it could be useful to inhibit the refresh of the screen in order to skip some not interesting visual events. |
||||
|
Example |
void Swap(long* a, long* b) {
/** Not VisualUpdateOn; **/
long temp=*a;
*a=*b;
*b=temp;
}
If Swap is used
to manipulate data structures that are being visualized. No visualization
occurs between /** Not VisualUpdateOn; **/
and the end of the Swap function. |
||||
|
Tip |
Predicates VisualUpdateOn and InferenceOn apparently produce the same effect. However, VisualUpdateOn inhibits only the update of the image on the screen, while InferenceOn inhibits the computation of Alpha predicates. For efficiency reasons, it is convenient to use VisualUpdateOn unless data structures referred to by Alpha predicates are not initialized. If you are not sure, use InferenceOn. |
||||