Graphic LODoptimization improvements - now draw only points in visible rect
This commit is contained in:
@@ -1202,7 +1202,6 @@ void Graphic::drawGraphics() {
|
|||||||
QTransform mat = painter->transform();
|
QTransform mat = painter->transform();
|
||||||
painter->resetTransform();
|
painter->resetTransform();
|
||||||
painter->setWorldMatrixEnabled(false);
|
painter->setWorldMatrixEnabled(false);
|
||||||
QPolygonF cpol;
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
for (int i = 0; i < graphics.size(); ++i) {
|
for (int i = 0; i < graphics.size(); ++i) {
|
||||||
GraphicType & t(graphics[i]);
|
GraphicType & t(graphics[i]);
|
||||||
@@ -1214,28 +1213,59 @@ void Graphic::drawGraphics() {
|
|||||||
int gpcnt = src_pol.size();
|
int gpcnt = src_pol.size();
|
||||||
qreal range = src_pol.back().x() - src_pol.front().x();
|
qreal range = src_pol.back().x() - src_pol.front().x();
|
||||||
qreal ppp = (gpcnt * selrect.width() / qMax(range, 1.E-9) / cwid);
|
qreal ppp = (gpcnt * selrect.width() / qMax(range, 1.E-9) / cwid);
|
||||||
lod = qBound<int>(0, qFloor(log2(ppp) - 2), src_lod.size());
|
lod = qBound<int>(0, qFloor(log2(ppp) - 1), src_lod.size());
|
||||||
//qDebug() << "draw lod" << lod;
|
//qDebug() << "draw lod" << lod << src_lod[lod - 1].size();
|
||||||
}
|
}
|
||||||
QPolygonF & rpol(lod == 0 ? src_pol : src_lod[lod - 1]);
|
QPolygonF & rpol(lod == 0 ? src_pol : src_lod[lod - 1]);
|
||||||
pen = t.pen;
|
int ind_start = -1, ind_end = -1;
|
||||||
if (qRound(pen.widthF()) == pen.widthF()) pen.setWidth(pen.width()*thick);
|
if (m_LODOptimization) {
|
||||||
else pen.setWidthF(pen.widthF()*thick);
|
qreal xs = selrect.left(), xe = selrect.right(), _offset = 2. / cwid * selrect.width();
|
||||||
pen.setCosmetic(true);
|
xs -= _offset; xe += _offset;
|
||||||
if (t.lines) {
|
for (int i = 0; i < rpol.size(); ++i) {
|
||||||
painter->setPen(pen);
|
qreal px = rpol[i].x();
|
||||||
if (t.fill) {
|
if (px < xs) continue;
|
||||||
cpol = rpol;
|
if (ind_start < 0)
|
||||||
painter->setBrush(t.fill_color);
|
ind_start = qMax(0, i - 1);
|
||||||
painter->drawPolygon(mat.map(cpol));
|
if (px > xe && ind_end < 0) {
|
||||||
} else
|
ind_end = qMin(rpol.size(), i + 1);
|
||||||
painter->drawPolyline(mat.map(rpol));
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ind_start < 0) ind_start = 0;
|
||||||
|
if (ind_end < 0) ind_end = rpol.size();
|
||||||
|
//qDebug() << "bound" << ind_start << ind_end << rpol.size();
|
||||||
|
} else {
|
||||||
|
ind_start = 0;
|
||||||
|
ind_end = rpol.size();
|
||||||
}
|
}
|
||||||
if (t.points) {
|
int polsize = ind_end - ind_start;
|
||||||
if (qRound(t.pointWidth) == t.pointWidth) pen.setWidth(qRound(t.pointWidth*thick));
|
if (polsize > 0) {
|
||||||
else pen.setWidthF(t.pointWidth*thick);
|
QPolygonF cpol;
|
||||||
painter->setPen(pen);
|
if (m_LODOptimization && polsize < rpol.size()) {
|
||||||
painter->drawPoints(mat.map(rpol));
|
cpol.resize(polsize);
|
||||||
|
memcpy(cpol.data(), &(rpol[ind_start]), polsize * sizeof(QPointF));
|
||||||
|
//qDebug() << "copy" << polsize;
|
||||||
|
} else {
|
||||||
|
cpol = rpol;
|
||||||
|
}
|
||||||
|
pen = t.pen;
|
||||||
|
if (qRound(pen.widthF()) == pen.widthF()) pen.setWidth(pen.width()*thick);
|
||||||
|
else pen.setWidthF(pen.widthF()*thick);
|
||||||
|
pen.setCosmetic(true);
|
||||||
|
if (t.lines) {
|
||||||
|
painter->setPen(pen);
|
||||||
|
if (t.fill) {
|
||||||
|
painter->setBrush(t.fill_color);
|
||||||
|
painter->drawPolygon(mat.map(cpol));
|
||||||
|
} else
|
||||||
|
painter->drawPolyline(mat.map(cpol));
|
||||||
|
}
|
||||||
|
if (t.points) {
|
||||||
|
if (qRound(t.pointWidth) == t.pointWidth) pen.setWidth(qRound(t.pointWidth*thick));
|
||||||
|
else pen.setWidthF(t.pointWidth*thick);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->drawPoints(mat.map(cpol));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
painter->setWorldMatrixEnabled(true);
|
painter->setWorldMatrixEnabled(true);
|
||||||
|
|||||||
@@ -151,7 +151,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="buttonVarAdd">
|
<widget class="QToolButton" name="buttonVarAdd">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/qglview/qglview.qrc">
|
||||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/blockview/qad_blockview.qrc">
|
||||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/application/qad_application.qrc">
|
||||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="treeGraphics">
|
<widget class="QTreeWidget" name="treeGraphics">
|
||||||
@@ -272,7 +272,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="buttonGraphicAdd">
|
<widget class="QToolButton" name="buttonGraphicAdd">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/qglview/qglview.qrc">
|
||||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/blockview/qad_blockview.qrc">
|
||||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
@@ -313,7 +313,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../utils/qad_utils.qrc">
|
<iconset resource="../../libs/application/qad_application.qrc">
|
||||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -372,7 +372,13 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../utils/qad_utils.qrc"/>
|
<include location="../../libs/application/qad_application.qrc"/>
|
||||||
|
<include location="../../libs/blockview/qad_blockview.qrc"/>
|
||||||
|
<include location="../../libs/qglview/qglview.qrc"/>
|
||||||
|
<include location="qpicalculator.qrc"/>
|
||||||
|
<include location="../../libs/application/qad_application.qrc"/>
|
||||||
|
<include location="../../libs/blockview/qad_blockview.qrc"/>
|
||||||
|
<include location="../../libs/qglview/qglview.qrc"/>
|
||||||
<include location="qpicalculator.qrc"/>
|
<include location="qpicalculator.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in New Issue
Block a user