Files
Slnkdwf/SlnkDWFCom/WhipFile.h
Jos Groot Lipman 80d0142c23 SLNKDWF 2.00
svn path=/Slnkdwf/trunk/; revision=12481
2007-08-01 13:42:28 +00:00

194 lines
5.6 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"
class CWhipFileState
{
public:
CWhipFileState()
{
m_reContouren.Parse(".*", FALSE);
m_reLabels.Parse(".*", FALSE);
m_reLayers.Parse(".*", FALSE);
m_hintScale = -1.0;
};
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;
}
BOOL SetFilterLayers(BSTR reLayers)
{
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()
{
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;
BOOL contLayerActive;
BOOL labelLayerActive;
double m_hintScale; // Kunnen we gebruiken om symbolen te 'geeken'
private:
CAtlRegExp<> m_reContouren;
CAtlRegExp<> m_reLabels;
CAtlRegExp<> m_reLayers; // Die met SaveAs moeten blijven
};
// 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(SetLabel)(BSTR IdentLabel, BSTR ExtraLabel);
STDMETHOD(SetColor)(BSTR IdentLabel, ULONG rgb, BYTE Alpha);
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, IUnknown** pVal);
STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream);
STDMETHOD(DefineBitmapSymbol)(BSTR symbolName, BSTR symbolPath, DOUBLE height);
STDMETHOD(get_Contour)(BSTR IdentLabel, IUnknown** 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<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);
};
OBJECT_ENTRY_AUTO(__uuidof(WhipFile), CWhipFile)