Results 1 to 20 of 24

Thread: [MathML] problem displaying a math expression

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    I had a quick look at your changes and IMHO it seems to me like you are working around issues that have to do with rounding errors because of an integer based implementation. Your patches somehow fix these problems by adding some margins here changing a factor there. This might be a solution when using a formula with QwtTextLabel, but when scaling comes into the game ( f.e. a formula on the canvas painted with QwtPlotRenderer to PDF ) your approach will not be enough.

    IMO a more promising approach would be to modify the renderer being completely floating point based ?

    Uwe

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    I must confess that, so far, I have been working on getting the original QtMmlWidget's MathML renderer to work within Qwt (which is now the case). From there, I have been working on fixing some issues I have found with the original MathML renderer (still working on it).

    This being said, I agree that a floating point based approach would be better. Maybe I should go through the code and, who knows, it might mean I don't have 'patch' certain things. Then again, there are some factors that were just plain wrong, so I had no choice but to 'fix' them. For example, say that you have x with i as a sub-script and j as a super-script. In this case, the MathML render uses g_script_size_multiplier to scale those scripts. However, the original value of g_script_size_multiplier is such that i and j would always overlap, hence I modified that value to 0.5 (from 0.7071) and as expected now everything is fine.

    Anyway, it's still very much work in progress, but I am hoping to be done with it within the next few days. (I can't afford to spend too much time on this.) From there, I leave it to you to incorporate 'my' version of the MathML render to Qwt or not. What is certain is that you are better placed than I am to test the renderer for use within Qwt (my use of Qwt is somewhat limited).

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    What about starting this way: I will set up a test application ( in qwt/playground/mathml ), where a MathML text is displayed in the center of a widget using the MathML renderer in its paint event. It will be using a transformation, that can be modified by the mouse ( scale factor + maybe a rotation ). Your contribution would be to set up a reasonable collection of MathML formulas, that can be loaded into the application.

    Then we can see easily where the renderer needs polishing.

    Uwe

  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Seems like a sensible approach to me. We should start by using a version of QtMmlWidget's MathML renderer that works with Qwt, but doesn't contain my 'fixes'/'patches'. From there, we should convert the code to use a floating point based approach. Finally, based on the results we get from the test application, we can see whether any of my 'fixes'/'patches' are still needed.

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    I suggest we leave the forum and continue by Email. Please send me a couple of MathML formulas I can use as a start for the test application.

    Uwe

  6. #6
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Sorry, but I can't seem to find how to send a private message on here. Anyway, you can find some formulas here and then my email address from my GitHub account.

  7. #7
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Guys, what is the status of Your current development? Is it ready to use: http://www.qtcentre.org/threads/6610...orkable-in-Qwt ?

  8. #8
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Uwe and I did exchange quite a few emails, and I ended up reworking the MathML engine quite a bit. I haven't done anything about it for quite a while, so I can't remember whether the version at https://github.com/uwerat/qwt-mml-dev is still up to date. So, just in case, you can find 'my' version at https://github.com/opencor/opencor/t...engines/mathml. What is sure is that the equation you mention at http://www.qtcentre.org/threads/6610...orkable-in-Qwt can now safely be rendered.

  9. The following 2 users say thank you to agarny for this useful post:

    AlekseyK (25th May 2016), fcona (12th July 2019)

  10. #9
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Quote Originally Posted by agarny View Post
    So, just in case, you can find 'my' version at https://github.com/opencor/opencor/t...engines/mathml. What is sure is that the equation you mention at http://www.qtcentre.org/threads/6610...orkable-in-Qwt can now safely be rendered.
    agarny, so You version mentioned above works fine, correct? Will try to replace qwt sources by Your version and rebuild. Thanks!

  11. #10
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    agarny, Your sources works fine. Thank You very much!!!

    Some bugs however:


    • formula background is white, need to be gray as button default color. autoFillBackground does not help.
    • Aslo font color changing through palette propery has effect: only for plain text, for MathML engine still black.
    • QwtText::setColor() has no effect
    • QwtText::setBackgroundBrush() has no effect
    • QwtText::setPaintAttribute() for color or background true or false has no effect


    Any way to fix?

    Note: need to add qwt_mml_entity_table.h/cpp files to mathml.pro also.

    Uwe, any chance to include this patches into official version? Thanks!
    Last edited by AlekseyK; 26th May 2016 at 01:52.

  12. #11
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Sorry AlekseyK, qtcentre.org wasn't working for me these past few days. Anyway, glad that the MathML renderer works for you.

    Regarding the issues that you have found:
    • formula background is white, need to be gray as button default color. autoFillBackground does not help.
      I made it white because that seemed more 'natural' to me, not to mention that this widget is not a button, so I don't see why it should be grey.
    • Aslo font color changing through palette propery has effect: only for plain text, for MathML engine still black.
      I am not sure what you mean by this, sorry.
    • QwtText::setColor() has no effect.
    • QwtText::setBackgroundBrush() has no effect.
    • QwtText::setPaintAttribute() for color or background true or false has no effect.
      I am not sure to what you are referring here. I mean, the widget is QwtMathMLDocument, so...?
    • need to add qwt_mml_entity_table.h/cpp files to mathml.pro also.
      Quite possible. Personally, I use CMake, so...


    I am sure there must be a way to fix your 'issues'. Unfortunately, I really don't have time for it at the moment, not least since it has yet to be officially included in Qwt. However, if Uwe was to officially incorporate my changes into Qwt, then I would certainly try to find the time to iron things out.

  13. #12
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Quote Originally Posted by agarny View Post
    Sorry AlekseyK, qtcentre.org wasn't working for me these past few days.
    It was down.

    Quote Originally Posted by agarny View Post
    Anyway, glad that the MathML renderer works for you.
    Thank You very much for this.

    Quote Originally Posted by agarny View Post
    Regarding the issues that you have found:
    [LIST][*]formula background is white, need to be gray as button default color. autoFillBackground does not help.
    I made it white because that seemed more 'natural' to me, not to mention that this widget is not a button, so I don't see why it should be grey.
    For document - yes. For label it should have label background, like in my example: http://www.qtcentre.org/attachment.p...138969&thumb=1

    Quote Originally Posted by agarny View Post
    [*]Aslo font color changing through palette propery has effect: only for plain text, for MathML engine still black.
    I am not sure what you mean by this, sorry.
    Formula font color. It is always black. I'd like to change it.

    Quote Originally Posted by agarny View Post
    [*]QwtText::setColor() has no effect.[*]QwtText::setBackgroundBrush() has no effect.[*]QwtText::setPaintAttribute() for color or background true or false has no effect.
    I am not sure to what you are referring here. I mean, the widget is QwtMathMLDocument, so...?
    I use QwtTextLabel.

    Quote Originally Posted by agarny View Post
    I am sure there must be a way to fix your 'issues'. Unfortunately, I really don't have time for it at the moment, not least since it has yet to be officially included in Qwt. However, if Uwe was to officially incorporate my changes into Qwt, then I would certainly try to find the time to iron things out.
    Thank You. Hope Uwe will see this conversation and add patches to official Qwt sources.

  14. #13
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [MathML] problem displaying a math expression

    Quote Originally Posted by AlekseyK View Post
    Hope Uwe will see this conversation and add patches to official Qwt sources.
    Unfortunately I lost a lot of time with implementing all the spline interpolation algos ( out of personal interest ) and I'm also working on another open source project, what is the reason why I'm heavily delayed with 6.2 - at least I hope I can release 6.1.3 soon.

    Alans version of the MathML stuff can be seen as the official version - it is planned to become part of Qwt 6.3. But always keep in mind, that its not my priority to offer a first class MathML package - all I ( and of course Alan in the first place ) did was to turn the orphaned MathML implementation from the Qt solutions package into something "usable".

    Uwe

Similar Threads

  1. Replies: 3
    Last Post: 22nd August 2013, 12:57
  2. Problem with regular expression not working
    By Suppaman in forum Qt Programming
    Replies: 6
    Last Post: 9th April 2013, 22:40
  3. Support of MathML in Qt
    By oficjalne100 in forum Newbie
    Replies: 0
    Last Post: 28th September 2011, 12:18
  4. Support of MathML in Qt
    By oficjalne100 in forum General Discussion
    Replies: 0
    Last Post: 25th September 2011, 17:24
  5. Regular Expression Problem
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2009, 09:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.