Example MFC controls - input from Timer

66 views
Skip to first unread message

yudi...@gmail.com

unread,
Jan 20, 2015, 1:29:28 PM1/20/15
to glg...@googlegroups.com
Hi:

Can someone share example code in "Controls" from "Example_MFC", But the input data not from "Slider" instead of from some where else, for example, OnTimer to set Dials value randomly.

Thanks
Lu

glg_devel

unread,
Jan 20, 2015, 4:28:38 PM1/20/15
to glg...@googlegroups.com
Hello Lu,

In the Controls example, SetResource method is used to push the value to the dial,
where the value is coming from the slider. Likewise, you can supply a random value to the
dial in a timer procedure:

    viewport.SetResource( "Dial/Value", GlgRand( low, high ) );

A timer can be added using GlgAddTimeOut method.

Various GLG examples use a timer to animate the drawing with random values,
for example, the following examples may be used:

  examples_mfc/animation
  examples_mfc/TagsExample

While animation example uses object resources for animation, TagsExample uses tags to animate
the drawing. The details are provided in the GLG Animation Tutorial:
  http://www.genlogic.com/doc_html/glgtut.html

To push a data value into a dial, you can use one of the following methods:

a)  Use resource name "Dial/Value", where Dial is the object name in the .g file:

    viewport.SetResource( "Dial/Value",  GlgRand( low, high ) );

b) In the GLG Builder, you can add a tag to the dial's Value, and use the tag to
animate the dial. For example, for tag source defined as "DialTag":

    viewport.SetTag( "DialTag",  GlgRand( low, high ) );

Note that the resource "Dial/Value" is a string representing a hierarchical resource path,
while the tag "DialTag" is global to the drawing and does not have a hierarchy.
The use of tags is demonstrated in the examples_mfc/TagsExample.

Kind regards,
Generic Logic Team

yudi...@gmail.com

unread,
Jan 21, 2015, 5:40:43 PM1/21/15
to glg...@googlegroups.com
Thanks.

How can label the Dial index sequence by increment 1, for example, from 0, 1, 2, 3... 



Thanks
Lu

glg_devel

unread,
Jan 22, 2015, 12:02:31 PM1/22/15
to glg...@googlegroups.com
Hello Lu,

All parameters of the GLG widgets can be configured using resources.
It can be done either at design time in the GLG Builder, using the Resource Browser,
or at run-time using GLG C++ API method SetResource. The best way to view
all available widget resources is to use the Resource Browser in the GLG Builder.

The following resources of a GLG dial widget can be used to configure labels and
other parameters:

   Low, High - define dial's data range;
   Axis/NumMajorTicks - defines number of major ticks
   Axis/NumMinorTicks - defines number of minor ticks
   Axis/NumLabels - defines number of labels.

Example:
Low = 0; High = 10; NumMajorTicks = 10; NumLabels =10.
These settings will display labels at each major tick, from 0 to 10, i.e.
0,1,2,3,..10

To set resources in a C++ program for an object named "Dial":

    viewport.SetResource( "Dial/Low", 0. );
    viewport.SetResource( "Dial/High", 10. );
    viewport.SetResource( "Dial/Axis/NumMajorTicks", 10. );
    viewport.SetResource( "Dial/Axis/NumLabel", 10. );
    
Best regards,
Generic Logic Team

yudi...@gmail.com

unread,
Jan 22, 2015, 7:03:23 PM1/22/15
to glg...@googlegroups.com
Hi

Thank you very much, now the dial value was set on OnTimer event. 
I had try to add a "Thermometer" dial into "Controls.g" $Widget. but always failed. 
I had try a day now, let expert give me some direction.

Thanks
Lu

glg_devel

unread,
Jan 23, 2015, 11:23:40 AM1/23/15
to glg...@googlegroups.com
Hello Lu,

The top level object  of any GLG drawing is a viewport named $Widget.
To add other widgets or objects to the drawing, they should be added
as children of the $Widget viewport.
 
For example, load controls.g into the GLG Builder, click to select $Widget viewport,
and use HierarchyDown button (down arrow) on the left to go "down" into the
viewport. Select a desired widget from the palette; it will be added as a child
of $Widget. Bring Properties for the newly created widget and assign a unique name
to it using the Name field, for example "Thermometer".

Once the widget is named, it can be accessed as a resource. In the example above,
the value of the Thermometer can be accesses in the program using resource name
"Thermometer/Value".

GLG Builder and Animation Tutorial provides detailed information on the
$Widget viewport, GLG object hierarchy, properties and resources, etc.
Reply all
Reply to author
Forward
0 new messages