/******************************************************************************
** Copyright (C) 2001, University of Alabama in Huntsville. All rights 
** reserved.
**
** File   : DrawableArc.cpp
**
** Author : Satish Hota
**
** Description:
**    This file provides the implementation for CDrawableArc class.
**
** History:
** 28-Nov-01 Satish Hota
**     File Created. 
** 30-Nov-01 Satish Hota
**     Added and implemented the Draw method.
******************************************************************************/

#include "stdafx.h"
#include "ConGraT.h"
#include "DrawableArc.h"

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

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

CDrawableArc::CDrawableArc()
{
    m_pFromElement = NULL;
    m_pToElement = NULL;
}

CDrawableArc::~CDrawableArc()
{

}

inline CDrawableElement* CDrawableArc::GetToObject()
{
    // TODO
    return m_pToElement;
}

inline CDrawableElement* CDrawableArc::GetFromObject()
{
    // TODO
    return m_pFromElement;
}

inline void CDrawableArc::SetFromObject(CDrawableElement *pFromObject)
{
    m_pFromElement = pFromObject;  
}

inline void CDrawableArc::SetToObject(CDrawableElement *pToObject)
{
    m_pToElement = pToObject;
}

long CDrawableArc::Draw()
{
    int nFromX, nFromY, nToX, nToY;
    int x1, y1, x2, y2;

    m_pFromElement->GetFromLocation (&x1, &y1);
    m_pFromElement->GetToLocation (&x2, &y2);
    nFromX = (x1 + x2)/2;
    nFromY = (y1 + y2)/2;

    m_pToElement->GetFromLocation (&x1, &y1);
    m_pToElement->GetToLocation (&x2, &y2);
    nToX = (x1 + x2)/2;
    nToY = (y1 + y2)/2;

    m_pFromElement->ClipLine(&nFromX, &nFromY, &nToX, &nToY);
    m_pToElement->ClipLine(&nFromX, &nFromY, &nToX, &nToY);

    SetFromLocation(nFromX, nFromY);
    SetToLocation(nToX, nToY);

    return CDrawableLine::Draw();
}
