PenExample shows how to use and track infrared pens with MultiTaction cells and Cornerstone SDK.
In Cornerstone 2.0 infrared pens are instances of MultiTouch::Pen. This example is very similar to MarkerExample demo.
Note: You need a configured MultiTaction cell with PenTracking enabled (firmware version 1.9.1-taction13 or newer) and an infrared pen for this example to actually do something. Alternatively you can use virtual pens by pressing 'y' once and then clicking on the screen.
For detecting marker input we need to extend the basic widget functionality by creating a custom widget that inherits from MultiWidgets::Widget. This is called PenVisualizer. This class will override the processPens function and draw colored circles for all detected pens by overriding the renderContent function.
We store the found pen locations in a private vector which is cleared on every call to the input function. We need to do this because a pen that was visible in the previous sample might not be present any longer:
Function processPens is called with a list of pens that are grabbed by our widget. We iterate all pens:
Pen locations are in screen coordinates, but we want to render those in widget coordinates. The conversion is done by MultiWidgets::GrabManager:
Next we save the pen locations so we can draw some circles later on:
To render our saved pens we override the renderContent function in which we call the default implementation and our own visualizePens function:
In visualizePens we simply draw a colored circle for each pen that we found in the previous input sample. All pen locations are already in local widget coordinates so we don't need to do any coordinate system conversions.
The full source code for the example is listed below: