Files
Slnkdwf/SlnkDWFCom/SLNKContour.cpp
Jos Groot Lipman 7f586d9727 1e aanzet labelrotation. Alleen parameter overdracht, heeft nog geen effect
svn path=/Slnkdwf/trunk/; revision=18472
2013-07-15 19:21:45 +00:00

263 lines
6.0 KiB
C++

// SLNKContour.cpp : Implementation of CSLNKContour
#include "stdafx.h"
#include "SLNKContour.h"
#include "DWGPoint.h"
#include "Whipfile.h"
// CSLNKContour
void CSLNKContour::SetImpl(CSLNKContourImpl * pSLNKContour)
{
m_SLNKContour = pSLNKContour;
m_doneBounds = false;
}
void CSLNKContour::calculateBounds()
{
if (m_doneBounds)
return;
m_doneBounds = true;
WT_Logical_Box bx = m_SLNKContour->bounds(); // Als je hierna nog punten toevoegt heb je een probleem
WT_Point3D dwgPt;
CComQIPtr<IDWGPoint> pt;
dwgPt = m_SLNKContour->m_Units.transform(bx.minpt());
m_dwgBounding->get_min(&pt);
pt->put_DwgX(dwgPt.m_x);
pt->put_DwgY(dwgPt.m_y);
pt.Release();
dwgPt = m_SLNKContour->m_Units.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(*m_SLNKContour);
dwgPt = m_SLNKContour->m_Units.transform(lp);
m_dwgCenter->put_DwgX(dwgPt.m_x);
m_dwgCenter->put_DwgY(dwgPt.m_y);
};
STDMETHODIMP CSLNKContour::SetColor(ULONG rgb, BYTE Alpha /*=255*/)
{
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;
}
STDMETHODIMP CSLNKContour::SetoutlineColor(ULONG rgb, BYTE Alpha /*=255*/)
{
int b=rgb%256;
int g=(rgb>>8)%256;
int r=(rgb>>16)%256;
m_SLNKContour->m_outlineColor.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ël
CStringW s(fName);
m_SLNKContour->m_Url.set( WD_URL_Optimize, Url, s);
}
return S_OK;
}
STDMETHODIMP CSLNKContour::MoveTop()
{
m_SLNKContour->m_onTop = true;
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
calculateBounds();
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
calculateBounds();
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_ShowLabel);
return bstrString.CopyTo(pVal);
}
STDMETHODIMP CSLNKContour::put_Label(BSTR newVal)
{
CString key(newVal);
m_SLNKContour->m_ShowLabel = 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;
}
STDMETHODIMP CSLNKContour::get_Lineweight(DOUBLE* pVal)
{
(*pVal) = m_SLNKContour->m_Lineweight;
return S_OK;
}
STDMETHODIMP CSLNKContour::put_Lineweight(DOUBLE newVal)
{
m_SLNKContour->m_Lineweight = newVal;
return S_OK;
}
STDMETHODIMP CSLNKContour::get_Fontheight(DOUBLE* pVal)
{
(*pVal) = m_SLNKContour->m_Fontheight;
return S_OK;
}
STDMETHODIMP CSLNKContour::put_Fontheight(DOUBLE newVal)
{
m_SLNKContour->m_Fontheight = newVal;
return S_OK;
}
STDMETHODIMP CSLNKContour::get_Labelposition(BYTE* pVal)
{
(*pVal) = m_SLNKContour->m_Labelpos;
return S_OK;
}
STDMETHODIMP CSLNKContour::put_Labelposition(BYTE newVal)
{
switch (newVal)
{
case 1: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_DEFAULT; break;
case 2: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_CENTROID; break;
case 3: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_TOPLEFT; break;
case 4: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_OUTSIDERIGHT; break;
case 5: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_OUTSIDEBOTTOM; break;
default: m_SLNKContour->m_Labelpos = CSLNKContourImpl::LABEL_DEFAULT;
}
return S_OK;
}
STDMETHODIMP CSLNKContour::get_LabelRotation(DOUBLE* pVal)
{
(*pVal) = m_SLNKContour->m_LabelRotation;
return S_OK;
}
STDMETHODIMP CSLNKContour::put_LabelRotation(DOUBLE newVal)
{
m_SLNKContour->m_LabelRotation = newVal;
return S_OK;
}
STDMETHODIMP CSLNKContour::AddPoint(DOUBLE pValX, DOUBLE pValY)
{
m_SLNKContour->AddPoint(pValX, pValY);
return S_OK;
};
STDMETHODIMP CSLNKContour::get_PointCount(LONG* pVal)
{
(*pVal) = m_SLNKContour->count();
return S_OK;
};
STDMETHODIMP CSLNKContour::get_PointItem(ULONG i, IDWGPoint** pVal)
{
if (i < 0 || i >= (ULONG)m_SLNKContour->count())
return E_INVALIDARG;
// calculateBounds();
CComObject<CDWGPoint> *thePoint;
HRESULT hr = CComObject<CDWGPoint>::CreateInstance(&thePoint);
if(FAILED(hr)) return hr;
thePoint->AddRef();
hr = thePoint->QueryInterface(IID_IDWGPoint, (void **)pVal);
//thePoint->SetParent(this);
thePoint->Release();
if(FAILED(hr)) return hr;
// TODO: Dit moeten de units van het symbool zijn, niet die van de parentWhipfile
WT_Point3D dwg = m_SLNKContour->m_Units.transform(m_SLNKContour->points()[i]);
thePoint->put_DwgX(dwg.m_x);
thePoint->put_DwgY(dwg.m_y);
return S_OK;
};