// WhipFile.h : Declaration of the CWhipFile #pragma once #include "resource.h" // main symbols #include "whiptk\whip_toolkit.h" #include "myWT_File.h" using namespace DWFCore; using namespace DWFToolkit; #include "SLNKContourImpl.h" #include "SLNKSymbol.h" #include "SLNKDWF.h" #define MAX_BUILDER 1000 // 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() { // // Maak object m_dwgLimits // CComObject *pBoundingBox; HRESULT hr = CComObject::CreateInstance(&pBoundingBox); if (FAILED(hr)) return hr; pBoundingBox->AddRef(); hr = pBoundingBox->QueryInterface(IID_IBoundingBox, (void **)&m_dwgLimits); pBoundingBox->Release(); if (FAILED(hr)) return hr; return S_OK; } void FinalRelease() { } public: STDMETHOD(Load)(BSTR WhipPath); STDMETHOD(LoadStream)(VARIANT EPlotStream); STDMETHOD(SetLayers)(BSTR reContouren, BSTR reLabels); STDMETHOD(SaveAs)(BSTR WhipPath, VARIANT_BOOL ascii); STDMETHOD(SaveAs2)(BSTR WhipPath, VARIANT_BOOL ascii); STDMETHOD(HighlightUnrecognized)(); STDMETHOD(SetLabelFont)(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols); STDMETHOD(SetSymbolFont)(BSTR FontName, DOUBLE FontHeight); STDMETHOD(SetLabelPosition)(BYTE LabelPos); STDMETHOD(get_AddSymbol)(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal); STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream, ISLNKContour** pContour); STDMETHOD(DefineW2DSymbol)(BSTR symbolName, BSTR WhipPath, ISLNKContour** pContour); STDMETHOD(DefineBitmapSymbol)(BSTR symbolName, BSTR symbolPath, DOUBLE height); STDMETHOD(SymbolOrigin)(BSTR symbolName, DOUBLE dwgX, DOUBLE dwgY); STDMETHOD(get_Contour)(BSTR IdentLabel, ISLNKContour** pVal); STDMETHOD(SetFilterLayers)(BSTR reLayers); STDMETHOD(get_FindInContour)(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal); STDMETHOD(get_AddContour)(ISLNKContour** pVal); STDMETHOD(get_UnmatchedLabels)(BSTR* pUnmatched); private: WT_String m_FontName, m_SymbolFontName; double m_FontHeight, m_FontHeightSymbols, m_SymbolFontHeight; CComQIPtr m_iEPlotSection; // Om scope levend te houden CComQIPtr m_dwgLimits; myWT_File m_W2DFile; long m_vdpi; WT_View m_view; // Initial view COLORREF m_forcePlanColor; BOOL m_forcePlan; WT_Logical_Point m_builder[MAX_BUILDER+1]; // om lijnstukken aan elkaar te plakken. 1000 lijkt me genoeg int m_builder_len; 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 bool pointnearend(CWhipFile *deze, WT_Units units, WT_Logical_Point & pt2); static void test_builder_now_complete(CWhipFile *deze, WT_Units &units); 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_outlineEllipse(WT_Outline_Ellipse & outlineEllipse, 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(return_ContourItem)(CSLNKContourImpl *pContour, ISLNKContour** pVal); STDMETHOD(get_minContSize)(DOUBLE* pVal); STDMETHOD(put_minContSize)(DOUBLE newVal); STDMETHOD(get_minMergeDistance)(DOUBLE* pVal); STDMETHOD(put_minMergeDistance)(DOUBLE newVal); STDMETHOD(get_flags)(LONG* pVal); STDMETHOD(put_flags)(LONG newVal); STDMETHOD(get_vectorDpi)(LONG* pVal); STDMETHOD(get_DwgLimits)(IBoundingBox** pVal); STDMETHOD(get_forcePlanColor)(LONG* pVal); STDMETHOD(put_forcePlanColor)(LONG newVal); // Voorheen WhipFileState public: ~CWhipFile() { for (size_t i=0; i mcUrl; return m_reContouren.Match(str, &mcUrl); } // Is dit een contourlabel laag BOOL labelMatch(const char* str) { CAtlREMatchContext<> mcUrl; return m_reLabels.Match(str, &mcUrl); } // Is dit een 'gewone' laag die in het resultaat moet verschijnen? BOOL layerMatch(const char* str) { CAtlREMatchContext<> mcUrl; return m_reLayers.Match(str, &mcUrl); } CAtlArray m_SLNKContouren; CAtlArray m_SLNKSymbols; CAtlMap m_SLNKSymbolDefinitions; CAtlArray m_SLNKLabels; CAtlArray m_UnmatchedLabels; WT_Units m_contunits; CString m_activeLayerName; BOOL m_contLayerActive; BOOL m_labelLayerActive; double m_hintScale; // Kunnen we gebruiken om symbolen te 'geeken' double m_minContSize; // Minimale oppervlakte om als contour te erkend worden double m_minMergeDistance; // Minimale afstand om lijnsegmenten te mergen long m_flags; BOOL m_forFind; // Extra info die we kunnen misbruiken private: CAtlRegExp<> m_reContouren; CAtlRegExp<> m_reLabels; CAtlRegExp<> m_reLayers; // Die met SaveAs moeten blijven WT_Integer32 m_next_node_num; const static WT_Logical_Point star[]; const static WT_Logical_Point octa[]; const static WT_Logical_Point square[]; const static WT_Logical_Point empty[]; }; OBJECT_ENTRY_AUTO(__uuidof(WhipFile), CWhipFile)