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

@@ -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)
@@ -682,11 +705,14 @@ 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))
{
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;
};