Solved
X and Y coordinates
Posted on 1998-09-27
Okay, here is my problem... hope i can find some kind souls here to help me.
Here is a part of my code for Segment 1 Dialog Box.
void CSegOne::OnSegoneapplyButton()
{
// to update the controls
UpdateData(TRUE);
// m_DispType and m_MotionType are basically combo
// box for deciding which equations to use and
// m_MaxHt and m_TwoAngle are variable determine
// by the users
if(m_DispType == 1 && m_MotionType == 0)
{
for (theta=0; theta<m_TwoAngle; theta+5)
{
displacement = (m_MaxHt/2)*(1-(cos(0.5*theta)));
}
OnOK();
Invalidate();
}
The problem is... after generating the various values for the displacement and theta, how to I update them to my OnDraw function so that I can plot the points out?
Here is a small part of my OnDraw function.
I have omitted certain lines to keep this question short.
void CCamView::OnDraw(CDC* pDC)
{
CCamDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->MoveTo(50, 150);
pDC->LineTo(450, 150);
pDC->LineTo(450, 350);
pDC->LineTo(50, 350);
pDC->LineTo(50, 150);
// Draw the vertical gridlines
pDC->SelectObject(&thin_line);
pDC->MoveTo(150, 150);
pDC->LineTo(150, 350);
pDC->MoveTo(250, 150);
pDC->LineTo(250, 350);
pDC->MoveTo(350, 150);
pDC->LineTo(350, 350);
// Draw the horizontal gridlines
pDC->MoveTo(50, 150);
pDC->LineTo(450, 150);
pDC->MoveTo(50, 200);
pDC->LineTo(450, 200);
pDC->MoveTo(50, 250);
pDC->LineTo(450, 250);
pDC->MoveTo(50, 300);
pDC->LineTo(450, 300);
// Label the x-axis
pDC->TextOut(50, 360, "0");
pDC->TextOut(150, 360, "100");
pDC->TextOut(250, 360, "200");
pDC->TextOut(350, 360, "300");
pDC->TextOut(450, 360, "400");
// To display the 4 different views
pDC->SelectObject(pOldPen);
CFont * pOldFont = pDC->SelectObject(&big_font);
if (m_SelectedView == "DISPLACEMENT")
{
CCamDoc* pDoc = GetDocument();
pDC->TextOut(50, 100, "Displacement Diagram");
pDC->SelectObject(&blue_line);
//here is essentially a str line
//m_XCoord is my theta and m_YCoord is my
//displacement. m_XCoord and m_YCoord have been
//initialised to 50 and 348 respectively.
pDC->MoveTo(m_XCoord, m_YCoord);
pDC->LineTo(m_XCoord+360, m_YCoord);
//On apply button, here is where i need to add in
//the codes for plotting of the points
}