UWVA#13921 Eiland herkenning en functie HighlightUnrecognized

svn path=/Slnkdwf/trunk/; revision=12488
This commit is contained in:
Jos Groot Lipman
2008-03-20 11:23:54 +00:00
parent 0b9083fc17
commit 2df57c7945
5 changed files with 67 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ interface IWhipFile : IDispatch{
[id(3), helpstring("method SaveAs")] HRESULT SaveAs([in] BSTR WhipPath);
[id(4), helpstring("method SetLabel")] HRESULT SetLabel([in] BSTR IdentLabel, [in] BSTR ExtraLabel);
[id(5), helpstring("method SetColor")] HRESULT SetColor([in] BSTR IdentLabel, [in] ULONG rgb, [in, defaultvalue(255)] BYTE Alpha);
[id(6), helpstring("method HighlightUnrecognized")] HRESULT HighlightUnrecognized();
[id(8), helpstring("method SetLabelFont")] HRESULT SetLabelFont([in] BSTR FontName, [in] DOUBLE FontHeight, [in, defaultvalue(0)] DOUBLE FontHeightSymbols);
[id(9), helpstring("method SetLabelPosition")] HRESULT SetLabelPosition([in, defaultvalue(1)] BYTE LabelPos);
[propget, id(10), helpstring("method ContoursXML")] HRESULT ContoursXML([out, retval] BSTR* pVal);

View File

@@ -1,6 +1,6 @@
// Zorg dat versies alfabetisch altijd op elkaar volgen!
#define SLNK_MAJOR_VERSION 2
#define SLNK_MINOR_VERSION 11
#define SLNK_MINOR_VERSION 12
#define SLNK_BUILD_VERSION 0
// Define resource strings

View File

@@ -178,11 +178,18 @@ STDMETHODIMP CWhip2PNG::SaveAsPNG(BSTR PNGPath)
myDoTRACE("\nCWhip2PNG::SaveAsPNG('%ls')", PNGPath);
CxImage img;
bool res = CreateCxImage(&img);
bool res;
try {
res = CreateCxImage(&img);
}
catch (CString& err)
{
return myAtlReportError (GetObjectCLSID(), "\nCWhip2PNG::SaveAsPNG('%ls')\n%s", (LPCSTR)PNGPath, err);
}
if (!res)
{
CString err; err.Format("Could not CreateCxImage: %s", img.GetLastError());
return myAtlReportError (GetObjectCLSID(), "\nCWhip2PNG::SaveAsPNG('%ls')\n%s", (LPCSTR)m_WhipPath, err);
return myAtlReportError (GetObjectCLSID(), "\nCWhip2PNG::SaveAsPNG('%ls')\n%s", (LPCSTR)PNGPath, err);
}
{

View File

@@ -346,11 +346,40 @@ xxxx++;
// Create a copy of the looping section
// Sample: i=6, j=2, diff=4 pt
CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i, myContour->points(), WD_True, m_State);
// Als alle volgende punten binnen myContour2 vallen hebben we met een (komend) eiland te maken.
// Dan hebben we spijt en gaan toch niet splitsen
bool allInside = true;
for (int i2=i+1; allInside && i2 < myContour->count(); i2++)
{
allInside = allInside && CSLNKContourImpl::PointInPolygon(myContour->points()[i2], *myContour2);
}
if(allInside)
{
delete myContour2; // toch maar niet
continue;
}
// Create a copy of the end section
CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, m_State);
// Omgekeerd: Als alle myContour2 punten binnen myContour3 vallen
// is het *eerste* stuk het eiland.
// Dan hebben we ook spijt en gaan toch niet splitsen
allInside = true;
for (int i2=0; allInside && i2 < myContour2->count(); i2++)
{
allInside = allInside && CSLNKContourImpl::PointInPolygon(myContour2->points()[i2], *myContour3);
}
if(allInside)
{
delete myContour2; // toch maar niet
delete myContour3;
continue;
}
myContour2->m_DWGArea = PolygonArea(myContour2, units);
m_State->m_SLNKContouren.Add(myContour2);
// Create a copy of the end section
CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, m_State);
// Delete the old one (seem all together a little overkill)
delete myContour;
myContour = myContour3;
@@ -891,6 +920,29 @@ STDMETHODIMP CWhipFile::SetColor(BSTR IdentLabel, ULONG rgb, BYTE Alpha /*=255*/
}
// Highlight unrecognized contouren
STDMETHODIMP CWhipFile::HighlightUnrecognized()
{
try {
for (size_t i=0; i<m_State.m_SLNKContouren.GetCount(); i++)
{
CSLNKContourImpl *contour= m_State.m_SLNKContouren[i];
if (contour->m_contLabel.length()==0)
{
contour->m_Color.set(255, 0, 0);
}
}
return S_OK;
}
catch (WT_Result::Enum e)
{
CString err;
err.Format("\nInternal error WT_Result::Enum %d",e);
return myAtlReportError (GetObjectCLSID(), "\nCWhipFile::HighlightUnrecognized()\n%s", err);
}
}
STDMETHODIMP CWhipFile::SetLabelFont(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols)
{
m_FontName.set(FontName);
@@ -924,7 +976,7 @@ STDMETHODIMP CWhipFile::get_ContoursXML(BSTR* pVal)
for (size_t i=0; i<m_State.m_SLNKContouren.GetCount(); i++)
{
CSLNKContourImpl *contour= m_State.m_SLNKContouren[i];
contour->serializeXML(XML, 0);
contour->serializeXML(XML, contour->m_parentWhipFileState->m_contunits);
}
XML.endElement();
XML.detach();

View File

@@ -147,6 +147,7 @@ public:
STDMETHOD(SaveAs2)(BSTR WhipPath);
STDMETHOD(SetLabel)(BSTR IdentLabel, BSTR ExtraLabel);
STDMETHOD(SetColor)(BSTR IdentLabel, ULONG rgb, BYTE Alpha);
STDMETHOD(HighlightUnrecognized)();
STDMETHOD(SetLabelFont)(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols);
STDMETHOD(SetLabelPosition)(BYTE LabelPos);
STDMETHOD(get_ContoursXML)(BSTR* pVal);