Originally Posted by
Gopala Krishna
Wait a second.. What did you try last time ? Did you implement FieldItem which also draws sub fields and internal shapes or did you use Q*Items for the subfields and internal shapes ?
If you had implemented FieldItem which draws everything inside it, then the performance you got should be better than that having child items. This is because more the items, more there is strain on bsp indexing and hence the whole mechanism slows down.
@Wysota: Am i wrong with the above assumption as you suggested the child items option ?
In the version I referred to (let's call it v1.1) I used the QGraphicsitem subclass FieldItem which draws the field's boundary rectangle, and added it to the scene:
.
Field = new FieldItem(&outRect,color,&fill);
scene->addItem(Field);
class FieldItem : public QGraphicsItem
.
Field = new FieldItem(&outRect,color,&fill);
scene->addItem(Field);
To copy to clipboard, switch view to plain text mode
"color" and "fill" are pointers to the 64-entry colorlist and bool fill parameter.
Field->paint is responsible for drawing the subfield bounds and the pattern shapes, there are no other GraphicsItems than Fields. The FieldItem object holds a QList with the subfields and pattern shapes, which are added to the Field object by the methods addSubField and addRect:
MainWindowImpl::DrawSubFieldBounds() {
.
Field->addSubfield(&sfRect);
.
}
.
MainWindowImpl::DrawRectangle(const QRectF inRectangle
) { .
Field->addRect(&rRect, AreaShot);
.
}
MainWindowImpl::DrawSubFieldBounds() {
.
Field->addSubfield(&sfRect);
.
}
.
MainWindowImpl::DrawRectangle(const QRectF inRectangle) {
.
Field->addRect(&rRect, AreaShot);
.
}
To copy to clipboard, switch view to plain text mode
As a summary, the performance is reasonable at the expense of complexity.
In the NEXT version (let's call it c1.2) I am using the full parent-child hierarchy with the convenience function QGraphicsRectItem, and ihis is what gives me the poor drawing performance but very light on memory consumprtion.
I will continue with this by subclassing to Field, SubField, and Shape and include levelOfDetail and as efficient drawing as possible.
Bookmarks