##// 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 Q_UNUSED(option)
85 Q_UNUSED(option)
86
86
87 painter->save();
87 painter->save();
88 //m_series->setUseOpenGL();
88 m_series->setUseOpenGL();
89
89
90 QRectF plotAreaRect = m_series->chart()->plotArea();
90 QRectF plotAreaRect = m_series->chart()->plotArea();
91 QRectF clipRect = mapColorMapToPlotArea();
91 QRectF clipRect = mapColorMapToPlotArea();
@@ -94,8 +94,7 void ColorMapChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
94 if(m_currentClipRect !=clipRect)
94 if(m_currentClipRect !=clipRect)
95 {
95 {
96 m_currentClipRect = clipRect;
96 m_currentClipRect = clipRect;
97 m_grid.reserve(clipRect.width()*clipRect.height());
97 m_grid.resize(clipRect.width()*clipRect.height()); //faster than reserve
98 m_grid.resize(clipRect.width()*clipRect.height());
99
98
100 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);
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 addColorBar(plotAreaRect);
100 addColorBar(plotAreaRect);
@@ -141,11 +140,23 QRectF ColorMapChart::mapColorMapToPlotArea()
141 double widthToPaint = (qMin(seriesMaxX, domainMaxX)-qMax(seriesMinX, domainMinX))*plotAreaRect.width()/(domainMaxX-domainMinX);
140 double widthToPaint = (qMin(seriesMaxX, domainMaxX)-qMax(seriesMinX, domainMinX))*plotAreaRect.width()/(domainMaxX-domainMinX);
142 double heightTopaint= (qMin(seriesMaxY, domainMaxY)-qMax(seriesMinY, domainMinY))*plotAreaRect.height()/(domainMaxY-domainMinY);
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 double pointX = (qMax(seriesMinX,domainMinX)-domainMinX)*plotAreaRect.width()/(domainMaxX-domainMinX);
145 double pointX = (qMax(seriesMinX,domainMinX)-domainMinX)*plotAreaRect.width()/(domainMaxX-domainMinX);
147 double pointY = (domainMaxY-qMin(seriesMaxY,domainMaxY))*plotAreaRect.height()/(domainMaxY-domainMinY);
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 return QRectF(QPointF(pointX,pointY) ,size);
160 return QRectF(QPointF(pointX,pointY) ,size);
150 }
161 }
151
162
@@ -79,6 +79,14 Q_SIGNALS:
79 void doubleClicked(const Point3D &point);
79 void doubleClicked(const Point3D &point);
80 void gradientTypeChanged();
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 private:
90 private:
83 inline bool isEmpty();
91 inline bool isEmpty();
84 void addColorBar(QRectF plotAreaRect);
92 void addColorBar(QRectF plotAreaRect);
@@ -88,7 +96,6 private:
88 QLinearGradient createColorMapGradient(GradientType gradientType);
96 QLinearGradient createColorMapGradient(GradientType gradientType);
89 void changeGradient(GradientType gradientType);
97 void changeGradient(GradientType gradientType);
90
98
91 protected:
92 QColorMapSeries *m_series;
99 QColorMapSeries *m_series;
93 QVector<Point3D> m_points;
100 QVector<Point3D> m_points;
94 QRectF m_rect;
101 QRectF m_rect;
General Comments 0
You need to be logged in to leave comments. Login now