From 185babff53bdea40038e5fbb0628feea023bc5f2 Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Wed, 11 Jan 2012 19:23:50 +0000 Subject: [PATCH] Versie 2.80 svn path=/Slnkdwf/trunk/; revision=12530 --- SlnkDWFCom/Options.cpp | 9 +- SlnkDWFCom/Options.h | 1 - SlnkDWFCom/SLNKContour.cpp | 40 ++++- SlnkDWFCom/SLNKContour.h | 4 + SlnkDWFCom/SLNKDWF.idl | 23 ++- SlnkDWFCom/SLNKDWFVersion.h | 2 +- SlnkDWFCom/SLNKSymbolDefImpl.cpp | 1 + SlnkDWFCom/SLNKSymbolImpl.h | 2 +- SlnkDWFCom/SLNKdwf.rc | 2 +- SlnkDWFCom/Whip2PNG.cpp | 44 ++++- SlnkDWFCom/Whip2PNG.h | 3 + SlnkDWFCom/WhipFile.cpp | 298 +++++++++++++++++++------------ SlnkDWFCom/WhipFile.h | 216 +++++++++------------- SlnkDWFImpl/SLNKContourImpl.cpp | 37 ++-- SlnkDWFImpl/SLNKContourImpl.h | 21 ++- SlnkDWFImpl/Whip2DCImpl.cpp | 171 ++++++++++-------- SlnkDWFImpl/Whip2DCState.cpp | 3 +- Standalone/SLNKDWFViewer.vcproj | 109 ++++++++++- Viewer/FindDlg.cpp | 4 +- Viewer/MainFrm.cpp | 64 ++++++- Viewer/SLNKDWFViewerView.cpp | 47 +++-- Viewer/SLNKDwfViewerView.h | 9 +- Viewer/Viewer.vcproj | 100 ++++++++++- Viewer/ViewerLib.h | 2 +- Viewer/mainfrm.h | 9 +- Viewer/stdafx.h | 7 +- WincmdContent/filesys.vcproj | 4 +- WincmdPacker/WincmdPacker.vcproj | 4 +- WincmdViewer/WINCDMDWF.vcproj | 8 +- 29 files changed, 835 insertions(+), 409 deletions(-) diff --git a/SlnkDWFCom/Options.cpp b/SlnkDWFCom/Options.cpp index 088866e..5a34908 100644 --- a/SlnkDWFCom/Options.cpp +++ b/SlnkDWFCom/Options.cpp @@ -10,7 +10,6 @@ CSLNKOptions::CSLNKOptions() { m_MinContSize = 0.20e6; // Minimale grootte voor een contour om herkend te worden m_SkipContLeader = FALSE; // ARKEY tekeningen hebben een leading lijntje voor de contour - m_SymbolOutlineAlpha = 0; // Zet op 255 om een bounding contour lijntje van symbolen te zien } // COptions @@ -35,7 +34,7 @@ STDMETHODIMP COptions::SetOption(BSTR optionName, VARIANT OptionValue) CString nm(optionName); nm.MakeUpper(); - if (nm=="MINCONTSIZE") + if (nm=="MINCONTSIZE") // deprecated sinds 2.80 { HRESULT hr = val.ChangeType(VT_R8); if (FAILED(hr)) return hr; @@ -47,11 +46,5 @@ STDMETHODIMP COptions::SetOption(BSTR optionName, VARIANT OptionValue) if (FAILED(hr)) return hr; g_SLNKOptions.m_SkipContLeader = val.boolVal; } - else if (nm=="SYMBOLOUTLINEALPHA") - { - HRESULT hr = val.ChangeType(VT_INT); - if (FAILED(hr)) return hr; - g_SLNKOptions.m_SymbolOutlineAlpha = val.intVal; - } return S_OK; } diff --git a/SlnkDWFCom/Options.h b/SlnkDWFCom/Options.h index 9955586..209d36b 100644 --- a/SlnkDWFCom/Options.h +++ b/SlnkDWFCom/Options.h @@ -18,7 +18,6 @@ public: double m_MinContSize; // In DWG Units BOOL m_SkipContLeader; // voor ARKEY - int m_SymbolOutlineAlpha; // voor bounding contour symbolen }; extern CSLNKOptions g_SLNKOptions; // The one and only diff --git a/SlnkDWFCom/SLNKContour.cpp b/SlnkDWFCom/SLNKContour.cpp index 58e9e86..5a6ddfb 100644 --- a/SlnkDWFCom/SLNKContour.cpp +++ b/SlnkDWFCom/SLNKContour.cpp @@ -21,20 +21,20 @@ void CSLNKContour::SetImpl(CSLNKContourImpl * pSLNKContour) WT_Point3D dwgPt; CComQIPtr pt; - dwgPt = pSLNKContour->m_parentWhipFileState->m_contunits.transform(bx.minpt()); + dwgPt = pSLNKContour->m_parentWhipFile->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()); + dwgPt = pSLNKContour->m_parentWhipFile->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); + dwgPt = pSLNKContour->m_parentWhipFile->m_contunits.transform(lp); m_dwgCenter->put_DwgX(dwgPt.m_x); m_dwgCenter->put_DwgY(dwgPt.m_y); }; @@ -49,6 +49,16 @@ STDMETHODIMP CSLNKContour::SetColor(ULONG rgb, BYTE Alpha /*=255*/) 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) { @@ -70,6 +80,11 @@ STDMETHODIMP CSLNKContour::SetUrl(BSTR Url, BSTR FriendlyName) return S_OK; } +STDMETHODIMP CSLNKContour::MoveTop() +{ + m_SLNKContour->m_onTop = true; + return S_OK; +} STDMETHODIMP CSLNKContour::get_Area(DOUBLE* pVal) { @@ -110,14 +125,14 @@ STDMETHODIMP CSLNKContour::put_Key(BSTR newVal) STDMETHODIMP CSLNKContour::get_Label(BSTR* pVal) { - CComBSTR bstrString(m_SLNKContour->m_ExtraLabel); + CComBSTR bstrString(m_SLNKContour->m_ShowLabel); return bstrString.CopyTo(pVal); } STDMETHODIMP CSLNKContour::put_Label(BSTR newVal) { CString key(newVal); - m_SLNKContour->m_ExtraLabel = newVal; + m_SLNKContour->m_ShowLabel = newVal; return S_OK; } @@ -136,3 +151,18 @@ STDMETHODIMP CSLNKContour::put_Hatch(BYTE newVal) 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; +} + diff --git a/SlnkDWFCom/SLNKContour.h b/SlnkDWFCom/SLNKContour.h index c68e730..7477a80 100644 --- a/SlnkDWFCom/SLNKContour.h +++ b/SlnkDWFCom/SLNKContour.h @@ -89,7 +89,9 @@ private: public: STDMETHOD(SetColor)(ULONG rgb, BYTE Alpha); + STDMETHOD(SetoutlineColor)(ULONG rgb, BYTE Alpha); STDMETHOD(SetUrl) (BSTR Url, BSTR FriendlyName); + STDMETHOD(MoveTop) (); STDMETHOD(get_Area)(DOUBLE* pVal); STDMETHOD(get_Extents)(IBoundingBox** pVal); STDMETHOD(get_Center)(IDWGPoint** pVal); @@ -99,6 +101,8 @@ public: STDMETHOD(put_Label)(BSTR newVal); STDMETHOD(get_Hatch)(BYTE* pVal); STDMETHOD(put_Hatch)(BYTE newVal); + STDMETHOD(get_Lineweight)(DOUBLE* pVal); + STDMETHOD(put_Lineweight)(DOUBLE newVal); }; //REMOVED OBJECT_ENTRY_AUTO(__uuidof(SLNKContour), CSLNKContour) diff --git a/SlnkDWFCom/SLNKDWF.idl b/SlnkDWFCom/SLNKDWF.idl index 0f2f66a..1fac2aa 100644 --- a/SlnkDWFCom/SLNKDWF.idl +++ b/SlnkDWFCom/SLNKDWF.idl @@ -47,12 +47,12 @@ interface IWhipFile : IDispatch{ [id(1), helpstring("method Load")] HRESULT Load([in] BSTR WhipPath); [id(2), helpstring("method LoadStream")] HRESULT LoadStream([in] VARIANT EPlotStream); [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(4), helpstring("Deprecated method SetLabel")] HRESULT SetLabel([in] BSTR IdentLabel, [in] BSTR ShowLabel); + [id(5), helpstring("Deprecated 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); + [propget, id(10), helpstring("Deprecated method ContoursXML")] HRESULT ContoursXML([out, retval] BSTR* pVal); [id(12), helpstring("method SetLayers")] HRESULT SetLayers([in] BSTR reContouren, [in] BSTR reLabels); [propget, id(14), helpstring("property AddSymbol")] HRESULT AddSymbol([in] DOUBLE dwgX, [in] DOUBLE dwgY, BSTR symbolName, [out, retval] ISLNKSymbol** pVal); [id(15), helpstring("method DefineSymbol")] HRESULT DefineSymbol([in] BSTR symbolName, [in] VARIANT EPlotStream); @@ -65,6 +65,8 @@ interface IWhipFile : IDispatch{ [propput, id(21), helpstring("property forFind")] HRESULT forFind([in] VARIANT_BOOL newVal); [propget, id(22), helpstring("property ContourCount")] HRESULT ContourCount([out, retval] LONG* pVal); [propget, id(23), helpstring("property ContourItem")] HRESULT ContourItem([in] ULONG i, [out, retval] ISLNKContour** pVal); + [propget, id(24), helpstring("property minContSize")] HRESULT minContSize([out, retval] DOUBLE* pVal); + [propput, id(24), helpstring("property minContSize")] HRESULT minContSize([in] DOUBLE newVal); }; [ object, @@ -103,6 +105,7 @@ interface IWhip2PNG : IDispatch{ [propput, id(21), helpstring("property forceGray")] HRESULT forceGray([in] VARIANT_BOOL newVal); [propget, id(22), helpstring("property LayerCount")] HRESULT LayerCount([out, retval] LONG* pVal); [propget, id(23), helpstring("property LayerItem")] HRESULT LayerItem([in] ULONG i, [out, retval] BSTR* pVal); + [id(24), helpstring("method SetAntialias")] HRESULT SetAntialias([in] LONG lFactor, [in, defaultvalue(0)] LONG lMethod); }; [ object, @@ -178,8 +181,8 @@ interface ISLNKEvent : IDispatch{ [propput, id(1), helpstring("property DwgX")] HRESULT DwgX([in] DOUBLE newVal); [propget, id(2), helpstring("property DwgY")] HRESULT DwgY([out, retval] DOUBLE* pVal); [propput, id(2), helpstring("property DwgY")] HRESULT DwgY([in] DOUBLE newVal); - [propget, id(7), helpstring("property ContourLabel")] HRESULT ContourLabel([out, retval] BSTR* pVal); - [propput, id(7), helpstring("property ContourLabel")] HRESULT ContourLabel([in] BSTR newVal); + [propget, id(7), helpstring("property ContourLabel")] HRESULT ContourLabel([out, retval] BSTR* pVal); // DEPRECATED + [propput, id(7), helpstring("property ContourLabel")] HRESULT ContourLabel([in] BSTR newVal); // DEPRECATED [propget, id(8), helpstring("property ContourLayer")] HRESULT ContourLayer([out, retval] BSTR* pVal); [propput, id(8), helpstring("property ContourLayer")] HRESULT ContourLayer([in] BSTR newVal); [propget, id(9), helpstring("property TextLabel")] HRESULT TextLabel([out, retval] BSTR* pVal); @@ -193,7 +196,9 @@ interface ISLNKEvent : IDispatch{ [propput, id(14), helpstring("property EdgeAngle")] HRESULT EdgeAngle([in] DOUBLE newVal); [propget, id(15), helpstring("property EdgeDistance")] HRESULT EdgeDistance([out, retval] DOUBLE* pVal); [propput, id(15), helpstring("property EdgeDistance")] HRESULT EdgeDistance([in] DOUBLE newVal); -}; + [propget, id(16), helpstring("property ContourKey")] HRESULT ContourKey([out, retval] BSTR* pVal); + [propput, id(16), helpstring("property ContourKey")] HRESULT ContourKey([in] BSTR newVal); + }; [ object, uuid(102FE53F-3C9A-47C6-9BAD-1434838FF53D), @@ -229,8 +234,10 @@ interface IDWGPoint : IDispatch{ pointer_default(unique) ] interface ISLNKContour : IDispatch{ - [id(2), helpstring("method SetColor")] HRESULT SetColor([in] ULONG rgb, [in, defaultvalue(255)] BYTE Alpha); + [id(1), helpstring("method SetColor")] HRESULT SetColor([in] ULONG rgb, [in, defaultvalue(255)] BYTE Alpha); + [id(2), helpstring("method SetoutlineColor")] HRESULT SetoutlineColor([in] ULONG rgb, [in, defaultvalue(255)] BYTE Alpha); [id(3), helpstring("method SetUrl")] HRESULT SetUrl([in] BSTR Url, [in] BSTR FriendlyName); + [id(4), helpstring("method MoveTop")] HRESULT MoveTop(); [propget, id(5), helpstring("property Area")] HRESULT Area([out, retval] DOUBLE* pVal); [propget, id(6), helpstring("property Extents")] HRESULT Extents([out, retval] IBoundingBox ** pVal); [propget, id(7), helpstring("property Center")] HRESULT Center([out, retval] IDWGPoint** pVal); @@ -240,6 +247,8 @@ interface ISLNKContour : IDispatch{ [propput, id(9), helpstring("property Label")] HRESULT Label([in] BSTR newVal); [propget, id(10), helpstring("property Hatch")] HRESULT Hatch([out, retval] BYTE* pVal); [propput, id(10), helpstring("property Hatch")] HRESULT Hatch([in] BYTE newVal); + [propget, id(11), helpstring("property Lineweight")] HRESULT Lineweight([out, retval] DOUBLE* pVal); + [propput, id(11), helpstring("property Lineweight")] HRESULT Lineweight([in] DOUBLE newVal); }; [ object, diff --git a/SlnkDWFCom/SLNKDWFVersion.h b/SlnkDWFCom/SLNKDWFVersion.h index 496bfa0..e7686be 100644 --- a/SlnkDWFCom/SLNKDWFVersion.h +++ b/SlnkDWFCom/SLNKDWFVersion.h @@ -1,6 +1,6 @@ // Zorg dat versies alfabetisch altijd op elkaar volgen! #define SLNK_MAJOR_VERSION 2 -#define SLNK_MINOR_VERSION 70 +#define SLNK_MINOR_VERSION 80 #define SLNK_BUILD_VERSION 0 // Define resource strings diff --git a/SlnkDWFCom/SLNKSymbolDefImpl.cpp b/SlnkDWFCom/SLNKSymbolDefImpl.cpp index 0857216..4d074ec 100644 --- a/SlnkDWFCom/SLNKSymbolDefImpl.cpp +++ b/SlnkDWFCom/SLNKSymbolDefImpl.cpp @@ -383,6 +383,7 @@ WT_Result CSLNKSymbolDefinition::serialize(WT_File & file, WT_Color pColor, BOOL WT_Color().serialize(file); // Op de default zetten. //TODO: Moet eigenlijk voor alle attributen + file.desired_rendition().line_weight() = WT_Line_Weight(0); WT_Line_Weight().serialize(file); WT_Result result; diff --git a/SlnkDWFCom/SLNKSymbolImpl.h b/SlnkDWFCom/SLNKSymbolImpl.h index 6aaa81b..7ce8652 100644 --- a/SlnkDWFCom/SLNKSymbolImpl.h +++ b/SlnkDWFCom/SLNKSymbolImpl.h @@ -8,7 +8,7 @@ class CSLNKSymbolImpl public: CSLNKSymbolImpl(void); - CSLNKSymbolImpl(double dwgX, double dwgY, CWhipFileState *State); + CSLNKSymbolImpl(double dwgX, double dwgY, CWhipFile *whipfile); WT_Result serialize (WT_File & file, WT_Units & units, CSLNKSymbolDefinition *symbdef, diff --git a/SlnkDWFCom/SLNKdwf.rc b/SlnkDWFCom/SLNKdwf.rc index 18582df..31d79dd 100644 --- a/SlnkDWFCom/SLNKdwf.rc +++ b/SlnkDWFCom/SLNKdwf.rc @@ -75,7 +75,7 @@ BEGIN VALUE "FileDescription", "Superlink DWF " VALUE "FileVersion", SLNK_BUILDVERSION "\0" VALUE "InternalName", "SLNKDWF.dll" - VALUE "LegalCopyright", "(c) SG|facilitor 2005-2011. All rights reserved." + VALUE "LegalCopyright", "(c) SG|facilitor 2005-2012. All rights reserved." VALUE "OriginalFilename", "SLNKDWF.dll" VALUE "ProductName", "Superlink" VALUE "ProductVersion", SLNK_BUILDVERSION "\0" diff --git a/SlnkDWFCom/Whip2PNG.cpp b/SlnkDWFCom/Whip2PNG.cpp index 6b2ac97..98cce6b 100644 --- a/SlnkDWFCom/Whip2PNG.cpp +++ b/SlnkDWFCom/Whip2PNG.cpp @@ -17,6 +17,11 @@ CWhip2PNG::CWhip2PNG() m_offsetY = 0; m_dScale = 1.0; m_lRotation = 0; + m_AAFactor = 1; + m_AAMethod = 0; // ximatran.cpp resample function + // 0 for slow (bilinear) method + // 1 for fast (nearest pixel) method, or + // 2 for accurate (bicubic spline interpolation) method. m_RegExp = ".*"; m_forcePaper = FALSE; m_forceBW = FALSE; @@ -106,6 +111,10 @@ bool CWhip2PNG::CreateCxImage(CxImage *img) HDC pDC = ::GetDC(0); HDC myDC = CreateCompatibleDC(pDC); //ReleaseDC(pDC); + m_sizeX *= m_AAFactor; + m_sizeY *= m_AAFactor; + m_offsetX *= m_AAFactor; + m_offsetY *= m_AAFactor; InitDC(myDC); // Stelt ook definitieve m_SizeX en m_SizeY vast #if 1 @@ -169,6 +178,15 @@ bool CWhip2PNG::CreateCxImage(CxImage *img) DeleteDC(myDC); ReleaseDC( NULL, pDC ); //Do not forget! + if (m_AAFactor != 1) + { + m_sizeX /= m_AAFactor; + m_sizeY /= m_AAFactor; + m_offsetX /= m_AAFactor; + m_offsetY /= m_AAFactor; + img->Resample(m_sizeX, m_sizeY, m_AAMethod); + } + return res; } @@ -290,7 +308,7 @@ void CWhip2PNG::putDWGInfo() // Zoek een punt dat de gebruiker in de tekening geklikt heeft. // Er wordt alleen een simpele tekst opgeleverd (hetzij aangeklikte truetype tekst -// of een Contour label). Meer details zijn via get_SLNKEvent te verkrijgen +// of een Contour key(!)). Meer details zijn via get_SLNKEvent te verkrijgen STDMETHODIMP CWhip2PNG::Find(LONG findX, LONG findY, BSTR* foundLabel) { CmyTimer timer("CWhip2PNG::Find"); @@ -301,24 +319,24 @@ STDMETHODIMP CWhip2PNG::Find(LONG findX, LONG findY, BSTR* foundLabel) // Er hoeft geen bitmap naar myDC omdat we toch niet painten InitDC(myDC); - CString ContourLabel, ContourLayer, TextLabel, TextLayer; + CString ContourKey, ContourLayer, TextLabel, TextLayer; double EdgeAngle, EdgeDistance; HRESULT res = m_iWhip2DC.Find(findX, findY, FALSE, - ContourLabel, ContourLayer, TextLabel, TextLayer, + ContourKey, ContourLayer, TextLabel, TextLayer, EdgeAngle, EdgeDistance); if (TextLabel != "") (*foundLabel) = TextLabel.AllocSysString(); - else if (ContourLabel != "") - (*foundLabel) = ContourLabel.AllocSysString(); + else if (ContourKey != "") + (*foundLabel) = ContourKey.AllocSysString(); double resX, resY; res = m_iWhip2DC.DPtoDWG(findX, findY, &resX, &resY); m_SLNKEvent->put_DwgX(resX); m_SLNKEvent->put_DwgY(resY); - m_SLNKEvent->put_ContourLabel(CComBSTR(ContourLabel)); + m_SLNKEvent->put_ContourKey(CComBSTR(ContourKey)); m_SLNKEvent->put_ContourLayer(CComBSTR(ContourLayer)); m_SLNKEvent->put_TextLabel(CComBSTR(TextLabel)); m_SLNKEvent->put_TextLayer(CComBSTR(TextLayer)); @@ -333,6 +351,20 @@ STDMETHODIMP CWhip2PNG::Find(LONG findX, LONG findY, BSTR* foundLabel) return S_OK; } +STDMETHODIMP CWhip2PNG::SetAntialias(LONG lFactor, LONG lMethod) +{ + if (lFactor < 1 || + lFactor > 16 || + lMethod < 0 || + lMethod > 2) + return myAtlReportError (GetObjectCLSID(), "\nCWhip2PNG::SetAntialias invalid parameters"); + + m_AAFactor = lFactor; + m_AAMethod = lMethod; + + return S_OK; +}; + STDMETHODIMP CWhip2PNG::SetDimensions(LONG sizeX, LONG sizeY, // PNG image size LONG offsetX, LONG offsetY, // Panning DOUBLE dScale, // Zooming, 1.0 default diff --git a/SlnkDWFCom/Whip2PNG.h b/SlnkDWFCom/Whip2PNG.h index 02ac0ad..5b7de12 100644 --- a/SlnkDWFCom/Whip2PNG.h +++ b/SlnkDWFCom/Whip2PNG.h @@ -94,6 +94,7 @@ private: LONG m_sizeX, m_sizeY; LONG m_offsetX, m_offsetY; + LONG m_AAFactor, m_AAMethod; double m_dScale; LONG m_lRotation; COLORREF m_paperColor; BOOL m_forcePaper; @@ -118,6 +119,8 @@ public: STDMETHOD(put_forceGray)(VARIANT_BOOL newVal); STDMETHOD(get_LayerCount)(LONG* pVal); STDMETHOD(get_LayerItem)(ULONG i, BSTR* pVal); + STDMETHOD(SetAntialias)(LONG lFactor, LONG lMethod); + }; OBJECT_ENTRY_AUTO(__uuidof(Whip2PNG), CWhip2PNG) diff --git a/SlnkDWFCom/WhipFile.cpp b/SlnkDWFCom/WhipFile.cpp index 077595c..1ad0ad6 100644 --- a/SlnkDWFCom/WhipFile.cpp +++ b/SlnkDWFCom/WhipFile.cpp @@ -63,12 +63,20 @@ CWhipFile::CWhipFile() m_FontHeight = 400.0; m_FontHeightSymbols = 200.0; + m_reContouren.Parse(".*", FALSE); + m_reLabels.Parse(".*", FALSE); + m_reLayers.Parse(".*", FALSE); + m_hintScale = -1.0; + m_minContSize = g_SLNKOptions.m_MinContSize; // deprecated via globale setting. Later 0.20e6 + m_forFind = TRUE; // backward compatible + m_activeLayerName = ""; + // Predefine fixed symbols CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(sizeof(star)/sizeof(star[0]), star); - m_State.m_SLNKSymbolDefinitions.SetAt("*STAR", symb); + m_SLNKSymbolDefinitions.SetAt("*STAR", symb); symb = new CSLNKSymbolDefinition(sizeof(octa)/sizeof(octa[0]), octa); - m_State.m_SLNKSymbolDefinitions.SetAt("*OCTAGON", symb); + m_SLNKSymbolDefinitions.SetAt("*OCTAGON", symb); } int xxxx; @@ -137,19 +145,20 @@ HRESULT CWhipFile::ProcessContouren() { m_W2DFile.set_file_mode(WT_File::File_Read); - // Alle callback functies zijn static. Die kunnen de variabele - // m_State niet benaderen. Daarom maar via set_user_data - m_W2DFile.heuristics().set_user_data((void *)&m_State); + // Alle callback functies zijn static. Die kunnen de member-variabelen + // niet benaderen. Daarom maar via set_user_data onzelf doorgeven + // (voor 2.80 deden we dat complexer via een m_State) + m_W2DFile.heuristics().set_user_data((void *)this); if (m_W2DFile.open() == WT_Result::Success) { xxxx=0; CmyTimer xx("Contouren opzoeken"); - m_State.contLayerActive = true; - m_State.labelLayerActive = true; // Kan bij de eerste laag anders blijken te zijn + m_contLayerActive = true; + m_labelLayerActive = true; // Kan bij de eerste laag anders blijken te zijn read_for_contours(); // Zoek eerst alle contouren en labels processLabels(); // En verwerk ze daarna - myDoTRACE("\nFound %d polylines, %d contours and %d labels.", xxxx, m_State.m_SLNKContouren.GetCount(), m_State.m_SLNKLabels.GetCount()); + myDoTRACE("\nFound %d polylines, %d contours and %d labels.", xxxx, m_SLNKContouren.GetCount(), m_SLNKLabels.GetCount()); m_W2DFile.close(); // closing Input file. } @@ -164,8 +173,14 @@ STDMETHODIMP CWhipFile::SetLayers(BSTR reContouren, BSTR reLabels) { myTRACE("\nParsing met contouren %ls", reContouren); myTRACE("\nParsing met labels %ls", (LPCTSTR)reLabels); - if (!m_State.SetLayers(reContouren, reLabels)) - return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to parse Whipfile regLayers"); + + REParseError status = m_reContouren.Parse( CString(reContouren), false ); + if (REPARSE_ERROR_OK != status) + return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to parse Whipfile contour regLayers"); + + status = m_reLabels.Parse( CString(reLabels), false ); + if (REPARSE_ERROR_OK != status) + return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to parse Whipfile label regLayers"); return S_OK; } @@ -174,8 +189,10 @@ STDMETHODIMP CWhipFile::SetLayers(BSTR reContouren, BSTR reLabels) STDMETHODIMP CWhipFile::SetFilterLayers(BSTR reLayers) { myTRACE("\nFilter met lagen %ls", reLayers); - if (!m_State.SetFilterLayers(reLayers)) - return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to parse Whipfile SetFilterLayers"); + + REParseError status = m_reLayers.Parse( CString(reLayers), false ); + if (REPARSE_ERROR_OK != status) + return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to parse Whipfile SetFilterLayers"); return S_OK; } @@ -198,7 +215,10 @@ void CWhipFile::read_for_contours() } while (result == WT_Result::Success); // Nu zijn ze wel een keer bekend, we hebben ze later weer nodig - m_State.m_contunits=m_W2DFile.rendition().drawing_info().units(); + // m_contunits=m_W2DFile.rendition().drawing_info().units();werkt niet goed met paperspace + // Deze doet het in de praktijk altijd wel? + m_contunits=m_W2DFile.rendition().viewport().viewport_units(); + m_view=m_W2DFile.rendition().rendering_options().view(); // We gaan er later nog een keer door voor de plattegrond. Geen processing dan @@ -229,16 +249,16 @@ double PolygonArea(WT_Point_Set * ps, WT_Units units) // Iterate all labels and determine in which contour they fall void CWhipFile::processLabels() { - for (size_t lbl=0; lblm_DWGArea/1e6); @@ -251,6 +271,8 @@ void CWhipFile::processLabels() { myTRACE(" en we hebben een kleinere. Reset prevContour"); prevContour->m_contLabel = ""; + prevContour->m_ShowLabel = ""; + prevContour->m_Key = ""; prevContour = contour; } else // Nieuwe contour is niet beter @@ -265,6 +287,7 @@ void CWhipFile::processLabels() // problemen als we via XML communiceren prevContour->m_Key.Trim(); prevContour->m_contLabel = prevContour->m_Key; + prevContour->m_ShowLabel = prevContour->m_Key; #ifdef SHAKE_FOR_TEST if (1||prevContour->m_Label.equals("x706")) { @@ -302,13 +325,13 @@ WT_Result CWhipFile::my_process_layer (WT_Layer & layer, WT_File & file) file.rendition().layer() = layer; WT_Layer *ll; - CWhipFileState *m_State = (CWhipFileState *)file.heuristics().user_data(); + CWhipFile *deze = (CWhipFile *)file.heuristics().user_data(); CString layer_name(layer.layer_name().ascii()); if (layer_name != "") // Anders zittie alleen maar in de weg { // Dat doet de default_process 'fout' // Overbodige lagen negeren we: - if (layer_name == m_State->m_activeLayerName) + if (layer_name == deze->m_activeLayerName) return WT_Result::Success; file.layer_list().add_layer(layer); @@ -318,13 +341,14 @@ WT_Result CWhipFile::my_process_layer (WT_Layer & layer, WT_File & file) { WT_Integer32 layer_num = layer.layer_num(); ll = file.layer_list().find_layer_from_index(layer_num); + layer_name = ll->layer_name().ascii(); } if (ll) { - m_State->m_activeLayerName = ll->layer_name().ascii(); - m_State->labelLayerActive = m_State->labelMatch(m_State->m_activeLayerName); - m_State->contLayerActive = m_State->contMatch(m_State->m_activeLayerName); + deze->m_activeLayerName = layer_name; + deze->m_labelLayerActive = deze->labelMatch(layer_name); + deze->m_contLayerActive = deze->contMatch(layer_name); } return WT_Result::Success; @@ -334,8 +358,8 @@ WT_Result CWhipFile::my_process_layer (WT_Layer & layer, WT_File & file) // but also for the rendition of the character '0' WT_Result CWhipFile::my_process_polyline(WT_Polyline & polyline, WT_File & file) { - CWhipFileState *m_State = (CWhipFileState *)file.heuristics().user_data(); - if (!m_State->contLayerActive) + CWhipFile *deze = (CWhipFile *)file.heuristics().user_data(); + if (!deze->m_contLayerActive) return WT_Result::Success; // Wrong layer bool frstIsLast = (polyline.points()[0].m_x == polyline.points()[polyline.count()-1].m_x && @@ -361,14 +385,15 @@ WT_Result CWhipFile::my_process_polyline(WT_Polyline & polyline, WT_File & file) xxxx++; - WT_Units units=file.rendition().drawing_info().units(); + //WT_Units units=file.rendition().drawing_info().units(); werkt niet goed met paperspace + WT_Units units=file.rendition().viewport().viewport_units(); // WD_True as we are going to mess CSLNKContourImpl *myContour; if (scndIsLast) // eerste lijntje droppen - myContour = new CSLNKContourImpl(polyline.count()-1,polyline.points()+1, WD_True, m_State); + myContour = new CSLNKContourImpl(polyline.count()-1,polyline.points()+1, WD_True, deze); else - myContour = new CSLNKContourImpl(polyline.count(),polyline.points(), WD_True, m_State); + myContour = new CSLNKContourImpl(polyline.count(),polyline.points(), WD_True, deze); // A major problem: Sometimes AutoCAD's DWFOUT merges two adjacent polylines // into one WT_Polyline. We hate that so we start splitting them again here @@ -390,7 +415,7 @@ xxxx++; dwgPt.m_x, dwgPt.m_y); // 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); + CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i, myContour->points(), WD_True, deze); // Als alle volgende punten binnen myContour2 vallen hebben we met een (komend) eiland te maken. // Dan hebben we spijt en gaan toch niet splitsen @@ -405,7 +430,7 @@ xxxx++; continue; } // Create a copy of the end section - CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, m_State); + CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, deze); // Omgekeerd: Als alle myContour2 punten binnen myContour3 vallen // is het *eerste* stuk het eiland. @@ -423,7 +448,7 @@ xxxx++; } myContour2->m_DWGArea = PolygonArea(myContour2, units); - m_State->m_SLNKContouren.Add(myContour2); + deze->m_SLNKContouren.Add(myContour2); // Delete the old one (seem all together a little overkill) delete myContour; @@ -455,16 +480,16 @@ xxxx++; // myTRACE("\nSplit case %d-%d",i,myContour->count()); // Create a copy of the looping section // Sample: i=6, j=2, diff=4 pt - CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i-j+1, myContour->points()+j, WD_True, m_State); + CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i-j+1, myContour->points()+j, WD_True, deze); myContour2->m_DWGArea = PolygonArea(myContour2, units); - m_State->m_SLNKContouren.Add(myContour2); + deze->m_SLNKContouren.Add(myContour2); // Close the hole in myContour for (int k=j+1; k+i-jcount(); k++) myContour->points()[k]=myContour->points()[k+i-j]; // Create a copy of the start section - CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-(i-j), myContour->points(), WD_True, m_State); + CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-(i-j), myContour->points(), WD_True, deze); // Delete the old one (seem all together a little overkill) delete myContour; myContour = myContour3; @@ -477,11 +502,12 @@ xxxx++; myContour->m_DWGArea = PolygonArea(myContour, units); WT_Point3D dwgPt = units.transform(myContour->points()[0]); - myTRACE("\nFound contour with area %8.2fm2 starting DWF(%d,%d) DWG(%.3f,%.3f)", - myContour->m_DWGArea/1e6, myContour->points()[0].m_x, myContour->points()[0].m_y, + myTRACE("\nFound contour with area %8.0f (%8.2fm2) starting DWF(%d,%d) DWG(%.3f,%.3f)", + myContour->m_DWGArea, myContour->m_DWGArea/1e6, + myContour->points()[0].m_x, myContour->points()[0].m_y, dwgPt.m_x, dwgPt.m_y); - if (myContour->m_DWGArea >= g_SLNKOptions.m_MinContSize) - m_State->m_SLNKContouren.Add(myContour);// Doet uiteindelijk wel een delete op myContour + if (myContour->m_DWGArea >= deze->m_minContSize) + deze->m_SLNKContouren.Add(myContour);// Doet uiteindelijk wel een delete op myContour else { myTRACE(" te klein bevonden"); @@ -495,12 +521,12 @@ xxxx++; // which will get used here WT_Result CWhipFile::my_process_text (WT_Text & text, WT_File & file) { - CWhipFileState *m_State = (CWhipFileState *)file.heuristics().user_data(); - if (!m_State->labelLayerActive) + CWhipFile *deze = (CWhipFile *)file.heuristics().user_data(); + if (!deze->m_labelLayerActive) return WT_Result::Success; // Wrong layer if (text.string().is_ascii() && strlen(text.string().ascii()) > 0) - m_State->m_SLNKLabels.Add(text); + deze->m_SLNKLabels.Add(text); return WT_Result::Success; } @@ -521,6 +547,8 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do my_plan_file.object_node_list().remove_all(); my_plan_file.dash_pattern_list().remove_all(); + // TODO Is dit 2.70 nog wel nodig? We doen verderop ook een en ander + // Zet wel m_activeLayerName dus nog laten zo my_plan_file.set_layer_action(my_process_layer); // Override default processing // Do the actual reading. CString last_layer; @@ -550,13 +578,14 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do { // TODO: Als !CurrentLayerOn dan zouden we ook nog fors kunnen schrappen in de WT_Attributes // die vaak niet meer van toepassing zijn. Dan moeten we echter met desireded rendition gaan werken // en dat is me nog even te veel werk. + // 2.80: WT_Color en WT_Font alvast wel via desired, scheelt best in de DWF-grootte const WT_Attribute *obj = (WT_Attribute *)my_plan_file.current_object(); switch(obj->object_id()) { case WT_Object::URL_ID: // Strippen omdat ze in de weg kunnen zitten met onze eigen URL's case WT_Object::Object_Node_ID: // kunnen we ook niets mee. Had RWSN#20095 in 1101EM0108_01.dwf break; - case WT_Object::Layer_ID: + case WT_Object::Layer_ID: { // Sla de oorspronkelijke contour lagen over // En ook de lagen die we niet willen CurrentLayerOn = TRUE; @@ -573,21 +602,31 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do } // Noot: gooi de originele contour-lagen er altijd uit - if ((m_State.labelMatch(m_State.m_activeLayerName) || - m_State.contMatch(m_State.m_activeLayerName) || - !m_State.layerMatch(m_State.m_activeLayerName)) + if ((labelMatch(m_activeLayerName) || + contMatch(m_activeLayerName) || + !layerMatch(m_activeLayerName)) ) CurrentLayerOn = FALSE; // Layer object hoeft ook niet meer geserialized else { - if (m_State.m_activeLayerName != last_layer) // cleaning, scheelt fors bij RIJSWIJKHB-02.dwf + if (m_activeLayerName != last_layer) // cleaning, scheelt fors bij RIJSWIJKHB-02.dwf { layer->serialize(my_file); - last_layer = m_State.m_activeLayerName; + last_layer = m_activeLayerName; } } break; } + case WT_Object::Color_ID: + { + my_file.desired_rendition().color() = *((WT_Color *)obj); + break; + } + case WT_Object::Font_ID: + { + my_file.desired_rendition().font() = *((WT_Font *)obj); + break; + } default: { #ifdef _DEBUG @@ -612,7 +651,7 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do } } - myDoTRACE("\nWritten %d/%d layers", my_plan_file.layer_list().count(), my_file.layer_list().count()); + myDoTRACE("\nWritten %d/%d layers", my_file.layer_list().count(), my_plan_file.layer_list().count()); // if (result == WT_Result::End_Of_DWF_Opcode_Found) // dwfresult = DwfResult::Success; @@ -693,16 +732,16 @@ private: bool CWhipFile::GenerateSymbols(myWT_File &my_file) { - double scale = m_State.m_contunits.application_to_dwf_transform()(0,0); + double scale = m_contunits.application_to_dwf_transform()(0,0); // TODO: Echt uniek layernum (en URL num) bepalen my_file.desired_rendition().layer() = WT_Layer(my_file, 65530, "SLNK Symbols"); - for (size_t i=0; im_symbolName == "" || !m_State.m_SLNKSymbolDefinitions.Lookup(symbol->m_symbolName)) - symbol->serialize(my_file, m_State.m_contunits, NULL, - m_State.m_hintScale, m_State.m_forFind); + CSLNKSymbolImpl *symbol= m_SLNKSymbols[i]; + if (symbol->m_symbolName == "" || !m_SLNKSymbolDefinitions.Lookup(symbol->m_symbolName)) + symbol->serialize(my_file, m_contunits, NULL, + m_hintScale, m_forFind); else { #ifdef _DEBUG @@ -711,8 +750,8 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file) cmt.set(s); cmt.serialize(my_file); #endif - symbol->serialize(my_file, m_State.m_contunits, m_State.m_SLNKSymbolDefinitions[symbol->m_symbolName], - m_State.m_hintScale, m_State.m_forFind); + symbol->serialize(my_file, m_contunits, m_SLNKSymbolDefinitions[symbol->m_symbolName], + m_hintScale, m_forFind); } } return true; @@ -720,7 +759,7 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file) bool CWhipFile::GenerateSymbolLabels(myWT_File &my_file) { - double scale = m_State.m_contunits.application_to_dwf_transform()(0,0); + double scale = m_contunits.application_to_dwf_transform()(0,0); // Zet een DC op om bij 'Center' de afmetingen van de tekst te kunnen bepalen int fontheight= myRound(m_FontHeightSymbols * scale); tempFontDC myDC(m_FontName); @@ -737,13 +776,13 @@ bool CWhipFile::GenerateSymbolLabels(myWT_File &my_file) // TODO: Echt uniek layernum (en URL num) bepalen my_file.desired_rendition().layer() = WT_Layer(my_file, 65531, "SLNK Symbol Labels"); - for (size_t i=0; im_dwgX, symbol->m_dwgY)); + WT_Logical_Point center = m_contunits.transform(WT_Point3D(symbol->m_dwgX, symbol->m_dwgY)); symbol->m_SLNKContour.m_ptLabel = center; WT_Transform wasTransform = my_file.heuristics().transform(); @@ -763,15 +802,21 @@ bool CWhipFile::GenerateSymbolLabels(myWT_File &my_file) // wegeschreven. Die komen dan helemaal onderop. Ze zouden anders afdekken // In de tweede slag komen alle transparante contouren. Die komen na de // plattegrond zodat de plattegrond doorschijnt. +// TODO: Sorteren op dunste contouren eerst, die dikke moeten bovenop? bool CWhipFile::GenerateContouren(WT_File &my_planfile, myWT_File &my_file, double scale, BOOL solidOnly) { // Zorg dat we zelf neutraal blijven WT_Layer keepLayer = my_planfile.rendition().layer(); WT_Color keepColor = my_planfile.rendition().color(); + WT_Line_Style keepStyle = my_planfile.rendition().line_style(); // Vertrouw de huidige rendition niet! WT_Color().serialize(my_file); + WT_Line_Style style; + style.line_join() = WT_Line_Style::Diamond_Join; + my_file.desired_rendition().line_weight() = myRound(10 * scale); + style.serialize(my_file); //Store the current object node hoewel die echt null zal zijn.... WT_Object_Node current_node = my_file.desired_rendition().object_node(); @@ -781,13 +826,29 @@ bool CWhipFile::GenerateContouren(WT_File &my_planfile, myWT_File &my_file, // Beide 'slagen' forceren (FSN#14349) my_file.desired_rendition().layer().serialize(my_file); - for (size_t i=0; im_outlineAlpha=0; // Onzichtbaar maken - contour->serialize(my_file, solidOnly, m_State.m_forFind); + CSLNKContourImpl *contour= m_SLNKContouren[i]; + if (contour->m_onTop) + { + while (last > i && last > 0 && m_SLNKContouren[last]->m_onTop) + last --; + if (last > i && last > 0) + { + m_SLNKContouren[i] = m_SLNKContouren[last]; + m_SLNKContouren[last] = contour; + last--; + } + } + + } + + for (size_t i=0; iserialize(my_file, solidOnly, m_forFind, scale); } my_file.desired_rendition().object_node() = current_node; @@ -797,6 +858,9 @@ bool CWhipFile::GenerateContouren(WT_File &my_planfile, myWT_File &my_file, if (keepLayer.layer_num()) keepLayer.serialize(my_file); // Zeker terugzetten my_file.desired_rendition().color() = my_file.rendition().color() = keepColor; keepColor.serialize(my_file); // Zeker terugzetten + my_file.desired_rendition().line_style() = my_file.rendition().line_style() = keepStyle; + keepStyle.serialize(my_file); // + return true; } @@ -820,12 +884,12 @@ bool CWhipFile::GenerateLabels(WT_File &my_planfile, myWT_File &my_file, double myfont.serialize(my_file); // Vertrouw niets. Expliciete serialize. Zie @@@ // En nu nog een keer alle teksten - for (size_t i=0; im_contLabel.length()!=0 && contour->m_ExtraLabel != "") + if (contour->m_contLabel.length()!=0 && contour->m_ShowLabel != "") { // We have got a proper label/contour // Alle teksten tekenen contour->SerializeLabel(my_file, m_LabelPos, fontheight, scale, myDC); @@ -846,7 +910,7 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file) { // Bepaal de te gebruiken hoogte in Logical Points - double scale = m_State.m_contunits.application_to_dwf_transform()(0,0); + double scale = m_contunits.application_to_dwf_transform()(0,0); myDoTRACE("\nSchaal: %.2f", scale); WT_Result result; @@ -915,7 +979,7 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file) // de teksten. Zodoende zijn de teksten altijd leesbaar GenerateContouren(m_W2DFile, my_file, scale, false); // Alle transparante kleuren //merging geeft vreemd effect op de contouren die we om symbolen tekenen in _DEBUG mode - // dan worden die contouren niet meer meegeschaalt? TODO: Uitzoeken + // dan worden die contouren niet meer meegeschaald? TODO: Uitzoeken //my_file.heuristics().set_allow_drawable_merging(WD_True); // Voor symbolen kan het (na verschalen) wel schelen GenerateSymbols(my_file); // Ook alle contouren van symbolen GenerateSymbolLabels(my_file); @@ -932,21 +996,21 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file) // mei 2007: DEPRECATED // Lege Identlabel zet alle labels op de extralabel+default -STDMETHODIMP CWhipFile::SetLabel(BSTR IdentLabel, BSTR ExtraLabel) +STDMETHODIMP CWhipFile::SetLabel(BSTR IdentLabel, BSTR ShowLabel) { try { - for (size_t i=0; im_contLabel.length()>0) { if (contour->m_contLabel.equals(IdentLabel) || SysStringLen(IdentLabel) == 0) { - contour->m_ExtraLabel = ExtraLabel; + contour->m_ShowLabel = ShowLabel; } if (SysStringLen(IdentLabel) == 0) - contour->m_ExtraLabel += contour->m_contLabel.ascii(); + contour->m_ShowLabel += contour->m_contLabel.ascii(); } } return S_OK; @@ -964,9 +1028,9 @@ STDMETHODIMP CWhipFile::SetLabel(BSTR IdentLabel, BSTR ExtraLabel) STDMETHODIMP CWhipFile::SetColor(BSTR IdentLabel, ULONG rgb, BYTE Alpha /*=255*/) { try { - for (size_t i=0; im_contLabel.length()>0 && (SysStringLen(IdentLabel) == 0 || contour->m_contLabel.equals(IdentLabel))) { @@ -991,9 +1055,9 @@ STDMETHODIMP CWhipFile::SetColor(BSTR IdentLabel, ULONG rgb, BYTE Alpha /*=255*/ STDMETHODIMP CWhipFile::HighlightUnrecognized() { try { - for (size_t i=0; im_contLabel.length()==0) { contour->m_Color.set(255, 0, 0); @@ -1040,10 +1104,10 @@ STDMETHODIMP CWhipFile::get_ContoursXML(BSTR* pVal) DWFXMLSerializer XML(_oUUID); XML.attach(XMLProps); XML.startElement( L"Contours", L"SLNKDWF" ); - for (size_t i=0; iserializeXML(XML, contour->m_parentWhipFileState->m_contunits); + CSLNKContourImpl *contour= m_SLNKContouren[i]; + contour->serializeXML(XML, contour->m_parentWhipFile->m_contunits); } XML.endElement(); XML.detach(); @@ -1058,8 +1122,8 @@ STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, myTRACE("\nAdding symbol %s at %.2f,%.2f", name, dwgX, dwgY); - CSLNKSymbolImpl *mySymbol = new CSLNKSymbolImpl(dwgX, dwgY, &m_State); - m_State.m_SLNKSymbols.Add(mySymbol); + CSLNKSymbolImpl *mySymbol = new CSLNKSymbolImpl(dwgX, dwgY, this); + m_SLNKSymbols.Add(mySymbol); // Als resultaat leveren we een COM object op waar je eventueel de rest van // de properties op kunt zetten @@ -1074,25 +1138,19 @@ STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, if(FAILED(hr)) return hr; theSymbol->SetImpl(mySymbol); // Heel belangrijk: zet de implementatie waar we een interface op bieden - if (!m_State.m_SLNKSymbolDefinitions.Lookup(name)) + if (!m_SLNKSymbolDefinitions.Lookup(name)) name = "*STAR"; // Die vinden we altijd ja - ATLASSERT(m_State.m_SLNKSymbolDefinitions.Lookup(name)); + ATLASSERT(m_SLNKSymbolDefinitions.Lookup(name)); mySymbol->m_symbolName = name; - mySymbol->m_SLNKContour.set(m_State.m_SLNKSymbolDefinitions[name]->m_BoundingContour.count(), - m_State.m_SLNKSymbolDefinitions[name]->m_BoundingContour.points(), true); // TODO: Is copy wel nodig?==>Ja, we gaan ze later transformeren! + mySymbol->m_SLNKContour.set(m_SLNKSymbolDefinitions[name]->m_BoundingContour.count(), + m_SLNKSymbolDefinitions[name]->m_BoundingContour.points(), true); // TODO: Is copy wel nodig?==>Ja, we gaan ze later transformeren! + // De voorgedefinieerde symbolen hebben alleen maar een contour. Die activeren we hier if (name[0] == '*') { + // Default rood mySymbol->m_SLNKContour.m_Color = WT_Color(255,0,0,255); - mySymbol->m_SLNKContour.m_outlineAlpha = 255; // Anders wordtie helemaal niet getekend? - } - else - { -#ifdef _DEBUG - mySymbol->m_SLNKContour.m_outlineAlpha = 255; // Altijd Zichtbaar maken -#else - mySymbol->m_SLNKContour.m_outlineAlpha = g_SLNKOptions.m_SymbolOutlineAlpha; // default Onzichtbaar maken -#endif + mySymbol->m_SLNKContour.m_outlineColor = WT_Color(255,0,0,255); // Anders wordtie helemaal niet getekend? } return S_OK; } @@ -1117,7 +1175,7 @@ STDMETHODIMP CWhipFile::DefineSymbol(BSTR symbolName, VARIANT EPlotStream) CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(EPlotSection); CString name(symbolName); - m_State.m_SLNKSymbolDefinitions.SetAt(name, symb); + m_SLNKSymbolDefinitions.SetAt(name, symb); } } else @@ -1132,7 +1190,7 @@ STDMETHODIMP CWhipFile::DefineBitmapSymbol(BSTR symbolName, BSTR symbolPath, dou myTRACE("\nDefining bitmap symbol %ls", symbolName); CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(CString(symbolPath), height); CString name(symbolName); - m_State.m_SLNKSymbolDefinitions.SetAt(name, symb); + m_SLNKSymbolDefinitions.SetAt(name, symb); //return E_INVALIDARG; return S_OK; @@ -1144,10 +1202,10 @@ STDMETHODIMP CWhipFile::DefineBitmapSymbol(BSTR symbolName, BSTR symbolPath, dou STDMETHODIMP CWhipFile::get_Contour(BSTR IdentLabel, ISLNKContour** pVal) { try { - for (size_t i=0; im_contLabel.length()>0 && contour->m_contLabel.equals(IdentLabel)) + CSLNKContourImpl *contour = m_SLNKContouren[i]; + if (contour->m_Key == CString(IdentLabel)) { return get_ContourItem((ULONG) i, pVal); } @@ -1166,14 +1224,14 @@ STDMETHODIMP CWhipFile::get_Contour(BSTR IdentLabel, ISLNKContour** pVal) STDMETHODIMP CWhipFile::get_hintScale(DOUBLE* pVal) { - (*pVal) = m_State.m_hintScale; + (*pVal) = m_hintScale; return S_OK; } STDMETHODIMP CWhipFile::put_hintScale(DOUBLE newVal) { - m_State.m_hintScale = newVal; + m_hintScale = newVal; myTRACE("\nhintScale set to %.6f", newVal); return S_OK; @@ -1181,7 +1239,7 @@ STDMETHODIMP CWhipFile::put_hintScale(DOUBLE newVal) STDMETHODIMP CWhipFile::put_forFind(VARIANT_BOOL newVal) { - m_State.m_forFind = newVal; + m_forFind = newVal; return S_OK; } @@ -1194,15 +1252,15 @@ STDMETHODIMP CWhipFile::get_FindInContour(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal) { CString result; WT_Point3D insertion(dwgX, dwgY); - WT_Logical_Point LPInsertion = m_State.m_contunits.transform(WT_Point3D(dwgX, dwgY)); + WT_Logical_Point LPInsertion = m_contunits.transform(WT_Point3D(dwgX, dwgY)); - for (size_t i=0; im_contLabel.length()>0) + CSLNKContourImpl *contour= m_SLNKContouren[i]; + if (contour->m_Key != "") if (CSLNKContourImpl::PointInPolygon(LPInsertion, *contour)) { - result = contour->m_contLabel; + result = contour->m_Key; (*pVal) = result.AllocSysString(); } } @@ -1211,14 +1269,14 @@ STDMETHODIMP CWhipFile::get_FindInContour(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal) STDMETHODIMP CWhipFile::get_ContourCount(LONG* pVal) { - *pVal = (LONG)m_State.m_SLNKContouren.GetCount(); + *pVal = (LONG)m_SLNKContouren.GetCount(); return S_OK; } STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal) { - if (i < 0 || i >= m_State.m_SLNKContouren.GetCount()) + if (i < 0 || i >= m_SLNKContouren.GetCount()) return E_INVALIDARG; CComObject *theContour; HRESULT hr = CComObject::CreateInstance(&theContour); @@ -1230,7 +1288,21 @@ STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal) theContour->Release(); if(FAILED(hr)) return hr; - theContour->SetImpl(m_State.m_SLNKContouren[i]); // Heel belangrijk: zet de implementatie waar we een interface op bieden + theContour->SetImpl(m_SLNKContouren[i]); // Heel belangrijk: zet de implementatie waar we een interface op bieden return S_OK; // Wel gevonden } + +STDMETHODIMP CWhipFile::get_minContSize(DOUBLE* pVal) +{ + (*pVal) = m_minContSize; + + return S_OK; +} + +STDMETHODIMP CWhipFile::put_minContSize(DOUBLE newVal) +{ + m_minContSize = newVal; + + return S_OK; +} diff --git a/SlnkDWFCom/WhipFile.h b/SlnkDWFCom/WhipFile.h index 30c4272..4b71082 100644 --- a/SlnkDWFCom/WhipFile.h +++ b/SlnkDWFCom/WhipFile.h @@ -13,48 +13,98 @@ using namespace DWFToolkit; #include "SLNKDWF.h" -class CWhipFileState +// CWhipFile +class ATL_NO_VTABLE CWhipFile : + public CComObjectRootEx, + public CComCoClass, + public ISupportErrorInfo, + public IDispatchImpl { public: - CWhipFileState() + CWhipFile(); + +DECLARE_REGISTRY_RESOURCEID(IDR_WHIPFILE) + + +BEGIN_COM_MAP(CWhipFile) + COM_INTERFACE_ENTRY(IWhipFile) + COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(ISupportErrorInfo) +END_COM_MAP() + +// ISupportsErrorInfo + STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); + + DECLARE_PROTECT_FINAL_CONSTRUCT() + + HRESULT FinalConstruct() { - m_reContouren.Parse(".*", FALSE); - m_reLabels.Parse(".*", FALSE); - m_reLayers.Parse(".*", FALSE); - m_hintScale = -1.0; - m_forFind = TRUE; // backward compatible - m_activeLayerName = ""; - }; - BOOL SetLayers(BSTR reContouren, BSTR reLabels) - { - REParseError status = m_reContouren.Parse( CString(reContouren), false ); - if (REPARSE_ERROR_OK != status) - { - myTRACE("\nSorry, kan reguliere expressie contouren niet parsen"); - // Unexpected error. - return FALSE; - } - status = m_reLabels.Parse( CString(reLabels), false ); - if (REPARSE_ERROR_OK != status) - { - myTRACE("\nSorry, kan reguliere expressie labelsB niet parsen"); - // Unexpected error. - return FALSE; - } - return TRUE; + return S_OK; } - BOOL SetFilterLayers(BSTR reLayers) + + void FinalRelease() { - REParseError status = m_reLayers.Parse( CString(reLayers), false ); - if (REPARSE_ERROR_OK != status) - { - myTRACE("\nSorry, kan reguliere expressie filterlayers niet parsen"); - // Unexpected error. - return FALSE; - } - return TRUE; } - ~CWhipFileState() + +public: + + STDMETHOD(Load)(BSTR WhipPath); + STDMETHOD(LoadStream)(VARIANT EPlotStream); + STDMETHOD(SetLayers)(BSTR reContouren, BSTR reLabels); + STDMETHOD(SaveAs)(BSTR WhipPath); + STDMETHOD(SaveAs2)(BSTR WhipPath); + STDMETHOD(SetLabel)(BSTR IdentLabel, BSTR ShowLabel); + 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); + STDMETHOD(get_AddSymbol)(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal); + STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream); + STDMETHOD(DefineBitmapSymbol)(BSTR symbolName, BSTR symbolPath, DOUBLE height); + STDMETHOD(get_Contour)(BSTR IdentLabel, ISLNKContour** pVal); + STDMETHOD(SetFilterLayers)(BSTR reLayers); + STDMETHOD(get_FindInContour)(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal); + +private: + + WT_String m_FontName; + double m_FontHeight, m_FontHeightSymbols; + CSLNKContourImpl::LABELPOS m_LabelPos; + + CComQIPtr m_iEPlotSection; // Om scope levend te houden + myWT_File m_W2DFile; + WT_View m_view; // Initial view + HRESULT ProcessContouren(); + HRESULT SerializePlan(WT_File & my_plan_file, myWT_File & my_file, double scale); + + bool GenerateSymbols(myWT_File &my_file); + bool GenerateSymbolLabels(myWT_File &my_file); + + bool GenerateContouren(WT_File &my_planfile, myWT_File &my_file, + double scale, BOOL solidOnly); + bool GenerateLabels(WT_File &my_planfile, myWT_File &my_file, double scale); + + STDMETHOD(Generate)(myWT_File &my_file); + void read_for_contours(); + void processLabels(); + static WT_Result my_process_layer (WT_Layer & layer, WT_File & file); + //static WT_Result my_process_polygon(WT_Polygon & polygon, WT_File & file); + static WT_Result my_process_polyline(WT_Polyline & polyline, WT_File & file); + static WT_Result my_process_polytriangle(WT_Polytriangle & polytriangle, WT_File & file); + static WT_Result my_process_text (WT_Text & text, WT_File & file); +public: + STDMETHOD(get_hintScale)(DOUBLE* pVal); + STDMETHOD(put_hintScale)(DOUBLE newVal); + STDMETHOD(put_forFind)(VARIANT_BOOL newVal); + STDMETHOD(get_ContourCount)(LONG* pVal); + STDMETHOD(get_ContourItem)(ULONG i, ISLNKContour** pVal); + STDMETHOD(get_minContSize)(DOUBLE* pVal); + STDMETHOD(put_minContSize)(DOUBLE newVal); + +// Voorheen WhipFileState +public: + ~CWhipFile() { for (size_t i=0; i m_reLayers; // Die met SaveAs moeten blijven }; -// CWhipFile -class ATL_NO_VTABLE CWhipFile : - public CComObjectRootEx, - public CComCoClass, - public ISupportErrorInfo, - public IDispatchImpl -{ -public: - CWhipFile(); - -DECLARE_REGISTRY_RESOURCEID(IDR_WHIPFILE) - - -BEGIN_COM_MAP(CWhipFile) - COM_INTERFACE_ENTRY(IWhipFile) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(ISupportErrorInfo) -END_COM_MAP() - -// ISupportsErrorInfo - STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); - - DECLARE_PROTECT_FINAL_CONSTRUCT() - - HRESULT FinalConstruct() - { - return S_OK; - } - - void FinalRelease() - { - } - -public: - - STDMETHOD(Load)(BSTR WhipPath); - STDMETHOD(LoadStream)(VARIANT EPlotStream); - STDMETHOD(SetLayers)(BSTR reContouren, BSTR reLabels); - STDMETHOD(SaveAs)(BSTR WhipPath); - 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); - STDMETHOD(get_AddSymbol)(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal); - STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream); - STDMETHOD(DefineBitmapSymbol)(BSTR symbolName, BSTR symbolPath, DOUBLE height); - STDMETHOD(get_Contour)(BSTR IdentLabel, ISLNKContour** pVal); - STDMETHOD(SetFilterLayers)(BSTR reLayers); - STDMETHOD(get_FindInContour)(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal); - -private: - CWhipFileState m_State; - - WT_String m_FontName; - double m_FontHeight, m_FontHeightSymbols; - CSLNKContourImpl::LABELPOS m_LabelPos; - - CComQIPtr m_iEPlotSection; // Om scope levend te houden - myWT_File m_W2DFile; - WT_View m_view; // Initial view - HRESULT ProcessContouren(); - HRESULT SerializePlan(WT_File & my_plan_file, myWT_File & my_file, double scale); - - bool GenerateSymbols(myWT_File &my_file); - bool GenerateSymbolLabels(myWT_File &my_file); - - bool GenerateContouren(WT_File &my_planfile, myWT_File &my_file, - double scale, BOOL solidOnly); - bool GenerateLabels(WT_File &my_planfile, myWT_File &my_file, double scale); - - STDMETHOD(Generate)(myWT_File &my_file); - void read_for_contours(); - void processLabels(); - static WT_Result my_process_layer (WT_Layer & layer, WT_File & file); - //static WT_Result my_process_polygon(WT_Polygon & polygon, WT_File & file); - static WT_Result my_process_polyline(WT_Polyline & polyline, WT_File & file); - static WT_Result my_process_polytriangle(WT_Polytriangle & polytriangle, WT_File & file); - static WT_Result my_process_text (WT_Text & text, WT_File & file); -public: - STDMETHOD(get_hintScale)(DOUBLE* pVal); - STDMETHOD(put_hintScale)(DOUBLE newVal); - STDMETHOD(put_forFind)(VARIANT_BOOL newVal); - STDMETHOD(get_ContourCount)(LONG* pVal); - STDMETHOD(get_ContourItem)(ULONG i, ISLNKContour** pVal); -}; - OBJECT_ENTRY_AUTO(__uuidof(WhipFile), CWhipFile) diff --git a/SlnkDWFImpl/SLNKContourImpl.cpp b/SlnkDWFImpl/SLNKContourImpl.cpp index e0c937f..0e41e79 100644 --- a/SlnkDWFImpl/SLNKContourImpl.cpp +++ b/SlnkDWFImpl/SLNKContourImpl.cpp @@ -11,9 +11,10 @@ /*static*/ WT_Integer32 CSLNKContourImpl::m_next_node_num = 0; // Eigenlijk initialiseren op laatste van planfile CSLNKContourImpl::CSLNKContourImpl(void) - : m_DWGArea(-1), m_outlineAlpha(255) + : m_DWGArea(-1), m_outlineColor(WT_RGBA32(128,128,128,255)) { - m_Color = WT_RGBA32(0,0,0,0); // alpha==0, 100% transparant + m_Color = WT_RGBA32(0,0,0,0); // alpha==0, onzichtbaar + m_Lineweight = 10.0; // 10mm default } CSLNKContourImpl::~CSLNKContourImpl(void) @@ -244,7 +245,7 @@ Subject 1.02: How do I find the distance from a point to a line? } // Signed Area needed for centroid! -// Negative is clockwise, Positve counterclockwise +// Negative is clockwise, Positive counterclockwise /*static*/double CSLNKContourImpl::DWFArea(const WT_Point_Set &pg) { int i; @@ -341,7 +342,7 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file, LABELPOS pos, else my_file.desired_rendition().color() = WT_Color(255,255,255,0); //Teksten wit - CString tok(m_ExtraLabel); // strtok seems to modify + CString tok(m_ShowLabel); // strtok seems to modify tok.Replace("~", "\n"); // We ondersteunen ook ~ als newline tok.Replace("[br]", "\n"); // We ondersteunen ook [br] als newline tok.Replace("[BR]", "\n"); // We ondersteunen ook [BR] als newline @@ -583,7 +584,7 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file, Als solidOnly dan alleen als alpha==255 en een label (wel herkend) ****************************************************************************/ -WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFind) +WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFind, double scale) { if (!m_fromSymbol && m_contLabel == "" && !solidOnly) // Alleen bij tweede slag { // May very well be a textobject itself, just emit it @@ -662,21 +663,23 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFi my_poly2.serialize(file); file.desired_rendition().fill_pattern() = pOld; } - // - // Nu nogmaals om de rand van de ruimte te tekenen - // Dikte is door de aanroeper al gezet - // - // TODO: Altijd contrasteren met achtergrond - if (m_outlineAlpha>0) // Voor symbolen niet nodig - { - file.desired_rendition().color() = WT_Color(128,128,128, m_outlineAlpha); // Set the color for the polyline - //my_file.desired_rendition().color() = WT_Color(0,0,0); // Zwart - WT_Polyline my_line( count(), points(), WD_False); - my_line.serialize(file); - } file.desired_rendition().url().clear(); } + + // + // Nu nogmaals om de zichtbare rand van de ruimte te tekenen + // + if (!solidOnly // Randje altijd alleen in de tweede slag zodat bij voorkeur bovenop + && m_outlineColor.rgba().m_rgb.a>0) // Voor symbolen niet nodig + { + file.desired_rendition().color() = m_outlineColor; // Set the color for the polyline + file.desired_rendition().line_weight() = myRound(m_Lineweight * scale); + // Fraaier bij lijndikte aan begin/eind + file.desired_rendition().line_style().line_end_cap() = WT_Line_Style::Round_Cap; + WT_Polyline my_line( count(), points(), WD_False); + my_line.serialize(file); + } } return WT_Result::Success; }; diff --git a/SlnkDWFImpl/SLNKContourImpl.h b/SlnkDWFImpl/SLNKContourImpl.h index cbaf3e2..71a0461 100644 --- a/SlnkDWFImpl/SLNKContourImpl.h +++ b/SlnkDWFImpl/SLNKContourImpl.h @@ -3,7 +3,7 @@ #define FONT_SIZER 1000 -class CWhipFileState; // Forward declaration +class CWhipFile; // Forward declaration class CSLNKContourImpl : public WT_Polygon @@ -23,29 +23,32 @@ public: int count, /**< The number of points in the array. */ WT_Logical_Point const * points, /**< Pointer to the array of points. */ WT_Boolean copy, /**< Whether the points should be copied or if their addresses should be used directly from the array. */ - CWhipFileState *parent + CWhipFile *parent ) - : WT_Polygon(count, points, copy), m_outlineAlpha(255), m_fromSymbol(false) + : WT_Polygon(count, points, copy), m_outlineColor(128,128,128,255), m_fromSymbol(false), m_onTop(false) { m_Color = WT_RGBA32(0,0,0,0); // alpha==0, 100% transparant - m_parentWhipFileState = parent; + m_Lineweight = 10.0; // 10 mm default + m_parentWhipFile = parent; } ~CSLNKContourImpl(void); public: WT_String m_contLabel; // As scanned from DWF-file CString m_Key; // standaard m_contLabel voor contouren maar kan (en voor symbolen moet) een andere waarde krijgen - WT_Color m_Color; - int m_outlineAlpha; // Default 255, zet op 0 voor transparant + WT_Color m_Color; // Vul-kleur + WT_Color m_outlineColor; // Contour kleur + BOOL m_onTop; // Deze wordt later (bovenop) getekend dan degene die niet onTop hebben BOOL m_fromSymbol; // Dan zijn onze bounds maar matig betrouwbaar zo lang ze niet getransformeerd zijn. - CWhipFileState *m_parentWhipFileState; + CWhipFile *m_parentWhipFile; WT_Fill_Pattern m_Pattern; WT_Logical_Point m_ptLabel; // Coordinates of the label - CString m_ExtraLabel; // Can be defined + CString m_ShowLabel; // As will be shown WT_URL_Item m_Url; // Can be defined double m_DWGArea; // As determined, original source drawing units + double m_Lineweight; // DWG coordinaten - WT_Result serialize(WT_File & file, BOOL solidOnly, BOOL forFind); + WT_Result serialize(WT_File & file, BOOL solidOnly, BOOL forFind, double scale); static BOOL PointInPolygon(const WT_Logical_Point pt, const WT_Point_Set &ps); static BOOL PointInPolygon(const CPoint pt, const CPoint *ps, int size); static void EdgeAngle(const WT_Logical_Point pt, const WT_Point_Set &ps, double &EdgeAngle, double &EdgeDistance); diff --git a/SlnkDWFImpl/Whip2DCImpl.cpp b/SlnkDWFImpl/Whip2DCImpl.cpp index 268ff67..d63a05d 100644 --- a/SlnkDWFImpl/Whip2DCImpl.cpp +++ b/SlnkDWFImpl/Whip2DCImpl.cpp @@ -16,8 +16,8 @@ // CWhip2DC -STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream, - const CString &WhipPath, +STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream, + const CString &WhipPath, const CString & RegExp, long sizeX, long sizeY, VARIANT_BOOL centerImage, VARIANT_BOOL maximize,/*=FALSE*/ double dwgScale/*=0.0*/, long lRotation /*=0*/) @@ -94,10 +94,10 @@ if (0) { // altijd 'gewoon' recht rekenen if (!maximize) m_State.SetExtents(view->view()); // m_mul wordt gezet en de loop eindigt else - { + { // 'Move' alles naar het midden van het eerste kwadrant // Anders kunnen we later bij bounds bepaling overflow krijgen - + // Waar roteren we eigenlijk omheen? WT_Logical_Point lCenter; if (m_State.m_lRotation==0||m_State.m_lRotation==90||m_State.m_lRotation==180||m_State.m_lRotation==270) @@ -123,7 +123,7 @@ if (0) { // altijd 'gewoon' recht rekenen m_State.SetExtents(WT_Logical_Box(dwfPtmin, dwfPtmax)); // m_mul wordt gezet en de loop eindigt } } - break; + break; } break; } @@ -168,7 +168,7 @@ if (0) { // altijd 'gewoon' recht rekenen double old_mul = m_State.m_mul; CSize old_size = m_State.m_Size; m_State.m_mul = 1.0/dwgScale/dScale; - + if (m_State.m_Maximize) // Eventueel centreren ongedaan maken m_State.m_MinMax = m_State.m_orgMinMax; @@ -178,11 +178,12 @@ if (0) { // altijd 'gewoon' recht rekenen m_State.m_Size.cx = max(m_State.m_Size.cx, 1); m_State.m_Size.cy = max(m_State.m_Size.cy, 1); - myDoTRACE("\nm_mul forced from %.8f to %.8f and size from (%d, %d) to (%d, %d)", + myDoTRACE("\nm_mul forced from %.8f to %.8f and size from (%d, %d) to (%d, %d)", old_mul, m_State.m_mul, old_size.cx,old_size.cy,m_State.m_Size.cx,m_State.m_Size.cy); } ATLASSERT(m_State.m_mul!=0); + return S_OK; } @@ -197,8 +198,29 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW, VARIANT_BOOL markers /* = #ifdef _DEBUG /// CneutralGDI neutralGDI("CWhip2DCImpl::Paint"); #endif + +//#define EXPERIMENT + // Helaas: bij sterk inzoomen (lijkt: m_mul > 1) komen er af en toe zwarte + // randen in de viewer te voorschijn +#ifdef EXPERIMENT + SetMapMode(m_State.myDC, MM_ANISOTROPIC); + SIZE wsz, vsz; + if (m_State.m_mul < 1.0) + { + SetWindowExtEx(m_State.myDC, myRound(m_State.m_Size.cx / m_State.m_mul), myRound(m_State.m_Size.cy / m_State.m_mul), &wsz); + SetViewportExtEx(m_State.myDC, m_State.m_Size.cx, m_State.m_Size.cy, &vsz); + } + else + { + SetWindowExtEx(m_State.myDC, m_State.m_Size.cx, m_State.m_Size.cy, &wsz); + SetViewportExtEx(m_State.myDC, myRound(m_State.m_Size.cx * m_State.m_mul), myRound(m_State.m_Size.cy * m_State.m_mul), &vsz); + } + m_State.m_mul = 1.0; + int mm = GetMapMode(m_State.myDC); +#endif + CmyTimer Timer("CWhip2DCImpl::Paint"); - + m_State.m_forceBW = forceBW; m_State.findIt = FALSE; @@ -236,6 +258,9 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW, VARIANT_BOOL markers /* = // Alle callback functies zijn static. Die kunnen de variabele // m_State niet benaderen. Daarom maar via set_user_data + // Voortschrijdend inzicht: doorgeven van (void *)this was eigenlijk + // veel praktischer geweest. Bij whipfile.cpp doen we dat al sinds + // 2.80 maar hier is me dat nog even te veel werk. my_input_file.heuristics().set_user_data((void *)&m_State); if (m_State.m_lRotation != 0) // Tijdens het laden roteren @@ -352,9 +377,9 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW, VARIANT_BOOL markers /* = { CString txt; txt.Format("%d", x); - TextOut(m_State.myDC, pt.x+5, pt.y, txt, txt.GetLength()); + TextOut(m_State.myDC, pt.x+5, pt.y, txt, txt.GetLength()); txt.Format("%d", y); - TextOut(m_State.myDC, pt.x+5, pt.y+10, txt, txt.GetLength()); + TextOut(m_State.myDC, pt.x+5, pt.y+10, txt, txt.GetLength()); } } } @@ -367,9 +392,9 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW, VARIANT_BOOL markers /* = //CPoint pt1 = m_State.DWFToLP(WT_Logical_Point(INT_MAX, -100000000)); HPEN m_pen = CreatePen(PS_SOLID, 3, RGB(255,255,0)); HPEN oldpen = (HPEN) SelectObject(m_State.myDC, m_pen); - MoveToEx(m_State.myDC, pt0.x, pt0.y, NULL); + MoveToEx(m_State.myDC, pt0.x, pt0.y, NULL); - LineTo(m_State.myDC, pt1.x, pt1.y); + LineTo(m_State.myDC, pt1.x, pt1.y); #endif } return S_OK; @@ -440,12 +465,12 @@ STDMETHODIMP CWhip2DCImpl::FindTexts(const CString &findText) * Return S_OK * * Called - * TODO: AsMap wordt voor steeds meer doeleinden gebruikt. Oppassen dat + * TODO: AsMap wordt voor steeds meer doeleinden gebruikt. Oppassen dat * bijvoorbeeld extents wel correct worden bepaald *****************************************************************************/ -STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, - BYTE AsMap, - CString & pContourLabel,CString & pContourLayer, +STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, + BYTE AsMap, + CString & pContourKey, CString & pContourLayer, CString & pTextLabel, CString & pTextLayer, double &pEdgeAngle, double &pEdgeDistance) { @@ -468,7 +493,7 @@ STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, CPoint ptback = m_State.DWFToLP(m_State.DWFfindXY); myTRACE("\nTerugvertaling: (%d, %d)\n", ptback.x, ptback.y); #endif - + myWT_File my_input_file; // input file. // For TextExtent32 @@ -515,7 +540,7 @@ STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, my_input_file.close(); // closing Input file. if (AsMap) - pContourLabel = m_State.MapBuilder; + pContourKey = m_State.MapBuilder; else { if (m_State.foundTextLabel != "") @@ -526,7 +551,7 @@ STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, if (m_State.foundNode.object_node_name()) { - pContourLabel = CString(m_State.foundNode.object_node_name().ascii()); + pContourKey = CString(m_State.foundNode.object_node_name().ascii()); pContourLayer = m_State.foundNodeLayer; pEdgeAngle = m_State.foundEdgeAngle; pEdgeDistance = m_State.foundEdgeDistance; @@ -543,12 +568,12 @@ STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY, } // Call Find() or Paint() first!! -STDMETHODIMP CWhip2DCImpl::DPtoDWG(LONG findX, LONG findY, +STDMETHODIMP CWhip2DCImpl::DPtoDWG(LONG findX, LONG findY, DOUBLE* resX, DOUBLE* resY) { m_State.LPfindXY = CPoint(findX, findY); DPtoLP(m_State.myDC, &m_State.LPfindXY, 1); - + if ((resX != NULL) && (resY != NULL)) { if (m_State.m_mul==0) // Geen extents, vast ook geen transform @@ -566,7 +591,7 @@ STDMETHODIMP CWhip2DCImpl::DPtoDWG(LONG findX, LONG findY, } // Call Find() or Paint() first!! -STDMETHODIMP CWhip2DCImpl::DWGExtents(DOUBLE* resminX, DOUBLE* resminY, +STDMETHODIMP CWhip2DCImpl::DWGExtents(DOUBLE* resminX, DOUBLE* resminY, DOUBLE* resmaxX, DOUBLE* resmaxY) { if (resminX && resminY && resmaxX && resmaxY) @@ -663,27 +688,27 @@ WT_Result CWhip2DCImpl::my_process_viewport (WT_Viewport & viewport, WT_File & f BOOL firstTime = (!file.rendition().viewport().contour()); file.rendition().viewport() = viewport; - // Voor de zekerheid opnieuw. ADT3_MTextFormattingCodesinScheduleTags.dwf had + // Voor de zekerheid opnieuw. ADT3_MTextFormattingCodesinScheduleTags.dwf had // (waarschijnlijk door de DWFPrinter) de eerste (Font) voor de eerste (Viewport) // en dan was de hoogte niet goed gezet m_State->my_process_font(file.rendition().font()); double dScale = viewport.viewport_units().application_to_dwf_transform()(0,0); myDoTRACE("\nThis viewport: 1 pixel = %.8f drawing units.", 1.0/(dScale*m_State->m_mul)); - + if (m_State->findIt) // When finding no need (or actually: support) for clipping return WT_Result::Success; if (!viewport.contour()) // dwftest_bc.dwf { - SelectClipRgn(m_State->myDC, NULL); - return WT_Result::Success; + SelectClipRgn(m_State->myDC, NULL); + return WT_Result::Success; } // Viewports-ANSI A.dwf heeft diverse viewports myTRACE("\nViewport met %d punten", viewport.contour()->total_points()); - - // TODO: Door afronding kan het gebeuren dat de clipregion ene pixel + + // TODO: Door afronding kan het gebeuren dat de clipregion ene pixel // te ver naar binnen valt waardoor meest rechtse lijntjes wegvallen // Daarom viewport ter grootte van minmax niet aanzetten // NOOT: Ook riskant als later symbolen net buiten de extents geplaatst zijn? @@ -694,20 +719,20 @@ WT_Result CWhip2DCImpl::my_process_viewport (WT_Viewport & viewport, WT_File & f return WT_Result::Success; } - CPoint *vertexList = - m_State->new_DWFToLP(WT_Point_Set(viewport.contour()->total_points(), + CPoint *vertexList = + m_State->new_DWFToLP(WT_Point_Set(viewport.contour()->total_points(), viewport.contour()->points(), false)); // LET OP: CreatePolyPolygonRgn verwacht Device Units! LPtoDP(m_State->myDC, vertexList, viewport.contour()->total_points()); if (m_State->m_hrgn) DeleteObject(m_State->m_hrgn); - m_State->m_hrgn = CreatePolyPolygonRgn(vertexList, (int *)viewport.contour()->counts(), + m_State->m_hrgn = CreatePolyPolygonRgn(vertexList, (int *)viewport.contour()->counts(), viewport.contour()->contours(), - ALTERNATE); + ALTERNATE); ATLASSERT(m_State->m_hrgn); - int res = SelectClipRgn(m_State->myDC, m_State->m_hrgn); + int res = SelectClipRgn(m_State->myDC, m_State->m_hrgn); ATLASSERT(res != ERROR); #ifdef _DEBUG { @@ -721,7 +746,7 @@ WT_Result CWhip2DCImpl::my_process_viewport (WT_Viewport & viewport, WT_File & f myTRACE("\nRegion aangemaakt: %s", s); } #endif - + return WT_Result::Success; } @@ -802,7 +827,7 @@ WT_Result CWhip2DCImpl::my_process_layer (WT_Layer & layer, WT_File & file) m_State->bLayerVisible = FALSE; // myTRACE("\nLayer %s .. does not match", ll->layer_name().ascii()); } - + // myTRACE("\nLayer %s .. does not match", ll->layer_name().ascii()); m_State->bIsSymbolLayer = (m_State->m_activeLayerName == "SLNK Symbols"); //myDoTRACE("\nLayer %s %d", ll->layer_name().ascii(), m_State->bIsSymbolLayer); @@ -909,8 +934,8 @@ WT_Result CWhip2DCImpl::my_process_Ellipse (WT_Ellipse & Ellipse, WT_File & file pos.m_y+myRound(sin(end +tilt)*minor)); CPoint s = m_State->DWFToLP(ls); CPoint e = m_State->DWFToLP(le); - MoveToEx(m_State->myDC, s.x, s.y, NULL); - LineTo(m_State->myDC, e.x, e.y); + MoveToEx(m_State->myDC, s.x, s.y, NULL); + LineTo(m_State->myDC, e.x, e.y); return WT_Result::Success; } @@ -995,7 +1020,7 @@ CString CWhip2DCImpl::PolyToMap(WT_Polygon & polygon, #endif LPtoDP(m_State->myDC, &pt1, 1); LPtoDP(m_State->myDC, &pt2, 1); - ptList.Format("%d,%d,%d,%d", min(pt1.x, pt2.x), min(pt1.y, pt2.y), + ptList.Format("%d,%d,%d,%d", min(pt1.x, pt2.x), min(pt1.y, pt2.y), max(pt1.x, pt2.x), max(pt1.y, pt2.y)); } else @@ -1223,7 +1248,7 @@ WT_Result CWhip2DCImpl::my_process_pngGroup4Image (WT_PNG_Group4_Image & pngGrou } //CString s; - //s.Format("CWhip2DCImpl::my_process_pngGroup4Image sz=%d dx=%d dy=%d", + //s.Format("CWhip2DCImpl::my_process_pngGroup4Image sz=%d dx=%d dy=%d", // pngGroup4Image.data_size(), dx, dy); //CmyTimer p(s); @@ -1244,7 +1269,7 @@ WT_Result CWhip2DCImpl::my_process_pngGroup4Image (WT_PNG_Group4_Image & pngGrou pStream->Release(); if (SUCCEEDED(res)) { - ::SetStretchBltMode(m_State->myDC, HALFTONE) ; + ::SetStretchBltMode(m_State->myDC, HALFTONE) ; m_pBitmap.Draw(m_State->myDC, Pt1.x, Pt2.y, dx, dy); } } @@ -1294,12 +1319,12 @@ WT_Result CWhip2DCImpl::my_process_pngGroup4Image (WT_PNG_Group4_Image & pngGrou // (GDI+ deed dat wel goed) //img.SetTransIndex(-1); //Draw2 (b)lijkt transparantie (op zwarte achtergrond) alleen goed te doen al we achtergrond/voorgrond zetten - COLORREF keepBk = SetBkColor(m_State->myDC, RGB(255, 255, 255)); - COLORREF keepText = SetTextColor(m_State->myDC, RGB(0, 0, 0)); - + COLORREF keepBk = SetBkColor(m_State->myDC, RGB(255, 255, 255)); + COLORREF keepText = SetTextColor(m_State->myDC, RGB(0, 0, 0)); + img.Draw2(m_State->myDC, Pt1.x, Pt2.y, dx, dy); - - SetBkColor(m_State->myDC, keepBk); + + SetBkColor(m_State->myDC, keepBk); SetTextColor(m_State->myDC, keepText); } else @@ -1350,8 +1375,8 @@ WT_Result CWhip2DCImpl::my_process_image (WT_Image & image, WT_File & file) HRESULT res = m_pBitmap.Load(pStream); pStream->Release(); if (SUCCEEDED(res)) - { - ::SetStretchBltMode(m_State->myDC, HALFTONE) ; + { + ::SetStretchBltMode(m_State->myDC, HALFTONE) ; m_pBitmap.Draw(m_State->myDC, Pt1.x, Pt2.y, Pt2.x - Pt1.x, Pt1.y - Pt2.y); } } @@ -1450,8 +1475,8 @@ if (!strcmp(text.string().ascii(),"TP036")) return WT_Result::Success; } else - m_State->m_kfm.TextOutSpacing(m_State->myDC, acPt.x, acPt.y, - text.string().ascii(), text.string().length(), + m_State->m_kfm.TextOutSpacing(m_State->myDC, acPt.x, acPt.y, + text.string().ascii(), text.string().length(), (m_State->m_spacing/1024.0)); //TextOut(m_State->myDC, acPt.x, acPt.y, text.string().ascii(), text.string().length()); } @@ -1478,7 +1503,7 @@ WT_Result CWhip2DCImpl::my_process_text_scan (WT_Text & text, WT_File & file) CString txt(text.string().ascii()); if (txt.Trim().GetLength() == 0) // Komt voor bij outlets van AC_C2_0 return WT_Result::Success; - + CFoundText tFound; tFound.m_FoundText = text; WT_Integer32 layer_num = file.rendition().layer().layer_num(); @@ -1516,7 +1541,7 @@ WT_Result CWhip2DCImpl::my_process_text_find (WT_Text & text, WT_File & file) if (text.bounds().bounds() != NULL) { CPoint pts[]= - { + { m_State->DWFToLP(text.bounds().bounds()[0]), m_State->DWFToLP(text.bounds().bounds()[1]), m_State->DWFToLP(text.bounds().bounds()[2]), @@ -1541,7 +1566,7 @@ WT_Result CWhip2DCImpl::my_process_text_find (WT_Text & text, WT_File & file) // GetTextExtentPoint32W(m_State->myDC, text.string().unicode(), text.string().length(), &Size); CPoint pts[]= - { + { acPt, CPoint(acPt.x+LPSize.cx, acPt.y), CPoint(acPt.x+LPSize.cx, acPt.y-LPSize.cy), @@ -1592,7 +1617,7 @@ WT_Result CWhip2DCImpl::my_process_background (WT_Background & background, WT_Fi COLORREF DCclr = RGB(clr.m_rgb.r, clr.m_rgb.g, clr.m_rgb.b); m_State->m_paperColor = DCclr; // Wordt later misschien opgevraagd. - + if (m_State->findIt) // When finding no need for actuel painting return WT_Result::Success; @@ -1651,7 +1676,7 @@ WT_Result CWhip2DCImpl::my_process_gouraudPolyline (WT_Gouraud_Polyline & gourau return WT_Result::Success; //myTRACE("\n !! Don't know how to handle gouraudPolyline very well yet!! (%d points)", gouraudPolyline.count()); - + #if 1 int w=myRound(file.rendition().line_weight().weight_value()*m_State->m_mul); @@ -1669,13 +1694,13 @@ WT_Result CWhip2DCImpl::my_process_gouraudPolyline (WT_Gouraud_Polyline & gourau int j; for (j = 0; j < dv; j++) { - COLORREF DCclr = RGB((clr.m_rgb.r*j + prev_clr.m_rgb.r*(dv-j))/dv, + COLORREF DCclr = RGB((clr.m_rgb.r*j + prev_clr.m_rgb.r*(dv-j))/dv, (clr.m_rgb.g*j + prev_clr.m_rgb.g*(dv-j))/dv, (clr.m_rgb.b*j + prev_clr.m_rgb.b*(dv-j))/dv); m_State->m_pen = CreatePen (PS_SOLID, w, DCclr); HPEN oldpen = (HPEN) SelectObject(m_State->myDC, m_State->m_pen); DeleteObject(oldpen); - LineTo(m_State->myDC, myRound(((double)pt.x*j+prev_pt.x*(dv-j))/dv), + LineTo(m_State->myDC, myRound(((double)pt.x*j+prev_pt.x*(dv-j))/dv), myRound(((double)pt.y*j+prev_pt.y*(dv-j))/dv)); } } @@ -1711,18 +1736,18 @@ WT_Result CWhip2DCImpl::my_process_gouraudPolyline (WT_Gouraud_Polyline & gourau for (int i = 0; i < gouraudPolyline.count(); i++) { WT_RGBA32 clr = gouraudPolyline.colors()[i]; - vert[2*i].x = m_State->DWFToLP(gouraudPolyline.points()[i]).x; - vert[2*i].y = m_State->DWFToLP(gouraudPolyline.points()[i]).y; + vert[2*i].x = m_State->DWFToLP(gouraudPolyline.points()[i]).x; + vert[2*i].y = m_State->DWFToLP(gouraudPolyline.points()[i]).y; // Pas op: TRIVERTEX verwacht 16 bit RGB! - vert[2*i].Red = clr.m_rgb.r<<8; - vert[2*i].Green = clr.m_rgb.g<<8; - vert[2*i].Blue = clr.m_rgb.b<<8; - vert[2*i+1].x = m_State->DWFToLP(gouraudPolyline.points()[i]).x; - vert[2*i+1].y = m_State->DWFToLP(gouraudPolyline.points()[i]).y+1; + vert[2*i].Red = clr.m_rgb.r<<8; + vert[2*i].Green = clr.m_rgb.g<<8; + vert[2*i].Blue = clr.m_rgb.b<<8; + vert[2*i+1].x = m_State->DWFToLP(gouraudPolyline.points()[i]).x; + vert[2*i+1].y = m_State->DWFToLP(gouraudPolyline.points()[i]).y+1; // Pas op: TRIVERTEX verwacht 16 bit RGB! - vert[2*i+1].Red = clr.m_rgb.r<<8; - vert[2*i+1].Green = clr.m_rgb.g<<8; - vert[2*i+1].Blue = clr.m_rgb.b<<8; + vert[2*i+1].Red = clr.m_rgb.r<<8; + vert[2*i+1].Green = clr.m_rgb.g<<8; + vert[2*i+1].Blue = clr.m_rgb.b<<8; vert[i].Alpha = clr.m_rgb.a<<8; gTri[i].Vertex1 = 2*i; gTri[i].Vertex2 = 2*(i+1); @@ -1747,12 +1772,12 @@ WT_Result CWhip2DCImpl::my_process_gouraudPolytriangle (WT_Gouraud_Polytriangle for (int i = 0; i < gouraudPolytriangle.count(); i++) { WT_RGBA32 clr = gouraudPolytriangle.colors()[i]; - vert[i].x = m_State->DWFToLP(gouraudPolytriangle.points()[i]).x; - vert[i].y = m_State->DWFToLP(gouraudPolytriangle.points()[i]).y; + vert[i].x = m_State->DWFToLP(gouraudPolytriangle.points()[i]).x; + vert[i].y = m_State->DWFToLP(gouraudPolytriangle.points()[i]).y; // Pas op: TRIVERTEX verwacht 16 bit RGB! - vert[i].Red = clr.m_rgb.r<<8; - vert[i].Green = clr.m_rgb.g<<8; - vert[i].Blue = clr.m_rgb.b<<8; + vert[i].Red = clr.m_rgb.r<<8; + vert[i].Green = clr.m_rgb.g<<8; + vert[i].Blue = clr.m_rgb.b<<8; vert[i].Alpha = clr.m_rgb.a<<8; gTri[i].Vertex1 = i; gTri[i].Vertex2 = i+1; @@ -1798,7 +1823,7 @@ STDMETHODIMP CWhip2DCImpl::get_TextItem(LONG i, CFoundText &pVal) { if (i<0 || i>=(LONG)m_State.m_FoundTexts.GetCount()) return E_INVALIDARG; - + pVal = m_State.m_FoundTexts.GetAt(i); return S_OK; } @@ -1807,7 +1832,7 @@ STDMETHODIMP CWhip2DCImpl::get_LayerItem(LONG i, CString* pVal) { if (i<0 || i>=(LONG)m_State.m_Layernames.GetSize()) return E_INVALIDARG; - + (*pVal) = m_State.m_Layernames[i]; return S_OK; } diff --git a/SlnkDWFImpl/Whip2DCState.cpp b/SlnkDWFImpl/Whip2DCState.cpp index 8ddce32..0c95b4d 100644 --- a/SlnkDWFImpl/Whip2DCState.cpp +++ b/SlnkDWFImpl/Whip2DCState.cpp @@ -79,6 +79,7 @@ CPoint *CWhip2DCState::new_DWFToLP(WT_Point_Set const &pts) } // Schaal de Whip-coordinatenruimte terug naar een GDI geschikte ruimte +// TODO: Kan dit echt niet via setviewportext/setwindowext? CPoint CWhip2DCState::DWFToLP(WT_Logical_Point const &pt) { return CPoint(myRound((pt.m_x - m_MinMax.minpt().m_x)*m_mul), @@ -561,7 +562,7 @@ void CWhip2DCState::AlphaPolygon(LPPOINT lpPoints, int nCount ) const #ifdef _DEBUG if (!res) { - myTRACE("\nHmmm, AlphaBlend failed?"); + myTRACE("\nHmmm, AlphaBlend failed? Probeer je SaveAsWMF of zo?"); _CrtDbgBreak(); } #endif diff --git a/Standalone/SLNKDWFViewer.vcproj b/Standalone/SLNKDWFViewer.vcproj index 903ff74..08c04ad 100644 --- a/Standalone/SLNKDWFViewer.vcproj +++ b/Standalone/SLNKDWFViewer.vcproj @@ -17,7 +17,7 @@ + + + + + + + + + + + + + + + + + + + + + + + 0) { m_iWhip2DC.Load(NULL, piEPlotSections->get_Item(m_nPage), L"", L".*", - 0, 0, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); + 1000, 800, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); } else { - m_iWhip2DC.Load(NULL, NULL, m_dwfPath, L".*", 0, 0, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); + m_iWhip2DC.Load(NULL, NULL, m_dwfPath, L".*", 1000, 800, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); } m_iWhip2DC.FindTexts(""); m_iWhip2DC.get_TextCount(&lCount); diff --git a/Viewer/MainFrm.cpp b/Viewer/MainFrm.cpp index f43b591..0a4b0d3 100644 --- a/Viewer/MainFrm.cpp +++ b/Viewer/MainFrm.cpp @@ -28,13 +28,30 @@ LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ { CreateSimpleToolBar(); -// CreateSimpleStatusBar(); + CreateSimpleStatusBar(); + m_status.Attach(m_hWndStatusBar); + ATLTRACE("\nEarly with m_Combo %x", m_Combo.m_hWnd); - m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); + m_wndSplit.Create ( *this, rcDefault ); + m_hWndClient = m_wndSplit; + + m_wndLayers.Create(m_wndSplit, rcDefault); + m_view.Create(m_wndSplit, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); + + m_wndSplit.SetSplitterPanes ( m_wndLayers, m_view ); + + m_wndLayers.AddColumn("Laag", 0); + m_wndLayers.SetColumnWidth(0, 195); + //m_wndLayers.AddColumn("#Cont", 1); + //m_wndLayers.AddItem(0, 0, "Hallo"); + //m_wndLayers.AddItem(1, 1, "Jij"); + UpdateLayout(); + m_wndSplit.SetSplitterPos ( 200 ); UIAddToolBar(m_hWndToolBar); -// UISetCheck(ID_VIEW_TOOLBAR, 1); + UISetCheck(ID_VIEW_TOOLBAR, 1); + UISetCheck(ID_VIEW_STATUS_BAR, 1); // register object for message filtering and idle updates // TODO: Het volgende crashed en lijkt niet echt nodig? @@ -61,6 +78,7 @@ void CMainFrame::SetDWF(const CString &dwfPath) m_view.SetDWF(dwfPath); // Maak de pagina's aan m_Combo.ResetContent(); + // m_wndLayers.resetcontent try { CDWFFileImpl m_iDWFFile; @@ -79,6 +97,28 @@ void CMainFrame::SetDWF(const CString &dwfPath) m_Combo.AddString(piEPlotSection->get_Title()); } ATLTRACE("\nDone filling ComboBox"); + + //CWhip2DCImpl *m_iWhip2DC = m_view.GetWhip2DC(); + CWhip2DCImpl m_iWhip2DC; + if (lCount > 0) + { + m_iWhip2DC.Load(NULL, piEPlotSections->get_Item(0 /*m_nPage*/), L"", L".*", + 1000, 800, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); + } + else + { + m_iWhip2DC.Load(NULL, NULL, dwfPath, L".*", 1000, 800, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); + } + + m_iWhip2DC.FindTexts(""); // forceer een scan + m_iWhip2DC.get_LayerCount(&lCount); + for (int i=0;i < lCount;i++) + { + CString tLayer; + m_iWhip2DC.get_LayerItem(i, &tLayer); + m_wndLayers.AddItem(i, 0, tLayer); + } + ATLTRACE("\nDone filling layers"); } catch (CString &ee) { @@ -106,6 +146,24 @@ LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt return 0; } +LRESULT CMainFrame::OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + BOOL bVisible = !::IsWindowVisible(m_hWndToolBar); + ::ShowWindow(m_hWndToolBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE); + UISetCheck(ID_VIEW_TOOLBAR, bVisible); + UpdateLayout(); + return 0; +} + +LRESULT CMainFrame::OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + BOOL bVisible = !::IsWindowVisible(m_hWndStatusBar); + ::ShowWindow(m_hWndStatusBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE); + UISetCheck(ID_VIEW_STATUS_BAR, bVisible); + UpdateLayout(); + return 0; +} + LRESULT CMainFrame::onSelChange(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int nTab = m_Combo.GetCurSel(); diff --git a/Viewer/SLNKDWFViewerView.cpp b/Viewer/SLNKDWFViewerView.cpp index 9594893..c33b586 100644 --- a/Viewer/SLNKDWFViewerView.cpp +++ b/Viewer/SLNKDWFViewerView.cpp @@ -4,13 +4,13 @@ #include "stdafx.h" -#include "atlgdix.h" +//#include "atlgdix.h" #include "SLNKDwfViewerView.h" #define SCL 1 -CSLNKDwfViewerView::CSLNKDwfViewerView() +CSLNKDwfViewerView::CSLNKDwfViewerView(CMainFrame& parent): m_Parent(parent) { m_nPage = 0; m_busyPanning = FALSE; @@ -85,14 +85,15 @@ void PaintToDC(HDC dc, CString dwfPath, int nPage, wSize.cx, wSize.cy, VARIANT_TRUE /*center*/, VARIANT_FALSE /* Maximize */); } - int mm = GetMapMode(dc); - SetMapMode(dc, MM_TEXT); + //int mm = GetMapMode(dc); + //SetMapMode(dc, MM_TEXT); + //SetMapMode(dc, MM_ANISOTROPIC); if (forPrint) iWhip2DC.put_paperColor(0xFFFFFF); // Altijd wit papier - iWhip2DC.Paint(VARIANT_FALSE); - SetMapMode(dc, mm); + iWhip2DC.Paint(VARIANT_FALSE,VARIANT_TRUE); // geen bw, met markers + //SetMapMode(dc, mm); } catch (CString &ee) { @@ -124,12 +125,13 @@ BOOL CSLNKDwfViewerView::my_progress_action(void *param, double progress) // Erg instabiel (door recursieve WM_PAINT?) // if (!DoEvents()) // return FALSE; + if (GetSystemMetrics(SM_REMOTESESSION)) { // App is running on a remote session. return TRUE; // Geen preview bij terminal services } - if (GetTickCount() - vw->m_Timer > 100) + if (GetTickCount() - vw->m_Timer > 333) { // Preview time // Tijdens het blitten willen we geen vertalingen CRect rc; @@ -225,7 +227,30 @@ void CSLNKDwfViewerView::DoPaint(CDCHandle dc) m_hDCOriginal = dc; // Hier gaan we wel progress op tekenen m_iWhip2DC.set_progress_action(my_progress_action, (void *) this); - ::PaintToDC(m_MemDC, m_dwfPath, m_nPage, m_iWhip2DC, wSize); + { + LARGE_INTEGER currTime; + LARGE_INTEGER endTime; + LARGE_INTEGER frequency; + if (!QueryPerformanceCounter(&currTime)) + return; + if (!QueryPerformanceFrequency(&frequency)) + return; + double tmStart = ((double)currTime.QuadPart)*1000/frequency.QuadPart; + + ::PaintToDC(m_MemDC, m_dwfPath, m_nPage, m_iWhip2DC, wSize); + if (!QueryPerformanceCounter(&endTime)) + return; + + if (!QueryPerformanceCounter(&currTime)) + return; + double tmEnd = ((double)currTime.QuadPart)*1000/frequency.QuadPart; + // En nu? + //LPCTSTR lpszMessage = _T("Hello, World"); + //::SendMessage(m_hWndStatusBar, SB_SETTEXT, 0, LPARAM(lpszMessage)); + CString s; + s.Format("Klaar in %.0lf ms", tmEnd - tmStart); + m_Parent.m_status.SetText(0, s); + } // Select the original bitmap back in m_MemDC.SelectBitmap(pOldBitmap); @@ -303,8 +328,8 @@ LRESULT CSLNKDwfViewerView::OnMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM lP CRect rc; GetClientRect(&rc); - CPoint newcenter(pt.x + (rc.right / 2.0 - pt.x) / zoom, - pt.y + (rc.bottom / 2.0 - pt.y) / zoom); + CPoint newcenter(pt.x + (rc.right / 2.0 - pt.x) / zoom + 0.5, + pt.y + (rc.bottom / 2.0 - pt.y) / zoom + 0.5); Zoom(newcenter, GetZoomScale() * zoom); @@ -353,7 +378,7 @@ LRESULT CSLNKDwfViewerView::OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lPa // SetCursor(::LoadCursor(AfxGetResourceHandle(), MAKEINTRESOURCE(IDC_HANDJE))); - SetScrollOffset(m_PanStartScroll + traveled); + SetScrollOffset(m_PanStartScroll + traveled); m_PanStartPoint = point; GetScrollOffset(m_PanStartScroll); } diff --git a/Viewer/SLNKDwfViewerView.h b/Viewer/SLNKDwfViewerView.h index a75db04..cdf6544 100644 --- a/Viewer/SLNKDwfViewerView.h +++ b/Viewer/SLNKDwfViewerView.h @@ -5,12 +5,13 @@ #pragma once #include "resource.h" -#include "atlgdix.h" +//#include "atlgdix.h" void PaintToDC(HDC dc, CString dwfPath, int nPage, CWhip2DCImpl &iWhip2DC, CSize wSize, BOOL forPrint = FALSE); +class CMainFrame; class CSLNKDwfViewerView : public CZoomScrollWindowImpl // , public CDoubleBufferImpl // , public COffscreenDraw @@ -19,9 +20,9 @@ class CSLNKDwfViewerView : public CZoomScrollWindowImpl public: DECLARE_WND_CLASS(NULL) - CSLNKDwfViewerView(); + //CSLNKDwfViewerView(); ~CSLNKDwfViewerView(); - + CSLNKDwfViewerView(CMainFrame& parent); BOOL PreTranslateMessage(MSG* pMsg); BEGIN_MSG_MAP(CSLNKDwfViewerView) @@ -90,4 +91,6 @@ private: CDCHandle m_hDCOriginal; static BOOL my_progress_action(void *param, double progress); time_t m_Timer; + + CMainFrame & m_Parent; }; diff --git a/Viewer/Viewer.vcproj b/Viewer/Viewer.vcproj index 12bff3c..9c66b2c 100644 --- a/Viewer/Viewer.vcproj +++ b/Viewer/Viewer.vcproj @@ -17,7 +17,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #include #include - +#include #include "atlrx.h" #include "../SLNKDWFImpl/SLNKDWFStaticRO.h" diff --git a/Viewer/mainfrm.h b/Viewer/mainfrm.h index 3b029b0..9eea43b 100644 --- a/Viewer/mainfrm.h +++ b/Viewer/mainfrm.h @@ -10,7 +10,7 @@ class CMainFrame : public CFrameWindowImpl, public CUpdateUI #include diff --git a/WincmdContent/filesys.vcproj b/WincmdContent/filesys.vcproj index aacce3f..3ff7012 100644 --- a/WincmdContent/filesys.vcproj +++ b/WincmdContent/filesys.vcproj @@ -49,7 +49,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="d:\Library\Wtl81\include;d:\Library\Dwf702\develop\global\src\dwf;d:\Library\Dwf702\develop\global\src\;.\CxImage\Zlib" + AdditionalIncludeDirectories="..\Wtl81\include;d:\Library\Dwf702\develop\global\src\dwf;d:\Library\Dwf702\develop\global\src\;.\CxImage\Zlib" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FILESYS_EXPORTS;;_CRT_SECURE_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="2" @@ -146,7 +146,7 @@