Skip to content

Commit

Permalink
Map editor: add angle information about linedefs and change format of…
Browse files Browse the repository at this point in the history
… line length. (#786)

* Changed information representation about line angles and point coordinates

* Fix wxWidgets assertion on non-existent FindItemByPosition(0)
  • Loading branch information
Dethernal authored and sirjuddington committed Sep 11, 2017
1 parent aef1555 commit 5afeba9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/MapEditor/Edit/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool Input::mouseMove(int new_x, int new_y)
double my = context_.snapToGrid(mouse_pos_map_.y, false);
string status_text;
if (context_.mapDesc().format == MAP_UDMF)
status_text = S_FMT("Position: (%1.3f, %1.3f)", mx, my);
status_text = S_FMT("Position: (%1.1f, %1.1f)", mx, my);
else
status_text = S_FMT("Position: (%d, %d)", (int)mx, (int)my);
MapEditor::setStatusText(status_text, 3);
Expand Down
3 changes: 2 additions & 1 deletion src/MapEditor/Renderer/Overlays/LineInfoOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void LineInfoOverlay::update(MapLine* line)
info_text += (S_FMT("Line #%d (%d)\n", line->getIndex(), line->getId()));
else
info_text += (S_FMT("Line #%d\n", line->getIndex()));
info_text += (S_FMT("Length: %d\n", MathStuff::round(line->getLength())));
info_text += (S_FMT("Length: %1.2f\n", line->getLength()));
info_text += (S_FMT("Angle: %1.2f\n", line->getAngle()));

// Line special
int as_id = line->intProperty("special");
Expand Down
12 changes: 12 additions & 0 deletions src/MapEditor/SLADEMap/MapLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,18 @@ double MapLine::getLength()
return length;
}

/* MapLine::getAngle
* Returns the angle (in degrees) of line, east is zero, front side counter-clock wise.
*******************************************************************/
double MapLine::getAngle()
{
if (!vertex1 || !vertex2)
return -1;
double angle = (180.0 / M_PI) * atan2(vertex1->yPos() - vertex2->yPos(), vertex1->xPos() - vertex2->xPos());
if (angle < 0) angle += 360.0;
return angle;
}

/* MapLine::doubleSector
* Returns true if the line has the same sector on both sides
*******************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/MapEditor/SLADEMap/MapLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class MapLine : public MapObject
fpoint2_t point2();
fseg2_t seg();
double getLength();
double getAngle();
bool doubleSector();
fpoint2_t frontVector();
fpoint2_t dirTabPoint(double length = 0);
Expand Down
2 changes: 1 addition & 1 deletion src/MapEditor/UI/MapEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void MapEditorWindow::setupLayout()

// Status bar
CreateStatusBar(4);
int status_widths[4] = { -1, 240, 200, 160 };
int status_widths[4] = { -1, 240, 200, 300 };
SetStatusWidths(4, status_widths);

// -- Console Panel --
Expand Down
2 changes: 1 addition & 1 deletion src/UI/STopWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void STopWindow::removeAllCustomToolBars()
// ----------------------------------------------------------------------------
void STopWindow::populateToolbarsMenu() const
{
while (toolbar_menu_->FindItemByPosition(0))
while (toolbar_menu_->GetMenuItemCount())
toolbar_menu_->Delete(toolbar_menu_->FindItemByPosition(0));

for (auto a = 0u; a < toolbar_->groups().size(); ++a)
Expand Down

0 comments on commit 5afeba9

Please sign in to comment.