The RTX C++ SDK has been improved for Version 12.6. One of the improvements will require minor source code changes when you upgrade to Version 12.6 of Investor/RT and build with the latest irtsdk.h SDK. The CPEN data type in Version 12.5 RTX is a C structure containing a pen color, pen width and pen style setting. In 12.6, CPEN is now a C++ class with a proper constructor and methods for working with CPEN instances. Version 12.5 declarations of CPEN looked like this:
CPEN myPen = {COLOR_RED, 1, PAT_SOLID}; /* declare a CPEN stucture and initialize it */
To compile correctly using the 12.6 SDK such declarations must be revised to use the CPEN class, i.e.
CPEN myPen(COLOR_RED); /* instantiate myPen with color red. NOTE: Width 1 and solid pattern are default */
If you wish to instantiate with a width greater than 1, specify the width you want to the constructor:
CPEN widerPen(COLOR_BLUE, 2); /* 2 pixel wide blue color pen */
Using CPEN methods
The following is for developers of more advanced RTX Extensions that perform customized drawing via the draw() RTX virtual function and have CPEN elements in their userdata as end user parameters.
Methods to operate with a CPEN object are: set, get, and getRTXPen. An RTXPen is the structure now used in userdata for any pen parameters in the 12.6 SDK. This is a change from 12.5 where CPEN was used for this purpose. The new method getRTXPen() is used to get the properties of a userdata parameter pen (an RTXPEN) into a CPEN object instance. For example, userdata may have a pen and/or color parameter, declared like this:
typedef struct _userdata { RTXPEN myPEN; COLOR lineColor; ... } UserData, *UserDataPtr;
In your draw() function you may have code to use the parameter myPEN or lineColor in drawing operations that involve a CPEN, e.g.
int myRTExtension::draw(void) { CPEN drawingPen(COLOR_RED); ... drawingPen.color = pUserData->lineColor; drawingPen.set(); /* set pen for draw operations */ ... drawingPen.getRTXPen(&pUserData->myPEN); drawingPen.set(); /* set pen for other draw operations */
In summary, all declarations of pens in userdata are defined now as RTXPEN instead of CPEN.. CPEN objects and the CPEN class methods are used to set(), get(), or getRTXPEN() the color,width and style from a userdata pen; Using the 12.6 SDK working with CPEN objects ensures that all CPEN are properly initialized. Only the color need be specified when declaring a CPEN. Width defaults to 1 and style defaults to solid drawing.