// EffCriteriaGraph.cpp: implementation of the EffCriteriaGraph class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "EffCriteriaGraph.h"
#include "TControlSystem.h"

#include "LearnDlg.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

void EffCriteriaGraph::init( CDialog *dialog )
{
   owner = dialog;

   // graph
   CRect rect;
   owner->GetDlgItem(IDC_EFF_CRITERIA_PIC)->GetWindowRect(rect);
   owner->ScreenToClient(rect);

   Create( WS_VISIBLE|WS_CHILD, rect, owner );

   SetRange( 0, 1.0 );
   SetYUnits( "" );
   SetXUnits( "" );
   SetBackgroundColor(GRAPH_BACK);
   SetGridColor(GRAPH_GRID);
   SetPlotColor(GRAPH_PLOT);

   CEdit *statc = (CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT);
   statc->SetWindowText( "0.0" );
   ((CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT))->Invalidate();
   ((CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT))->UpdateWindow();
}

void EffCriteriaGraph::draw()
{
   double effCriteria;
   controlSystem->messageHandler( CSM_GET_EFF_CRITERIA, (void*)&effCriteria );

   AppendPoint( effCriteria );

   owner->GetDlgItem(IDC_EFF_CRITERIA_PIC)->Invalidate();
   owner->GetDlgItem(IDC_EFF_CRITERIA_PIC)->UpdateWindow();

   CEdit *statc = (CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT);
   CString str;
   str.Format( "%10.20f", effCriteria );
   statc->SetWindowText( str );
   ((CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT))->Invalidate();
   ((CEdit*)owner->GetDlgItem(IDC_EDIT_EFF_CRIT))->UpdateWindow();
}

void EffCriteriaGraph::reset()
{
   Reset();
   owner->GetDlgItem(IDC_EFF_CRITERIA_PIC)->Invalidate();
   owner->GetDlgItem(IDC_EFF_CRITERIA_PIC)->UpdateWindow();
}   

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

EffCriteriaGraph::EffCriteriaGraph()
{

}

EffCriteriaGraph::~EffCriteriaGraph()
{

}
