COPASI API  4.16.103
Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
PaintWidget Class Reference

#include <CQTSSATimeScaleWidget.h>

Inheritance diagram for PaintWidget:
Inheritance graph
[legend]
Collaboration diagram for PaintWidget:
Collaboration graph
[legend]

Public Member Functions

void paintTimeScale (int select)
 
 PaintWidget (QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
 
 ~PaintWidget ()
 

Public Attributes

bool mClear
 
CVector< C_FLOAT64mVector
 

Protected Member Functions

void paintEvent (QPaintEvent *)
 

Private Attributes

int mSelection
 

Detailed Description

Definition at line 22 of file CQTSSATimeScaleWidget.h.

Constructor & Destructor Documentation

PaintWidget::PaintWidget ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WFlags  fl = 0 
)

Definition at line 98 of file CQTSSATimeScaleWidget.cpp.

99  : QWidget(parent, fl),
100  mSelection(0)
101 {
102  setObjectName(QString::fromUtf8(name));
103 
104  if (!name)
105  setObjectName("PaintWidget");
106 }
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
PaintWidget::~PaintWidget ( )

Definition at line 111 of file CQTSSATimeScaleWidget.cpp.

112 {
113  // no need to delete child widgets, Qt does it all for us
114 }

Member Function Documentation

void PaintWidget::paintEvent ( QPaintEvent *  )
protected

Definition at line 122 of file CQTSSATimeScaleWidget.cpp.

References C_INT32, mClear, mSelection, mVector, and CVectorCore< CType >::size().

123 {
124 
125  if (mVector.size() == 0) return;
126 
127  if (mClear) return;
128 
129  int position;
130  int space = 35;
131 
132  int maxScaleValue = -1000;
133  int minScaleValue = 1000;
134  unsigned C_INT32 j;
135 
136  for (j = 0; j < mVector.size(); ++j)
137  {
138  if (fabs(mVector[j]) == std::numeric_limits<C_FLOAT64>::infinity())
139  continue;
140 
141  if ((int)(log10(fabs(mVector[j])) + 1) > maxScaleValue)
142  maxScaleValue = (int)(log10(fabs(mVector[j])) + 1);
143 
144  if ((int)(log10(fabs(mVector[j])) - 1) < minScaleValue)
145  minScaleValue = (int)(log10(fabs(mVector[j])) - 1);
146  }
147 
148  int scaleValueRange = maxScaleValue - minScaleValue;
149 
150  QPainter paint(this);
151  paint.save();
152 
153  //paint.setWindow(0, 0, 1000, 1000);
154  QRect v = paint.viewport();
155 
156  //paint.setFont(QFont("Courier", 15));
157 
158  //Legend
159  paint.setPen(QPen(QColor(180, 0, 0), 5));
160  paint.drawLine(space, space, space, space + 10);
161  paint.setPen(QPen(QColor(0, 0, 0), 1));
162  paint.drawText(space + 5, space + 10, " - negative time scale values");
163 
164  paint.setPen(QPen(QColor(0, 180, 0), 5));
165  paint.drawLine(space, space + 20, space, space + 30);
166  paint.setPen(QPen(QColor(0, 0, 0), 1));
167  paint.drawText(space + 5, space + 30, " - positive time scale values");
168 
169  //axis
170  paint.setPen(QPen(QColor(100, 100, 100), 1));
171  int yCentre = v.bottom() - space - 30;
172  int scaleBegin = space;
173  int scaleEnd = v.right() - space; //(maxScaleValue - minScaleValue) * (1000 - 2 * space) / scaleValueRange + space;
174  int axisLength = scaleEnd - scaleBegin;
175  paint.drawLine(scaleBegin, yCentre, scaleEnd, yCentre);
176 
177  //tics
178  C_INT32 i;
179 
180  for (i = 0; i <= scaleValueRange; i++)
181  {
182  position = scaleBegin + (int)(i * axisLength / scaleValueRange);
183  paint.drawLine(position, yCentre + 10, position, yCentre);
184  paint.drawText(position - 5, yCentre + 30, QString::number(minScaleValue + i));
185  }
186 
187  paint.setPen(QPen(QColor(0, 180, 0), 1));
188 
189  //values
190  int yTop = yCentre - 50;
191  int xText = v.right() - space - 230;
192  int yText = space + 30;
193 
194  for (j = 0; j < mVector.size(); j++)
195  {
196  position = scaleBegin + (int)((log10(fabs(mVector[j])) - minScaleValue) * axisLength / scaleValueRange);
197 
198  if ((uint)mSelection == (uint)(mVector.size() - 1 - j))
199  {
200  if (mVector[j] < 0)
201  paint.setPen(QPen(QColor(180, 20, 20), 4));
202  else
203  paint.setPen(QPen(QColor(20, 180, 20), 4));
204 
205  paint.drawLine(position, yCentre - 1, position, yTop);
206  paint.setPen(QPen(QColor(200, 200, 200), 1));
207  // paint.setFont(QFont("Courier", 20));
208  paint.drawLine(xText, yText, position + 1, yTop - 1);
209  paint.drawLine(xText, yText, scaleEnd, yText);
210  paint.setPen(QPen(QColor(0, 0, 0), 1));
211 
212  if (mVector[j] < 0)
213  paint.drawText(xText + 1, yText - 15, " log10 (|" + QString::number(mVector[j]) + "|) = " + QString::number(log10(fabs(mVector[j]))));
214  else
215  paint.drawText(xText + 1, yText - 15, " log10 (" + QString::number(fabs(mVector[j])) + ") = " + QString::number(log10(fabs(mVector[j]))));
216 
217  paint.drawText(scaleBegin + scaleEnd / 2 - 50, yCentre + 50, " log timescale");
218  }
219  else
220  {
221  if (mVector[j] < 0)
222  paint.setPen(QPen(QColor(180, 20, 20), 2));
223  else
224  paint.setPen(QPen(QColor(20, 180, 20), 2));
225 
226  paint.drawLine(position, yCentre - 1, position, yTop);
227  }
228  }
229 
230  paint.restore();
231 }
#define C_INT32
Definition: copasi.h:90
size_t size() const
Definition: CVector.h:100
CVector< C_FLOAT64 > mVector
void PaintWidget::paintTimeScale ( int  select)

Definition at line 116 of file CQTSSATimeScaleWidget.cpp.

References mSelection.

Referenced by CQTSSATimeScaleWidget::changedInterval(), and CQTSSATimeScaleWidget::paintTimeScale().

117 {
118  mSelection = select;
119  repaint();
120 }

Member Data Documentation

bool PaintWidget::mClear
int PaintWidget::mSelection
private

Definition at line 39 of file CQTSSATimeScaleWidget.h.

Referenced by paintEvent(), and paintTimeScale().

CVector< C_FLOAT64> PaintWidget::mVector

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