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:
@@ -1,6 +1,6 @@
|
||||
// Zorg dat versies alfabetisch altijd op elkaar volgen!
|
||||
#define SLNK_MAJOR_VERSION 3
|
||||
#define SLNK_MINOR_VERSION 00
|
||||
#define SLNK_MINOR_VERSION 01
|
||||
#define SLNK_BUILD_VERSION 0
|
||||
|
||||
// Define resource strings
|
||||
|
||||
@@ -386,16 +386,21 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
|
||||
case CSLNKContourImpl::LABEL_DEFAULT:
|
||||
break;
|
||||
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_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;
|
||||
}
|
||||
case CSLNKContourImpl::LABEL_OUTSIDERIGHT: // Iets naar rechts en verticaal centreren
|
||||
{
|
||||
// Eerst een keer simuleren om grootte te bepalen
|
||||
ATLASSERT(myDC!=NULL);
|
||||
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = (ptBR.m_x - ptTxt.m_x);
|
||||
ptTxt.m_y -= (ptBR.m_y - ptTxt.m_y)/2 + l_fontheight*9/10;
|
||||
CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = ptBR.cx;
|
||||
ptTxt.m_y -= ptBR.cy + l_fontheight*9/10;
|
||||
ptTxt.m_x += l_fontheight/4;
|
||||
break;
|
||||
}
|
||||
@@ -403,10 +408,10 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
|
||||
{
|
||||
// Eerst een keer simuleren om grootte te bepalen
|
||||
ATLASSERT(myDC!=NULL);
|
||||
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = (ptBR.m_x - ptTxt.m_x);
|
||||
CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = ptBR.cx;
|
||||
ptTxt.m_y -= l_fontheight;
|
||||
ptTxt.m_x -= (ptBR.m_x - ptTxt.m_x)/2;
|
||||
ptTxt.m_x -= width/2;
|
||||
break;
|
||||
}
|
||||
case CSLNKContourImpl::LABEL_CENTROID:
|
||||
@@ -415,10 +420,16 @@ void CSLNKContourImpl::SerializeLabel(WT_File &my_file,
|
||||
if (!CSLNKContourImpl::PointInPolygon(ptTxt, *this))
|
||||
ptTxt = LabelPosition(CSLNKContourImpl::LABEL_DEFAULT);
|
||||
// Eerst een keer simuleren om grootte te bepalen
|
||||
WT_Logical_Point ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = (ptBR.m_x - ptTxt.m_x);
|
||||
ptTxt.m_x -= (ptBR.m_x - ptTxt.m_x)/2;
|
||||
ptTxt.m_y -= (ptBR.m_y - ptTxt.m_y)/2 + l_fontheight*9/10;
|
||||
CSize ptBR = DrawOneLabel(my_file, ptTxt, tok, l_fontheight, scale, myDC);
|
||||
width = ptBR.cx;
|
||||
double dx = width / 2.0;
|
||||
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
|
||||
// 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);
|
||||
@@ -440,7 +451,7 @@ pm.serialize(my_file);
|
||||
// is the calculated bottomright of the full text
|
||||
// Als width==-1 is centreren niet mogelijk/nodig
|
||||
// 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,
|
||||
CString tok,
|
||||
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
|
||||
{
|
||||
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;
|
||||
|
||||
//TODO: UBB sluitcodes ondersteunen
|
||||
@@ -456,6 +468,10 @@ WT_Logical_Point CSLNKContourImpl::DrawOneLabel(WT_File &my_file,
|
||||
CString token = tok.Tokenize("\n", curpos);
|
||||
int line = 0;
|
||||
bool centering=false;
|
||||
if (m_LabelRotation != 0)
|
||||
{
|
||||
my_file.desired_rendition().font().rotation().set((int)(m_LabelRotation * 65536 / 360));
|
||||
}
|
||||
while( token != "" )
|
||||
{
|
||||
// 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
|
||||
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)
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
static WT_Logical_Point Centroid(const WT_Point_Set &pg);
|
||||
WT_Logical_Point LabelPosition(LABELPOS pos = LABEL_DEFAULT);
|
||||
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,
|
||||
CString tok,
|
||||
int l_fontheight,
|
||||
|
||||
Reference in New Issue
Block a user