Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub/super-script formatting isn't working for titles in 3D plots #9101

Closed
mantid-roman opened this issue Oct 28, 2013 · 2 comments
Closed

Sub/super-script formatting isn't working for titles in 3D plots #9101

mantid-roman opened this issue Oct 28, 2013 · 2 comments
Assignees

Comments

@mantid-roman
Copy link
Contributor

This issue was originally TRAC 8256

Issue details are blank in trac


Keywords: student

@mantid-roman
Copy link
Contributor Author

Keith Brown (2014-06-26T13:07:51):
not going to get this done before i leave, leaving to anyone


@eXeC64 (2014-07-14T14:15:26):
I've been investigating this issue and it's a little bizarre.

Firstly:
Mantid/MantidPlot/src/lib/src/TextFormatButtons.cpp - TextFormatButtons::addSubscript

void TextFormatButtons::addSubscript()
{
  if (d_buttons == TexLegend || d_buttons == Equation || d_buttons == Plot3D)
    formatText("_{","}");
  else
    formatText("`<sub>`","`</sub>`");
}

For 3D plots it's specifically choosing to use TeX style superscript and subscript syntax. Now, this could either suggest that it did somehow work once, or it could be to cover up a bug.

The bug: Create a 3D plot. Open its properties and set the title to "<sub>subscripted text</sub>" and hit ok. The title on the plot will literally be "<sub>subscripted text</sub>". Now, re-open the plot's properties. You'll find that you just have "subscripted text" in subscript, and that next time you hit "Ok" or "Apply", the title completely disappears from the plot and seems irretrievable without creating a new plot.

I've investigated both the 2D and 3D plots, and they both just pass a QString into either QwtPlot or QwtPlot3D. So I went digging into QwtPlot and QwtPlot3D's code to try and figure out why it works for one but not the other.

QwtPlot3D uses QPainter::drawText(int x, int y, QString text) to draw onto a QPixmap and then pass the pixel data to OpenGL for drawing.

QwtPlot uses QwtTextLabel (based off of QFrame) which then uses QwtText to draw its plot titles. Internally QwtText uses QwtTextEngine, which uses QwtPainter::drawText, which uses QPainter::drawText to draw pixels in a QPixmap.

So after all that indirection, they both use QPainter to draw text into a QPixmap. Why one works and not the other remains a mystery, but it looks like to fix this issue would require debugging and modification of QwtPlot3D itself.

I've managed to resolve the bug I described above, but actually enabling superscript and subscript in the 3D plot title is going to be an extremely involved affair it seems.


@eXeC64 (2014-07-14T14:15:44):
Fixed 3D plot dialog fields being superscripted.

Using <sub>text</sub> would cause text to be subscript next time the
title or axis properties tabs were opened, which cause the fields to
disappear from the plot. This commit fixes that issue.

Refs http://trac.mantidproject.org/mantid/ticket/8256

ac41c39


@eXeC64 (2014-07-14T14:55:41):
After deliberation with Martyn, I've concluded that QwtPlot3D doesn't support using superscript or subscript in the title or axis labels, and as no user has yet requested it, the issue will be left unresolved.

However, since a smaller, but related, defect (described and fixed above) has been discovered and fixed. This ticket will be marked as 'fixed' and the corrections merged.

'''Testing:'''

To reproduce the bug described above: Load any data set and create a 3D plot of it. Change one of the labels or the title to "<sub>bug</sub>" or "<sup>bug</sup>" and press "Ok". Then re-open the change label/title dialogue (You should notice that the text itself will be sub/superscript in the dialogue) and press "Ok." again. The title or axis label will disappear, and changing its text will not make it reappear.

'''Fixed behaviour:'''

The text will not be super/subscript when you re-open the label/axis title dialogue, but will still be the markup to represent such formatting. Pressing "Ok" will not cause the title/axis label to disappear.


@mantid-roman (2014-07-25T15:20:45):
Tried on windows. Title still disappears.

@NickDraper
Copy link
Contributor

Not worth fixing as this will be replaced in M4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants