COPASI API  4.16.103
Public Types | Public Member Functions | Protected Attributes | List of all members
CQEffectDescription Class Reference

#include <CQEffectDescription.h>

Collaboration diagram for CQEffectDescription:
Collaboration graph
[legend]

Public Types

enum  Mode { DropShadow, Colorize, Scale }
 

Public Member Functions

void applyToScene (CQLayoutScene &scene, qreal t)
 
 CQEffectDescription (const std::string &cn, qreal startScale, qreal endScale)
 
 CQEffectDescription (const std::string &cn, Mode mode=Colorize, const QColor &startColor=Qt::white, const QColor &endColor=Qt::red)
 
const std::string & getCN () const
 
const QColor & getEndColor () const
 
Mode getMode () const
 
qreal getScaleEnd () const
 
qreal getScaleStart () const
 
const QColor & getStartColor () const
 
virtual void removeFromScene (CQLayoutScene &scene)
 
void setCN (const std::string &cn)
 
void setEndColor (const QColor &color)
 
void setMode (Mode mode)
 
void setScaleEnd (qreal scale)
 
void setScaleStart (qreal scale)
 
void setStartColor (const QColor &color)
 
virtual ~CQEffectDescription ()
 

Protected Attributes

std::string mCN
 
QColor mEndColor
 
Mode mMode
 
qreal mScaleEnd
 
qreal mScaleStart
 
QColor mStartColor
 

Detailed Description

Definition at line 14 of file CQEffectDescription.h.

Member Enumeration Documentation

Enumerator
DropShadow 
Colorize 
Scale 

Definition at line 17 of file CQEffectDescription.h.

Constructor & Destructor Documentation

CQEffectDescription::CQEffectDescription ( const std::string &  cn,
qreal  startScale,
qreal  endScale 
)

Definition at line 49 of file CQEffectDescription.cpp.

50  : mCN(cn)
51  , mStartColor(Qt::white)
52  , mEndColor(Qt::red)
53  , mScaleStart(startScale)
54  , mScaleEnd(endScale)
55  , mMode(Scale)
56 {
57 }
CQEffectDescription::CQEffectDescription ( const std::string &  cn,
Mode  mode = Colorize,
const QColor &  startColor = Qt::white,
const QColor &  endColor = Qt::red 
)

Definition at line 39 of file CQEffectDescription.cpp.

40  : mCN(cn)
41  , mStartColor(startColor)
42  , mEndColor(endColor)
43  , mScaleStart(0.5)
44  , mScaleEnd(2.0)
45  , mMode(mode)
46 {
47 }
CQEffectDescription::~CQEffectDescription ( )
virtual

Definition at line 59 of file CQEffectDescription.cpp.

60 {
61 }

Member Function Documentation

void CQEffectDescription::applyToScene ( CQLayoutScene scene,
qreal  t 
)

Definition at line 112 of file CQEffectDescription.cpp.

References Colorize, DropShadow, CQLayoutScene::getItemFor(), interpolate(), linear(), mCN, mEndColor, mMode, mScaleEnd, mScaleStart, mStartColor, Scale, and CQCopasiEffect::setScale().

113 {
114  QGraphicsItem *item = scene.getItemFor(mCN);
115 
116  if (item == NULL)
117  return;
118 
119  switch (mMode)
120  {
121  default:
122  case DropShadow:
123  {
124  QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(&scene);
125  effect->setColor(interpolate(mStartColor, mEndColor, t));
126  effect->setBlurRadius(25);
127  effect->setEnabled(true);
128  effect->setOffset(0);
129  item->setGraphicsEffect(effect);
130  }
131  break;
132 
133  case Colorize:
134  {
135  QGraphicsColorizeEffect* effect = new QGraphicsColorizeEffect(&scene);
136  effect->setColor(interpolate(mStartColor, mEndColor, t));
137  effect->setStrength(1);
138  effect->setEnabled(true);
139  item->setGraphicsEffect(effect);
140  }
141  break;
142 
143  case Scale:
144  {
145  CQCopasiEffect* effect = new CQCopasiEffect();
146  effect->setScale(linear(mScaleStart, mScaleEnd, t));
147  effect->setEnabled(true);
148  item->setGraphicsEffect(effect);
149  }
150  break;
151  }
152 }
QColor interpolate(const QColor &a, const QColor &b, float t)
qreal linear(qreal a, qreal b, qreal t)
void setScale(qreal scale)
QGraphicsItem * getItemFor(const std::string &cn)
const std::string & CQEffectDescription::getCN ( ) const

Definition at line 63 of file CQEffectDescription.cpp.

References mCN.

Referenced by CQEffectDescriptionEdit::initFrom(), and CQAnimationSettingsEditor::initFrom().

