30 #include <QPainterPath>
31 #include <QGraphicsScene>
36 using namespace KDChart;
46 , m_diagram( diagram )
52 delete m_scene; m_scene = 0;
70 Q_ASSERT( m_diagram );
71 if ( m_scene && m_scene->sceneRect().intersects( rect ) ) {
73 QModelIndexList indexes;
77 QModelIndex index ( m_diagram->model()->index( i->
row(), i->
column(), m_diagram->rootIndex() ) );
83 return QModelIndexList();
89 Q_ASSERT( m_diagram );
90 if ( m_scene && m_scene->sceneRect().contains( point ) ) {
92 QModelIndexList indexes;
96 QModelIndex index ( m_diagram->model()->index( i->
row(), i->
column(), m_diagram->rootIndex() ) );
97 if ( !indexes.contains(index) )
103 return QModelIndexList();
109 if ( !m_diagram->model()->hasIndex( row, column, m_diagram->rootIndex() ) )
111 const QModelIndex index = m_diagram->model()->index( row, column, m_diagram->rootIndex() );
112 return m_itemMap.contains( index ) ? m_itemMap[ index ]->polygon() : QPolygon();
117 if ( !m_diagram->model()->hasIndex( row, column, m_diagram->rootIndex() ) )
119 const QModelIndex index = m_diagram->model()->index( row, column, m_diagram->rootIndex() );
120 return m_itemMap.contains( index ) ? m_itemMap[ index ]->polygon().boundingRect() : QRectF();
126 m_scene->addItem( item );
127 m_itemMap.insert( m_diagram->model()->index( item->
row(), item->
column(), m_diagram->rootIndex() ), item );
138 item->setPolygon( polygon );
145 QPointF ossfet( -0.5*diameter.width(), -0.5*diameter.height() );
146 path.addEllipse( QRectF( location + ossfet, diameter ) );
147 addPolygon( row, column, QPolygonF( path.toFillPolygon() ) );
155 addCircle( row, column, from, QSizeF( 1.5, 1.5 ) );
162 static const QPointF pixel( 1.0, 1.0 );
164 if ( from.x() < to.x() ) {
171 const QPointF lineVector( right - left );
172 const qreal lineVectorLength = sqrt( lineVector.x() * lineVector.x() + lineVector.y() * lineVector.y() );
173 const QPointF lineVectorUnit( lineVector / lineVectorLength );
174 const QPointF normOfLineVectorUnit( -lineVectorUnit.y(), lineVectorUnit.x() );
176 const QPointF one( left - lineVectorUnit + normOfLineVectorUnit );
177 const QPointF two( left - lineVectorUnit - normOfLineVectorUnit );
178 const QPointF three( right + lineVectorUnit - normOfLineVectorUnit );
179 const QPointF four( right + lineVectorUnit + normOfLineVectorUnit );
180 addPolygon( row, column, QPolygonF() << one << two << three << four );