Fixjes in whipfile.AddContour
svn path=/Slnkdwf/trunk/; revision=18375
This commit is contained in:
@@ -14,27 +14,34 @@
|
||||
void CSLNKContour::SetImpl(CSLNKContourImpl * pSLNKContour)
|
||||
{
|
||||
m_SLNKContour = pSLNKContour;
|
||||
if (m_SLNKContour->m_fromSymbol) return; // Die zijn vast nog niet getransformeerd
|
||||
m_doneBounds = false;
|
||||
}
|
||||
|
||||
WT_Logical_Box bx = pSLNKContour->bounds();
|
||||
void CSLNKContour::calculateBounds()
|
||||
{
|
||||
if (m_doneBounds)
|
||||
return;
|
||||
m_doneBounds = true;
|
||||
|
||||
WT_Logical_Box bx = m_SLNKContour->bounds(); // Als je hierna nog punten toevoegt heb je een probleem
|
||||
|
||||
WT_Point3D dwgPt;
|
||||
CComQIPtr<IDWGPoint> pt;
|
||||
|
||||
dwgPt = pSLNKContour->m_parentWhipFile->m_contunits.transform(bx.minpt());
|
||||
dwgPt = m_SLNKContour->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_parentWhipFile->m_contunits.transform(bx.maxpt());
|
||||
dwgPt = m_SLNKContour->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_parentWhipFile->m_contunits.transform(lp);
|
||||
WT_Logical_Point lp = CSLNKContourImpl::Centroid(*m_SLNKContour);
|
||||
dwgPt = m_SLNKContour->m_parentWhipFile->m_contunits.transform(lp);
|
||||
m_dwgCenter->put_DwgX(dwgPt.m_x);
|
||||
m_dwgCenter->put_DwgY(dwgPt.m_y);
|
||||
};
|
||||
@@ -98,6 +105,7 @@ STDMETHODIMP CSLNKContour::get_Extents(IBoundingBox** pVal)
|
||||
if (m_SLNKContour->m_fromSymbol)
|
||||
return E_NOTIMPL; // (nog) niet op symbolen
|
||||
|
||||
calculateBounds();
|
||||
return m_dwgBounding->QueryInterface(IID_IBoundingBox, (void**)pVal);
|
||||
}
|
||||
|
||||
@@ -105,6 +113,8 @@ STDMETHODIMP CSLNKContour::get_Center(IDWGPoint** pVal)
|
||||
{
|
||||
if (m_SLNKContour->m_fromSymbol)
|
||||
return E_NOTIMPL; // (nog) niet op symbolen
|
||||
|
||||
calculateBounds();
|
||||
return m_dwgCenter->QueryInterface(IID_IDWGPoint, (void**)pVal);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,11 @@ END_COM_MAP()
|
||||
HRESULT hr = pParent->QueryInterface(IID_IWhipFile, (void **)&m_parent_iWhipFile);
|
||||
};
|
||||
void SetImpl(CSLNKContourImpl * pSLNKContour);
|
||||
void calculateBounds();
|
||||
|
||||
private:
|
||||
CSLNKContourImpl * m_SLNKContour;
|
||||
bool m_doneBounds; // zijn de volgende twee bepaald?
|
||||
CComQIPtr<IDWGPoint> m_dwgCenter;
|
||||
CComQIPtr<IBoundingBox> m_dwgBounding;
|
||||
CComQIPtr<IWhipFile> m_parent_iWhipFile; // Om scope levend te houden
|
||||
|
||||
@@ -682,6 +682,12 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFi
|
||||
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;
|
||||
|
||||
// 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))
|
||||
AddPoint(points()[0]);
|
||||
|
||||
WT_Polyline my_line( count(), points(), WD_False);
|
||||
my_line.serialize(file);
|
||||
}
|
||||
@@ -690,9 +696,16 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly, BOOL forFi
|
||||
};
|
||||
|
||||
void CSLNKContourImpl::AddPoint(double pValX, double pValY, WT_Units units)
|
||||
{
|
||||
AddPoint(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);
|
||||
|
||||
// TODO: Overflow controle?
|
||||
WT_Logical_Point *pts = new WT_Logical_Point[count()+1];
|
||||
int i;
|
||||
for (i = 0; i < count(); i++)
|
||||
@@ -700,7 +713,7 @@ void CSLNKContourImpl::AddPoint(double pValX, double pValY, WT_Units units)
|
||||
pts[i] = points()[i];
|
||||
}
|
||||
// Het nieuwe punt
|
||||
pts[i] = units.transform(WT_Point3D(pValX, pValY));
|
||||
pts[i] = pt;
|
||||
|
||||
// Bij wasEmpty het eerste dummy punt overslaan
|
||||
set(wasEmpty?1:(count() + 1), &pts[wasEmpty?1:0], true);
|
||||
@@ -710,5 +723,4 @@ void CSLNKContourImpl::AddPoint(double pValX, double pValY, WT_Units units)
|
||||
m_ptLabel = points()[0];
|
||||
|
||||
delete[] pts;
|
||||
|
||||
}
|
||||
@@ -67,5 +67,6 @@ public:
|
||||
double scale,
|
||||
HDC myDC, int width=-2);
|
||||
void AddPoint(double pValX, double pValY, WT_Units units);
|
||||
void AddPoint(WT_Logical_Point pt);
|
||||
static WT_Integer32 m_next_node_num;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user