diff --git a/src/Editor/DearImGui/Drawable.cpp b/src/Editor/DearImGui/Drawable.cpp index 7cd84aa..01688c7 100644 --- a/src/Editor/DearImGui/Drawable.cpp +++ b/src/Editor/DearImGui/Drawable.cpp @@ -77,6 +77,32 @@ static void drawArrow(ImDrawList* draw_list, ImVec2 const& A, ImVec2 const& B, draw_list->AddConvexPolyFilled(points.data(), points.size(), color); } +//------------------------------------------------------------------------------ +void drawArc(ImDrawList* draw_list, Node* from, Node* to, ImVec2* click_position, ImVec2 const& origin, ImVec2 const& cursor) +{ + if (from != nullptr) + { + drawArrow(draw_list, + origin + ImVec2(from->x, from->y), + origin + ImVec2(cursor.x, cursor.y), + OUTLINE_COLOR); + } + else if (to != nullptr) + { + drawArrow(draw_list, + origin + ImVec2(cursor.x, cursor.y), + origin + ImVec2(to->x, to->y), + OUTLINE_COLOR); + } + else if (click_position != nullptr) + { + drawArrow(draw_list, + origin + ImVec2(click_position->x, click_position->y), + origin + ImVec2(cursor.x, cursor.y), + OUTLINE_COLOR); + } +} + //------------------------------------------------------------------------------ void drawArc(ImDrawList* draw_list, Arc const& arc, TypeOfNet const type, ImVec2 const& origin, float const alpha) { diff --git a/src/Editor/DearImGui/Drawable.hpp b/src/Editor/DearImGui/Drawable.hpp index 983392e..36c546f 100644 --- a/src/Editor/DearImGui/Drawable.hpp +++ b/src/Editor/DearImGui/Drawable.hpp @@ -33,7 +33,7 @@ static const float TRANS_HEIGHT = TRANS_WIDTH / 3.0f; // Rectangle height for r static const float PLACE_RADIUS = TRANS_WIDTH / 2.0f; // Circle radius for rendering Places static const float TOKEN_RADIUS = 2.0f; // Circle radius for rendering tokens - +void drawArc(ImDrawList* draw_list, Node* from, Node* to, ImVec2* click_position, ImVec2 const& origin, ImVec2 const& cursor); void drawArc(ImDrawList* draw_list, Arc const& arc, TypeOfNet const type, ImVec2 const& origin, float const alpha); void drawToken(ImDrawList* draw_list, float const x, float const y); void drawTimedToken(ImDrawList* draw_list, size_t tokens, float const x, float const y); diff --git a/src/Editor/PetriEditor.cpp b/src/Editor/PetriEditor.cpp index 839784e..67e7f3d 100644 --- a/src/Editor/PetriEditor.cpp +++ b/src/Editor/PetriEditor.cpp @@ -1600,6 +1600,11 @@ void Editor::PetriView::drawPetriNet(Net& net, Simulation& simulation) it->y = m_mouse.position.y; } + // Show the arc we are creating + drawArc(m_canvas.draw_list, m_mouse.from, m_mouse.to, + m_mouse.arc_from_unknown_node ? &m_mouse.click_position : nullptr, + origin, m_mouse.position); + // Draw critical cycle //for (auto& a: m_marked_arcs) // draw(*a, 255);