Add a python extension function to access picked location. Refs #2065

This commit is contained in:
baldurk
2022-05-31 11:26:59 +01:00
parent 6d7d4829ee
commit f01dfbecc1
3 changed files with 35 additions and 0 deletions
+9
View File
@@ -667,6 +667,15 @@ bounds parameters will be clamped to the available subresources.
)");
virtual void GotoLocation(uint32_t x, uint32_t y) = 0;
DOCUMENT(R"(Returns the currently selected texel location in the current texture.
If no location is currently selected or there is no current texture, this will return ``(-1, -1)``.
:return: The currently picked pixel location.
:rtype: Tuple[int,int]
)");
virtual rdcpair<int32_t, int32_t> GetPickedLocation() = 0;
DOCUMENT(R"(Return the currently selected texture overlay.
:return: The currently selected texture overlay.
+25
View File
@@ -1815,6 +1815,7 @@ void TextureViewer::UI_UpdateChannels()
INVOKE_MEMFN(RT_UpdateAndDisplay);
INVOKE_MEMFN(RT_UpdateVisualRange);
UI_UpdateStatusText();
}
void TextureViewer::SetupTextureTabs()
@@ -3791,6 +3792,30 @@ void TextureViewer::on_locationGoto_clicked()
ShowGotoPopup();
}
rdcpair<int32_t, int32_t> TextureViewer::GetPickedLocation()
{
TextureDescription *texptr = GetCurrentTexture();
if(texptr)
{
QPoint p = m_PickedPoint;
p.setX(p.x() >> (int)m_TexDisplay.subresource.mip);
p.setY(p.y() >> (int)m_TexDisplay.subresource.mip);
uint32_t mipHeight = qMax(1U, texptr->height >> (int)m_TexDisplay.subresource.mip);
if(ShouldFlipForGL())
p.setY((int)(mipHeight - 1) - p.y());
if(m_TexDisplay.flipY)
p.setY((int)(mipHeight - 1) - p.y());
return {p.x(), p.y()};
}
return {-1, -1};
}
void TextureViewer::ShowGotoPopup()
{
TextureDescription *texptr = GetCurrentTexture();
+1
View File
@@ -143,6 +143,7 @@ public:
Subresource GetSelectedSubresource() override;
void SetSelectedSubresource(Subresource sub) override;
rdcpair<int32_t, int32_t> GetPickedLocation() override;
void GotoLocation(uint32_t x, uint32_t y) override;
DebugOverlay GetTextureOverlay() override;
void SetTextureOverlay(DebugOverlay overlay) override;