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

Fix TransformControl's BlockOrbit behavior #2030

Merged
merged 2 commits into from
Jul 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/gui/plugins/transform_control/TransformControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ namespace gz::sim

/// \brief Block orbit
public: bool blockOrbit = false;

/// \brief True if BlockOrbit events should be sent
public: bool sendBlockOrbit = false;
};
}

Expand Down Expand Up @@ -499,10 +502,17 @@ void TransformControlPrivate::HandleTransform()

this->HandleMouseEvents();

gz::gui::events::BlockOrbit blockOrbitEvent(this->blockOrbit);
gz::gui::App()->sendEvent(
gz::gui::App()->findChild<gz::gui::MainWindow *>(),
&blockOrbitEvent);
if (this->sendBlockOrbit)
{
// Events with false should only be sent once
if (!this->blockOrbit)
this->sendBlockOrbit = false;

gz::gui::events::BlockOrbit blockOrbitEvent(this->blockOrbit);
gz::gui::App()->sendEvent(
gz::gui::App()->findChild<gz::gui::MainWindow *>(),
&blockOrbitEvent);
}
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -534,6 +544,7 @@ void TransformControlPrivate::HandleMouseEvents()
if (axis != gz::math::Vector3d::Zero)
{
this->blockOrbit = true;
this->sendBlockOrbit = true;
// start the transform process
this->transformControl.SetActiveAxis(axis);
this->transformControl.Start();
Expand All @@ -553,13 +564,15 @@ void TransformControlPrivate::HandleMouseEvents()
else
{
this->blockOrbit = false;
this->sendBlockOrbit = true;
return;
}
}
}
else if (this->mouseEvent.Type() == gz::common::MouseEvent::RELEASE)
{
this->blockOrbit = false;
this->sendBlockOrbit = true;

this->isStartWorldPosSet = false;
if (this->transformControl.Active())
Expand Down Expand Up @@ -706,6 +719,7 @@ void TransformControlPrivate::HandleMouseEvents()
}

this->blockOrbit = true;
this->sendBlockOrbit = true;
// compute the the start and end mouse positions in normalized coordinates
auto imageWidth = static_cast<double>(this->camera->ImageWidth());
auto imageHeight = static_cast<double>(
Expand Down