v2.10 Symbool rotatie
svn path=/Slnkdwf/trunk/; revision=12485
This commit is contained in:
@@ -188,6 +188,7 @@ bool CDWFFileImpl::Save()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CDWFFileImpl::Open(const CString &DWFPath)
|
||||
{
|
||||
@@ -247,7 +248,6 @@ bool CDWFFileImpl::Open(const CString &DWFPath)
|
||||
throw myCString ("\nCDWFFileImpl::Open('%s')\n%s", DWFPath, err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DESIRED_CODE(WHIP_OUTPUT)
|
||||
bool CDWFFileImpl::get_PropertiesXML(CString & pVal)
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "slnkcontourImpl.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define PALETTE_RED 1 // Color in the default colormap is red.
|
||||
|
||||
/*static*/ WT_Integer32 CSLNKContourImpl::m_next_node_num = 0; // Eigenlijk initialiseren op laatste van planfile
|
||||
@@ -61,9 +65,187 @@ BOOL CSLNKContourImpl::PointInPolygon(const CPoint pt, const CPoint *ps, int siz
|
||||
return c;
|
||||
}
|
||||
|
||||
// http://www.codeguru.com/forum/printthread.php?t=194400
|
||||
void DistanceFromLine(double cx, double cy, double ax, double ay ,
|
||||
double bx, double by, double &distanceSegment,
|
||||
double &distanceLine)
|
||||
{
|
||||
|
||||
//
|
||||
// find the distance from the point (cx,cy) to the line
|
||||
// determined by the points (ax,ay) and (bx,by)
|
||||
//
|
||||
// distanceSegment = distance from the point to the line segment
|
||||
// distanceLine = distance from the point to the line (assuming
|
||||
// infinite extent in both directions
|
||||
//
|
||||
|
||||
/*
|
||||
|
||||
Subject 1.02: How do I find the distance from a point to a line?
|
||||
|
||||
|
||||
Let the point be C (Cx,Cy) and the line be AB (Ax,Ay) to (Bx,By).
|
||||
Let P be the point of perpendicular projection of C on AB. The parameter
|
||||
r, which indicates P's position along AB, is computed by the dot product
|
||||
of AC and AB divided by the square of the length of AB:
|
||||
|
||||
(1) AC dot AB
|
||||
r = ---------
|
||||
||AB||^2
|
||||
|
||||
r has the following meaning:
|
||||
|
||||
r=0 P = A
|
||||
r=1 P = B
|
||||
r<0 P is on the backward extension of AB
|
||||
r>1 P is on the forward extension of AB
|
||||
0<r<1 P is interior to AB
|
||||
|
||||
The length of a line segment in d dimensions, AB is computed by:
|
||||
|
||||
L = sqrt( (Bx-Ax)^2 + (By-Ay)^2 + ... + (Bd-Ad)^2)
|
||||
|
||||
so in 2D:
|
||||
|
||||
L = sqrt( (Bx-Ax)^2 + (By-Ay)^2 )
|
||||
|
||||
and the dot product of two vectors in d dimensions, U dot V is computed:
|
||||
|
||||
D = (Ux * Vx) + (Uy * Vy) + ... + (Ud * Vd)
|
||||
|
||||
so in 2D:
|
||||
|
||||
D = (Ux * Vx) + (Uy * Vy)
|
||||
|
||||
So (1) expands to:
|
||||
|
||||
(Cx-Ax)(Bx-Ax) + (Cy-Ay)(By-Ay)
|
||||
r = -------------------------------
|
||||
L^2
|
||||
|
||||
The point P can then be found:
|
||||
|
||||
Px = Ax + r(Bx-Ax)
|
||||
Py = Ay + r(By-Ay)
|
||||
|
||||
And the distance from A to P = r*L.
|
||||
|
||||
Use another parameter s to indicate the location along PC, with the
|
||||
following meaning:
|
||||
s<0 C is left of AB
|
||||
s>0 C is right of AB
|
||||
s=0 C is on AB
|
||||
|
||||
Compute s as follows:
|
||||
|
||||
(Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
|
||||
s = -----------------------------
|
||||
L^2
|
||||
|
||||
|
||||
Then the distance from C to P = |s|*L.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
double r_numerator = (cx-ax)*(bx-ax) + (cy-ay)*(by-ay);
|
||||
double r_denomenator = (bx-ax)*(bx-ax) + (by-ay)*(by-ay);
|
||||
double r = r_numerator / r_denomenator;
|
||||
//
|
||||
double px = ax + r*(bx-ax);
|
||||
double py = ay + r*(by-ay);
|
||||
//
|
||||
double s = ((ay-cy)*(bx-ax)-(ax-cx)*(by-ay) ) / r_denomenator;
|
||||
|
||||
distanceLine = fabs(s)*sqrt(r_denomenator);
|
||||
|
||||
//
|
||||
// (xx,yy) is the point on the lineSegment closest to (cx,cy)
|
||||
//
|
||||
double xx = px;
|
||||
double yy = py;
|
||||
|
||||
if ( (r >= 0) && (r <= 1) )
|
||||
{
|
||||
distanceSegment = distanceLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
double dist1 = (cx-ax)*(cx-ax) + (cy-ay)*(cy-ay);
|
||||
double dist2 = (cx-bx)*(cx-bx) + (cy-by)*(cy-by);
|
||||
if (dist1 < dist2)
|
||||
{
|
||||
xx = ax;
|
||||
yy = ay;
|
||||
distanceSegment = sqrt(dist1);
|
||||
}
|
||||
else
|
||||
{
|
||||
xx = bx ;
|
||||
yy = by;
|
||||
distanceSegment = sqrt(dist2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Vind de hoek van de edge van ps die het dichts bij pt ligt
|
||||
// (het maakt ons niet uit of pt er binnen of buiten ligt)
|
||||
// A = P2Y - P1Y
|
||||
// B = P1X - P2X
|
||||
// C = P2X * P1Y - P2Y * P1X
|
||||
// DistToLine = Abs((A * PX + B * PY + C) / Sqr(A * A + B * B))
|
||||
/*static*/ void CSLNKContourImpl::EdgeAngle(const WT_Logical_Point pt, const WT_Point_Set &ps, double &EdgeAngle, double &EdgeDistance)
|
||||
{
|
||||
double ptx = pt.m_x;
|
||||
double pty = pt.m_y;
|
||||
int i, j, c = 0;
|
||||
double minDistSeg = 0x7FFFFFFF; // Max WT_Integer32
|
||||
double minDistLine;
|
||||
double angle = 0.0;
|
||||
myTRACE("\npt = %d,%d", pt.m_x, pt.m_y);
|
||||
for (i = 0, j = ps.count()-1; i < ps.count(); j = i++) {
|
||||
WT_Logical_Point pt1 = ps.points()[i];
|
||||
WT_Logical_Point pt2 = ps.points()[j];
|
||||
double DistSeg, DistLine;
|
||||
DistanceFromLine(pt.m_x, pt.m_y,
|
||||
pt1.m_x, pt1.m_y,
|
||||
pt2.m_x, pt2.m_y,
|
||||
DistSeg, DistLine);
|
||||
|
||||
// Bij een 'ingedeukte' ruimte kan DistSeg == minDistSeg zijn. Dan wil
|
||||
// je juist een zo'n groot mogelijke afstand tot de virtuele projectie
|
||||
if (DistSeg < minDistSeg || (DistSeg == minDistSeg && DistLine > minDistLine))
|
||||
{
|
||||
long dy = pt2.m_y - pt1.m_y;
|
||||
long dx = pt2.m_x - pt1.m_x;
|
||||
|
||||
//ASSERT(!(dx == 0 && dy == 0));
|
||||
|
||||
angle = atan2((double)dy, (double)dx) * (180 / PI); // Tussen -180 en +180
|
||||
if (dy==0) if (dx<0) angle=-180; else angle=0;
|
||||
|
||||
myTRACE("\nDist %.1f angle set to: %.3f", DistSeg, angle);
|
||||
minDistSeg = DistSeg;
|
||||
minDistLine = DistLine;
|
||||
}
|
||||
}
|
||||
if (DWFArea(ps) < 0)
|
||||
EdgeAngle = angle;
|
||||
else
|
||||
EdgeAngle = 180+angle;
|
||||
if (EdgeAngle < 0) EdgeAngle += 360;
|
||||
EdgeDistance = minDistLine; //We rekenen met Seg maar projecteren uiteindelijk op Line
|
||||
}
|
||||
|
||||
// Signed Area needed for centroid!
|
||||
// Negative is clockwise, Positve counterclockwise
|
||||
/*static*/double CSLNKContourImpl::DWFArea(const WT_Polygon &pg)
|
||||
/*static*/double CSLNKContourImpl::DWFArea(const WT_Point_Set &pg)
|
||||
{
|
||||
int i;
|
||||
double area = 0;
|
||||
@@ -121,7 +303,7 @@ WT_Logical_Point CSLNKContourImpl::LabelPosition(LABELPOS pos /*= LABEL_DEFAULT*
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/WT_Logical_Point CSLNKContourImpl::Centroid(const WT_Polygon &pg)
|
||||
/*static*/WT_Logical_Point CSLNKContourImpl::Centroid(const WT_Point_Set &pg)
|
||||
{
|
||||
double ptx = 0;
|
||||
double pty = 0;
|
||||
@@ -393,11 +575,14 @@ WT_Result CSLNKContourImpl::serialize(WT_File & file, BOOL solidOnly)
|
||||
{
|
||||
if (!m_fromSymbol && m_contLabel == "" && !solidOnly) // Alleen bij tweede slag
|
||||
{ // May very well be a textobject itself, just emit it
|
||||
#ifdef _DEBUG
|
||||
// niet meer in release-mode
|
||||
file.desired_rendition().color() =
|
||||
WT_Color(PALETTE_RED, file.desired_rendition().color_map());
|
||||
file.desired_rendition().line_weight() = 0;
|
||||
WT_Polyline my_line( count(), points(), WD_False);
|
||||
my_line.serialize(file);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ // We have got a proper label/contour
|
||||
|
||||
@@ -48,8 +48,9 @@ public:
|
||||
WT_Result serialize(WT_File & file, BOOL solidOnly);
|
||||
static BOOL PointInPolygon(const WT_Logical_Point pt, const WT_Point_Set &ps);
|
||||
static BOOL PointInPolygon(const CPoint pt, const CPoint *ps, int size);
|
||||
static double DWFArea(const WT_Polygon &pg);
|
||||
static WT_Logical_Point Centroid(const WT_Polygon &pg);
|
||||
static void EdgeAngle(const WT_Logical_Point pt, const WT_Point_Set &ps, double &EdgeAngle, double &EdgeDistance);
|
||||
static double DWFArea(const WT_Point_Set &pg);
|
||||
static WT_Logical_Point Centroid(const WT_Point_Set &pg);
|
||||
WT_Logical_Point LabelPosition(LABELPOS pos = LABEL_DEFAULT);
|
||||
void SerializeLabel(WT_File &my_file, LABELPOS pos,
|
||||
int fontheight,
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
Name="SLNKDWFStaticRW"
|
||||
ProjectGUID="{6EA5FCEC-1DB0-4542-8E41-9423021BD460}"
|
||||
RootNamespace="SLNKDWF"
|
||||
|
||||
|
||||
|
||||
|
||||
Keyword="AtlProj"
|
||||
>
|
||||
<Platforms>
|
||||
|
||||
@@ -20,7 +20,7 @@ STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream,
|
||||
const CString &WhipPath,
|
||||
const CString & RegExp, long sizeX, long sizeY,
|
||||
VARIANT_BOOL centerImage, VARIANT_BOOL maximize,/*=FALSE*/
|
||||
double dwgScale/*=0.0*/)
|
||||
double dwgScale/*=0.0*/, long lRotation /*=0*/)
|
||||
{
|
||||
m_State.Reset();
|
||||
|
||||
@@ -29,6 +29,7 @@ STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream,
|
||||
m_State.m_Layernames.RemoveAll();
|
||||
m_State.m_centerImage = centerImage;
|
||||
m_State.m_Maximize = maximize;
|
||||
m_State.m_lRotation = lRotation;
|
||||
|
||||
m_iEPlotSection = EPlotStream;
|
||||
|
||||
@@ -47,6 +48,8 @@ STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream,
|
||||
// tussen DWF units en device units
|
||||
// maximize: Voor (draggable) symbolen moeten we de exacte extents/bounds weten
|
||||
// van de drawable entiteiten en doorzoeken we gegarandeerd de hele tekening
|
||||
// TODO: Om helemaal bij client-side aan te sluiten moeten we de
|
||||
// de extents van ((de extents van de boudingbox rechtop) geroteerd) gebruiken
|
||||
myWT_File my_input_file; // input file.
|
||||
if (m_iEPlotSection)
|
||||
{
|
||||
@@ -58,6 +61,16 @@ STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream,
|
||||
my_input_file.set_filename(m_WhipPath.ascii());
|
||||
m_State.m_mul=0;
|
||||
my_input_file.set_file_mode(WT_File::File_Read);
|
||||
|
||||
if (m_State.m_lRotation != 0)
|
||||
{
|
||||
WT_Logical_Point lCenter(0,0);
|
||||
WT_Transform trans(lCenter, 1.0, 1.0, m_State.m_lRotation);
|
||||
my_input_file.heuristics().set_transform(trans);
|
||||
my_input_file.heuristics().set_apply_transform(true);
|
||||
my_input_file.rendition().font().rotation() = MulDiv(m_State.m_lRotation,16384,90);
|
||||
}
|
||||
|
||||
WT_Result result;
|
||||
if (my_input_file.open() != WT_Result::Success)
|
||||
throw myCString("\nCWhip2DCImpl::Load: unable to open file '%s'", m_WhipPath.ascii());
|
||||
@@ -100,10 +113,16 @@ STDMETHODIMP CWhip2DCImpl::Load(HDC hDC, CEPlotSectionImpl *EPlotStream,
|
||||
}
|
||||
case WT_Object::Drawable:
|
||||
{
|
||||
if (!my_input_file.rendition().visibility().visible())
|
||||
break;
|
||||
WT_Drawable *obj = (WT_Drawable *)my_input_file.current_object();
|
||||
if (obj->object_id() != WT_Object::Origin_ID)// Belachelijk dat die Drawable is?
|
||||
if (obj->object_id() != WT_Object::Origin_ID // Belachelijk dat die Drawable is?
|
||||
// && obj->object_id() != WT_Object::Text_ID // Text roteert nog niet goed
|
||||
)
|
||||
{
|
||||
WT_Logical_Box bx = obj->bounds(&my_input_file);
|
||||
ATLASSERT(bx.minpt().m_x<=bx.maxpt().m_x);
|
||||
ATLASSERT(bx.minpt().m_y<=bx.maxpt().m_y);
|
||||
m_State.m_MinMax.minpt().m_x = min(m_State.m_MinMax.minpt().m_x, bx.minpt().m_x);
|
||||
m_State.m_MinMax.minpt().m_y = min(m_State.m_MinMax.minpt().m_y, bx.minpt().m_y);
|
||||
m_State.m_MinMax.maxpt().m_x = max(m_State.m_MinMax.maxpt().m_x, bx.minpt().m_x);
|
||||
@@ -202,6 +221,14 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW)
|
||||
// m_State niet benaderen. Daarom maar via set_user_data
|
||||
my_input_file.heuristics().set_user_data((void *)&m_State);
|
||||
|
||||
if (m_State.m_lRotation != 0) // Tijdens het laden roteren
|
||||
{
|
||||
WT_Logical_Point lCenter(0,0);
|
||||
WT_Transform trans(lCenter, 1.0, 1.0, m_State.m_lRotation);
|
||||
my_input_file.heuristics().set_transform(trans);
|
||||
my_input_file.heuristics().set_apply_transform(true);
|
||||
}
|
||||
|
||||
my_input_file.set_file_mode(WT_File::File_Read);
|
||||
|
||||
if (my_input_file.open() == WT_Result::Success)
|
||||
@@ -214,15 +241,12 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW)
|
||||
SetTextColor(m_State.myDC, RGB(0, 0, 0));
|
||||
|
||||
// Standaard zit onze m_pen in de DC
|
||||
// Alleen als echt nodig (w>1) stoppen we tijdelijk m_penExt erin.
|
||||
// Die is wel trager namelijk
|
||||
m_State.m_pen = CreatePen(PS_INSIDEFRAME, 0, GetTextColor(m_State.myDC));
|
||||
m_State.m_brush = CreateSolidBrush(GetTextColor(m_State.myDC));
|
||||
LOGBRUSH b;
|
||||
b.lbColor = GetTextColor(m_State.myDC);
|
||||
//b.lbHatch = hatchCode;
|
||||
b.lbStyle = BS_SOLID;
|
||||
m_State.m_penExt = ExtCreatePen(PS_GEOMETRIC, 0, &b, 0, NULL);
|
||||
|
||||
HBRUSH oldbrush=(HBRUSH) SelectObject(m_State.myDC, m_State.m_pen);
|
||||
HPEN oldpen=(HPEN)SelectObject(m_State.myDC, m_State.m_brush);
|
||||
@@ -242,7 +266,6 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW)
|
||||
SelectObject(m_State.myDC, oldpen);
|
||||
DeleteObject(m_State.m_brush);
|
||||
DeleteObject(m_State.m_pen);
|
||||
DeleteObject(m_State.m_penExt);
|
||||
|
||||
if (result != WT_Result::Success)
|
||||
throw myCString("\nCWhip2DCImpl::Paint: unable to read file '%s'", m_WhipPath.ascii());
|
||||
@@ -333,6 +356,7 @@ STDMETHODIMP CWhip2DCImpl::Paint(VARIANT_BOOL forceBW)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Zoek alle teksten in de tekening op en lever ze op als array
|
||||
STDMETHODIMP CWhip2DCImpl::FindTexts(const CString &findText)
|
||||
{
|
||||
CmyTimer Timer("CWhip2DCImpl::FindText");
|
||||
@@ -403,7 +427,8 @@ STDMETHODIMP CWhip2DCImpl::FindTexts(const CString &findText)
|
||||
STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY,
|
||||
BYTE AsMap,
|
||||
CString & pContourLabel,CString & pContourLayer,
|
||||
CString & pTextLabel, CString & pTextLayer)
|
||||
CString & pTextLabel, CString & pTextLayer,
|
||||
double &pEdgeAngle, double &pEdgeDistance)
|
||||
{
|
||||
CmyTimer Timer("CWhip2DCImpl::Find (includes AsMap)");
|
||||
|
||||
@@ -484,6 +509,8 @@ STDMETHODIMP CWhip2DCImpl::Find(LONG findX, LONG findY,
|
||||
{
|
||||
pContourLabel = CString(m_State.foundNode.object_node_name().ascii());
|
||||
pContourLayer = m_State.foundNodeLayer;
|
||||
pEdgeAngle = m_State.foundEdgeAngle;
|
||||
pEdgeDistance = m_State.foundEdgeDistance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,6 +912,7 @@ WT_Result CWhip2DCImpl::my_process_outlineEllipse (WT_Outline_Ellipse & outlineE
|
||||
return my_process_Ellipse(outlineEllipse, file, FALSE);
|
||||
}
|
||||
|
||||
// Genereer een een html <area> fragment
|
||||
CString CWhip2DCImpl::PolyToMap(WT_Polygon & polygon,
|
||||
WT_Object_Node node, WT_URL URL,
|
||||
CWhip2DCState *m_State)
|
||||
@@ -899,18 +927,64 @@ CString CWhip2DCImpl::PolyToMap(WT_Polygon & polygon,
|
||||
return "";
|
||||
}
|
||||
|
||||
for (int i = 0; i < polygon.count(); i++)
|
||||
#if 0
|
||||
// het werkt niet:PtVisible levert altijd false op (omdat we geen bitmap selecteren in CWhip2PNG::GetAsMap?
|
||||
BOOL anyVisible = false; // als de boundingcontour geheel buiten beeld valt is hij niet nodig
|
||||
// Uit priaktische overwegingen implementeren we dat als: een
|
||||
// hoekpunt van de bounding contour moet in beeld zijn
|
||||
#endif
|
||||
CString shape;
|
||||
if (polygon.count() == 5 && // Linksom of rechtsom rechthoekig
|
||||
((polygon.points()[0].m_x == polygon.points()[1].m_x &&
|
||||
polygon.points()[1].m_y == polygon.points()[2].m_y &&
|
||||
polygon.points()[2].m_x == polygon.points()[3].m_x &&
|
||||
polygon.points()[3].m_y == polygon.points()[4].m_y
|
||||
) ||
|
||||
(polygon.points()[0].m_y == polygon.points()[1].m_y &&
|
||||
polygon.points()[1].m_x == polygon.points()[2].m_x &&
|
||||
polygon.points()[2].m_y == polygon.points()[3].m_y &&
|
||||
polygon.points()[3].m_x == polygon.points()[4].m_x
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
CPoint pt = m_State->DWFToLP(polygon.points()[i]);
|
||||
LPtoDP(m_State->myDC, &pt, 1);
|
||||
CString s;
|
||||
s.Format("%s,%d,%d", ptList, pt.x, pt.y);
|
||||
ptList = s;
|
||||
shape = "rect";
|
||||
CPoint pt1 = m_State->DWFToLP(polygon.points()[0]);
|
||||
CPoint pt2 = m_State->DWFToLP(polygon.points()[2]);
|
||||
#if 0
|
||||
anyVisible|=PtVisible(m_State->myDC, pt1.x,pt1.y);
|
||||
anyVisible|=PtVisible(m_State->myDC, pt2.x,pt1.y);
|
||||
anyVisible|=PtVisible(m_State->myDC, pt2.x,pt2.y);
|
||||
anyVisible|=PtVisible(m_State->myDC, pt1.x,pt2.y);
|
||||
#endif
|
||||
LPtoDP(m_State->myDC, &pt1, 1);
|
||||
LPtoDP(m_State->myDC, &pt2, 1);
|
||||
ptList.Format("%d,%d,%d,%d", min(pt1.x, pt2.x), min(pt1.y, pt2.y),
|
||||
max(pt1.x, pt2.x), max(pt1.y, pt2.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
shape = "poly";
|
||||
for (int i = 0; i < polygon.count(); i++)
|
||||
{
|
||||
CPoint pt = m_State->DWFToLP(polygon.points()[i]);
|
||||
#if 0
|
||||
anyVisible|=PtVisible(m_State->myDC, pt.x,pt.y);
|
||||
#endif
|
||||
LPtoDP(m_State->myDC, &pt, 1);
|
||||
CString s;
|
||||
s.Format("%s,%d,%d", ptList, pt.x, pt.y);
|
||||
ptList = s;
|
||||
}
|
||||
ptList = ptList.Mid(1); // Eerste komma er af
|
||||
}
|
||||
ptList = ptList.Mid(1); // Eerste komma er af
|
||||
|
||||
#if 0
|
||||
if (!anyVisible)
|
||||
return ""; // Toch niet in beeld
|
||||
#endif
|
||||
CString Coords, Title, Href;
|
||||
Coords.Format("COORDS=\"%s\"", ptList);
|
||||
Coords.Format("coords=\"%s\"", ptList);
|
||||
|
||||
WT_URL_List lUrl = URL.url();
|
||||
|
||||
@@ -921,7 +995,7 @@ CString CWhip2DCImpl::PolyToMap(WT_Polygon & polygon,
|
||||
if (firstURL->address().length() == 0)
|
||||
Href = "";
|
||||
else
|
||||
Href.Format("HREF=\"%s\"", CString(firstURL->address().ascii()));
|
||||
Href.Format("href=\"%s\"", CString(firstURL->address().ascii()));
|
||||
if (firstURL->friendly_name().is_ascii())
|
||||
ttl = firstURL->friendly_name().ascii();
|
||||
else
|
||||
@@ -931,18 +1005,19 @@ CString CWhip2DCImpl::PolyToMap(WT_Polygon & polygon,
|
||||
ttl = objKey; // Is dit wel zo logisch/wenselijk?
|
||||
|
||||
ttl.Replace("\\n", "\n");
|
||||
Title.Format("TITLE=\"%s\"", ttl);
|
||||
Title.Format("title=\"%s\"", ttl);
|
||||
|
||||
CString smbl = "";
|
||||
if (m_State->bIsSymbolLayer && objKey != "")
|
||||
smbl.Format("SLNKSymbolKey=\"%s\"", objKey);
|
||||
smbl.Format("\nSLNKSymbolKey=\"%s\"", objKey);
|
||||
|
||||
CString Builder;
|
||||
Builder.Format("\n<AREA SHAPE=\"poly\"\n%s\n%s\n%s\n%s>",
|
||||
Coords, Title, Href, smbl);
|
||||
Builder.Format("\n<area shape=\"%s\"\n%s\n%s\n%s%s>",
|
||||
shape, Coords, Title, Href, smbl);
|
||||
return Builder;
|
||||
};
|
||||
|
||||
// Binnen DWF is een polygon altijd 'gevuld'
|
||||
WT_Result CWhip2DCImpl::my_process_polygon (WT_Polygon & polygon, WT_File & file)
|
||||
{
|
||||
CWhip2DCState *m_State = (CWhip2DCState *)file.heuristics().user_data();
|
||||
@@ -953,15 +1028,25 @@ WT_Result CWhip2DCImpl::my_process_polygon (WT_Polygon & polygon, WT_File & file
|
||||
{
|
||||
// Zo weinig mogelijk onze penExt gebruiken want die is trager.
|
||||
// Voor de arcering is hij mogelijk wel nodig
|
||||
HPEN pOld = (HPEN)SelectObject(m_State->myDC, m_State->m_penExt);
|
||||
CPoint *vertexList = m_State->new_DWFToLP(polygon);
|
||||
if (m_State->m_forceBW) // Dan nooit vullen
|
||||
if (m_State->m_forceBW) // Dan nooit vullen, wel outline
|
||||
{
|
||||
HPEN pen = CreatePen(PS_SOLID, 0, RGB(0,0,0)); // Alleen outline tekenen
|
||||
HPEN pOld = (HPEN)SelectObject(m_State->myDC, pen);
|
||||
Polyline(m_State->myDC, vertexList, polygon.count());
|
||||
SelectObject(m_State->myDC, pOld);
|
||||
DeleteObject(pen);
|
||||
}
|
||||
else if (m_State->m_alpha==255) // Normal polygon
|
||||
{
|
||||
HPEN pen = CreatePen(PS_NULL, 0, RGB(0,0,0)); // Geen outline tekenen
|
||||
HPEN pOld = (HPEN)SelectObject(m_State->myDC, pen);
|
||||
Polygon(m_State->myDC, vertexList, polygon.count());
|
||||
SelectObject(m_State->myDC, pOld);
|
||||
DeleteObject(pen);
|
||||
}
|
||||
else
|
||||
m_State->AlphaPolygon(vertexList, polygon.count());
|
||||
SelectObject(m_State->myDC, pOld);
|
||||
}
|
||||
return WT_Result::Success;
|
||||
}
|
||||
@@ -972,10 +1057,14 @@ WT_Result CWhip2DCImpl::my_process_polygon_find (WT_Polygon & polygon, WT_File &
|
||||
if (!m_State->bLayerVisible)
|
||||
return WT_Result::Success;
|
||||
|
||||
// Kijk if we het punt gevonden hebben
|
||||
// Kijk of we het punt gevonden hebben
|
||||
if (CSLNKContourImpl::PointInPolygon(m_State->DWFfindXY, polygon))
|
||||
{
|
||||
m_State->foundNode = file.rendition().object_node();
|
||||
CSLNKContourImpl::EdgeAngle(m_State->DWFfindXY, polygon, m_State->foundEdgeAngle, m_State->foundEdgeDistance);
|
||||
double scale = file.rendition().viewport().viewport_units().application_to_dwf_transform()(0,0);
|
||||
m_State->foundEdgeDistance /= scale;
|
||||
|
||||
WT_Integer32 layer_num = file.rendition().layer().layer_num();
|
||||
WT_Layer *ll = file.layer_list().find_layer_from_index(layer_num);
|
||||
if (ll&&ll->layer_name().ascii())
|
||||
|
||||
@@ -125,11 +125,12 @@ public:
|
||||
STDMETHOD(Load)(HDC hDC, CEPlotSectionImpl *EPlotSection, const CString &WhipPath,
|
||||
const CString &RegExp, long sizeX, long sizeY,
|
||||
VARIANT_BOOL centerImage, VARIANT_BOOL maximize=FALSE,
|
||||
double dwgScale=0.0);
|
||||
double dwgScale=0.0, long lRotation=0);
|
||||
STDMETHOD(Paint)(VARIANT_BOOL forceBW);
|
||||
STDMETHOD(Find)(LONG findX, LONG findY, BYTE AsMap,
|
||||
CString &pContourLabel, CString &pContourLayer,
|
||||
CString &pTextLabel, CString &pTextLayer);
|
||||
CString &pTextLabel, CString &pTextLayer,
|
||||
double &EdgeAngle, double &EdgeDistance);
|
||||
STDMETHOD(FindTexts) (const CString &findText);
|
||||
STDMETHOD(DPtoDWG)(LONG findX, LONG findY, DOUBLE* resX, DOUBLE* resY);
|
||||
STDMETHOD(DWGExtents)(DOUBLE* resminX, DOUBLE* resminY, DOUBLE* resmaxX, DOUBLE* resmaxY);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.141592653589793f
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
CWhip2DCState::CWhip2DCState()
|
||||
@@ -31,6 +31,7 @@ void CWhip2DCState::Reset()
|
||||
m_font = NULL;
|
||||
m_forcePaper = false;
|
||||
m_Maximize = false;
|
||||
m_lRotation = 0;
|
||||
}
|
||||
|
||||
CWhip2DCState::~CWhip2DCState()
|
||||
@@ -537,8 +538,12 @@ void CWhip2DCState::AlphaPolygon(LPPOINT lpPoints, int nCount ) const
|
||||
myTRACE("\nHmmm, BitBlt failed?");
|
||||
|
||||
HBRUSH oldbrush = (HBRUSH) SelectObject(hMemDC,m_brush);
|
||||
HPEN pen = CreatePen(PS_NULL, 0, RGB(0,0,0)); // Geen outline tekenen
|
||||
HPEN pOld = (HPEN)SelectObject(hMemDC, pen);
|
||||
|
||||
Polygon(hMemDC, lpPoints, nCount);
|
||||
SelectObject(hMemDC, pOld);
|
||||
DeleteObject(pen);
|
||||
|
||||
SelectObject(hMemDC,oldbrush);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
LOGFONT m_logfont;
|
||||
WT_Integer32 m_spacing;
|
||||
WT_Integer32 m_height; // Niet afgeronde waarde voor SetupPixel
|
||||
HPEN m_pen, m_penExt;
|
||||
HPEN m_pen;
|
||||
HFONT m_font;
|
||||
HRGN m_hrgn;
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
BOOL m_forceBW;
|
||||
BOOL m_Maximize;
|
||||
BOOL m_centerImage;
|
||||
long m_lRotation;
|
||||
double m_mul; // schaal onze DWF-coordinaten naar bitmap coordinaten
|
||||
|
||||
CSize m_Size;
|
||||
@@ -76,6 +77,8 @@ public:
|
||||
CString foundNodeLayer;
|
||||
CString foundTextLabel;
|
||||
CString foundTextLayer;
|
||||
double foundEdgeAngle;
|
||||
double foundEdgeDistance;
|
||||
WT_Logical_Point DWFfindXY;
|
||||
int geekFontSize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user