need some shortening help (gauge)

hi all,
currently my code is very long
and i wish to shorten it with math formulae
sadly im still very new to this language
and need major help..

void CGlassCockpitDlg::OutflowValve()
{
CPen GreenPen(PS_SOLID,2,RGB(0,255,0));
CPen BlackPen(PS_SOLID,2,RGB(0,0,0));
CPen WhitePen(PS_SOLID,2,RGB(255,255,255));
CBrush GreenBrush(RGB(0,255,0));
CBrush BlackBrush(RGB(0,0,0));
/////////////////////////////OUTFLOW LEFT/////////////////////////////
if(OutflowValveLeft!=1) //Switch LEFT(AUTO)(OutflowValveLeft==0)
{
memdcECSAnimation.SetTextColor(RGB(255,255,255));
memdcECSAnimation.TextOut(494,203,"AUTO");
TRACE("L AUTO mode
");

TRACE("Charge L
");
Lcharge=TRUE;
}

else if(OutflowValveLeft!=0) //Switch LEFT(MAN)(OutflowValveLeft==1)
{
memdcECSAnimation.SetTextColor(RGB(225,170,0));
memdcECSAnimation.TextOut(494,203,"MAN");
TRACE("L MAN mode
");

if(Outflow_control1==2)//&& (Ldischarge==FALSE))
{
TRACE("Discharge L
");
Ldischarge=TRUE;
}

else if(Outflow_control2==4)// && (Lcharge==FALSE))
{
TRACE("Charge L
");
Lcharge=TRUE;
}

else if((Outflow_control1==0)&&(Outflow_control2==0))
{
Left=LPosition;
LMOTOR=Left;
LeftNeedle[Left];
Lcharge=Ldischarge=FALSE;
}

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(522,130); //left valve line
memdcECSAnimation.LineTo(522,196);

memdcECSAnimation.MoveTo(515,132);
memdcECSAnimation.LineTo(515,139);

memdcECSAnimation.MoveTo(515,187); //right valve line
memdcECSAnimation.LineTo(515,194);

memdcECSAnimation.MoveTo(480,163);
memdcECSAnimation.LineTo(487,163);
}

if(Lcharge==TRUE)
{
if(LPosition<=255)//(LPosition<255)
{
TRACE("L Charging in progress
");
LPosition=(LPosition+1);
TRACE("LPosition = %d
", LPosition);
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
TRACE("Left = %d
", Left);
TRACE("
");
LeftNeedle[Left];
Lcharge=FALSE;

if(LPosition==255)
{
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
LeftNeedle[Left];
Lcharge=FALSE;
}
}

/*else if(LPosition==255)
{
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
LeftNeedle[Left];
Lcharge=FALSE;
}*/
}

if(Ldischarge==TRUE)
{
if(LPosition>=0)//(LPosition>0)
{
TRACE("L Discharging in progress
");
LPosition=(LPosition-1);
TRACE("LPosition = %d
", LPosition);
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
TRACE("Left = %d
", Left);
TRACE("
");
LeftNeedle[Left];
Ldischarge=FALSE;

if(LPosition==0)
{
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
LeftNeedle[Left];
Ldischarge=FALSE;
}
}

/*else if(LPosition==0)
{
Left=LPosition;
LMOTOR=Left;
TRACE("LMOTOR = %d
", LMOTOR);
LeftNeedle[Left];
Ldischarge=FALSE;
}*/
}
/////////////////////////////////////////////////////////////

if(Left==255)
{
memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(515,136);//1
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=252) && (Left<=254))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(515,136);//1
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(514,136);//2
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=249) && (Left<=251))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(514,136);//2
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(513,136);//3
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=246) && (Left<=248))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(513,136);//3
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(512,136);//4
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=243) && (Left<=245))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(512,136);//4
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(511,136);//5
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=240) && (Left<=242))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(511,136);//5
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(510,137);//6
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=237) && (Left<=239))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(510,137);//6
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(509,137);//7
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=234) && (Left<=236))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(509,137);//7
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(508,137);//8
memdcECSAnimation.LineTo(515,163);
}

else if((Left>=231) && (Left<=233))
{
memdcECSAnimation.SelectObject(&BlackPen);
memdcECSAnimation.MoveTo(508,137);//8
memdcECSAnimation.LineTo(515,163);

memdcECSAnimation.SelectObject(&WhitePen);
memdcECSAnimation.MoveTo(507,137);//9
memdcECSAnimation.LineTo(515,163);
}
ect ect till 0

what this does is given specific pushes of a button
the line in a vertical semi circle will move from
south to north

i know theres a way to shorten it but i dont really understand how to

i found this
http://www.programmersheaven.com/mb/Win32API/371397/371397/is-the-a-way-to-rotate-a-line-clockwise/

looks like the way to do it
but i cant really fit it in

if anyone could help me out with this
id be very thankful

thanks!


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories