Drawing arc over circular meter control

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Drawing arc over circular meter control

Post by BobLivingston »

Is it possible to draw an arc using script over a circular meter control?

I have a circular meter that I would like to have changing regions. I know the regions cannot change on the control itself, so I'd like to be able to draw a few arcs over the control that I can redraw based on tags. Is there some control I could use to draw the arc? Maybe the polyline control?
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Drawing arc over circular meter control

Post by mark.monroe »

Hi Bob,

I would recommend making the Circular control transparent and even turn off the scale. Then create a series of scales yourself in GIMP or some other photo editing application. You can then use the multipicture control to control which scale picture you use based on a tag value.

Another way would be for you to create little pictures that you could overlay onto the scale and then once again use the multipicture to change which one is shown based on a tag value. You could also change whether or not they are visible in the "Dynamics" group.
Snap 2012-05-11 at 10.10.13.png
Snap 2012-05-11 at 10.10.13.png (147.18 KiB) Viewed 10630 times
Snap 2012-05-11 at 10.10.44.png
Snap 2012-05-11 at 10.10.44.png (103.06 KiB) Viewed 10630 times
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Re: Drawing arc over circular meter control

Post by BobLivingston »

I managed to find a way to display the range arc I wanted by tweaking a Polyline control when my range tags change.

sample code:

private void Update_KWrange(System.Object sender, System.EventArgs e)
{
const double Meter_Min = 0; // Smallest unit on meter
const double Meter_Range = 400; // Range of unit on meter
const double Meter_StartAngle = 230; // Start angle of meter
const double Meter_FullAngle = 280; // degrees between start and end angle of meter
const double Arc_Radius = 106; // radius of range arc

double KWmin = Globals.Tags.KW_Min.Value; // range min tag
double KWmax = Globals.Tags.KW_Max.Value; // range max tag
double Angle_Start, Angle_Range;
int Num_Steps;

// Calculate start angle and range of arc
Angle_Start = Meter_StartAngle - (KWmin - Meter_Min) / Meter_Range * Meter_FullAngle;
Angle_Range = (KWmax - KWmin) / Meter_Range * Meter_FullAngle;
Num_Steps = (int)(Math.Abs(Angle_Range * Arc_Radius / 90.0f) + 0.5f);

// Compute start angle and step rate for arc
Angle_Range = (Angle_Range * Math.PI) / (180.0f * ((double)Num_Steps)); // calculate range of steps (in radians)
Angle_Start *= Math.PI / 180.0f; // convert angle to radians

// The following assumes meter has a width/height of 290
PointD[] Points = new PointD[Num_Steps + 1];
for (int i = 0; ; i++)
{
Points = new PointD(
145.5f + Math.Cos(Angle_Start) * Arc_Radius, // X
145.5f - Math.Sin(Angle_Start) * Arc_Radius // Y
);

if (i >= Num_Steps) break;

Angle_Start -= Angle_Range; // move to the next point
}

// tweak polyline control
this.m_KWrange.Points = new Neo.ApplicationFramework.Common.Collections.PointDList(Points);
}
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Re: Drawing arc over circular meter control

Post by BobLivingston »

Does the Polyline control have an anti-aliasing option/setting?
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Drawing arc over circular meter control

Post by mark.monroe »

Hi Bob,

No it does not have an anti-aliasing option.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply