v3.01 LabelRotation op contour ondersteund. Werkt (nog) alleen goed voor LabelPostion==2 (centroid)

en (nog) niet bij meerdere regels tekst.

svn path=/Slnkdwf/trunk/; revision=19817
This commit is contained in:
Jos Groot Lipman
2013-11-14 08:47:44 +00:00
parent 7d1ee93fa4
commit 8a9634c61c
3 changed files with 43 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
// Zorg dat versies alfabetisch altijd op elkaar volgen! // Zorg dat versies alfabetisch altijd op elkaar volgen!
#define SLNK_MAJOR_VERSION 3 #define SLNK_MAJOR_VERSION 3
#define SLNK_MINOR_VERSION 00 #define SLNK_MINOR_VERSION 01
#define SLNK_BUILD_VERSION 0 #define SLNK_BUILD_VERSION 0
// Define resource strings // Define resource strings

View File

@@ -386,16 +386,21 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
case CSLNKContourImpl::LABEL_DEFAULT: case CSLNKContourImpl::LABEL_DEFAULT:
break; break;
case CSLNKContourImpl::LABEL_TOPLEFT: // Iets naar rechtstonder moven case CSLNKContourImpl::LABEL_TOPLEFT: // Iets naar rechtstonder moven
{
ATLASSERT(myDC!=NULL);
CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
ptTxt.m_x += l_fontheight/4; ptTxt.m_x += l_fontheight/4;
ptTxt.m_y -= l_fontheight; ptTxt.m_y -= l_fontheight; // ptBR.cy; lijkt beter maar eigenlijk willen we de hoogte
// van de *eerste* regel er af trekken
break; break;
}
case CSLNKContourImpl::LABEL_OUTSIDERIGHT: // Iets naar rechts en verticaal centreren case CSLNKContourImpl::LABEL_OUTSIDERIGHT: // Iets naar rechts en verticaal centreren
{ {
// Eerst een keer simuleren om grootte te bepalen // Eerst een keer simuleren om grootte te bepalen
ATLASSERT(myDC!=NULL); ATLASSERT(myDC!=NULL);
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC); CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
width = (ptBR.m_x - ptTxt.m_x); width = ptBR.cx;
ptTxt.m_y -= (ptBR.m_y - ptTxt.m_y)/2 + l_fontheight*9/10; ptTxt.m_y -= ptBR.cy + l_fontheight*9/10;
ptTxt.m_x += l_fontheight/4; ptTxt.m_x += l_fontheight/4;
break; break;
} }
@@ -403,10 +408,10 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
{ {
// Eerst een keer simuleren om grootte te bepalen // Eerst een keer simuleren om grootte te bepalen
ATLASSERT(myDC!=NULL); ATLASSERT(myDC!=NULL);
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC); CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
width = (ptBR.m_x - ptTxt.m_x); width = ptBR.cx;
ptTxt.m_y -= l_fontheight; ptTxt.m_y -= l_fontheight;
ptTxt.m_x -= (ptBR.m_x - ptTxt.m_x)/2; ptTxt.m_x -= width/2;
break; break;
} }
case CSLNKContourImpl::LABEL_CENTROID: case CSLNKContourImpl::LABEL_CENTROID:
@@ -415,10 +420,16 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
if (!CSLNKContourImpl::PointInPolygon(ptTxt, *this)) if (!CSLNKContourImpl::PointInPolygon(ptTxt, *this))
ptTxt = LabelPosition(CSLNKContourImpl::LABEL_DEFAULT); ptTxt = LabelPosition(CSLNKContourImpl::LABEL_DEFAULT);
// Eerst een keer simuleren om grootte te bepalen // Eerst een keer simuleren om grootte te bepalen
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC); CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
width = (ptBR.m_x - ptTxt.m_x); width = ptBR.cx;
ptTxt.m_x -= (ptBR.m_x - ptTxt.m_x)/2; double dx = width / 2.0;
ptTxt.m_y -= (ptBR.m_y - ptTxt.m_y)/2 + l_fontheight*9/10; double dy = ptBR.cy / 2.0;
// m_LabelRotation meerekenen
double radian = m_LabelRotation / 180.0 * PI;
int rdx = myRound(dx * cos(radian) - dy * sin(radian));
int rdy = myRound(dy * cos(radian) + dx * sin(radian));
ptTxt.m_x -= rdx;
ptTxt.m_y -= rdy;
// Nooit verder naar links/boven dan TOPLEFT zou doen // Nooit verder naar links/boven dan TOPLEFT zou doen
// JGL: jul 2007: Waarom niet? Bij heel kleine ruimtes mag bij centreren de boel er best wel iets buiten // JGL: jul 2007: Waarom niet? Bij heel kleine ruimtes mag bij centreren de boel er best wel iets buiten
// WT_Logical_Point ptTL = LabelPosition(CSLNKContourImpl::LABEL_TOPLEFT); // WT_Logical_Point ptTL = LabelPosition(CSLNKContourImpl::LABEL_TOPLEFT);
@@ -440,7 +451,7 @@ pm.serialize(my_file);
// is the calculated bottomright of the full text // is the calculated bottomright of the full text
// Als width==-1 is centreren niet mogelijk/nodig // Als width==-1 is centreren niet mogelijk/nodig
// Als width>0 is centreren mogelijk via [c] // Als width>0 is centreren mogelijk via [c]
WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file, CSize CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
WT_Logical_Point ptTxt, WT_Logical_Point ptTxt,
CString tok, CString tok,
int l_fontheight, int l_fontheight,
@@ -449,6 +460,7 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
int width/*=-2*/)// Voor centreren. Moet aanroeper al een keer bepaald hebben int width/*=-2*/)// Voor centreren. Moet aanroeper al een keer bepaald hebben
{ {
long max_width=0; // Bepaal hiermee 'rechtsonder' van de tekst als myDC long max_width=0; // Bepaal hiermee 'rechtsonder' van de tekst als myDC
long tot_height=0; // Bepaal hiermee 'rechtsonder' van de tekst als myDC
my_file.desired_rendition().font().height() = l_fontheight; my_file.desired_rendition().font().height() = l_fontheight;
//TODO: UBB sluitcodes ondersteunen //TODO: UBB sluitcodes ondersteunen
@@ -456,6 +468,10 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
CString token = tok.Tokenize("\n", curpos); CString token = tok.Tokenize("\n", curpos);
int line = 0; int line = 0;
bool centering=false; bool centering=false;
if (m_LabelRotation != 0)
{
my_file.desired_rendition().font().rotation().set((int)(m_LabelRotation * 65536 / 360));
}
while( token != "" ) while( token != "" )
{ {
// invariant (ook bij binnenkomst): ptTxt.m_y bevat het linksonderpunt van de huidige regel // invariant (ook bij binnenkomst): ptTxt.m_y bevat het linksonderpunt van de huidige regel
@@ -534,7 +550,11 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
else else
thisLineHeight = myRound(double(size)*l_fontheight/100); thisLineHeight = myRound(double(size)*l_fontheight/100);
ptTxt.m_y -= (thisLineHeight - l_fontheight); // Correctie op de invariant voor huidige regel // Correctie op de invariant voor huidige regel
// De *eerste* regel moet je echter maar voor de aanroep opgelost hebben
if (line > 0)
ptTxt.m_y -= (thisLineHeight - l_fontheight);
if (width != -2) if (width != -2)
my_file.desired_rendition().font().height() = thisLineHeight; my_file.desired_rendition().font().height() = thisLineHeight;
} }
@@ -594,8 +614,9 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
token = tok.Tokenize("\n", curpos); token = tok.Tokenize("\n", curpos);
ptTxt.m_y -= l_fontheight + skipextra; ptTxt.m_y -= l_fontheight + skipextra;
tot_height += thisLineHeight;
} }
return WT_Logical_Point(ptTxt.m_x+MulDiv(max_width,l_fontheight,FONT_SIZER), ptTxt.m_y); return CSize(MulDiv(max_width,l_fontheight,FONT_SIZER), tot_height);
} }
/**************************************************************************** /****************************************************************************

View File

@@ -33,7 +33,7 @@ public:
BOOL m_onTop; // Deze wordt later (bovenop) getekend dan degene die niet onTop hebben 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. BOOL m_fromSymbol; // Dan zijn onze bounds maar matig betrouwbaar zo lang ze niet getransformeerd zijn.
BOOL m_isDynamic; // Dan zal het eerste punt toevoegen niet meer alles resetten 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? WT_Units m_Units; // In welke eenheid zijn de LP coordinaten van deze contour?
// Zal voor symbooldefinities afwijken van de whipfile en symbool inserts // Zal voor symbooldefinities afwijken van de whipfile en symbool inserts
WT_Fill_Pattern m_Pattern; WT_Fill_Pattern m_Pattern;
WT_Logical_Point m_ptLabel; // Coordinates of the label WT_Logical_Point m_ptLabel; // Coordinates of the label
@@ -53,12 +53,12 @@ public:
static WT_Logical_Point Centroid(const WT_Point_Set &pg); static WT_Logical_Point Centroid(const WT_Point_Set &pg);
WT_Logical_Point LabelPosition(LABELPOS pos = LABEL_DEFAULT); WT_Logical_Point LabelPosition(LABELPOS pos = LABEL_DEFAULT);
void SerializeLabel(WT_File &my_file, double scale, HDC myDC); void SerializeLabel(WT_File &my_file, double scale, HDC myDC);
WT_Logical_Point DrawOneLabel(WT_File &my_file, CSize DrawOneLabel(WT_File &my_file,
WT_Logical_Point ptTxt, WT_Logical_Point ptTxt,
CString tok, CString tok,
int l_fontheight, int l_fontheight,
double scale, double scale,
HDC myDC, int width=-2); HDC myDC, int width=-2);
void AddPoint(double pValX, double pValY); void AddPoint(double pValX, double pValY);
void AddPoint(WT_Logical_Point pt); void AddPoint(WT_Logical_Point pt);
static WT_Integer32 m_next_node_num; static WT_Integer32 m_next_node_num;