Skip to content

Commit

Permalink
Fix sendEvent calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Oct 29, 2023
1 parent cf9743d commit 5a4ab11
Show file tree
Hide file tree
Showing 29 changed files with 311 additions and 230 deletions.
3 changes: 2 additions & 1 deletion acm/demo/acm_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ int main(int argc, char** argv)
entries.push_back({ "link_2", "link_3", "Adjacent" });
entries.push_back({ "link_3", "link_4", "Adjacent" });

QApplication::sendEvent(qApp, new tesseract_gui::events::AllowedCollisionMatrixAdd(component_info, entries));
tesseract_gui::events::AllowedCollisionMatrixAdd event(component_info, entries);
QApplication::sendEvent(qApp, &event);

return QApplication::exec();
}
12 changes: 6 additions & 6 deletions acm/src/models/allowed_collision_matrix_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ bool AllowedCollisionMatrixModel::setData(const QModelIndex& index, const QVaria
}
}

QApplication::sendEvent(
qApp,
new events::SceneGraphModifyLinkVisibilityALL(data_->component_info, LinkVisibilityFlags::WIREBOX, false));
events::SceneGraphModifyLinkVisibilityALL event(data_->component_info, LinkVisibilityFlags::WIREBOX, false);
QApplication::sendEvent(qApp, &event);
if (!links.empty())
QApplication::sendEvent(
qApp,
new events::SceneGraphModifyLinkVisibility(data_->component_info, links, LinkVisibilityFlags::WIREBOX, true));
{
events::SceneGraphModifyLinkVisibility event(data_->component_info, links, LinkVisibilityFlags::WIREBOX, true);
QApplication::sendEvent(qApp, &event);
}
}
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion acm/src/widgets/add_allowed_collision_entry_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void AddAllowedCollisionEntryDialog::accept()
entry[2] = ui_->reasonLineEdit->text().toStdString();
data.push_back(entry);

QApplication::sendEvent(qApp, new events::AllowedCollisionMatrixAdd(component_info_, data));
events::AllowedCollisionMatrixAdd event(component_info_, data);
QApplication::sendEvent(qApp, &event);
}

} // namespace tesseract_gui
10 changes: 6 additions & 4 deletions acm/src/widgets/allowed_collision_matrix_editor_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ void AllowedCollisionMatrixEditorWidget::onRemoveButtonClicked()
if (idx.isValid() && idx.parent().isValid())
remove.push_back({ m->data(idx.parent()).toString().toStdString(), m->data(idx).toString().toStdString() });

QApplication::sendEvent(qApp, new events::AllowedCollisionMatrixRemove(m->getComponentInfo(), remove));
events::AllowedCollisionMatrixRemove event(m->getComponentInfo(), remove);
QApplication::sendEvent(qApp, &event);
}
}

Expand All @@ -124,16 +125,17 @@ void AllowedCollisionMatrixEditorWidget::onAddButtonClicked()

void AllowedCollisionMatrixEditorWidget::onGenerateButtonClicked()
{
QApplication::sendEvent(
qApp, new events::AllowedCollisionMatrixGenerate(getComponentInfo(), ui_->resolutionSlider->value()));
events::AllowedCollisionMatrixGenerate event(getComponentInfo(), ui_->resolutionSlider->value());
QApplication::sendEvent(qApp, &event);
}

void AllowedCollisionMatrixEditorWidget::onApplyButtonClicked()
{
auto cmd = std::make_shared<tesseract_environment::ModifyAllowedCollisionsCommand>(
ui_->acm_widget->getModel()->getAllowedCollisionMatrix(),
tesseract_environment::ModifyAllowedCollisionsType::REPLACE);
QApplication::sendEvent(qApp, new events::EnvironmentApplyCommand(getComponentInfo(), { cmd }));
events::EnvironmentApplyCommand event(getComponentInfo(), { cmd });
QApplication::sendEvent(qApp, &event);
}

} // namespace tesseract_gui
17 changes: 8 additions & 9 deletions collision/src/models/contact_results_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,20 @@ bool ContactResultsModel::setData(const QModelIndex& index, const QVariant& valu
auto* derived_item = static_cast<ContactResultStandardItem*>(item);
auto* parent_item = static_cast<ContactResultVectorStandardItem*>(item->parent());

QApplication::sendEvent(qApp,
new events::ContactResultsVisbility(data_->component_info,
parent_item->getUUID(),
derived_item->contact_result.getUUID(),
value.value<Qt::CheckState>() == Qt::Checked));
events::ContactResultsVisbility event(data_->component_info,
parent_item->getUUID(),
derived_item->contact_result.getUUID(),
value.value<Qt::CheckState>() == Qt::Checked);
QApplication::sendEvent(qApp, &event);
}
else if (item->type() == static_cast<int>(StandardItemType::COLLISION_CONTACT_RESULT_VECTOR))
{
assert(dynamic_cast<ContactResultVectorStandardItem*>(item) != nullptr);
auto* derived_item = static_cast<ContactResultVectorStandardItem*>(item);

QApplication::sendEvent(qApp,
new events::ContactResultsVisbility(data_->component_info,
derived_item->getUUID(),
value.value<Qt::CheckState>() == Qt::Checked));
events::ContactResultsVisbility event(
data_->component_info, derived_item->getUUID(), value.value<Qt::CheckState>() == Qt::Checked);
QApplication::sendEvent(qApp, &event);
}
}
return QStandardItemModel::setData(index, value, role);
Expand Down
7 changes: 3 additions & 4 deletions collision/src/widgets/contact_results_compute_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ void ContactResultsComputeWidget::onComputeClicked()
config.contact_request.type =
static_cast<tesseract_collision::ContactTestType>(ui->contact_test_type->currentIndex());

