##// END OF EJS Templates
Some perfs improvments....
jeandet -
r2902:1f7564788f9d 5.7
parent child
Show More
@@ -85,7 +85,7 void ColorMapChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
85 85 Q_UNUSED(option)
86 86
87 87 painter->save();
88 //m_series->setUseOpenGL();
88 m_series->setUseOpenGL();
89 89
90 90 QRectF plotAreaRect = m_series->chart()->plotArea();
91 91 QRectF clipRect = mapColorMapToPlotArea();
@@ -94,8 +94,7 void ColorMapChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
94 94 if(m_currentClipRect !=clipRect)
95 95 {
96 96 m_currentClipRect = clipRect;
97 m_grid.reserve(clipRect.width()*clipRect.height());
98 m_grid.resize(clipRect.width()*clipRect.height());
97 m_grid.resize(clipRect.width()*clipRect.height()); //faster than reserve
99 98
100 99 m_series->getUniformGrid(qMax(m_series->minX(),domain()->minX()),qMin(m_series->maxX(),domain()->maxX()),qMax(m_series->minY(),domain()->minY()),qMin(m_series->maxY(),domain()->maxY()), clipRect.width(),clipRect.height(),m_grid, QColorMapSeries::LastPixel);
101 100 addColorBar(plotAreaRect);
@@ -141,11 +140,23 QRectF ColorMapChart::mapColorMapToPlotArea()
141 140 double widthToPaint = (qMin(seriesMaxX, domainMaxX)-qMax(seriesMinX, domainMinX))*plotAreaRect.width()/(domainMaxX-domainMinX);
142 141 double heightTopaint= (qMin(seriesMaxY, domainMaxY)-qMax(seriesMinY, domainMinY))*plotAreaRect.height()/(domainMaxY-domainMinY);
143 142
144 QSizeF size = QSize(widthToPaint,heightTopaint);
143
145 144
146 145 double pointX = (qMax(seriesMinX,domainMinX)-domainMinX)*plotAreaRect.width()/(domainMaxX-domainMinX);
147 146 double pointY = (domainMaxY-qMin(seriesMaxY,domainMaxY))*plotAreaRect.height()/(domainMaxY-domainMinY);
148 147
148 if(Q_UNLIKELY(widthToPaint < 0))
149 widthToPaint = 0;
150 if(Q_UNLIKELY(heightTopaint < 0))
151 heightTopaint = 0;
152
153 QSizeF size = QSize(widthToPaint,heightTopaint);
154
155 if(Q_UNLIKELY(pointX < 0))
156 pointX = 0;
157 if(Q_UNLIKELY(pointY < 0))
158 pointY = 0;
159
149 160 return QRectF(QPointF(pointX,pointY) ,size);
150 161 }
151 162
@@ -79,6 +79,14 Q_SIGNALS:
79 79 void doubleClicked(const Point3D &point);
80 80 void gradientTypeChanged();
81 81
82 protected:
83 // void updateGeometry();
84 // void mousePressEvent(QGraphicsSceneMouseEvent *event);
85 // void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
86 // void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
87 // void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
88 // void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
89
82 90 private:
83 91 inline bool isEmpty();
84 92 void addColorBar(QRectF plotAreaRect);
@@ -88,7 +96,6 private:
88 96 QLinearGradient createColorMapGradient(GradientType gradientType);
89 97 void changeGradient(GradientType gradientType);
90 98
91 protected:
92 99 QColorMapSeries *m_series;
93 100 QVector<Point3D> m_points;
94 101 QRectF m_rect;
General Comments 0
You need to be logged in to leave comments. Login now