Skip to content

Commit 8bc589a

Browse files
committed
Some Cleanup in DasherView Classes
1 parent 404a3b8 commit 8bc589a

File tree

4 files changed

+60
-61
lines changed

4 files changed

+60
-61
lines changed

Src/DasherCore/DasherView.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void CDasherView::ChangeScreen(CDasherScreen *NewScreen) {
3737

3838
/////////////////////////////////////////////////////////////////////////////
3939

40-
void CDasherView::DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iWidth, const ColorPalette::Color& color) {
40+
void CDasherView::DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iWidth, const ColorPalette::Color& color) const {
4141
if (!ClipLineToVisible(x1, y1, x2, y2)) return;
4242
std::vector<point> vPoints;
4343
point p;
@@ -49,7 +49,7 @@ void CDasherView::DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iW
4949
Screen()->Polyline(pts, static_cast<int>(vPoints.size()), iWidth, color);
5050
}
5151

52-
bool CDasherView::ClipLineToVisible(myint &x1, myint &y1, myint &x2, myint &y2) {
52+
bool CDasherView::ClipLineToVisible(myint &x1, myint &y1, myint &x2, myint &y2) const {
5353
if (x1 > x2) return ClipLineToVisible(x2,y2,x1,y1);
5454
//ok. have x1 <= x2...
5555
const CDasherView::DasherCoordScreenRegion vr = VisibleRegion();
@@ -87,7 +87,7 @@ bool CDasherView::ClipLineToVisible(myint &x1, myint &y1, myint &x2, myint &y2)
8787

8888
/// Draw a polyline specified in Dasher co-ordinates
8989

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

9292
point * ScreenPoints = new point[n];
9393

@@ -100,7 +100,7 @@ void CDasherView::DasherPolyline(myint *x, myint *y, int n, int iWidth, const Co
100100
}
101101

102102
// Draw a polyline with an arrow on the end
103-
void CDasherView::DasherPolyarrow(myint *x, myint *y, int n, int iWidth, const ColorPalette::Color& color, double dArrowSizeFactor) {
103+
void CDasherView::DasherPolyarrow(myint *x, myint *y, int n, int iWidth, const ColorPalette::Color& color, double dArrowSizeFactor) const {
104104

105105
point * ScreenPoints = new point[n+3];
106106

@@ -124,7 +124,7 @@ void CDasherView::DasherPolyarrow(myint *x, myint *y, int n, int iWidth, const C
124124

125125
// Draw a box specified in Dasher co-ordinates
126126

127-
void CDasherView::DasherDrawRectangle(myint iDasherMaxX, myint iDasherMinY, myint iDasherMinX, myint iDasherMaxY, const ColorPalette::Color& color, const ColorPalette::Color& outlineColor, int iThickness) {
127+
void CDasherView::DasherDrawRectangle(myint iDasherMaxX, myint iDasherMinY, myint iDasherMinX, myint iDasherMaxY, const ColorPalette::Color& color, const ColorPalette::Color& outlineColor, int iThickness) const {
128128
//This assertion is more aggressive than necessary (Dasher has been working
129129
// in many cases where it would fail, with only occassional display glitches)
130130
// so if it causes trouble, it should be safe to remove...
@@ -144,7 +144,7 @@ void CDasherView::DasherDrawRectangle(myint iDasherMaxX, myint iDasherMinY, myin
144144

145145
/// Draw a rectangle centred on a given dasher co-ordinate, but with a size specified in screen co-ordinates (used for drawing the mouse blob)
146146

147-
void CDasherView::DasherDrawCentredRectangle(myint iDasherX, myint iDasherY, screenint iSize, const ColorPalette::Color& color, const ColorPalette::Color& outlineColor, bool bDrawOutline) {
147+
void CDasherView::DasherDrawCentredRectangle(myint iDasherX, myint iDasherY, screenint iSize, const ColorPalette::Color& color, const ColorPalette::Color& outlineColor, bool bDrawOutline) const {
148148
screenint iScreenX;
149149
screenint iScreenY;
150150

Src/DasherCore/DasherView.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ class Dasher::CDasherView
6363
/// Convert a screen co-ordinate to Dasher co-ordinates
6464
///
6565

66-
virtual void Screen2Dasher(screenint iInputX, screenint iInputY, myint& iDasherX, myint& iDasherY) = 0;
66+
virtual void Screen2Dasher(screenint iInputX, screenint iInputY, myint& iDasherX, myint& iDasherY) const = 0;
6767

6868
///
6969
/// Convert Dasher co-ordinates to screen co-ordinates
7070
///
7171

72-
virtual void Dasher2Screen(myint iDasherX, myint iDasherY, screenint& iScreenX, screenint& iScreenY) = 0;
72+
virtual void Dasher2Screen(myint iDasherX, myint iDasherY, screenint& iScreenX, screenint& iScreenY) const = 0;
7373

7474
///
7575
/// Convert Dasher co-ordinates to polar co-ordinates (r,theta), with 0<r<1, 0<theta<2*pi
7676
///
77-
virtual void Dasher2Polar(myint iDasherX, myint iDasherY, double& r, double& theta) = 0;
77+
virtual void Dasher2Polar(myint iDasherX, myint iDasherY, double& r, double& theta) const = 0;
7878

79-
virtual bool IsSpaceAroundNode(myint y1, myint y2) =0;
79+
virtual bool IsSpaceAroundNode(myint y1, myint y2) const = 0;
8080

8181
// ScreenRegion in DasherCoords
8282
struct DasherCoordScreenRegion
@@ -94,7 +94,7 @@ class Dasher::CDasherView
9494
Dasher::screenint maxX;
9595
Dasher::screenint maxY;
9696
};
97-
virtual DasherCoordScreenRegion VisibleRegion() = 0;
97+
virtual DasherCoordScreenRegion VisibleRegion() const = 0;
9898

9999
/// @}
100100

@@ -136,7 +136,7 @@ class Dasher::CDasherView
136136
/// @param pRoot outermost node to render. should cover screen if possible;
137137
/// function will blank out around it (in white) if not
138138
/// @return the innermost node covering the crosshair
139-
virtual CDasherNode* Render(CDasherNode* pRoot, myint iRootMin, myint iRootMax, CExpansionPolicy& policy) =0;
139+
virtual CDasherNode* Render(CDasherNode* pRoot, myint iRootMin, myint iRootMax, CExpansionPolicy& policy) = 0;
140140

141141
/// @}
142142

@@ -153,15 +153,15 @@ class Dasher::CDasherView
153153
/// @{
154154

155155
///Draw a straight line in Dasher-space - which may be curved on the screen...
156-
void DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iWidth, const ColorPalette::Color& color);
156+
void DasherSpaceLine(myint x1, myint y1, myint x2, myint y2, int iWidth, const ColorPalette::Color& color) const;
157157

158-
virtual void DasherSpaceArc(myint cy, myint r, myint x1, myint y1, myint x2, myint y2, const ColorPalette::Color& color, int iLineWidth) =0;
158+
virtual void DasherSpaceArc(myint cy, myint r, myint x1, myint y1, myint x2, myint y2, const ColorPalette::Color& color, int iLineWidth) const = 0;
159159

160160
///
161161
/// Draw a polyline specified in Dasher co-ordinates
162162
///
163163

164-
void DasherPolyline(myint* x, myint* y, int n, int iWidth, const ColorPalette::Color& color);
164+
void DasherPolyline(myint* x, myint* y, int n, int iWidth, const ColorPalette::Color& color) const;
165165

166166
/// Draw a polyarrow
167167
/// The parameters x and y allow the client to specify points in Dasher space
@@ -178,7 +178,7 @@ class Dasher::CDasherView
178178
/// \param color line color, as per Polyline (-1 => use "default" 0)
179179
/// \param dArrowSizeFactor - the factor by which to scale the "hat" on the arrow
180180
///
181-
void DasherPolyarrow(myint* x, myint* y, int n, int iWidth, const ColorPalette::Color& color, double dArrowSizeFactor = 0.7071);
181+
void DasherPolyarrow(myint* x, myint* y, int n, int iWidth, const ColorPalette::Color& color, double dArrowSizeFactor = 0.7071) const;
182182

183183
///
184184
/// Draw a rectangle specified in Dasher co-ordinates
@@ -187,7 +187,7 @@ class Dasher::CDasherView
187187
/// \param iThickness line width for outline, < 1 => no outline.
188188
///
189189
void DasherDrawRectangle(myint iDasherMaxX, myint iDasherMinY, myint iDasherMinX, myint iDasherMaxY, const ColorPalette::Color& color, const
190-
ColorPalette::Color& outlineColor, int iThickness);
190+
ColorPalette::Color& outlineColor, int iThickness) const;
191191

192192
///
193193
/// Draw a centred rectangle specified in Dasher co-ordinates (used for mouse cursor)
@@ -196,7 +196,7 @@ class Dasher::CDasherView
196196
///
197197

198198
void DasherDrawCentredRectangle(myint iDasherX, myint iDasherY, screenint iSize, const ColorPalette::Color& color, const ColorPalette::Color&
199-
outlineColor, bool bDrawOutline);
199+
outlineColor, bool bDrawOutline) const;
200200

201201
/// Set a color scheme
202202
///
@@ -211,7 +211,7 @@ class Dasher::CDasherView
211211
/// by intersecting with all boundaries.
212212
/// \return true if any part of the line was within the visible region; in this case, (x1,y1)-(x2,y2) delineate exactly that part
213213
/// false if the line would be entirely outside the visible region; x1, y1, x2, y2 undefined.
214-
bool ClipLineToVisible(myint& x1, myint& y1, myint& x2, myint& y2);
214+
bool ClipLineToVisible(myint& x1, myint& y1, myint& x2, myint& y2) const;
215215

216216
protected:
217217
///Convert a straight line in Dasher-space, to coordinates for a corresponding polyline on the screen
@@ -221,7 +221,7 @@ class Dasher::CDasherView
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
223223
/// 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;
224+
virtual void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<point>& vPoints) const = 0;
225225

226226
const ColorPalette* m_pColorPalette = nullptr;
227227
private:

Src/DasherCore/DasherViewSquare.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CDasherViewSquare::CDasherViewSquare(CSettingsStore* pSettingsStore, CDasherScre
5555
parameter == LP_GEOMETRY)
5656
{
5757
m_bVisibleRegionValid = false;
58-
SetScaleFactor();
58+
ComputeScaleFactor();
5959
}
6060
});
6161
}
@@ -70,7 +70,7 @@ void CDasherViewSquare::SetOrientation(Options::ScreenOrientations newOrient)
7070
if (newOrient == GetOrientation()) return;
7171
CDasherView::SetOrientation(newOrient);
7272
m_bVisibleRegionValid = false;
73-
SetScaleFactor();
73+
ComputeScaleFactor();
7474
}
7575

7676
/////////////////////////////////////////////////////////////////////////////
@@ -176,7 +176,7 @@ CDasherNode* CDasherViewSquare::Render(CDasherNode* pRoot, myint iRootMin, myint
176176
/// specified as two co-ordinates, intended to the be the corners of
177177
/// the leading edge of the containing box.
178178

179-
CDasherViewSquare::CTextString* CDasherViewSquare::DasherDrawText(myint iDasherMaxX, myint iDasherMidY, CDasherScreen::Label* pLabel, const ColorPalette::Color& Color)
179+
CDasherViewSquare::CTextString* CDasherViewSquare::DasherDrawText(myint iDasherMaxX, myint iDasherMidY, CDasherScreen::Label* pLabel, const ColorPalette::Color& Color) const
180180
{
181181
screenint x, y;
182182
Dasher2Screen(iDasherMaxX, iDasherMidY, x, y);
@@ -315,7 +315,7 @@ CDasherViewSquare::CTextString::~CTextString()
315315
}
316316
}
317317

318-
void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, myint midy2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth)
318+
void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, myint midy2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth) const
319319
{
320320
DASHER_ASSERT(y1 <= midy1 && midy1 <= midy2 && midy2 <= y2);
321321

@@ -410,7 +410,7 @@ void CDasherViewSquare::TruncateTri(myint x, myint y1, myint y2, myint midy1, my
410410

411411
#define sq(X) ((X)*(X))
412412

413-
void CDasherViewSquare::Circle(myint Range, myint y1, myint y2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth)
413+
void CDasherViewSquare::Circle(myint Range, myint y1, myint y2, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth) const
414414
{
415415
std::vector<point> pts;
416416
myint cy((y1 + y2) / 2), r(Range / 2), x1, x2;
@@ -465,7 +465,7 @@ void CDasherViewSquare::Circle(myint Range, myint y1, myint y2, const ColorPalet
465465
delete[] p_array;
466466
}
467467

468-
void CDasherViewSquare::CircleTo(myint cy, myint r, myint y1, myint x1, myint y3, myint x3, point dest, std::vector<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) const
469469
{
470470
myint y2((y1 + y3) / 2);
471471
myint x2(static_cast<myint>(sqrt((sq(r) - sq(cy - y2)) * dXMul)));
@@ -485,7 +485,7 @@ void CDasherViewSquare::CircleTo(myint cy, myint r, myint y1, myint x1, myint y3
485485
}
486486
#undef sq
487487

488-
void CDasherViewSquare::DasherSpaceArc(myint cy, myint r, myint x1, myint y1, myint x2, myint y2, const ColorPalette::Color& color, int iLineWidth)
488+
void CDasherViewSquare::DasherSpaceArc(myint cy, myint r, myint x1, myint y1, myint x2, myint y2, const ColorPalette::Color& color, int iLineWidth) const
489489
{
490490
point p;
491491
//start point
@@ -507,7 +507,7 @@ void CDasherViewSquare::DasherSpaceArc(myint cy, myint r, myint x1, myint y1, my
507507
Screen()->Polyline(p_array, static_cast<int>(pts.size()), iLineWidth, color);
508508
}
509509

510-
void CDasherViewSquare::Quadric(myint Range, myint lowY, myint highY, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth)
510+
void CDasherViewSquare::Quadric(myint Range, myint lowY, myint highY, const ColorPalette::Color& fillColor, const ColorPalette::Color& outlineColor, int lineWidth) const
511511
{
512512
static const double RR2 = 1.0 / sqrt(2.0);
513513
const int midY = static_cast<int>((lowY + highY) / 2);
@@ -536,7 +536,7 @@ void CDasherViewSquare::Quadric(myint Range, myint lowY, myint highY, const Colo
536536
#undef NUM_STEPS
537537
}
538538

539-
bool CDasherViewSquare::IsSpaceAroundNode(myint y1, myint y2)
539+
bool CDasherViewSquare::IsSpaceAroundNode(myint y1, myint y2) const
540540
{
541541
const DasherCoordScreenRegion visibleRegion = VisibleRegion();
542542
const myint maxX(y2 - y1);
@@ -730,7 +730,7 @@ void CDasherViewSquare::DisjointRender(CDasherNode* pRender, myint y1, myint y2,
730730
}
731731
}
732732

733-
void CDasherViewSquare::DasherDrawCube(myint iDasherMaxX, myint iDasherMinY, myint iDasherMinX, myint iDasherMaxY, CubeDepthLevel nodeDepth, CubeDepthLevel parentDepth, const ColorPalette::Color& Color, const ColorPalette::Color& outlineColor, int iThickness, ScreenRegion* parentScreenBounds)
733+
void CDasherViewSquare::DasherDrawCube(myint iDasherMaxX, myint iDasherMinY, myint iDasherMinX, myint iDasherMaxY, CubeDepthLevel nodeDepth, CubeDepthLevel parentDepth, const ColorPalette::Color& Color, const ColorPalette::Color& outlineColor, int iThickness, ScreenRegion* parentScreenBounds) const
734734
{
735735
screenint iScreenMaxX, iScreenMinY, iScreenMinX, iScreenMaxY;
736736
Dasher2Screen(iDasherMaxX, iDasherMinY, iScreenMaxX, iScreenMinY);
@@ -803,7 +803,7 @@ bool CDasherViewSquare::CoversCrosshair(myint Range, myint y1, myint y2)
803803
return false;
804804
}
805805

806-
ColorPalette::Color CDasherViewSquare::SimulateTransparency(CDasherNode* pCurrentNode)
806+
ColorPalette::Color CDasherViewSquare::SimulateTransparency(CDasherNode* pCurrentNode) const
807807
{
808808
if(pCurrentNode == nullptr) return GetNamedColor(NamedColor::background);
809809

@@ -881,7 +881,7 @@ void CDasherViewSquare::NewRender(CDasherNode* pCurrentNode, myint y1, myint y2,
881881
const int line_width = labs(m_pSettingsStore->GetLongParameter(LP_OUTLINE_WIDTH));
882882
const ColorPalette::Color& fill_color = line_width < 0 ? ColorPalette::noColor : (m_pSettingsStore->GetBoolParameter(BP_SIMULATE_TRANSPARENCY) ? SimulateTransparency(pCurrentNode) : pCurrentNode->getNodeColor(m_pColorPalette));
883883
const ColorPalette::Color& outline_color = line_width == 0 ? ColorPalette::noColor : pCurrentNode->getOutlineColor(m_pColorPalette);
884-
884+
885885
switch (m_pSettingsStore->GetLongParameter(LP_SHAPE_TYPE))
886886
{
887887
case Options::OVERLAPPING_RECTANGLE:
@@ -1008,7 +1008,7 @@ void CDasherViewSquare::NewRender(CDasherNode* pCurrentNode, myint y1, myint y2,
10081008
/// just the inverse of the mapping used to calculate the screen
10091009
/// positions of boxes etc.
10101010

1011-
void CDasherViewSquare::Screen2Dasher(screenint iInputX, screenint iInputY, myint& iDasherX, myint& iDasherY)
1011+
void CDasherViewSquare::Screen2Dasher(screenint iInputX, screenint iInputY, myint& iDasherX, myint& iDasherY) const
10121012
{
10131013
// Things we're likely to need:
10141014

@@ -1041,7 +1041,7 @@ void CDasherViewSquare::Screen2Dasher(screenint iInputX, screenint iInputY, myin
10411041
iDasherY = iymap(iDasherY);
10421042
}
10431043

1044-
void CDasherViewSquare::SetScaleFactor(void)
1044+
void CDasherViewSquare::ComputeScaleFactor()
10451045
{
10461046
//Parameters for X non-linearity.
10471047
// Set some defaults here, in case we change(d) them later...
@@ -1141,7 +1141,7 @@ inline myint CDasherViewSquare::CustomIDivScaleFactor(myint iNumerator)
11411141
// return (iNumerator + iDenominator - 1) / iDenominator;
11421142
}
11431143

1144-
void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint& iScreenX, screenint& iScreenY)
1144+
void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint& iScreenX, screenint& iScreenY) const
11451145
{
11461146
// Apply the nonlinearities
11471147

@@ -1180,7 +1180,7 @@ void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint&
11801180
}
11811181
}
11821182

1183-
void CDasherViewSquare::Dasher2Polar(myint iDasherX, myint iDasherY, double& r, double& theta)
1183+
void CDasherViewSquare::Dasher2Polar(myint iDasherX, myint iDasherY, double& r, double& theta) const
11841184
{
11851185
iDasherX = xmap(iDasherX);
11861186
iDasherY = ymap(iDasherY);
@@ -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<point>& vPoints)
1197+
void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<point>& vPoints) const
11981198
{
11991199
if (x1 != x2 && y1 != y2)
12001200
{
@@ -1264,7 +1264,7 @@ void CDasherViewSquare::DasherLine2Screen(myint x1, myint y1, myint x2, myint y2
12641264
vPoints.push_back(p);
12651265
}
12661266

1267-
CDasherView::DasherCoordScreenRegion CDasherViewSquare::VisibleRegion()
1267+
CDasherView::DasherCoordScreenRegion CDasherViewSquare::VisibleRegion() const
12681268
{
12691269
if (!m_bVisibleRegionValid)
12701270
{
@@ -1299,7 +1299,7 @@ CDasherView::DasherCoordScreenRegion CDasherViewSquare::VisibleRegion()
12991299
void CDasherViewSquare::ScreenResized(CDasherScreen* NewScreen)
13001300
{
13011301
m_bVisibleRegionValid = false;
1302-
SetScaleFactor();
1302+
ComputeScaleFactor();
13031303
}
13041304

13051305
/// Draw the crosshair

0 commit comments

Comments
 (0)