64 {
65  return mCN;
66 }
const QColor & CQEffectDescription::getEndColor ( ) const

Definition at line 73 of file CQEffectDescription.cpp.

References mEndColor.

Referenced by CQEffectDescriptionEdit::initFrom().

74 {
75  return mEndColor;
76 }
CQEffectDescription::Mode CQEffectDescription::getMode ( ) const

Definition at line 88 of file CQEffectDescription.cpp.

References mMode.

Referenced by CQEffectDescriptionEdit::initFrom().

89 {
90  return mMode;
91 }
qreal CQEffectDescription::getScaleEnd ( ) const

Definition at line 83 of file CQEffectDescription.cpp.

References mScaleEnd.

Referenced by CQEffectDescriptionEdit::initFrom().

84 {
85  return mScaleEnd;
86 }
qreal CQEffectDescription::getScaleStart ( ) const

Definition at line 78 of file CQEffectDescription.cpp.

References mScaleStart.

Referenced by CQEffectDescriptionEdit::initFrom().

79 {
80  return mScaleStart;
81 }
const QColor & CQEffectDescription::getStartColor ( ) const

Definition at line 68 of file CQEffectDescription.cpp.

References mStartColor.

Referenced by CQEffectDescriptionEdit::initFrom().

69 {
70  return mStartColor;
71 }
void CQEffectDescription::removeFromScene ( CQLayoutScene scene)
virtual

Definition at line 97 of file CQEffectDescription.cpp.

References CQLayoutScene::getItemFor(), and mCN.

98 {
99  QGraphicsItem *item = scene.getItemFor(mCN);
100 
101  if (item == NULL)
102  return;
103 
104  QGraphicsEffect* effect = item->graphicsEffect();
105 
106  if (effect == NULL)
107  return;
108 
109  effect->setEnabled(false);
110 }
QGraphicsItem * getItemFor(const std::string &cn)
void CQEffectDescription::setCN ( const std::string &  cn)

Definition at line 154 of file CQEffectDescription.cpp.

References mCN.

155 {
156  mCN = cn;
157 }
void CQEffectDescription::setEndColor ( const QColor &  color)

Definition at line 164 of file CQEffectDescription.cpp.

References mEndColor.

Referenced by CQEffectDescriptionEdit::saveTo(), and CQEffectDescriptionEdit::toDescription().

165 {
166  mEndColor = color;
167 }
void CQEffectDescription::setMode ( CQEffectDescription::Mode  mode)

Definition at line 92 of file CQEffectDescription.cpp.

References mMode.

Referenced by CQEffectDescriptionEdit::saveTo(), and CQEffectDescriptionEdit::toDescription().

93 {
94  mMode = mode;
95 }
void CQEffectDescription::setScaleEnd ( qreal  scale)

Definition at line 174 of file CQEffectDescription.cpp.

References mScaleEnd.

Referenced by CQEffectDescriptionEdit::saveTo(), and CQEffectDescriptionEdit::toDescription().

175 {
176  mScaleEnd = scale;
177 }
void CQEffectDescription::setScaleStart ( qreal  scale)

Definition at line 169 of file CQEffectDescription.cpp.

References mScaleStart.

Referenced by CQEffectDescriptionEdit::saveTo(), and CQEffectDescriptionEdit::toDescription().

170 {
171  mScaleStart = scale;
172 }
void CQEffectDescription::setStartColor ( const QColor &  color)

Definition at line 159 of file CQEffectDescription.cpp.

References mStartColor.

Referenced by CQEffectDescriptionEdit::saveTo(), and CQEffectDescriptionEdit::toDescription().

160 {
161  mStartColor = color;
162 }

Member Data Documentation

std::string CQEffectDescription::mCN
protected

Definition at line 51 of file CQEffectDescription.h.

Referenced by applyToScene(), getCN(), removeFromScene(), and setCN().

QColor CQEffectDescription::mEndColor
protected

Definition at line 53 of file CQEffectDescription.h.

Referenced by applyToScene(), getEndColor(), and setEndColor().

Mode CQEffectDescription::mMode
protected

Definition at line 56 of file CQEffectDescription.h.

Referenced by applyToScene(), getMode(), and setMode().

qreal CQEffectDescription::mScaleEnd
protected

Definition at line 55 of file CQEffectDescription.h.

Referenced by applyToScene(), getScaleEnd(), and setScaleEnd().

qreal CQEffectDescription::mScaleStart
protected

Definition at line 54 of file CQEffectDescription.h.

Referenced by applyToScene(), getScaleStart(), and setScaleStart().

QColor CQEffectDescription::mStartColor
protected

Definition at line 52 of file CQEffectDescription.h.

Referenced by applyToScene(), getStartColor(), and setStartColor().


The documentation for this class was generated from the following files: