Skip to content

Commit 0c4ca93

Browse files
committed
Defining point as global type, making it available from the outside
1 parent 858828d commit 0c4ca93

16 files changed

+48
-46
lines changed

Src/DasherCore/CircleStartHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CCircleStartHandler::~CCircleStartHandler() {
3939
m_pSettingsStore->OnParameterChanged.Unsubscribe(this);
4040
}
4141

42-
CDasherScreen::point CCircleStartHandler::CircleCenter(CDasherView *pView) {
42+
point CCircleStartHandler::CircleCenter(CDasherView *pView) {
4343
if (m_iScreenRadius!=-1) return m_screenCircleCenter;
4444

4545
m_pView->Dasher2Screen(CDasherModel::ORIGIN_X, CDasherModel::ORIGIN_Y, m_screenCircleCenter.x, m_screenCircleCenter.y);
@@ -62,7 +62,7 @@ CDasherScreen::point CCircleStartHandler::CircleCenter(CDasherView *pView) {
6262

6363
bool CCircleStartHandler::DecorateView(CDasherView *pView) {
6464
RegisterView(pView);
65-
CDasherScreen::point ctr = CircleCenter(pView);
65+
point ctr = CircleCenter(pView);
6666

6767
const bool bAboutToChange = m_bInCircle && m_iEnterTime != std::numeric_limits<long>::max();
6868
if (m_pFilter->isPaused()) {
@@ -77,7 +77,7 @@ bool CCircleStartHandler::DecorateView(CDasherView *pView) {
7777
void CCircleStartHandler::Timer(unsigned long iTime, dasherint mouseX, dasherint mouseY,CDasherView *pView) {
7878
RegisterView(pView);
7979

80-
CDasherScreen::point ctr = CircleCenter(pView);
80+
point ctr = CircleCenter(pView);
8181
screenint x,y;
8282
pView->Dasher2Screen(mouseX, mouseY, x, y);
8383
int dx=x-ctr.x, dy=y-ctr.y;

Src/DasherCore/CircleStartHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class CCircleStartHandler : public CStartHandler {
2424
///Radius of circle in screen coordinates (-1 = needs recomputing)
2525
int m_iScreenRadius;
2626
CDasherView *m_pView;
27-
virtual CDasherScreen::point CircleCenter(CDasherView *pView);
27+
virtual point CircleCenter(CDasherView *pView);
2828
private:
2929
///Cached center of screen circle (needs recomputing if radius does)
30-
CDasherScreen::point m_screenCircleCenter;
30+
point m_screenCircleCenter;
3131
CSettingsStore* m_pSettingsStore;
3232
};
3333
}

Src/DasherCore/CompassMode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool CCompassMode::DecorateView(CDasherView *pView, CDasherInput *pInput) {
6969
bool bFirst(true);
7070

7171
while(iPos >= 0) {
72-
CDasherScreen::point p[2];
72+
point p[2];
7373

7474
pView->Dasher2Screen(-100, iPos, p[0].x, p[0].y);
7575

Src/DasherCore/DasherButtons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void CDasherButtons::Timer(unsigned long Time, CDasherView *pView, CDasherInput
8888
void CDasherButtons::NewDrawGoTo(CDasherView *pView, myint iDasherMin, myint iDasherMax, bool bActive) {
8989
myint iHeight(iDasherMax - iDasherMin);
9090

91-
CDasherScreen::point p[4];
91+
point p[4];
9292

9393
pView->Dasher2Screen( 0, iDasherMin, p[0].x, p[0].y);
9494
pView->Dasher2Screen( iHeight, iDasherMin, p[1].x, p[1].y);

Src/DasherCore/DasherScreen.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ class Dasher::CDasherScreen
6262
return m_iHeight;
6363
}
6464

65-
//! Structure defining a point on the screen
66-
typedef struct tagpoint
67-
{
68-
screenint x;
69-
screenint y;
70-
} point;
71-
7265
///Abstract class for objects representing strings that can be drawn on the screen.
7366
/// Platform-specific instances are created by the MakeLabel(String) method, which
7467
/// may then be passed to GetSize() and DrawText().

Src/DasherCore/DasherTypes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ namespace Dasher
4646
// All screen co-ordinates are of type screenint
4747
typedef int32_t screenint;
4848

49+
//! Structure defining a point on the screen
50+
typedef struct point
51+
{
52+
screenint x = 0;
53+
screenint y = 0;
54+
point() = default;
55+
point(screenint X, screenint Y) : x(X), y(Y) {}
56+
} point;
57+
4958
// Using a signed symbol type allows "Out of band" ie negative {{{
5059
// values to be used to flag non-symbol data. For example commands
5160
// in dasher nodes.

Src/DasherCore/DasherView.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ void CDasherView::ChangeScreen(CDasherScreen *NewScreen) {
3939

4040
void CDasherView::DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iWidth, const ColorPalette::Color& color) {
4141
if (!ClipLineToVisible(x1, y1, x2, y2)) return;
42-
std::vector<CDasherScreen::point> vPoints;
43-
CDasherScreen::point p;
42+
std::vector<point> vPoints;
43+
point p;
4444
Dasher2Screen(x1, y1, p.x, p.y);
4545
vPoints.push_back(p);
4646
DasherLine2Screen(x1,y1,x2,y2,vPoints);
47-
CDasherScreen::point *pts = new CDasherScreen::point[vPoints.size()];
47+
point *pts = new point[vPoints.size()];
4848
for (int i = static_cast<int>(vPoints.size()); i-->0; ) pts[i] = vPoints[i];
4949
Screen()->Polyline(pts, static_cast<int>(vPoints.size()), iWidth, color);
5050
}
@@ -89,7 +89,7 @@ bool CDasherView::ClipLineToVisible(myint &x1, myint &y1, myint &x2, myint &y2)
8989

9090
void CDasherView::DasherPolyline(myint *x, myint *y, int n, int iWidth, const ColorPalette::Color& color) {
9191

92-
CDasherScreen::point * ScreenPoints = new CDasherScreen::point[n];
92+
point * ScreenPoints = new point[n];
9393

9494
for(int i(0); i < n; ++i)
9595
Dasher2Screen(x[i], y[i], ScreenPoints[i].x, ScreenPoints[i].y);
@@ -102,7 +102,7 @@ void CDasherView::DasherPolyline(myint *x, myint *y, int n, int iWidth, const Co
102102
// Draw a polyline with an arrow on the end
103103
void CDasherView::DasherPolyarrow(myint *x, myint *y, int n, int iWidth, const ColorPalette::Color& color, double dArrowSizeFactor) {
104104

105-
CDasherScreen::point * ScreenPoints = new CDasherScreen::point[n+3];
105+
point * ScreenPoints = new point[n+3];
106106

107107
for(int i(0); i < n; ++i)
108108
Dasher2Screen(x[i], y[i], ScreenPoints[i].x, ScreenPoints[i].y);

Src/DasherCore/DasherView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ class Dasher::CDasherView
220220
/// \param x2 , y2 Dasher co-ordinates of end of line segment; also guaranteed within VisibleRegion.
221221
/// \param vPoints vector to which to add screen points. Note that at the point that DasherLine2Screen is called,
222222
/// the screen coordinates of the first point should already have been added to this vector; DasherLine2Screen
223-
/// will then add exactly one CDasherScreen::point for each line segment required.
224-
virtual void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<CDasherScreen::point>& vPoints) =0;
223+
/// will then add exactly one point for each line segment required.
224+
virtual void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<point>& vPoints) =0;
225225

226226
const ColorPalette* m_pColorPalette = nullptr;
227227
private:

Src/DasherCore/DasherViewSquare.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, my
364364
}
365365
}
366366
// midy1,x1 is now start point
367-
std::vector<CDasherScreen::point> pts(1);
367+
std::vector<point> pts(1);
368368
Dasher2Screen(x1, midy1, pts[0].x, pts[0].y);
369369
DasherLine2Screen(x1, midy1, tempx1, y1, pts);
370370
if (tempx1)
@@ -402,7 +402,7 @@ void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, my
402402
else
403403
DASHER_ASSERT(pts.back().x == pts[0].x && pts.back().y == pts[0].y);
404404

405-
auto p_array = new CDasherScreen::point[pts.size()];
405+
auto p_array = new point[pts.size()];
406406
for (unsigned int i = 0; i < pts.size(); i++) p_array[i] = pts[i];
407407
Screen()->Polygon(p_array, static_cast<int>(pts.size()), fillColor, outlineColor, lineWidth);
408408
delete[] p_array;
@@ -412,11 +412,11 @@ void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, my
412412

413413
void CDasherViewSquare::Circle(myint Range, myint y1, myint y2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth)
414414
{
415-
std::vector<CDasherScreen::point> pts;
415+
std::vector<point> pts;
416416
myint cy((y1 + y2) / 2), r(Range / 2), x1, x2;
417417
const DasherCoordScreenRegion visibleRegion = VisibleRegion();
418418

419-
CDasherScreen::point p;
419+
point p;
420420
//run along bottom edge...
421421
if (y1 < visibleRegion.minY)
422422
{
@@ -459,17 +459,17 @@ void CDasherViewSquare::Circle(myint Range, myint y1, myint y2, const ColorPalet
459459
Dasher2Screen(0, visibleRegion.maxX, p.x, p.y);
460460
pts.push_back(p);
461461
}
462-
auto p_array = new CDasherScreen::point[pts.size()];
462+
auto p_array = new point[pts.size()];
463463
for (unsigned int i = 0; i < pts.size(); i++) p_array[i] = pts[i];
464464
Screen()->Polygon(p_array, static_cast<int>(pts.size()), fillColor, outlineColor, lineWidth);
465465
delete[] p_array;
466466
}
467467

468-
void CDasherViewSquare::CircleTo(myint cy, myint r, myint y1, myint x1, myint y3, myint x3, CDasherScreen::point dest, std::vector<CDasherScreen::point>& pts, double dXMul)
468+
void CDasherViewSquare::CircleTo(myint cy, myint r, myint y1, myint x1, myint y3, myint x3, point dest, std::vector<point>& pts, double dXMul)
469469
{
470470
myint y2((y1 + y3) / 2);
471471
myint x2(static_cast<myint>(sqrt((sq(r) - sq(cy - y2)) * dXMul)));
472-
CDasherScreen::point mid; //where midpoint of circle/arc should be
472+
point mid; //where midpoint of circle/arc should be
473473
Dasher2Screen(x2, y2, mid.x, mid.y); //(except "midpoint" measured along y axis)
474474
int lmx = (pts.back().x + dest.x) / 2, lmy = (pts.back().y + dest.y) / 2; //midpoint of straight line
475475
if (abs(dest.y - pts.back().y) < 2 || abs(mid.x - lmx) + abs(mid.y - lmy) < 2)
@@ -487,10 +487,10 @@ void CDasherViewSquare::CircleTo(myint cy, myint r, myint y1, myint x1, myint y3
487487

488488
void CDasherViewSquare::DasherSpaceArc(myint cy, myint r, myint x1, myint y1, myint x2, myint y2, const ColorPalette::Color& color, int iLineWidth)
489489
{
490-
CDasherScreen::point p;
490+
point p;
491491
//start point
492492
Dasher2Screen(x1, y1, p.x, p.y);
493-
std::vector<CDasherScreen::point> pts;
493+
std::vector<point> pts;
494494
pts.push_back(p);
495495
//if circle goes behind crosshair and we want the point of max-x, force division into two sections with that point as boundary
496496
if (r > CDasherModel::ORIGIN_X && ((y1 < cy) ^ (y2 < cy)))
@@ -502,7 +502,7 @@ void CDasherViewSquare::DasherSpaceArc(myint cy, myint r, myint x1, myint y1, my
502502
}
503503
Dasher2Screen(x2, y2, p.x, p.y);
504504
CircleTo(cy, r, y1, x1, y2, x2, p, pts, 1.0);
505-
auto p_array = new CDasherScreen::point[pts.size()];
505+
auto p_array = new point[pts.size()];
506506
for (unsigned int i = 0; i < pts.size(); i++) p_array[i] = pts[i];
507507
Screen()->Polyline(p_array, static_cast<int>(pts.size()), iLineWidth, color);
508508
}
@@ -512,7 +512,7 @@ void CDasherViewSquare::Quadric(myint Range, myint lowY, myint highY, const Colo
512512
static const double RR2 = 1.0 / sqrt(2.0);
513513
const int midY = static_cast<int>((lowY + highY) / 2);
514514
#define NUM_STEPS 40
515-
CDasherScreen::point p_array[2 * NUM_STEPS + 2];
515+
point p_array[2 * NUM_STEPS + 2];
516516

517517
const DasherCoordScreenRegion visibleRegion = VisibleRegion();
518518
{
@@ -1194,7 +1194,7 @@ void CDasherViewSquare::Dasher2Polar(myint iDasherX, myint iDasherY, double& r,
11941194
r = sqrt(x * x + y * y);
11951195
}
11961196

1197-
void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<CDasherScreen::point>& vPoints)
1197+
void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<point>& vPoints)
11981198
{
11991199
if (x1 != x2 && y1 != y2)
12001200
{
@@ -1221,7 +1221,7 @@ void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2
12211221
if (m_pSettingsStore->GetLongParameter(LP_NONLINEAR_X) && (x1 > m_iXlogThres || x2 > m_iXlogThres))
12221222
{
12231223
//into logarithmic section
1224-
CDasherScreen::point pStart, pScreenMid, pEnd;
1224+
point pStart, pScreenMid, pEnd;
12251225
Dasher2Screen(x2, y2, pEnd.x, pEnd.y);
12261226
for (;;)
12271227
{
@@ -1231,7 +1231,7 @@ void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2
12311231
pScreenMid.y = (pStart.y + pEnd.y) / 2;
12321232
//whereas a straight line _in_Dasher_space_ passes through pDasherMid:
12331233
myint xMid = (x1 + x2) / 2, yMid = (y1 + y2) / 2;
1234-
CDasherScreen::point pDasherMid;
1234+
point pDasherMid;
12351235
Dasher2Screen(xMid, yMid, pDasherMid.x, pDasherMid.y);
12361236

12371237
//since we know both endpoints are in the same section of the screen wrt. Y nonlinearity,
@@ -1259,7 +1259,7 @@ void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2
12591259
//ok, not in x nonlinear section; fall through.
12601260
}
12611261

1262-
CDasherScreen::point p;
1262+
point p;
12631263
Dasher2Screen(x2, y2, p.x, p.y);
12641264
vPoints.push_back(p);
12651265
}

Src/DasherCore/DasherViewSquare.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Dasher::CDasherViewSquare : public CDasherView
106106
/// dest - point (x2,y2) in screen coords
107107
/// pts - vector into which to store points; on entry, last element should already be screen-coords of (x1,y1)
108108
/// dXMul - multiply x coords (in dasher space) by this (i.e. aspect ratio), for ovals
109-
void CircleTo(myint cy, myint r, myint y1, myint x1, myint y3, myint x3, CDasherScreen::point dest, std::vector<CDasherScreen::point>& pts, double dXMul);
109+
void CircleTo(myint cy, myint r, myint y1, myint x1, myint y3, myint x3, point dest, std::vector<point>& pts, double dXMul);
110110
void Circle(myint Range, myint y1, myint y2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth);
111111
void Quadric(myint Range, myint lowY, myint highY, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int
112112
lineWidth);
@@ -193,7 +193,7 @@ class Dasher::CDasherViewSquare : public CDasherView
193193
//Divides by SCALE_FACTOR, rounding away from 0
194194
inline myint CustomIDivScaleFactor(myint iNumerator);
195195

196-
void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<CDasherScreen::point>& vPoints) override;
196+
void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<point>& vPoints) override;
197197

198198
// Called on screen size or orientation changes
199199
void SetScaleFactor();

0 commit comments

Comments
 (0)