/******************************************************************************
** Copyright (C) 2001, University of Alabama in Huntsville. All rights 
** reserved.
**
** File   : DrawableLine.cpp
**
** Author : Satish Hota
**
** Description:
**    This file provides implementation for CDrawableLine class.
**
** History:
** 24-Nov-01 Satish Hota
**     File Created. 
** 26-Nov-01 Satish Hota
**     Removed PostUpdate in the Draw method. 
** 28-Nov-01 Satish Hota
**     Added LineType, LineEndType, member variables and access methods.
** 30-Nov-01 Satish Hota
**     Initialized member variables in the constructor.  Beefed up the
**     implementation of the Draw method to draw different line types with
**     different end types.
******************************************************************************/

#include "stdafx.h"
#include "ConGraT.h"
#include "DrawableLine.h"

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

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

CDrawableLine::CDrawableLine()
{
    m_eLineType = CDrawableLine::LineType_Solid;
    m_eLineEndType = CDrawableLine::LineEndType_Default;
}

CDrawableLine::~CDrawableLine()
{

}

long CDrawableLine::Draw()
{
    CMFCDevConHelper::PenType ePenType;
    CMFCDevConHelper::LineEndType eLineEndType;

    if(m_eLineType == CDrawableLine::LineType_Solid)
    {
        ePenType = CMFCDevConHelper::PenType_Solid;
    }
    else if(m_eLineType == CDrawableLine::LineType_Dashed)
    {
        ePenType = CMFCDevConHelper::PenType_Dashed;
    }

    // Translate from CDrawable::LineEndType to
    // CMFCDevConHelper::LineEndType
    eLineEndType = CMFCDevConHelper::LineEndType_Default;
    if(m_eLineEndType == CDrawableLine::LineEndType_StartArrow)
    {
        eLineEndType = CMFCDevConHelper::LineEndType_StartArrow;
    }
    else if(m_eLineEndType == CDrawableLine::LineEndType_EndArrow)
    {
        eLineEndType = CMFCDevConHelper::LineEndType_EndArrow;
    }
    else if(m_eLineEndType == CDrawableLine::LineEndType_ArrowsAtBothEnds)
    {
        eLineEndType = CMFCDevConHelper::LineEndType_ArrowsAtBothEnds;
    }

    c_pDevConHelper->DrawLine(m_nFromX, m_nFromY, m_nToX, m_nToY, ePenType, eLineEndType);

    return CG_S_OK;
}


void CDrawableLine::SetLineType(LineType eLineType)
{
    m_eLineType = eLineType;
}

CDrawableLine::LineType CDrawableLine::GetLineType()
{
    return m_eLineType;
}

void CDrawableLine::SetLineEndType(LineEndType eLineEndType)
{
    m_eLineEndType = eLineEndType;
}

CDrawableLine::LineEndType CDrawableLine::GetLineEndType()
{
    return m_eLineEndType;
}
