Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Read and write user camera pose from ModelListWidget (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters committed May 4, 2015
1 parent 3b410fc commit c0833bb
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion gazebo/gui/ModelListWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,11 @@ void ModelListWidget::PhysicsPropertyChanged(QtProperty * /*_item*/)
}

/////////////////////////////////////////////////
void ModelListWidget::ScenePropertyChanged(QtProperty * /*_item*/)
void ModelListWidget::ScenePropertyChanged(QtProperty * _item)
{
msgs::Scene msg;

QtProperty *cameraPoseProperty = NULL;
QList<QtProperty*> properties = this->propTreeBrowser->properties();
for (QList<QtProperty*>::iterator iter = properties.begin();
iter != properties.end(); ++iter)
Expand All @@ -679,10 +680,30 @@ void ModelListWidget::ScenePropertyChanged(QtProperty * /*_item*/)
this->FillColorMsg((*iter), msg.mutable_background());
else if ((*iter)->propertyName().toStdString() == "shadows")
msg.set_shadows(this->variantManager->value((*iter)).toBool());
else if ((*iter)->propertyName().toStdString() == "camera_pose")
cameraPoseProperty = *iter;
}

msg.set_name(gui::get_world());
this->scenePub->Publish(msg);

if (cameraPoseProperty)
{
std::string changedProperty = _item->propertyName().toStdString();
if (changedProperty == "x"
|| changedProperty == "y"
|| changedProperty == "z"
|| changedProperty == "roll"
|| changedProperty == "pitch"
|| changedProperty == "yaw")
{
msgs::Pose poseMsg;
this->FillPoseMsg(cameraPoseProperty, &poseMsg, poseMsg.GetDescriptor());
rendering::UserCameraPtr cam = gui::get_active_camera();
if (cam)
cam->SetWorldPose(msgs::Convert(poseMsg));
}
}
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -2389,6 +2410,20 @@ void ModelListWidget::FillPropertyTree(const msgs::Scene &_msg,
}
this->propTreeBrowser->addProperty(item);

// Create and set the gui camera pose
item = this->variantManager->addProperty(
QtVariantPropertyManager::groupTypeId(), tr("camera_pose"));
{
auto browserItem = this->propTreeBrowser->addProperty(item);
rendering::UserCameraPtr cam = gui::get_active_camera();
math::Pose cameraPose;
if (cam)
cameraPose = cam->GetWorldPose();

this->FillPoseProperty(msgs::Convert(cameraPose), item);
this->propTreeBrowser->setExpanded(browserItem, true);
}

// Create and set the shadows property
item = this->variantManager->addProperty(QVariant::Bool, tr("shadows"));
if (_msg.has_shadows())
Expand Down

0 comments on commit c0833bb

Please sign in to comment.