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 #419 by calculating transformed x/y in image-based maps #421

Merged
merged 3 commits into from
Feb 10, 2022
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
33 changes: 27 additions & 6 deletions rmf_traffic_editor/gui/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,6 @@ void Editor::populate_property_editor(const Edge& edge)

void Editor::populate_property_editor(const Vertex& vertex, const int index)
{
const Level& level = building.levels[level_idx];
const double scale = level.drawing_meters_per_pixel;

property_editor->blockSignals(true); // otherwise we get tons of callbacks
property_editor->setRowCount(6 + vertex.params.size());

Expand All @@ -1456,9 +1453,33 @@ void Editor::populate_property_editor(const Vertex& vertex, const int index)
{
property_editor_set_row(1, "x (pixels)", vertex.x, 3, true);
property_editor_set_row(2, "y (pixels)", vertex.y, 3, true);
property_editor_set_row(3, "x (m)", vertex.x * scale);
const double y_flip = building.coordinate_system.is_y_flipped() ? -1 : 1;
property_editor_set_row(4, "y (m)", y_flip * vertex.y * scale);

const size_t ref_level_idx =
static_cast<size_t>(building.get_reference_level_idx());

if (ref_level_idx < building.levels.size())
{
QPointF p_ref_level;
building.transform_between_levels(
level_idx,
QPoint(vertex.x, vertex.y),
ref_level_idx,
p_ref_level);

const double y_flip = building.coordinate_system.is_y_flipped() ? -1 : 1;
const double scale =
building.levels[ref_level_idx].drawing_meters_per_pixel;
const QPointF p_meters(
p_ref_level.x() * scale,
p_ref_level.y() * scale * y_flip);
property_editor_set_row(3, "x (m)", p_meters.x());
property_editor_set_row(4, "y (m)", p_meters.y());
}
else
{
property_editor_set_row(3, "x (m)", "");
property_editor_set_row(4, "y (m)", "");
}
}
else
{
Expand Down