Skip to content

Commit 600a0b6

Browse files
Simplified the integral drawing code
Resolves #1543
1 parent ec5fbe8 commit 600a0b6

File tree

1 file changed

+41
-100
lines changed

1 file changed

+41
-100
lines changed

src/cells/IntCell.cpp

Lines changed: 41 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -215,107 +215,48 @@ void IntCell::Draw(wxPoint point)
215215

216216
wxPoint base(point), under(point), over(point), var(point), sign(point);
217217

218-
if (configuration->CheckTeXFonts())
219-
{
220-
SetForeground();
221-
auto fontsize1 = AFontSize(m_fontSize_Scaled * 1.5);
222-
wxASSERT(fontsize1.IsValid());
223-
224-
Style style = Style(fontsize1)
225-
.FontName(configuration->GetTeXCMEX());
226-
227-
if (!style.IsFontOk())
228-
configuration->CheckTeXFonts(false);
229-
230-
dc->SetFont(style.GetFont());
231-
dc->DrawText(wxT("\u005A"),
232-
sign.x,
233-
sign.y - m_signTop);
234-
}
235-
else
236-
{
237-
#if defined __WXMSW__
238-
SetForeground();
239-
auto fontsize1 = AFontSize(Scale_Px(INTEGRAL_FONT_SIZE));
240-
int m_signWCenter = m_signWidth / 2;
241-
wxASSERT(fontsize1.IsValid());
242-
243-
Style style = Style(fontsize1)
244-
.FontName(configuration->GetSymbolFontName());
245-
246-
dc->SetFont(style.GetFont());
247-
dc->DrawText(INTEGRAL_TOP,
248-
sign.x + m_signWCenter - m_charWidth / 2,
249-
sign.y - (m_signHeight + 1) / 2);
250-
dc->DrawText(INTEGRAL_BOTTOM,
251-
sign.x + m_signWCenter - m_charWidth / 2,
252-
sign.y + (m_signHeight + 1) / 2 - m_charHeight);
253-
254-
int top, bottom;
255-
top = sign.y - (m_signHeight + 1) / 2 + m_charHeight / 2;
256-
bottom = sign.y + (m_signHeight + 1) / 2 - (3 * m_charHeight) / 2;
257-
if (top <= bottom)
218+
SetPen(1.5);
219+
// top decoration
220+
int m_signWCenter = m_signWidth / 2;
221+
wxPoint points[7] =
258222
{
259-
wxASSERT_MSG(m_charHeight>=2,_("Font issue: The char height is too small!"));
260-
if(m_charHeight <= 2)
261-
m_charHeight = 2;
262-
263-
while (top < bottom)
264-
{
265-
dc->DrawText(INTEGRAL_EXTEND,
266-
point.x + m_signWCenter - m_charWidth / 2,
267-
top);
268-
top += (2*m_charHeight)/3;
269-
}
270-
dc->DrawText(INTEGRAL_EXTEND,
271-
point.x + m_signWCenter - m_charWidth / 2,
272-
sign.y + (m_signHeight + 1) / 2 - (3 * m_charHeight) / 2);
273-
}
274-
#else
275-
SetPen(1.5);
276-
// top decoration
277-
int m_signWCenter = m_signWidth / 2;
278-
wxPoint points[7] =
279-
{
280-
{sign.x + m_signWCenter + 2 * (m_signWidth / 4),
281-
sign.y - (m_signHeight - Scale_Px(1)) / 2 + m_signWidth / 4},
282-
{sign.x + m_signWCenter + m_signWidth / 4,
283-
sign.y - (m_signHeight - Scale_Px(1)) / 2},
284-
{sign.x + m_signWCenter,
285-
sign.y - (m_signHeight - Scale_Px(1)) / 2 + 2* (m_signWidth / 4)
286-
+ Scale_Px(.35)},
287-
288-
// The line
289-
{sign.x + m_signWCenter + Scale_Px(.5),
290-
sign.y},
291-
292-
// Bottom Decoration
293-
{sign.x + m_signWCenter,
294-
sign.y + (m_signHeight - Scale_Px(1)) / 2 - 2* (m_signWidth / 4)
295-
+ Scale_Px(.35)},
296-
{sign.x + m_signWCenter - m_signWidth / 4,
297-
sign.y + (m_signHeight - Scale_Px(1)) / 2},
298-
{sign.x + m_signWCenter - 2 * (m_signWidth / 4),
299-
sign.y + (m_signHeight - Scale_Px(1)) / 2 - m_signWidth / 4}
300-
};
301-
302-
configuration->GetAntialiassingDC()->DrawSpline(7, points);
303-
points[1] = {sign.x + m_signWCenter + m_signWidth / 4,
304-
sign.y - (m_signHeight - Scale_Px(1.25)) / 2};
305-
points[2] = {sign.x + m_signWCenter,
306-
sign.y - (m_signHeight - Scale_Px(1)) / 2 + 2* (m_signWidth / 4)
307-
- Scale_Px(.35)};
308-
points[3] = {sign.x + m_signWCenter - Scale_Px(.5),
309-
sign.y};
310-
points[4] = {sign.x + m_signWCenter,
311-
sign.y + (m_signHeight - Scale_Px(1)) / 2 - 2* (m_signWidth / 4)
312-
+ Scale_Px(.35)};
313-
points[5] = {sign.x + m_signWCenter - m_signWidth / 4,
314-
sign.y + (m_signHeight - Scale_Px(1.25)) / 2};
315-
configuration->GetAntialiassingDC()->DrawSpline(7, points);
316-
// line
317-
#endif
318-
}
223+
{sign.x + m_signWCenter + 2 * (m_signWidth / 4),
224+
sign.y - (m_signHeight - Scale_Px(1)) / 2 + m_signWidth / 4},
225+
{sign.x + m_signWCenter + m_signWidth / 4,
226+
sign.y - (m_signHeight - Scale_Px(1)) / 2},
227+
{sign.x + m_signWCenter,
228+
sign.y - (m_signHeight - Scale_Px(1)) / 2 + 2* (m_signWidth / 4)
229+
+ Scale_Px(.35)},
230+
231+
// The line
232+
{sign.x + m_signWCenter + Scale_Px(.5),
233+
sign.y},
234+
235+
// Bottom Decoration
236+
{sign.x + m_signWCenter,
237+
sign.y + (m_signHeight - Scale_Px(1)) / 2 - 2* (m_signWidth / 4)
238+
+ Scale_Px(.35)},
239+
{sign.x + m_signWCenter - m_signWidth / 4,
240+
sign.y + (m_signHeight - Scale_Px(1)) / 2},
241+
{sign.x + m_signWCenter - 2 * (m_signWidth / 4),
242+
sign.y + (m_signHeight - Scale_Px(1)) / 2 - m_signWidth / 4}
243+
};
244+
245+
configuration->GetAntialiassingDC()->DrawSpline(7, points);
246+
points[1] = {sign.x + m_signWCenter + m_signWidth / 4,
247+
sign.y - (m_signHeight - Scale_Px(1.25)) / 2};
248+
points[2] = {sign.x + m_signWCenter,
249+
sign.y - (m_signHeight - Scale_Px(1)) / 2 + 2* (m_signWidth / 4)
250+
- Scale_Px(.35)};
251+
points[3] = {sign.x + m_signWCenter - Scale_Px(.5),
252+
sign.y};
253+
points[4] = {sign.x + m_signWCenter,
254+
sign.y + (m_signHeight - Scale_Px(1)) / 2 - 2* (m_signWidth / 4)
255+
+ Scale_Px(.35)};
256+
points[5] = {sign.x + m_signWCenter - m_signWidth / 4,
257+
sign.y + (m_signHeight - Scale_Px(1.25)) / 2};
258+
configuration->GetAntialiassingDC()->DrawSpline(7, points);
259+
// line
319260

320261
if (m_intStyle == INT_DEF)
321262
{

0 commit comments

Comments
 (0)