COPASI API  4.16.103
CQCopasiEffect.cpp
Go to the documentation of this file.
1 // Copyright (C) 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
7 
8 #include <QtGui/QPainter>
9 #include <QtGui/QGraphicsEffect>
10 
12  : mScale(1.0)
13 {
14 }
15 
17 {
18 }
19 
20 void CQCopasiEffect::setScale(qreal scale)
21 {
22  mScale = scale;
23 }
24 
25 void CQCopasiEffect::draw(QPainter* painter)
26 {
27  QPoint offset;
28  const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
29 
30  if (pixmap.isNull())
31  return;
32 
33  painter->save();
34  painter->setWorldTransform(QTransform());
35  QRectF rect = pixmap.rect();
36 
37  QTransform trans = QTransform::fromScale(mScale, mScale);
38  QPixmap transformed = pixmap.transformed(trans, Qt::SmoothTransformation);
39  QRectF transRect = transformed.rect();
40 
41  QPointF newOffset = offset + (rect.center() - transRect.center());
42 
43  painter->drawPixmap(newOffset, transformed);
44  painter->restore();
45 }
void draw(QPainter *painter)
void setScale(qreal scale)
virtual ~CQCopasiEffect()