Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/light manip UI #159

Merged
merged 9 commits into from
Jan 30, 2024
Merged

Feature/light manip UI #159

merged 9 commits into from
Jan 30, 2024

Conversation

toloudis
Copy link
Contributor

@toloudis toloudis commented Jan 16, 2024

A key missing component of in-viewport light manipulator. User interaction with the manipulator was not updating the numeric entry fields in the user interface. This change resolves that.

It also adds some code to the keypress handler so that the rotation gizmo and the light gizmo are in sync.
There is a button in the area light control panel to toggle the in-viewport controls. Or press "R" to toggle light source rotation gizmo on/off.
There is also a translation gizmo but since it is non-functional, it will stay disconnected from the UI.

// m_activeTool = new MoveTool();
// m_activeTool = new RotateTool();
// m_tools.push_back(new AreaLightTool());
m_areaLightTool = new AreaLightTool();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is showing two different patterns: one where I abstractly add a "disableable" tool to the list of tools (new ScaleBarTool below), and one where I explicitly create a tool and expect outside code to add/remove it as needed. I'm not sure if future work in this code will unify the two approaches, but both work for now as long as the bookkeeping is done properly.

@toloudis toloudis marked this pull request as ready for review January 16, 2024 21:25
@toloudis toloudis requested a review from a team as a code owner January 16, 2024 21:25
@toloudis toloudis requested review from meganrm, blairlyons, interim17, ShrimpCryptid, frasercl and ascibisz and removed request for a team January 16, 2024 21:25
@toloudis toloudis force-pushed the feature/light-manip-ui branch from 1634fca to 4924bb7 Compare January 16, 2024 23:57
Comment on lines +292 to +326
// toggle rotate tool
if (m_areaLightMode == AREALIGHT_MODE::NONE || m_areaLightMode == AREALIGHT_MODE::TRANS) {
m_viewerWindow->showAreaLightGizmo(true);
m_viewerWindow->setTool(
new RotateTool(m_viewerWindow->m_toolsUseLocalSpace, ManipulationTool::s_manipulatorSize * devicePixelRatioF()));
m_viewerWindow->forEachTool(
[this](ManipulationTool* tool) { tool->setUseLocalSpace(m_viewerWindow->m_toolsUseLocalSpace); });
m_areaLightMode = AREALIGHT_MODE::ROT;
} else {
m_viewerWindow->showAreaLightGizmo(false);
m_viewerWindow->setTool(nullptr);
m_areaLightMode = AREALIGHT_MODE::NONE;
}
}

// TODO currently this function is not wired up to any gui at all.
// This is because translation of area light source still needs work.
// (Currently rotation is sufficient.)
void
GLView3D::toggleAreaLightTranslateControls()
{
// toggle translate tool
if (m_areaLightMode == AREALIGHT_MODE::NONE || m_areaLightMode == AREALIGHT_MODE::ROT) {
m_viewerWindow->showAreaLightGizmo(true);
m_viewerWindow->setTool(
new MoveTool(m_viewerWindow->m_toolsUseLocalSpace, ManipulationTool::s_manipulatorSize * devicePixelRatioF()));
m_viewerWindow->forEachTool(
[this](ManipulationTool* tool) { tool->setUseLocalSpace(m_viewerWindow->m_toolsUseLocalSpace); });
m_areaLightMode = AREALIGHT_MODE::TRANS;
} else {
m_viewerWindow->showAreaLightGizmo(false);
m_viewerWindow->setTool(nullptr);
m_areaLightMode = AREALIGHT_MODE::NONE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note for the future, there's some duplicated boilerplate between these two methods. Might be worth seeing if they can be combined or reduced whenever the translation controls go in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's something for later. There's a big TODO at the top of the translate function and it may be completely changed when it's time to wire it up to something. This code is here to sort of remind us that it's similar to the rotate code but they can work together with the mode variable. Think I should just delete it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to keep in, it's a good reminder.

if (show) {
m_tools.push_back(m_areaLightTool);
} else {
m_tools.erase(std::remove(m_tools.begin(), m_tools.end(), m_areaLightTool), m_tools.end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are other tools in m_tools after m_areaLightTool, would this potentially erase/hide other tools unintentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sort of a standard recipe for "get rid of one element from a vector, by value". std::remove finds the thing and makes sure it is shifted to the end of the list, and returns an iterator to the start of the removed things... and vector::erase drops it from m_tools.

Copy link
Contributor

@ShrimpCryptid ShrimpCryptid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, built and tested locally without any issues. I left a couple questions about potential bugs and I'll approve once those are resolved.

…s-on-load

add option to keep current agave settings when loading
@toloudis toloudis merged commit 54efdab into feature/scalebar Jan 30, 2024
4 of 7 checks passed
@toloudis toloudis deleted the feature/light-manip-ui branch January 30, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants