#include <ilviews/protos/protomgr.h>
#include <ilviews/protos/valuesrc.h>
#include <ilviews/protos/allaccs.h>
#include <ilviews/protos/protocnt.h>
#include <ilviews/view.h>
#include <ilviews/allobj.h>
#include <ilviews/graphics.h>
#include <ilviews/msglabel.h>
// --------------------------------------------------------------------------
// Quit from the Window Manager
// --------------------------------------------------------------------------
static void Quit(IlvView* view, IlvAny)
{
IlvDisplay* display = view->getDisplay();
delete view;
delete display;
IlvExit(0);
}
static void TimerAction(IlvTimer*, IlvAny arg)
{
static IlvUInt currentValue = 0;
static IlvInt increment = 2;
// Get the Value Source
IlvValueSource* valueSource = (IlvValueSource*)arg;
// Value variation
currentValue += increment;
// Min and Max tests
if ((currentValue < 0) || (currentValue > 100))
{
currentValue -= increment;
increment = -increment;
}
// Push the new value
valueSource->pushValue(IlvValue("SuperGaugeData", currentValue));
}
int main(int argc, char* argv[])
{
IlvDisplay* display = new IlvDisplay("Protos", 0, argc,
argv);
if (!display || display->isBad())
{
IlvFatalError("Couldn't open display");
delete display;
return -1;
}
IlvProtoManager* protoman = new IlvProtoManager(display);
IlvView* view = new IlvView(display, "Proto sample", "Proto
sample",
IlvRect(0,
0, 400, 180));
protoman->addView(view);
// Load a data file into the Prototype manager
protoman->read("GaugePanel.ilv");
// Get a pointer to the value source
IlvValueSource* source = protoman->getValueSource("AppliData");
// Create a timer for animation
IlvTimer* timer = new IlvTimer(display, 0, 50, TimerAction,
source);
timer->run();
// Create a view for the manager
view->setDestroyCallback(Quit);
// Set double-buffering to avoid flickering
protoman->setDoubleBuffering(view, IlvTrue);
view->show();
// Wait for user events
IlvMainLoop();
return 0;
} |