Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class GraphicsScene : public QGraphicsScene
{
GraphicsScene( QObject * p = NULL );
~GraphicsScene();
protected:
void drawItems( QPainter * painter, int nbItem, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget * widget = NULL );
};
GraphicsScene::GraphicsScene( QObject * p = NULL ) : QGraphicsScene ( p )
{
// ...
}
GraphicsScene::~GraphicsScene()
{
// ...
}
void GraphicsScene::drawItems( QPainter * painter, int nbItem, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget * widget = NULL )
{
// ...
}
|
This post has been edited 5 times, last edit by "Nicolas SOUCHON" (Dec 16th 2007, 5:40pm)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
void QGraphicsScene::drawItems(QPainter *painter,
int numItems,
QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[], QWidget *widget)
{
Q_D(QGraphicsScene);
// Detect if painter state protection is disabled.
bool painterStateProtection = d->painterStateProtection(painter);
QTransform oldTransform = painter->worldTransform();
for (int i = 0; i < numItems; ++i) {
// Save painter
if (painterStateProtection)
painter->save();
QGraphicsItem *item = items[i];
if (item->d_ptr->itemIsUntransformable()) {
painter->setTransform(item->deviceTransform(painter->worldTransform()), false);
} else {
painter->setTransform(item->sceneTransform(), true);
}
if (item->flags() & QGraphicsItem::ItemClipsToShape)
painter->setClipPath(item->shape(), Qt::IntersectClip);
if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
// Set a clip path on \a painter by walking up the parent item
// chain of \a item, intersecting clip paths as long as the item's
// ancestor clips children.
QGraphicsItem *target = item->parentItem();
do {
painter->setClipPath(item->mapFromItem(target, target->shape()), Qt::IntersectClip);
} while ((target->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
&& (target = target->parentItem()));
}
item->paint(painter, &options[i], widget);
// Restore painter
if (painterStateProtection)
painter->restore();
else
painter->setWorldTransform(oldTransform);
}
}
|
|
|
Source code |
1 |
#define Q_D(Class) Class##Private * const d = d_func() |
This post has been edited 1 times, last edit by "Nicolas SOUCHON" (Dec 16th 2007, 6:57pm)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
void myQGraphicsScene::drawItems(QPainter *painter,
int numItems,
QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[], QWidget *widget)
{
for (int i = 0; i < numItems; ++i) {
painter->save();
QGraphicsItem *item = items[i];
item->paint(painter, &options[i], widget);
painter->restore();
}
}
|
This post has been edited 1 times, last edit by "bnilsson" (Dec 16th 2007, 7:08pm)