DefineSymbol levert voortaan zijn bounding contour als resultaat

Op contouren kun je via PountCount en PointItem de punten opvragen (in DWG coordinate)
Daarmee kun je uiteindelijk de bounding contour van een symbool aanpassen (fijnslijpen)

svn path=/Slnkdwf/trunk/; revision=18381
This commit is contained in:
Jos Groot Lipman
2013-07-07 15:36:05 +00:00
parent 742b659ae0
commit fc01e8cdc5
11 changed files with 159 additions and 96 deletions

View File

@@ -2,6 +2,7 @@
#include "stdafx.h"
#include "SLNKContour.h"
#include "DWGPoint.h"
#include "Whipfile.h"
// Merk op dat sommige functies ook nog in WhipFile zijn gedefinieerd. Die moeten daar weg omdat we
@@ -28,20 +29,20 @@ void CSLNKContour::calculateBounds()
WT_Point3D dwgPt;
CComQIPtr<IDWGPoint> pt;
dwgPt = m_SLNKContour->m_parentWhipFile->m_contunits.transform(bx.minpt());
dwgPt = m_SLNKContour->m_Units.transform(bx.minpt());
m_dwgBounding->get_min(&pt);
pt->put_DwgX(dwgPt.m_x);
pt->put_DwgY(dwgPt.m_y);
pt.Release();
dwgPt = m_SLNKContour->m_parentWhipFile->m_contunits.transform(bx.maxpt());
dwgPt = m_SLNKContour->m_Units.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(*m_SLNKContour);
dwgPt = m_SLNKContour->m_parentWhipFile->m_contunits.transform(lp);
dwgPt = m_SLNKContour->m_Units.transform(lp);
m_dwgCenter->put_DwgX(dwgPt.m_x);
m_dwgCenter->put_DwgY(dwgPt.m_y);
};
@@ -214,10 +215,39 @@ STDMETHODIMP CSLNKContour::put_Labelposition(BYTE newVal)
STDMETHODIMP CSLNKContour::AddPoint(DOUBLE pValX, DOUBLE pValY)
{
// Het lijkt nogal onzinnig m_SLNKContour zijn eigen m_contunits door te geven
// SLNKContourImpl.h heeft echter alleen een forward declaration naar CWhipFile
// en compile technisch werd het me anders te ingewikkeld.
m_SLNKContour->AddPoint(pValX, pValY, m_SLNKContour->m_parentWhipFile->m_contunits);
m_SLNKContour->AddPoint(pValX, pValY);
return S_OK;
};
STDMETHODIMP CSLNKContour::get_PointCount(LONG* pVal)
{
(*pVal) = m_SLNKContour->count();
return S_OK;
};
STDMETHODIMP CSLNKContour::get_PointItem(ULONG i, IDWGPoint** pVal)
{
if (i < 0 || i >= (ULONG)m_SLNKContour->count())
return E_INVALIDARG;
// calculateBounds();
CComObject<CDWGPoint> *thePoint;
HRESULT hr = CComObject<CDWGPoint>::CreateInstance(&thePoint);
if(FAILED(hr)) return hr;
thePoint->AddRef();
hr = thePoint->QueryInterface(IID_IDWGPoint, (void **)pVal);
//thePoint->SetParent(this);
thePoint->Release();
if(FAILED(hr)) return hr;
// TODO: Dit moeten de units van het symbool zijn, niet die van de parentWhipfile
WT_Point3D dwg = m_SLNKContour->m_Units.transform(m_SLNKContour->points()[i]);
thePoint->put_DwgX(dwg.m_x);
thePoint->put_DwgY(dwg.m_y);
return S_OK;
};

View File

@@ -110,6 +110,8 @@ public:
STDMETHOD(get_Labelposition)(BYTE* pVal);
STDMETHOD(put_Labelposition)(BYTE newVal);
STDMETHOD(AddPoint)(DOUBLE pValX, DOUBLE pValY);
STDMETHOD(get_PointCount)(LONG* pVal);
STDMETHOD(get_PointItem)(ULONG i, IDWGPoint** pVal);
};
//REMOVED OBJECT_ENTRY_AUTO(__uuidof(SLNKContour), CSLNKContour)

View File

@@ -52,7 +52,7 @@ interface IWhipFile : IDispatch{
[id(9), helpstring("method SetLabelPosition")] HRESULT SetLabelPosition([in, defaultvalue(1)] BYTE LabelPos);
[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);
[id(15), helpstring("method DefineSymbol")] HRESULT DefineSymbol([in] BSTR symbolName, [in] VARIANT EPlotStream, [out, retval] ISLNKContour** pContour);
[id(16), helpstring("method DefineBitmapSymbol")] HRESULT DefineBitmapSymbol([in] BSTR symbolName, [in] BSTR symbolPath, [in] DOUBLE height);
[propget, id(17), helpstring("property Contour")] HRESULT Contour([in] BSTR IdentLabel, [out, retval] ISLNKContour** pVal);
[id(18), helpstring("method SetFilterLayers")] HRESULT SetFilterLayers([in] BSTR reLayers);
@@ -250,6 +250,8 @@ interface ISLNKContour : IDispatch{
[propget, id(13), helpstring("property Fontheight")] HRESULT Fontheight([out, retval] DOUBLE* pVal);
[propput, id(13), helpstring("property Fontheight")] HRESULT Fontheight([in] DOUBLE pVal);
[id(14), helpstring("property AddPoint")] HRESULT AddPoint([in] DOUBLE pValX, [in] DOUBLE pValY);
[propget, id(15), helpstring("property PointCount")] HRESULT PointCount([out, retval] LONG* pVal);
[propget, id(16), helpstring("property PointItem")] HRESULT PointItem([in] ULONG i, [out, retval] IDWGPoint** pVal);
};
[
object,

View File

@@ -1,9 +1,9 @@
#include "StdAfx.h"
#include "myEPlotSection.h"
#include "SLNKSymbolDefImpl.h"
#include "../SLNKDWFImpl/CxImage\CxImage\ximage.h"
#include "../SLNKDWFImpl/Whip2DCImpl.h"
#include "SLNKContourImpl.h"
#include "SLNKSymbolDefImpl.h"
#include <math.h>
// Bij EPlotsection (external DWF)
@@ -17,28 +17,31 @@ CSLNKSymbolDefinition::CSLNKSymbolDefinition(CComQIPtr<IEPlotSection> EPlotSecti
m_AsBitmap = NULL;
m_BuiltIn = false;
m_hasBitmap = false;
calculateBoundary(m_BoundingContour);
//m_Origin = m_Center;
calculateBoundary(m_BoundingContour); // rekent ook BoundingContour.m_Units van het symbool uit
m_Origin = CSLNKContourImpl::Centroid(m_BoundingContour);
};
// Bij Contour list (builtin symbol)
CSLNKSymbolDefinition::CSLNKSymbolDefinition(int count, WT_Logical_Point const *points)
CSLNKSymbolDefinition::CSLNKSymbolDefinition(int count, WT_Logical_Point const *points, WT_Units units)
{
m_BuiltIn = true;
m_wtFile.set_eplotsection(NULL);
this->m_dwgScale = 1.0;
m_AsBitmap = NULL;
m_BoundingContour.m_Units = units;
m_BoundingContour.set(count, points, false);
m_Origin = CSLNKContourImpl::Centroid(m_BoundingContour);
};
// By bitmap
CSLNKSymbolDefinition::CSLNKSymbolDefinition(CString const filepath, double const height)
CSLNKSymbolDefinition::CSLNKSymbolDefinition(CString const filepath, double const height, WT_Units units)
{
m_wtFile.set_eplotsection(NULL);
m_AsBitmap = NULL;
m_BuiltIn = false;
m_BoundingContour.m_Units = units;
CxImage img;
if (!img.Load(filepath))
{ // Rood kruisje?
@@ -92,7 +95,7 @@ CSLNKSymbolDefinition::~CSLNKSymbolDefinition(void)
// http://geometryalgorithms.com/Archive/algorithm_0107/algorithm_0107.htm
// (v2: bounding convex hull waarschijnlijk overkill)
#include <assert.h>
WT_Result CSLNKSymbolDefinition::calculateBoundary (WT_Polygon &BoundingContour, WT_Transform *tm/*=null*/)
WT_Result CSLNKSymbolDefinition::calculateBoundary (CSLNKContourImpl &BoundingContour, WT_Transform *tm/*=null*/)
{
WT_Result result;
@@ -149,8 +152,8 @@ WT_Result CSLNKSymbolDefinition::calculateBoundary (WT_Polygon &BoundingContour,
}
ViewportDone = TRUE;
WT_Viewport *viewport = (WT_Viewport *)m_wtFile.current_object();
WT_Units symbolunits = viewport->viewport_units();
m_dwgScale = symbolunits.application_to_dwf_transform()(0,0); // Symbol's dScale
BoundingContour.m_Units = viewport->viewport_units(); // Die onthouden we
m_dwgScale = BoundingContour.m_Units.application_to_dwf_transform()(0,0); // Symbol's dScale
break;
}
break;
@@ -259,7 +262,6 @@ WT_Result CSLNKSymbolDefinition::calculateBoundary (WT_Polygon &BoundingContour,
WT_Logical_Point(Qmin2+Ymax+Qmin2, Ymax),
WT_Logical_Point(Xmin, Xmin-Qmin2-Qmin2),
WT_Logical_Point(Xmin, Pmin2-Xmin+Pmin2)};
m_Center = WT_Logical_Point(Xmin/2+Xmax/2,Ymin/2+Ymax/2);
BoundingContour.set(sizeof(pts3)/sizeof(pts3[0]), pts3, true);

View File

@@ -2,25 +2,26 @@
#include "Whiptk/whip_toolkit.h"
#include "myWT_File.h"
#include "SLNKContour.h"
class CSLNKSymbolDefinition
{
public:
CSLNKSymbolDefinition(CComQIPtr<IEPlotSection> EPlotSection);
CSLNKSymbolDefinition(int count, WT_Logical_Point const *points) ;
CSLNKSymbolDefinition(CString const filepath, double const height);
CSLNKSymbolDefinition(int count, WT_Logical_Point const *points, WT_Units units);
CSLNKSymbolDefinition(CString const filepath, double const height, WT_Units units);
~CSLNKSymbolDefinition(void);
CComQIPtr<IEPlotSection> m_iEPlotSection; // Om scope levend te houden
myWT_File m_wtFile; // Beetje redundant?
WT_Logical_Box m_BoundingBox;
WT_Polygon m_BoundingContour;
CSLNKContourImpl m_BoundingContour;
WT_Logical_Point m_Origin;
WT_Logical_Point m_Center; // Wordt gezet bij berekenen boundingcontour
double m_dwgScale;
WT_Drawable *asBitmap(int pixeldx, int pixeldy, long paperColor);
WT_Result serialize(WT_File & file, WT_Color pColor, BOOL pColorSet);
WT_Result calculateBoundary(WT_Polygon &m_BoundingContour, WT_Transform *tm=NULL);
WT_Result calculateBoundary(CSLNKContourImpl &m_BoundingContour, WT_Transform *tm=NULL);
bool m_hasBitmap; // Kunnen we moeilijk roteren
private:

View File

@@ -14,7 +14,7 @@ CSLNKSymbolImpl::~CSLNKSymbolImpl(void)
{
}
CSLNKSymbolImpl::CSLNKSymbolImpl(double dwgX, double dwgY, CWhipFile *whipfile)
CSLNKSymbolImpl::CSLNKSymbolImpl(double dwgX, double dwgY, WT_Units units)
{
m_dwgX = dwgX;
m_dwgY = dwgY;
@@ -22,7 +22,7 @@ CSLNKSymbolImpl::CSLNKSymbolImpl(double dwgX, double dwgY, CWhipFile *whipfile)
m_Rotation = 0;
m_Scale = 1.0;
m_ColorSet = false;
m_SLNKContour.m_parentWhipFile = whipfile;
m_SLNKContour.m_Units = units;
m_SLNKContour.m_fromSymbol=true;
m_SLNKContour.m_outlineColor.set(0,0,0,0); // alpha=0-->transparant
m_SLNKContour.m_Labelpos = CSLNKContourImpl::LABEL_OUTSIDEBOTTOM; // default voor symbolen

View File

@@ -8,7 +8,7 @@ class CSLNKSymbolImpl
public:
CSLNKSymbolImpl(void);
CSLNKSymbolImpl(double dwgX, double dwgY, CWhipFile *whipfile);
CSLNKSymbolImpl(double dwgX, double dwgY, WT_Units units);
WT_Result serialize (WT_File & file, WT_Units & units,
CSLNKSymbolDefinition *symbdef,
@@ -19,8 +19,7 @@ public:
~CSLNKSymbolImpl(void);
public:
double m_dwgX, m_dwgY;
//CString m_Label;
//CString m_Key;
CString m_symbolName;
int m_Rotation;
double m_Scale;

View File

@@ -86,16 +86,16 @@ CWhipFile::CWhipFile()
m_activeLayerName = "";
// Predefine fixed symbols
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(sizeof(star)/sizeof(star[0]), star);
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(sizeof(star)/sizeof(star[0]), star, m_contunits);
m_SLNKSymbolDefinitions.SetAt("*STAR", symb);
symb = new CSLNKSymbolDefinition(sizeof(octa)/sizeof(octa[0]), octa);
symb = new CSLNKSymbolDefinition(sizeof(octa)/sizeof(octa[0]), octa, m_contunits);
m_SLNKSymbolDefinitions.SetAt("*OCTAGON", symb);
symb = new CSLNKSymbolDefinition(sizeof(square)/sizeof(square[0]), square);
symb = new CSLNKSymbolDefinition(sizeof(square)/sizeof(square[0]), square, m_contunits);
m_SLNKSymbolDefinitions.SetAt("*SQUARE", symb);
symb = new CSLNKSymbolDefinition(sizeof(empty)/sizeof(empty[0]), empty);
symb = new CSLNKSymbolDefinition(sizeof(empty)/sizeof(empty[0]), empty, m_contunits);
m_SLNKSymbolDefinitions.SetAt("*EMPTY", symb);
}
@@ -409,14 +409,15 @@ WT_Result CWhipFile::my_process_polyline(WT_Polyline & polyline, WT_File & file)
xxxx++;
//WT_Units units=file.rendition().drawing_info().units(); werkt niet goed met paperspace
// Waarom zetten we hier m_contunits eigenlijk nog niet gewoon direct?
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, deze);
myContour = new CSLNKContourImpl(polyline.count()-1,polyline.points()+1, WD_True, units);
else
myContour = new CSLNKContourImpl(polyline.count(),polyline.points(), WD_True, deze);
myContour = new CSLNKContourImpl(polyline.count(),polyline.points(), WD_True, units);
// 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
@@ -438,7 +439,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, deze);
CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i, myContour->points(), WD_True, units);
// Als alle volgende punten binnen myContour2 vallen hebben we met een (komend) eiland te maken.
// Dan hebben we spijt en gaan toch niet splitsen
@@ -453,7 +454,7 @@ xxxx++;
continue;
}
// Create a copy of the end section
CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, deze);
CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-i, myContour->points()+i, WD_True, units);
// Omgekeerd: Als alle myContour2 punten binnen myContour3 vallen
// is het *eerste* stuk het eiland.
@@ -503,7 +504,7 @@ 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, deze);
CSLNKContourImpl *myContour2 = new CSLNKContourImpl(i-j+1, myContour->points()+j, WD_True, units);
myContour2->m_DWGArea = PolygonArea(myContour2, units);
deze->m_SLNKContouren.Add(myContour2);
@@ -512,7 +513,7 @@ xxxx++;
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, deze);
CSLNKContourImpl *myContour3 = new CSLNKContourImpl(myContour->count()-(i-j), myContour->points(), WD_True, units);
// Delete the old one (seem all together a little overkill)
delete myContour;
myContour = myContour3;
@@ -1078,7 +1079,7 @@ 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, this);
CSLNKSymbolImpl *mySymbol = new CSLNKSymbolImpl(dwgX, dwgY, m_contunits);
mySymbol->m_SLNKContour.m_Fontheight = m_FontHeightSymbols;
m_SLNKSymbols.Add(mySymbol);
@@ -1112,43 +1113,38 @@ STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName,
return S_OK;
}
STDMETHODIMP CWhipFile::DefineSymbol(BSTR symbolName, VARIANT EPlotStream)
STDMETHODIMP CWhipFile::DefineSymbol(BSTR symbolName, VARIANT EPlotStream, ISLNKContour** pContour)
{
myTRACE("\nDefining symbol %ls", symbolName);
if (EPlotStream.vt!=VT_ERROR)
{
VARIANT *var2 = &EPlotStream;
if (var2->vt==(VT_VARIANT|VT_BYREF)) // ByRef
var2 = (VARIANT *)var2->pvarVal;
if (EPlotStream.vt == VT_ERROR)
return E_INVALIDARG;
if (var2->vt==VT_DISPATCH)
{
CComQIPtr<IEPlotSection> EPlotSection;
EPlotSection = var2->pdispVal;
if (!EPlotSection)
return E_INVALIDARG;
else
{
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(EPlotSection);
VARIANT *var2 = &EPlotStream;
if (var2->vt==(VT_VARIANT|VT_BYREF)) // ByRef
var2 = (VARIANT *)var2->pvarVal;
CString name(symbolName);
m_SLNKSymbolDefinitions.SetAt(name, symb);
}
}
else
return E_INVALIDARG;
}
if (var2->vt!=VT_DISPATCH)
return E_INVALIDARG;
return S_OK;
CComQIPtr<IEPlotSection> EPlotSection;
EPlotSection = var2->pdispVal;
if (!EPlotSection)
return E_INVALIDARG;
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(EPlotSection);
CString name(symbolName);
m_SLNKSymbolDefinitions.SetAt(name, symb);
return return_ContourItem(&symb->m_BoundingContour, pContour); // Geef de contour terug in pcontour
}
STDMETHODIMP CWhipFile::DefineBitmapSymbol(BSTR symbolName, BSTR symbolPath, double height)
{
myTRACE("\nDefining bitmap symbol %ls", symbolName);
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(CString(symbolPath), height);
CSLNKSymbolDefinition * symb = new CSLNKSymbolDefinition(CString(symbolPath), height, m_contunits);
CString name(symbolName);
m_SLNKSymbolDefinitions.SetAt(name, symb);
//return E_INVALIDARG;
return S_OK;
}
@@ -1231,10 +1227,8 @@ STDMETHODIMP CWhipFile::get_ContourCount(LONG* pVal)
return S_OK;
}
STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal)
STDMETHODIMP CWhipFile::return_ContourItem(CSLNKContourImpl *pContour, ISLNKContour** pVal)
{
if (i < 0 || i >= m_SLNKContouren.GetCount())
return E_INVALIDARG;
CComObject<CSLNKContour> *theContour;
HRESULT hr = CComObject<CSLNKContour>::CreateInstance(&theContour);
if(FAILED(hr)) return hr;
@@ -1245,11 +1239,19 @@ STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal)
theContour->Release();
if(FAILED(hr)) return hr;
theContour->SetImpl(m_SLNKContouren[i]); // Heel belangrijk: zet de implementatie waar we een interface op bieden
theContour->SetImpl(pContour); // Heel belangrijk: zet de implementatie waar we een interface op bieden
return S_OK; // Wel gevonden
}
STDMETHODIMP CWhipFile::get_ContourItem(ULONG i, ISLNKContour** pVal)
{
if (i < 0 || i >= m_SLNKContouren.GetCount())
return E_INVALIDARG;
return return_ContourItem(m_SLNKContouren[i], pVal);
}
STDMETHODIMP CWhipFile::get_minContSize(DOUBLE* pVal)
{
(*pVal) = m_minContSize;
@@ -1267,8 +1269,10 @@ STDMETHODIMP CWhipFile::put_minContSize(DOUBLE newVal)
STDMETHODIMP CWhipFile::get_AddContour(ISLNKContour** pVal)
{
// Je mag eigenlijk geen echt lege contour doorgeven, daar assert de pointset.cpp op?
CSLNKContourImpl *myContour = new CSLNKContourImpl(sizeof(empty)/sizeof(empty[0]), empty, WD_True, this);
CSLNKContourImpl *myContour = new CSLNKContourImpl(sizeof(empty)/sizeof(empty[0]), empty, WD_True, m_contunits);
myContour->m_contLabel = "Dynamic"; // Anders wordt hij niet getekend uiteindelijk
myContour->m_isDynamic = false; // Klinkt tegenstrijdig maar zorgt dat eerste AddPoint de boel reset
this->m_SLNKContouren.Add(myContour);

View File

@@ -57,7 +57,7 @@ public:
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);
STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream, ISLNKContour** pContour);
STDMETHOD(DefineBitmapSymbol)(BSTR symbolName, BSTR symbolPath, DOUBLE height);
STDMETHOD(get_Contour)(BSTR IdentLabel, ISLNKContour** pVal);
STDMETHOD(SetFilterLayers)(BSTR reLayers);
@@ -96,6 +96,7 @@ public:
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);

