Ticket #8256 (reopened)

Opened 7 years ago

Last modified 5 years ago

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

Reported by: Roman Tolchenov Owned by: Harry Jeffery
Priority: major Milestone: Backlog
Component: GUI Keywords: student
Cc: Blocked By:
Blocking: Tester: Roman Tolchenov

Description


Change History

comment:1 Changed 7 years ago by Nick Draper

  • Status changed from new to assigned
  • Owner set to Keith Brown

comment:2 Changed 6 years ago by Keith Brown

  • Owner changed from Keith Brown to Anyone

not going to get this done before i leave, leaving to anyone

comment:3 Changed 6 years ago by Nick Draper

  • Keywords student added

comment:4 Changed 6 years ago by Martyn Gigg

  • Milestone changed from Backlog to Release 3.3

comment:5 Changed 6 years ago by Harry Jeffery

  • Owner changed from Anyone to Harry Jeffery
  • Status changed from assigned to inprogress

comment:6 Changed 6 years ago by Harry Jeffery

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.

comment:7 Changed 6 years ago by Harry Jeffery

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 #8256

Changeset: ac41c39eb98aaa6ad20408abfe0dc966ea913acb

comment:8 Changed 6 years ago by Harry Jeffery

  • Status changed from inprogress to verify
  • Resolution set to fixed

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.

comment:9 Changed 6 years ago by Roman Tolchenov

  • Status changed from verify to verifying
  • Tester set to Roman Tolchenov

comment:10 Changed 6 years ago by Roman Tolchenov

  • Status changed from verifying to reopened
  • Resolution fixed deleted

Tried on windows. Title still disappears.

comment:11 Changed 6 years ago by Harry Jeffery

  • Milestone changed from Release 3.3 to Release 3.4

comment:12 Changed 6 years ago by Harry Jeffery

  • Milestone changed from Release 3.4 to Backlog

comment:13 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9101

Note: See TracTickets for help on using tickets.