21#include "kis_perspective_grid.h"
23int KisSubPerspectiveGrid::s_lastIndex = 0;
25KisSubPerspectiveGrid::KisSubPerspectiveGrid(KisPerspectiveGridNodeSP topLeft, KisPerspectiveGridNodeSP topRight, KisPerspectiveGridNodeSP bottomRight, KisPerspectiveGridNodeSP bottomLeft) : m_topLeft(topLeft), m_topRight(topRight), m_bottomRight(bottomRight), m_bottomLeft(bottomLeft), m_subdivisions(5), m_leftGrid(0), m_rightGrid(0), m_topGrid(0), m_bottomGrid(0), m_index(++s_lastIndex)
30bool KisSubPerspectiveGrid::contains(
const KisPoint p)
const
33 KisPerspectiveMath::LineEquation d1 = KisPerspectiveMath::computeLineEquation( topLeft(), topRight() );
34 kdDebug() << p.y() <<
" " << (p.x() * d1.a + d1.b) << endl;
35 if( p.y() >= p.x() * d1.a + d1.b)
37 d1 = KisPerspectiveMath::computeLineEquation( topRight(), bottomRight() );
38 kdDebug() << p.y() <<
" " << (p.x() * d1.a + d1.b) << endl;
39 if( p.y() >= p.x() * d1.a + d1.b)
41 d1 = KisPerspectiveMath::computeLineEquation( bottomRight(), bottomLeft() );
42 kdDebug() << p.y() <<
" " << (p.x() * d1.a + d1.b) << endl;
43 if( p.y() <= p.x() * d1.a + d1.b)
45 d1 = KisPerspectiveMath::computeLineEquation( bottomLeft(), topLeft() );
46 kdDebug() << p.y() <<
" " << (p.x() * d1.a + d1.b) << endl;
47 if( p.y() <= p.x() * d1.a + d1.b)
58KisPerspectiveGrid::KisPerspectiveGrid()
63KisPerspectiveGrid::~KisPerspectiveGrid()
68bool KisPerspectiveGrid::addNewSubGrid( KisSubPerspectiveGrid* ng )
70 if(hasSubGrids() && !ng->topGrid() && !ng->bottomGrid() && !ng->leftGrid() && !ng->rightGrid() )
72 kdError() <<
"sub grids need a neighbourgh if they are not the first grid to be added" << endl;
75 m_subGrids.push_back(ng);
80void KisPerspectiveGrid::clearSubGrids( )
82 for( TQValueList<KisSubPerspectiveGrid*>::const_iterator it = begin(); it != end(); ++it)
89KisSubPerspectiveGrid* KisPerspectiveGrid::gridAt(
KisPoint p)
91 for( TQValueList<KisSubPerspectiveGrid*>::const_iterator it = begin(); it != end(); ++it)
93 if( (*it)->contains(p) )
A double-based point class that can return it's coordinates approximated to integers.