View File

@@ -10,6 +10,9 @@
/*static*/ WT_Integer32 CSLNKContourImpl::m_next_node_num = 0; // Eigenlijk initialiseren op laatste van planfile
// Constructor voor symboldef's en symbolen
// Hier weten we vaak de contour polygon nog niet (of kunnen die pas later bepalen/
// invullen met transformatie)
CSLNKContourImpl::CSLNKContourImpl(void)
: m_DWGArea(-1), m_outlineColor(WT_RGBA32(128,128,128,255))
{
@@ -17,6 +20,26 @@ CSLNKContourImpl::CSLNKContourImpl(void)
m_Lineweight = 10.0; // 10mm default
m_Fontheight = 200.0;
m_Labelpos = LABEL_DEFAULT;
m_isDynamic = false;
}
// Constructor voor gescande contouren
CSLNKContourImpl::CSLNKContourImpl(
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. */
WT_Units units
)
: WT_Polygon(count, points, copy), m_outlineColor(128,128,128,255),
m_fromSymbol(false), m_onTop(false)
{
m_DWGArea = -1;
m_Color = WT_RGBA32(0,0,0,0); // alpha==0, 100% transparant
m_Lineweight = 10.0; // 10 mm default
m_Fontheight = 200.0;
m_Labelpos = LABEL_DEFAULT;
m_Units = units;
m_isDynamic = false;
}
CSLNKContourImpl::~CSLNKContourImpl(void)
@@ -686,7 +709,10 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFi
// Als eerste punt ongelijk aan laatste punt dan points() eentje uitbreiden
// De polygon sluit vanzelf wel maar deze polyline niet
if (count() > 2 && (points()[0].m_x != points()[count()-1].m_x || points()[0].m_y != points()[count()-1].m_y))
{
m_isDynamic = true; // Voorkom reset
AddPoint(points()[0]);
}
WT_Polyline my_line( count(), points(), WD_False);
my_line.serialize(file);
@@ -695,32 +721,36 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFi
return WT_Result::Success;
};
void CSLNKContourImpl::AddPoint(double pValX, double pValY, WT_Units units)
void CSLNKContourImpl::AddPoint(double pValX, double pValY)
{
AddPoint(units.transform(WT_Point3D(pValX, pValY)));
AddPoint(m_Units.transform(WT_Point3D(pValX, pValY)));
}
void CSLNKContourImpl::AddPoint(WT_Logical_Point pt)
{
bool wasEmpty = (points()[0].m_x == INT_MAX &&
points()[0].m_y == INT_MAX);
WT_Logical_Point *pts = new WT_Logical_Point[m_isDynamic?count()+1:1];
if (!pts)
throw WT_Result::Out_Of_Memory_Error;
// TODO: Overflow controle?
WT_Logical_Point *pts = new WT_Logical_Point[count()+1];
int i;
for (i = 0; i < count(); i++)
int i = 0;
if (m_isDynamic) // Dan hebben we al zinvolle punten
{
pts[i] = points()[i];
for (i = 0; i < count(); i++)
{
pts[i] = points()[i];
}
}
// Het nieuwe punt
pts[i] = pt;
// Bij wasEmpty het eerste dummy punt overslaan
set(wasEmpty?1:(count() + 1), &pts[wasEmpty?1:0], true);
set(m_isDynamic?(count() + 1):1, pts, true);
// Na elk punt voor de zekerheid area opnieuw?
if (wasEmpty)
if (!m_isDynamic)
m_ptLabel = points()[0];
delete[] pts;
m_isDynamic = true; // Zodat geen reset bij volgende punten toevoegen
}

View File

@@ -3,8 +3,6 @@
#define FONT_SIZER 1000
class CWhipFile; // Forward declaration
class CSLNKContourImpl :
public WT_Polygon
{
@@ -23,16 +21,8 @@ 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. */
CWhipFile *parent
)
: 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_Lineweight = 10.0; // 10 mm default
m_Fontheight = 200.0;
m_Labelpos = LABEL_DEFAULT;
m_parentWhipFile = parent;
}
WT_Units units
);
~CSLNKContourImpl(void);
public:
@@ -42,7 +32,9 @@ public:
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.
CWhipFile *m_parentWhipFile;
BOOL m_isDynamic; // Dan zal het eerste punt toevoegen niet meer alles resetten
WT_Units m_Units; // In welke eenheid zijn de LP coordinaten van deze contour?
// Zal voor symbooldefinities afwijken van de whipfile en symbool inserts
WT_Fill_Pattern m_Pattern;
WT_Logical_Point m_ptLabel; // Coordinates of the label
CString m_ShowLabel; // As will be shown
@@ -66,7 +58,7 @@ public:
int l_fontheight,
double scale,
HDC myDC, int width=-2);
void AddPoint(double pValX, double pValY, WT_Units units);
void AddPoint(double pValX, double pValY);
void AddPoint(WT_Logical_Point pt);
static WT_Integer32 m_next_node_num;
};