Verified Commit f4f8085f authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

Added new methods to KisMagneticWorker to properly accomodate the algorithm

parent 3b86ab52
......@@ -342,6 +342,8 @@ public:
m_mainArea = mainRect;
m_aLabelArea = aLabelRegion.boundingRect();
m_bLabelArea = bLabelRegion.boundingRect();
//QRegion::rects() is deprecated, https://doc.qt.io/qt-5/qregion-obsolete.html#rects
m_aLabelRects = aLabelRegion.rects();
m_bLabelRects = bLabelRegion.rects();
......
......@@ -56,20 +56,28 @@ class AstarHeuristic : public boost::astar_heuristic<KisLazyFillGraph, double> {
double operator()(VertexDescriptor v){
auto prev = m_pmap[v];
auto di = (m_goal.y - prev.y) * v.x + (m_goal.x - prev.x) * v.y;
double di = (m_goal.y - prev.y) * v.x + (m_goal.x - prev.x) * v.y;
di = std::abs(di + prev.x * m_goal.y + prev.y * m_goal.x);
auto dist = [](VertexDescriptor p1, VertexDescriptor p2){
return std::sqrt(std::pow(p1.y-p2.y, 2) + std::pow(p1.x-p2.x, 2));
};
auto dz = dist(prev, m_goal);
double dz = dist(prev, m_goal);
di = di/dz;
auto dm = dist(v, m_goal);
double dm = dist(v, m_goal);
return coeff_a * di + coeff_b * (dm - dz);
}
};
KisMagneticWorker::KisMagneticWorker(KisPaintDeviceSP dev, const QRect &rect):
m_dev(dev), m_rect(rect)
{ }
void KisMagneticWorker::run(KisPaintDeviceSP dev, const QRect &rect)
{
KisGaussianKernel::applyLoG(dev, rect, 2, -1.0, QBitArray(), 0);
}
void KisMagneticWorker::computeEdge(QPoint start, QPoint end)
{
KisGaussianKernel::applyLoG(m_dev, m_rect, 2, -1.0, QBitArray(), 0);
}
......@@ -23,7 +23,13 @@
class KRITASELECTIONTOOLS_EXPORT KisMagneticWorker{
public:
KisMagneticWorker(KisPaintDeviceSP dev, const QRect &rect);
void run(KisPaintDeviceSP dev, const QRect& rect);
void computeEdge(QPoint start, QPoint end);
private:
KisPaintDeviceSP m_dev;
const QRect m_rect;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment