139 lines
3.6 KiB
C++
139 lines
3.6 KiB
C++
// SLNKContour.cpp : Implementation of CSLNKContour
|
||
|
||
#include "stdafx.h"
|
||
#include "SLNKContour.h"
|
||
#include "Whipfile.h"
|
||
|
||
// Merk op dat sommige functies ook nog in WhipFile zijn gedefinieerd. Die moeten daar weg omdat we
|
||
// tegenwoordig (mei 2007) via WhipFile.Contour("label") een Contour object opleveren waar je alles
|
||
// maar op doet, of beter nog mettertijd WhipFile.Contours.Item("label")
|
||
// Voor backward compatibiliteit laten we de Whipfile nog maar even intact
|
||
|
||
// CSLNKContour
|
||
|
||
void CSLNKContour::SetImpl(CSLNKContourImpl * pSLNKContour)
|
||
{
|
||
m_SLNKContour = pSLNKContour;
|
||
if (m_SLNKContour->m_fromSymbol) return; // Die zijn vast nog niet getransformeerd
|
||
|
||
WT_Logical_Box bx = pSLNKContour->bounds();
|
||
|
||
WT_Point3D dwgPt;
|
||
CComQIPtr<IDWGPoint> pt;
|
||
|
||
dwgPt = pSLNKContour->m_parentWhipFileState->m_contunits.transform(bx.minpt());
|
||
m_dwgBounding->get_min(&pt);
|
||
pt->put_DwgX(dwgPt.m_x);
|
||
pt->put_DwgY(dwgPt.m_y);
|
||
pt.Release();
|
||
|
||
dwgPt = pSLNKContour->m_parentWhipFileState->m_contunits.transform(bx.maxpt());
|
||
m_dwgBounding->get_max(&pt);
|
||
pt->put_DwgX(dwgPt.m_x);
|
||
pt->put_DwgY(dwgPt.m_y);
|
||
pt.Release();
|
||
|
||
WT_Logical_Point lp = CSLNKContourImpl::Centroid(*pSLNKContour);
|
||
dwgPt = pSLNKContour->m_parentWhipFileState->m_contunits.transform(lp);
|
||
m_dwgCenter->put_DwgX(dwgPt.m_x);
|
||
m_dwgCenter->put_DwgY(dwgPt.m_y);
|
||
};
|
||
|
||
STDMETHODIMP CSLNKContour::SetColor(ULONG rgb, BYTE Alpha /*=0*/)
|
||
{
|
||
int b=rgb%256;
|
||
int g=(rgb>>8)%256;
|
||
int r=(rgb>>16)%256;
|
||
m_SLNKContour->m_Color.set(r, g, b, Alpha);
|
||
|
||
return S_OK;
|
||
}
|
||
|
||
// De FriendlyName verschijnt uiteindelijk als tooltip
|
||
STDMETHODIMP CSLNKContour::SetUrl(BSTR Url, BSTR FriendlyName)
|
||
{
|
||
CString fName(FriendlyName);
|
||
if (fName=="")
|
||
fName=m_SLNKContour->m_contLabel.ascii();
|
||
|
||
// Merk op: \n lijkt \012 te zijn?
|
||
fName.Replace("\012", "\\n"); // Anders corrupte (ascii?) DWF
|
||
fName.Replace("\015", "\\n"); // Anders corrupte (ascii?) DWF
|
||
|
||
if (WT_String::is_ascii(fName.GetLength(), fName))
|
||
m_SLNKContour->m_Url.set( WD_URL_Optimize, (LPCSTR)CString(Url), (LPCSTR)fName);
|
||
else
|
||
{ // Use UNICODE for example for Micha<68>l
|
||
CStringW s(fName);
|
||
m_SLNKContour->m_Url.set( WD_URL_Optimize, Url, s);
|
||
}
|
||
|
||
return S_OK;
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Area(DOUBLE* pVal)
|
||
{
|
||
*pVal = m_SLNKContour->m_DWGArea;
|
||
|
||
return S_OK;
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Extents(IBoundingBox** pVal)
|
||
{
|
||
if (m_SLNKContour->m_fromSymbol)
|
||
return E_NOTIMPL; // (nog) niet op symbolen
|
||
|
||
return m_dwgBounding->QueryInterface(IID_IBoundingBox, (void**)pVal);
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Center(IDWGPoint** pVal)
|
||
{
|
||
if (m_SLNKContour->m_fromSymbol)
|
||
return E_NOTIMPL; // (nog) niet op symbolen
|
||
return m_dwgCenter->QueryInterface(IID_IDWGPoint, (void**)pVal);
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Key(BSTR* pVal)
|
||
{
|
||
CComBSTR bstrString(m_SLNKContour->m_Key);
|
||
|
||
return bstrString.CopyTo(pVal);
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::put_Key(BSTR newVal)
|
||
{
|
||
CString key(newVal);
|
||
m_SLNKContour->m_Key = key;
|
||
|
||
return S_OK;
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Label(BSTR* pVal)
|
||
{
|
||
CComBSTR bstrString(m_SLNKContour->m_ExtraLabel);
|
||
return bstrString.CopyTo(pVal);
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::put_Label(BSTR newVal)
|
||
{
|
||
CString key(newVal);
|
||
m_SLNKContour->m_ExtraLabel = newVal;
|
||
return S_OK;
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::get_Hatch(BYTE* pVal)
|
||
{
|
||
(*pVal) = m_SLNKContour->m_Pattern;
|
||
|
||
return S_OK;
|
||
}
|
||
|
||
STDMETHODIMP CSLNKContour::put_Hatch(BYTE newVal)
|
||
{
|
||
WT_Fill_Pattern patt = WT_Fill_Pattern((WT_Fill_Pattern::WT_Pattern_ID)newVal);
|
||
m_SLNKContour->m_Pattern.set(patt);
|
||
//contour->m_Pattern.pattern_scale() = 1.0;
|
||
|
||
return S_OK;
|
||
}
|