21#ifndef KIS_PERSPECTIVE_GRID_H
22#define KIS_PERSPECTIVE_GRID_H
24#include <tqvaluelist.h>
26#include <kis_perspective_math.h>
28#include <ksharedptr.h>
30class KisPerspectiveGridNode :
public KisPoint,
public TDEShared {
32 inline KisPerspectiveGridNode(
double x,
double y) :
KisPoint(x,y) { }
35typedef TDESharedPtr<KisPerspectiveGridNode> KisPerspectiveGridNodeSP;
37class KisSubPerspectiveGrid {
39 KisSubPerspectiveGrid(KisPerspectiveGridNodeSP topLeft, KisPerspectiveGridNodeSP topRight, KisPerspectiveGridNodeSP bottomRight, KisPerspectiveGridNodeSP bottomLeft);
41 inline KisPoint topBottomVanishingPoint() {
return computeVanishingPoint( topLeft(), topRight(), bottomLeft(), bottomRight() ); };
42 inline KisPoint leftRightVanishingPoint() {
return computeVanishingPoint( topLeft(), bottomLeft(), topRight(), bottomRight() ); };
44 inline KisSubPerspectiveGrid* leftGrid() {
return m_leftGrid; }
45 inline void setLeftGrid(KisSubPerspectiveGrid* g) { Q_ASSERT(m_leftGrid==0); m_leftGrid = g; }
46 inline KisSubPerspectiveGrid* rightGrid() {
return m_rightGrid; }
47 inline void setRightGrid(KisSubPerspectiveGrid* g) { Q_ASSERT(m_rightGrid==0); m_rightGrid = g; }
48 inline KisSubPerspectiveGrid* topGrid() {
return m_topGrid; }
49 inline void setTopGrid(KisSubPerspectiveGrid* g) { Q_ASSERT(m_topGrid==0); m_topGrid = g; }
50 inline KisSubPerspectiveGrid* bottomGrid() {
return m_bottomGrid; }
51 inline void setBottomGrid(KisSubPerspectiveGrid* g) { Q_ASSERT(m_bottomGrid==0); m_bottomGrid = g; }
52 inline const KisPerspectiveGridNodeSP topLeft()
const {
return m_topLeft; }
53 inline KisPerspectiveGridNodeSP topLeft() {
return m_topLeft; }
54 inline const KisPerspectiveGridNodeSP topRight()
const {
return m_topRight; }
55 inline KisPerspectiveGridNodeSP topRight() {
return m_topRight; }
56 inline const KisPerspectiveGridNodeSP bottomLeft()
const {
return m_bottomLeft; }
57 inline KisPerspectiveGridNodeSP bottomLeft() {
return m_bottomLeft; }
58 inline const KisPerspectiveGridNodeSP bottomRight()
const {
return m_bottomRight; }
59 inline KisPerspectiveGridNodeSP bottomRight() {
return m_bottomRight; }
60 inline int subdivisions()
const {
return m_subdivisions; }
65 inline int index()
const {
return m_index; }
70 bool contains(
const KisPoint p)
const;
72 inline KisPoint computeVanishingPoint(KisPerspectiveGridNodeSP p11, KisPerspectiveGridNodeSP p12, KisPerspectiveGridNodeSP p21, KisPerspectiveGridNodeSP p22)
74 KisPerspectiveMath::LineEquation d1 = KisPerspectiveMath::computeLineEquation( p11, p12 );
75 KisPerspectiveMath::LineEquation d2 = KisPerspectiveMath::computeLineEquation( p21, p22 );
76 return KisPerspectiveMath::computeIntersection(d1,d2);
79 KisPerspectiveGridNodeSP m_topLeft, m_topRight, m_bottomLeft, m_bottomRight;
80 KisSubPerspectiveGrid *m_leftGrid, *m_rightGrid, *m_topGrid, *m_bottomGrid;
83 static int s_lastIndex;
86class KisPerspectiveGrid {
89 ~KisPerspectiveGrid();
93 bool addNewSubGrid( KisSubPerspectiveGrid* ng );
94 inline TQValueList<KisSubPerspectiveGrid*>::const_iterator begin()
const {
return m_subGrids.begin(); }
95 inline TQValueList<KisSubPerspectiveGrid*>::const_iterator end()
const {
return m_subGrids.end(); }
96 inline bool hasSubGrids()
const {
return !m_subGrids.isEmpty(); }
98 inline int countSubGrids()
const {
return m_subGrids.size(); }
102 KisSubPerspectiveGrid* gridAt(
KisPoint p);
104 TQValueList<KisSubPerspectiveGrid*> m_subGrids;
A double-based point class that can return it's coordinates approximated to integers.