QApplication::sendEvent(
qApp,
new events::ContactResultsCompute(
getComponentInfo(), config, events::ContactResultsCompute::StateType::CURRENT_STATE, "Contact Results"));
events::ContactResultsCompute event(
getComponentInfo(), config, events::ContactResultsCompute::StateType::CURRENT_STATE, "Contact Results");
QApplication::sendEvent(qApp, &event);
}

void ContactResultsComputeWidget::ctor(std::shared_ptr<const ComponentInfo> component_info)
Expand Down
3 changes: 2 additions & 1 deletion command_language/demo/command_language_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ int main(int argc, char** argv)
tesseract_gui::CompositeInstructionWidget widget(component_info);
widget.show();

QApplication::sendEvent(qApp, new tesseract_gui::events::CompositeInstructionSet(component_info, program, "general"));
tesseract_gui::events::CompositeInstructionSet event(component_info, program, "general");
QApplication::sendEvent(qApp, &event);

return QApplication::exec();
}
65 changes: 43 additions & 22 deletions common/src/environment_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ void tesseractEventFilterHelper(const tesseract_environment::Event& event,
case tesseract_environment::Events::SCENE_STATE_CHANGED:
{
const auto& e = static_cast<const tesseract_environment::SceneStateChangedEvent&>(event);
QApplication::sendEvent(qApp,
new tesseract_gui::events::SceneStateChanged(env_wrapper.getComponentInfo(), e.state));
tesseract_gui::events::SceneStateChanged event(env_wrapper.getComponentInfo(), e.state);
QApplication::sendEvent(qApp, &event);
break;
}
}
Expand Down Expand Up @@ -199,8 +199,8 @@ void eventFilterHelper(QObject* /*obj*/,
tracked_object[contact.first] = crv;
}

QApplication::sendEvent(
qApp, new tesseract_gui::events::ContactResultsSet(component_info, tracked_object, e->getNamespace()));
tesseract_gui::events::ContactResultsSet event(component_info, tracked_object, e->getNamespace());
QApplication::sendEvent(qApp, &event);
}
else if (event->type() == tesseract_gui::events::AllowedCollisionMatrixGenerate::kType)
{
Expand Down Expand Up @@ -266,7 +266,8 @@ void eventFilterHelper(QObject* /*obj*/,
}
}

QApplication::sendEvent(qApp, new tesseract_gui::events::AllowedCollisionMatrixSet(component_info, acm));
tesseract_gui::events::AllowedCollisionMatrixSet event(component_info, acm);
QApplication::sendEvent(qApp, &event);
}
else if (event->type() == tesseract_gui::events::EnvironmentApplyCommand::kType)
{
Expand All @@ -288,19 +289,28 @@ void broadcastHelper(const std::shared_ptr<const tesseract_gui::ComponentInfo>&
return;

// Broadcast environment data
QApplication::sendEvent(qApp, new tesseract_gui::events::SceneGraphSet(component_info, env.getSceneGraph()->clone()));
QApplication::sendEvent(qApp, new tesseract_gui::events::SceneStateChanged(component_info, env.getState()));
QApplication::sendEvent(qApp,
new tesseract_gui::events::EnvironmentCommandsSet(component_info, env.getCommandHistory()));
QApplication::sendEvent(
qApp, new tesseract_gui::events::AllowedCollisionMatrixSet(component_info, *env.getAllowedCollisionMatrix()));
tesseract_gui::events::SceneGraphSet set_scene_graph_event(component_info, env.getSceneGraph()->clone());
QApplication::sendEvent(qApp, &set_scene_graph_event);

tesseract_gui::events::SceneStateChanged scene_state_changed_event(component_info, env.getState());
QApplication::sendEvent(qApp, &scene_state_changed_event);

tesseract_gui::events::EnvironmentCommandsSet set_environment_commands_event(component_info, env.getCommandHistory());
QApplication::sendEvent(qApp, &set_environment_commands_event);

tesseract_gui::events::AllowedCollisionMatrixSet set_acm_event(component_info, *env.getAllowedCollisionMatrix());
QApplication::sendEvent(qApp, &set_acm_event);

auto kin_info = env.getKinematicsInformation();
QApplication::sendEvent(qApp,
new tesseract_gui::events::KinematicGroupsSet(
component_info, kin_info.chain_groups, kin_info.joint_groups, kin_info.link_groups));
QApplication::sendEvent(qApp, new tesseract_gui::events::GroupJointStatesSet(component_info, kin_info.group_states));
QApplication::sendEvent(qApp, new tesseract_gui::events::GroupTCPsSet(component_info, kin_info.group_tcps));
tesseract_gui::events::KinematicGroupsSet set_kin_groups_event(
component_info, kin_info.chain_groups, kin_info.joint_groups, kin_info.link_groups);
QApplication::sendEvent(qApp, &set_kin_groups_event);

tesseract_gui::events::GroupJointStatesSet set_group_joint_states_event(component_info, kin_info.group_states);
QApplication::sendEvent(qApp, &set_group_joint_states_event);

tesseract_gui::events::GroupTCPsSet set_group_tcps_event(component_info, kin_info.group_tcps);
QApplication::sendEvent(qApp, &set_group_tcps_event);
}

namespace tesseract_gui
Expand All @@ -313,12 +323,23 @@ EnvironmentWrapper::EnvironmentWrapper(std::shared_ptr<const ComponentInfo> comp
EnvironmentWrapper::~EnvironmentWrapper()
{
// clear environment data
QApplication::sendEvent(qApp, new events::SceneGraphClear(component_info_));
QApplication::sendEvent(qApp, new events::EnvironmentCommandsClear(component_info_));
QApplication::sendEvent(qApp, new events::AllowedCollisionMatrixClear(component_info_));
QApplication::sendEvent(qApp, new events::KinematicGroupsClear(component_info_));
QApplication::sendEvent(qApp, new events::GroupJointStatesClear(component_info_));
QApplication::sendEvent(qApp, new events::GroupTCPsClear(component_info_));
events::SceneGraphClear clear_scene_graph_event(component_info_);
QApplication::sendEvent(qApp, &clear_scene_graph_event);

events::EnvironmentCommandsClear clear_environment_commands_event(component_info_);
QApplication::sendEvent(qApp, &clear_environment_commands_event);

events::AllowedCollisionMatrixClear clear_acm_event(component_info_);
QApplication::sendEvent(qApp, &clear_acm_event);

events::KinematicGroupsClear clear_kin_groups_event(component_info_);
QApplication::sendEvent(qApp, &clear_kin_groups_event);

events::GroupJointStatesClear clear_group_joint_states_event(component_info_);
QApplication::sendEvent(qApp, &clear_group_joint_states_event);

events::GroupTCPsClear clear_group_tcps_event(component_info_);
QApplication::sendEvent(qApp, &clear_group_tcps_event);
}

std::shared_ptr<const ComponentInfo> EnvironmentWrapper::getComponentInfo() const { return component_info_; }
Expand Down
20 changes: 14 additions & 6 deletions joint_trajectory/demo/joint_trajectory_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ int main(int argc, char** argv)
window.setCentralWidget(new tesseract_gui::JointTrajectoryWidget(component_info));
window.show();

QApplication::sendEvent(qApp, new tesseract_gui::events::JointTrajectoryAdd(component_info, trajectory_set));
QApplication::sendEvent(qApp, new tesseract_gui::events::JointTrajectoryAdd(component_info, trajectory_set1));
QApplication::sendEvent(qApp, new tesseract_gui::events::JointTrajectoryAdd(component_info, trajectory_set2));
QApplication::sendEvent(qApp, new tesseract_gui::events::JointTrajectoryAdd(component_info, trajectory_set3));
QApplication::sendEvent(qApp,
new tesseract_gui::events::JointTrajectoryRemove(component_info, trajectory_set2.getUUID()));
tesseract_gui::events::JointTrajectoryAdd event(component_info, trajectory_set);
QApplication::sendEvent(qApp, &event);

tesseract_gui::events::JointTrajectoryAdd event1(component_info, trajectory_set1);
QApplication::sendEvent(qApp, &event1);

tesseract_gui::events::JointTrajectoryAdd event2(component_info, trajectory_set2);
QApplication::sendEvent(qApp, &event2);

tesseract_gui::events::JointTrajectoryAdd event3(component_info, trajectory_set3);
QApplication::sendEvent(qApp, &event3);

tesseract_gui::events::JointTrajectoryRemove event4(component_info, trajectory_set2.getUUID());
QApplication::sendEvent(qApp, &event4);

return QApplication::exec();
}
13 changes: 9 additions & 4 deletions joint_trajectory/src/models/joint_trajectory_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ bool openJointTrajectorySet(const std::shared_ptr<const ComponentInfo>& componen
{
auto jts = tesseract_common::Serialization::fromArchiveFileXML<tesseract_common::JointTrajectorySet>(
filename.toStdString());
QApplication::sendEvent(qApp, new events::JointTrajectoryAdd(component_info, std::move(jts)));

events::JointTrajectoryAdd event(component_info, std::move(jts));
QApplication::sendEvent(qApp, &event);
return true;
}

if (suffix == "jtsb" && file_info.suffix() == "jtsb")
{
auto jts = tesseract_common::Serialization::fromArchiveFileBinary<tesseract_common::JointTrajectorySet>(
filename.toStdString());
QApplication::sendEvent(qApp, new events::JointTrajectoryAdd(component_info, std::move(jts)));
events::JointTrajectoryAdd event(component_info, std::move(jts));
QApplication::sendEvent(qApp, &event);
return true;
}

Expand All @@ -77,7 +80,8 @@ bool openJointTrajectorySet(const std::shared_ptr<const ComponentInfo>& componen
tesseract_common::JointTrajectorySet jts(initial_state, jt.description);
jts.appendJointTrajectory(jt);

QApplication::sendEvent(qApp, new events::JointTrajectoryAdd(component_info, std::move(jts)));
events::JointTrajectoryAdd event(component_info, std::move(jts));
QApplication::sendEvent(qApp, &event);
return true;
}

Expand All @@ -95,7 +99,8 @@ bool openJointTrajectorySet(const std::shared_ptr<const ComponentInfo>& componen
initial_state[jt.states.front().joint_names[i]] = jt.states.front().position[i];

tesseract_common::JointTrajectorySet jts(initial_state, jt.description);
QApplication::sendEvent(qApp, new events::JointTrajectoryAdd(component_info, std::move(jts)));
events::JointTrajectoryAdd event(component_info, std::move(jts));
QApplication::sendEvent(qApp, &event);
return true;
}

Expand Down
15 changes: 10 additions & 5 deletions joint_trajectory/src/widgets/joint_trajectory_tool_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,26 @@ JointTrajectoryToolBar::JointTrajectoryToolBar(std::shared_ptr<const ComponentIn
{
data_->component_info = std::move(component_info);
data_->remove_all_action = addAction(icons::getClearIcon(), "Remove All", [this]() {
QApplication::sendEvent(qApp, new events::JointTrajectoryRemoveAll(data_->component_info));
events::JointTrajectoryRemoveAll event(data_->component_info);
QApplication::sendEvent(qApp, &event);
});
data_->remove_action = addAction(icons::getTrashIcon(), "Remove All", [this]() {
QApplication::sendEvent(qApp, new events::JointTrajectoryRemoveSelected(data_->component_info));
events::JointTrajectoryRemoveSelected event(data_->component_info);
QApplication::sendEvent(qApp, &event);
});
addSeparator();
data_->open_action = addAction(icons::getImportIcon(), "Open", [this]() {
QApplication::sendEvent(qApp, new events::JointTrajectoryOpen(data_->component_info));
events::JointTrajectoryOpen event(data_->component_info);
QApplication::sendEvent(qApp, &event);
});
data_->save_action = addAction(icons::getSaveIcon(), "Save", [this]() {
QApplication::sendEvent(qApp, new events::JointTrajectorySave(data_->component_info));
events::JointTrajectorySave event(data_->component_info);
QApplication::sendEvent(qApp, &event);
});
addSeparator();
data_->plot_action = addAction(icons::getPlotIcon(), "Plot Joint Trajectory", [this]() {
QApplication::sendEvent(qApp, new events::JointTrajectoryPlot(data_->component_info));
events::JointTrajectoryPlot event(data_->component_info);
QApplication::sendEvent(qApp, &event);
});

data_->save_action->setDisabled(true);
Expand Down
Loading

0 comments on commit 5a4ab11

Please sign in to comment.