Skip to content

Commit f01dfbe

Browse files
committed
Add a python extension function to access picked location. Refs #2065
1 parent 6d7d482 commit f01dfbe

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

qrenderdoc/Code/Interface/QRDInterface.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,15 @@ bounds parameters will be clamped to the available subresources.
667667
)");
668668
virtual void GotoLocation(uint32_t x, uint32_t y) = 0;
669669

670+
DOCUMENT(R"(Returns the currently selected texel location in the current texture.
671+
672+
If no location is currently selected or there is no current texture, this will return ``(-1, -1)``.
673+
674+
:return: The currently picked pixel location.
675+
:rtype: Tuple[int,int]
676+
)");
677+
virtual rdcpair<int32_t, int32_t> GetPickedLocation() = 0;
678+
670679
DOCUMENT(R"(Return the currently selected texture overlay.
671680
672681
:return: The currently selected texture overlay.

qrenderdoc/Windows/TextureViewer.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,7 @@ void TextureViewer::UI_UpdateChannels()
18151815

18161816
INVOKE_MEMFN(RT_UpdateAndDisplay);
18171817
INVOKE_MEMFN(RT_UpdateVisualRange);
1818+
UI_UpdateStatusText();
18181819
}
18191820

18201821
void TextureViewer::SetupTextureTabs()
@@ -3791,6 +3792,30 @@ void TextureViewer::on_locationGoto_clicked()
37913792
ShowGotoPopup();
37923793
}
37933794

3795+
rdcpair<int32_t, int32_t> TextureViewer::GetPickedLocation()
3796+
{
3797+
TextureDescription *texptr = GetCurrentTexture();
3798+
3799+
if(texptr)
3800+
{
3801+
QPoint p = m_PickedPoint;
3802+
3803+
p.setX(p.x() >> (int)m_TexDisplay.subresource.mip);
3804+
p.setY(p.y() >> (int)m_TexDisplay.subresource.mip);
3805+
3806+
uint32_t mipHeight = qMax(1U, texptr->height >> (int)m_TexDisplay.subresource.mip);
3807+
3808+
if(ShouldFlipForGL())
3809+
p.setY((int)(mipHeight - 1) - p.y());
3810+
if(m_TexDisplay.flipY)
3811+
p.setY((int)(mipHeight - 1) - p.y());
3812+
3813+
return {p.x(), p.y()};
3814+
}
3815+
3816+
return {-1, -1};
3817+
}
3818+
37943819
void TextureViewer::ShowGotoPopup()
37953820
{
37963821
TextureDescription *texptr = GetCurrentTexture();

qrenderdoc/Windows/TextureViewer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class TextureViewer : public QFrame, public ITextureViewer, public ICaptureViewe
143143

144144
Subresource GetSelectedSubresource() override;
145145
void SetSelectedSubresource(Subresource sub) override;
146+
rdcpair<int32_t, int32_t> GetPickedLocation() override;
146147
void GotoLocation(uint32_t x, uint32_t y) override;
147148
DebugOverlay GetTextureOverlay() override;
148149
void SetTextureOverlay(DebugOverlay overlay) override;

0 commit comments

Comments
 (0)