169 lines
5.3 KiB
C++
169 lines
5.3 KiB
C++
// 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"
|
|
|
|
// CWhipFile
|
|
class ATL_NO_VTABLE CWhipFile :
|
|
public CComObjectRootEx<CComSingleThreadModel>,
|
|
public CComCoClass<CWhipFile, &CLSID_WhipFile>,
|
|
public ISupportErrorInfo,
|
|
public IDispatchImpl<IWhipFile, &IID_IWhipFile, &LIBID_SLNKDWFLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
|
|
{
|
|
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(HighlightUnrecognized)();
|
|
STDMETHOD(SetLabelFont)(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols);
|
|
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(get_Contour)(BSTR IdentLabel, ISLNKContour** pVal);
|
|
STDMETHOD(SetFilterLayers)(BSTR reLayers);
|
|
STDMETHOD(get_FindInContour)(DOUBLE dwgX, DOUBLE dwgY, BSTR* pVal);
|
|
STDMETHOD(get_AddContour)(ISLNKContour** pVal);
|
|
|
|
private:
|
|
|
|
WT_String m_FontName;
|
|
double m_FontHeight, m_FontHeightSymbols;
|
|
|
|
CComQIPtr<IEPlotSection> 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(return_ContourItem)(CSLNKContourImpl *pContour, ISLNKContour** pVal);
|
|
STDMETHOD(get_minContSize)(DOUBLE* pVal);
|
|
STDMETHOD(put_minContSize)(DOUBLE newVal);
|
|
|
|
// Voorheen WhipFileState
|
|
public:
|
|
~CWhipFile()
|
|
{
|
|
for (size_t i=0; i<m_SLNKContouren.GetCount(); i++)
|
|
delete m_SLNKContouren[i];
|
|
|
|
for (size_t i=0; i<m_SLNKSymbols.GetCount(); i++)
|
|
delete m_SLNKSymbols[i];
|
|
|
|
POSITION pos;
|
|
CString key;
|
|
CSLNKSymbolDefinition * value;
|
|
pos = m_SLNKSymbolDefinitions.GetStartPosition();
|
|
// Now iterate the map, element by element
|
|
while (pos != NULL) {
|
|
key = m_SLNKSymbolDefinitions.GetKeyAt(pos);
|
|
value = m_SLNKSymbolDefinitions.GetNextValue(pos);
|
|
delete value;
|
|
}
|
|
}
|
|
// Is dit een contour laag
|
|
BOOL contMatch(const char* str)
|
|
{
|
|
CAtlREMatchContext<> 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<CSLNKContourImpl *> m_SLNKContouren;
|
|
CAtlArray<CSLNKSymbolImpl *> m_SLNKSymbols;
|
|
CAtlMap<CString, CSLNKSymbolDefinition *> m_SLNKSymbolDefinitions;
|
|
CAtlArray<WT_Text> m_SLNKLabels;
|
|
|
|
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
|
|
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)
|