MUIDrawManager text2D on top

MUIDrawManager text2D on top

chaneyx
Advocate Advocate
2,385 Views
9 Replies
Message 1 of 10

MUIDrawManager text2D on top

chaneyx
Advocate
Advocate

How do I ensure that text2D draws on top of  all other elements? 

 

I am making a variant of MayaPluginForSpreticle which has letter box and text functionality. I thought I could modify draw order or push the glVertex3d z values away from camera for all non text elements but my text2D calls are going underneath the letter box masks. 

 

The GL_LINES are behaving as expected. But the GL_QUADS are not. 

 

Thank you

 

 

 

 

0 Likes
Accepted solutions (1)
2,386 Views
9 Replies
Replies (9)
Message 2 of 10

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

MUiDrawManager::text2d and other 2d drawings should respect z component of MPoint for depth sorting. Please try to assign a z value for the input of MUiDrawManager::text2d like MPoint(x,y, -0.001) or other 2d drawings with (x,y,0.001).

 

Yours,

Li

Message 3 of 10

chaneyx
Advocate
Advocate

This is helpful. 

 

Is there any way to draw on top of the Maya Camera's Gate Mask? My hope is to put informative text on top of it for playblasts. No z values seem to do this. 

 

Thanks

 

 

0 Likes
Message 4 of 10

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

It is drawn after rendering, so z won't affect this. I've got two ideas for this.

 

1. Create a render override for the viewport.

 

You could get a standard viewport operation and modify the hud part with addUiDrawables. You could test this with viewRenderOverride in the devkit. Adding a MUiDrawManager::text2d in viewRenderHUDOperation::addUIDrawables should be able to let you draw text over gate masks.

 

2.Using Qt

 

Viewport is a QWidget, so you could add QLabel to it. e.g.

import maya.OpenMaya as om
import maya.OpenMayaUI as omui
import maya.cmds as cmds

from PySide2.QtCore import * 
from PySide2.QtGui import * 
from PySide2.QtWidgets import *
from shiboken2 import *

control = cmds.playblast(ae=True)
qwidget = omui.MQtUtil.findControl(control)

viewport = wrapInstance(long(qwidget), QWidget) 


label = QLabel(qwidget)
label.move(10,10)
label.setText("Test")
label.show()

But this method will have a background. I didn't find a good solution for this but it should be ok if you are drawing above gate masks.

 

Yours,

Li

 

 

0 Likes
Message 5 of 10

chaneyx
Advocate
Advocate

I like the simple idea of the QT solution. 

 

The code snippet produces these errors : 

 

# Error: TypeError: file <maya console> line 12: 'PySide2.QtWidgets.QLabel' called with wrong argument types:
PySide2.QtWidgets.QLabel(SwigPyObject)
Supported signatures:
PySide2.QtWidgets.QLabel(PySide2.QtWidgets.QWidget = None, PySide2.QtCore.Qt.WindowFlags = Qt.WindowFlags())
PySide2.QtWidgets.QLabel(unicode, PySide2.QtWidgets.QWidget = None, PySide2.QtCore.Qt.WindowFlags = Qt.WindowFlags()) #

 

Which I think is simply fixed by using 

label = QLabel(viewport)  as opposed to (qwidget)

 

But I do not see the "Test" label anywhere. Where should I expect it to appear? 

 

Thank you, 

Chris 

0 Likes
Message 6 of 10

chaneyx
Advocate
Advocate

Is the QT code that makes the viewport accessible like all the mel based UIs are?

 

I can modify that directly rather than trying to add elements to it after the fact. 

 

0 Likes
Message 7 of 10

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Yes, it is label = QLabel(viewport). It is on the top-left corner of viewport. I guess I made it wrong accidentally while cleaning up the code.

 


图片.png

The code before qLabel should give you Qt access to the viewport widget. You could try otherways but it could be much harder and not working. Using a widget is the easist way to do that.

 

Yours,

Li

0 Likes
Message 8 of 10

chaneyx
Advocate
Advocate

This seems to be a very straight forward solution. Unfortunately it is not working on my Mac OSX 10.13.1 with Maya 2018 but it is clearly working on your end. 

 

I will tinker with it unless you have some more ideas for possible solutions.

 

Thanks

0 Likes
Message 9 of 10

chaneyx
Advocate
Advocate

chengXiLiLabel.jpg

0 Likes
Message 10 of 10

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

It looks like viewport is drawing above the whole panel on the Mac. I was testing on windows, it was fine. I tried idea 1 and it works on Mac.

 

If you don't have to draw on the gate masks, maybe you could try to caclucate the geom of the film gate like spReticleLoc did and avoid drawing the text on the film gates.

 

Yours,

Li

0 Likes