ui: graph view edges
Added simple edges to the graph view. Also fixed a memory leak source in QtMainWindow. fortune cookie message = Good health will be with you.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||
|
||||
#include "qpen.h"
|
||||
|
||||
#include "component/view/graphElements/GraphNode.h"
|
||||
|
||||
QtGraphEdge::QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target)
|
||||
: m_owner(owner)
|
||||
, m_target(target)
|
||||
{
|
||||
std::shared_ptr<GraphNode> o = owner.lock();
|
||||
std::shared_ptr<GraphNode> t = target.lock();
|
||||
|
||||
if (o != NULL && t != NULL)
|
||||
{
|
||||
this->setLine(o->getPosition().x, o->getPosition().y,t->getPosition().x, t->getPosition().y);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Either the owner or the target node could is null.");
|
||||
}
|
||||
|
||||
QPen blackPen(Qt::black);
|
||||
blackPen.setWidth(3);
|
||||
|
||||
this->setPen(blackPen);
|
||||
}
|
||||
|
||||
QtGraphEdge::~QtGraphEdge()
|
||||
{
|
||||
}
|
||||
|
||||
void QtGraphEdge::ownerMoved()
|
||||
{
|
||||
std::shared_ptr<GraphNode> node = m_owner.lock();
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
this->setLine(node->getPosition().x, node->getPosition().y, this->line().x2(), this->line().y2());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Owner node is null.");
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphEdge::targetMoved()
|
||||
{
|
||||
std::shared_ptr<GraphNode> node = m_target.lock();
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
this->setLine(this->line().x1(), this->line().y1(), node->getPosition().x, node->getPosition().y);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Target node is null.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user