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

#include <scrollbar.h>

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

Public Slots

virtual void moveSlider (double min, double max)
 
virtual void setBase (double min, double max)
 

Signals

void sliderMoved (Qt::Orientation, double, double)
 
void valueChanged (Qt::Orientation, double, double)
 

Public Member Functions

int extent () const
 
bool isInverted () const
 
bool isLogScale () const
 
double maxBaseValue () const
 
double maxSliderValue () const
 
double minBaseValue () const
 
double minSliderValue () const
 
 ScrollBar (QWidget *parent=NULL)
 
 ScrollBar (Qt::Orientation, QWidget *parent=NULL)
 
 ScrollBar (double minBase, double maxBase, bool logscale, Qt::Orientation o, QWidget *parent=NULL)
 
void setInverted (bool)
 
void setLogScale (bool l)
 

Protected Member Functions

double mapFromTick (int) const
 
int mapToTick (double) const
 
void sliderRange (int value, double &min, double &max) const
 

Private Slots

void catchSliderMoved (int value)
 
void catchValueChanged (int value)
 

Private Member Functions

void init ()
 

Private Attributes

int d_baseTicks
 
bool d_inverted
 
double d_maxBase
 
double d_minBase
 
bool mLogScale
 

Detailed Description

Definition at line 28 of file scrollbar.h.

Constructor & Destructor Documentation

ScrollBar::ScrollBar ( QWidget *  parent = NULL)

Definition at line 31 of file scrollbar.cpp.

References init().

31  :
32  QScrollBar(parent),
33  mLogScale(false)
34 {
35  init();
36 }
void init()
Definition: scrollbar.cpp:56
bool mLogScale
Definition: scrollbar.h:76
ScrollBar::ScrollBar ( Qt::Orientation  o,
QWidget *  parent = NULL 
)

Definition at line 38 of file scrollbar.cpp.

References init().

39  :
40  QScrollBar(o, parent),
41  mLogScale(false)
42 {
43  init();
44 }
void init()
Definition: scrollbar.cpp:56
bool mLogScale
Definition: scrollbar.h:76
ScrollBar::ScrollBar ( double  minBase,
double  maxBase,
bool  logscale,
Qt::Orientation  o,
QWidget *  parent = NULL 
)

Definition at line 46 of file scrollbar.cpp.

References init(), moveSlider(), and setBase().

47  :
48  QScrollBar(o, parent),
49  mLogScale(logscale)
50 {
51  init();
52  setBase(minBase, maxBase);
53  moveSlider(minBase, maxBase);
54 }
void init()
Definition: scrollbar.cpp:56
bool mLogScale
Definition: scrollbar.h:76
virtual void moveSlider(double min, double max)
Definition: scrollbar.cpp:99
virtual void setBase(double min, double max)
Definition: scrollbar.cpp:82

Member Function Documentation

void ScrollBar::catchSliderMoved ( int  value)
privateslot

Definition at line 211 of file scrollbar.cpp.

References max, min, sliderMoved(), and sliderRange().

Referenced by init().

212 {
213  double min, max;
214  sliderRange(value, min, max);
215  emit sliderMoved(orientation(), min, max);
216 }
void sliderRange(int value, double &min, double &max) const
Definition: scrollbar.cpp:161
void sliderMoved(Qt::Orientation, double, double)
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
void ScrollBar::catchValueChanged ( int  value)
privateslot

Definition at line 204 of file scrollbar.cpp.

References max, min, sliderRange(), and valueChanged().

Referenced by init().

205 {
206  double min, max;
207  sliderRange(value, min, max);
208  emit valueChanged(orientation(), min, max);
209 }
void sliderRange(int value, double &min, double &max) const
Definition: scrollbar.cpp:161
void valueChanged(Qt::Orientation, double, double)
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
int ScrollBar::extent ( ) const

Definition at line 218 of file scrollbar.cpp.

Referenced by ScrollZoomer::layoutScrollBars(), and ScrollZoomer::updateScrollBars().

219 {
220 #if QT_VERSION < 0x040000
221  return style().pixelMetric(QStyle::PM_ScrollBarExtent, this);
222 #else
223  QStyleOptionSlider opt;
224  opt.init(this);
225  opt.subControls = QStyle::SC_None;
226  opt.activeSubControls = QStyle::SC_None;
227  opt.orientation = orientation();
228  opt.minimum = minimum();
229  opt.maximum = maximum();
230  opt.sliderPosition = sliderPosition();
231  opt.sliderValue = value();
232  opt.singleStep = singleStep();
233  opt.pageStep = pageStep();
234  opt.upsideDown = invertedAppearance();
235 
236  if (orientation() == Qt::Horizontal)
237  opt.state |= QStyle::State_Horizontal;
238 
239  return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &opt, this);
240 #endif
241 }
void ScrollBar::init ( )
private

Definition at line 56 of file scrollbar.cpp.

References catchSliderMoved(), catchValueChanged(), d_baseTicks, d_inverted, d_maxBase, d_minBase, moveSlider(), sliderMoved(), and valueChanged().

Referenced by ScrollBar().

57 {
58  d_inverted = orientation() == Qt::Vertical;
59  d_baseTicks = 1000000;
60  d_minBase = 0.0;
61  d_maxBase = 1.0;
63 
64  connect(this, SIGNAL(sliderMoved(int)), SLOT(catchSliderMoved(int)));
65  connect(this, SIGNAL(valueChanged(int)), SLOT(catchValueChanged(int)));
66 }
int d_baseTicks
Definition: scrollbar.h:75
bool d_inverted
Definition: scrollbar.h:72
void sliderMoved(Qt::Orientation, double, double)
void catchValueChanged(int value)
Definition: scrollbar.cpp:204
void catchSliderMoved(int value)
Definition: scrollbar.cpp:211
virtual void moveSlider(double min, double max)
Definition: scrollbar.cpp:99
double d_minBase
Definition: scrollbar.h:73
double d_maxBase
Definition: scrollbar.h:74
void valueChanged(Qt::Orientation, double, double)
bool ScrollBar::isInverted ( ) const

Definition at line 77 of file scrollbar.cpp.

References d_inverted.

Referenced by moveSlider(), and sliderRange().

78 {
79  return d_inverted;
80 }
bool d_inverted
Definition: scrollbar.h:72
bool ScrollBar::isLogScale ( ) const

Definition at line 248 of file scrollbar.cpp.

References mLogScale.

249 {
250  return mLogScale;
251 }
bool mLogScale
Definition: scrollbar.h:76
double ScrollBar::mapFromTick ( int  tick) const
protected

Definition at line 199 of file scrollbar.cpp.

References d_baseTicks, d_maxBase, and d_minBase.

Referenced by sliderRange().

200 {
201  return d_minBase + (d_maxBase - d_minBase) * tick / d_baseTicks;
202 }
int d_baseTicks
Definition: scrollbar.h:75
double d_minBase
Definition: scrollbar.h:73
double d_maxBase
Definition: scrollbar.h:74
int ScrollBar::mapToTick ( double  v) const
protected

Definition at line 194 of file scrollbar.cpp.

References d_baseTicks, d_maxBase, and d_minBase.

Referenced by moveSlider().

195 {
196  return (int)((v - d_minBase) / (d_maxBase - d_minBase) * d_baseTicks);
197 }
int d_baseTicks
Definition: scrollbar.h:75
double d_minBase
Definition: scrollbar.h:73
double d_maxBase
Definition: scrollbar.h:74
double ScrollBar::maxBaseValue ( ) const

Definition at line 153 of file scrollbar.cpp.

References d_maxBase, and mLogScale.

154 {
155  if (mLogScale)
156  return exp(d_maxBase);
157  else
158  return d_maxBase;
159 }
bool mLogScale
Definition: scrollbar.h:76
double d_maxBase
Definition: scrollbar.h:74
double ScrollBar::maxSliderValue ( ) const

Definition at line 186 of file scrollbar.cpp.

References max, and sliderRange().

Referenced by setBase(), and setInverted().

187 {
188  double max, dummy;
189  sliderRange(value(), dummy, max);
190 
191  return max;
192 }
void sliderRange(int value, double &min, double &max) const
Definition: scrollbar.cpp:161
#define max(a, b)
Definition: f2c.h:176
double ScrollBar::minBaseValue ( ) const

Definition at line 145 of file scrollbar.cpp.

References d_minBase, and mLogScale.

146 {
147  if (mLogScale)
148  return exp(d_minBase);
149  else
150  return d_minBase;
151 }
bool mLogScale
Definition: scrollbar.h:76
double d_minBase
Definition: scrollbar.h:73
double ScrollBar::minSliderValue ( ) const

Definition at line 178 of file scrollbar.cpp.

References min, and sliderRange().

Referenced by setBase(), and setInverted().

179 {
180  double min, dummy;
181  sliderRange(value(), min, dummy);
182 
183  return min;
184 }
void sliderRange(int value, double &min, double &max) const
Definition: scrollbar.cpp:161
#define min(a, b)
Definition: f2c.h:175
void ScrollBar::moveSlider ( double  min,
double  max 
)
virtualslot

Definition at line 99 of file scrollbar.cpp.

References d_baseTicks, d_maxBase, d_minBase, isInverted(), mapToTick(), and mLogScale.

Referenced by init(), ScrollBar(), setBase(), setInverted(), and ScrollZoomer::updateScrollBars().

100 {
101  if (mLogScale)
102  {
103  min = log(min);
104  max = log(max);
105  }
106 
107  int sliderTicks;
108  sliderTicks = qRound((max - min) /
110 
111  // setRange initiates a valueChanged of the scrollbars
112  // in some situations. So we block
113  // and unblock the signals.
114 
115  blockSignals(true);
116 
117  setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2);
118  int steps = sliderTicks / 200;
119 
120  if (steps <= 0)
121  steps = 1;
122 
123 #if QT_VERSION < 0x040000
124  setSteps(steps, sliderTicks);
125 #else
126  setSingleStep(steps);
127  setPageStep(sliderTicks);
128 #endif
129 
130  int tick;
131  tick = mapToTick(min + (max - min) / 2);
132 
133  if (isInverted())
134  tick = d_baseTicks - tick;
135 
136 #if QT_VERSION < 0x040000
137  directSetValue(tick);
138  rangeChange();
139 #else
140  setSliderPosition(tick);
141 #endif
142  blockSignals(false);
143 }
int d_baseTicks
Definition: scrollbar.h:75
bool mLogScale
Definition: scrollbar.h:76
bool isInverted() const
Definition: scrollbar.cpp:77
int mapToTick(double) const
Definition: scrollbar.cpp:194
double d_minBase
Definition: scrollbar.h:73
double d_maxBase
Definition: scrollbar.h:74
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
void ScrollBar::setBase ( double  min,
double  max 
)
virtualslot

Definition at line 82 of file scrollbar.cpp.

References d_maxBase, d_minBase, max, maxSliderValue(), min, minSliderValue(), mLogScale, and moveSlider().

Referenced by ScrollBar(), and ScrollZoomer::updateScrollBars().

83 {
84  if (mLogScale)
85  {
86  min = log(min);
87  max = log(max);
88  }
89 
90  if (min != d_minBase || max != d_maxBase)
91  {
92  d_minBase = min;
93  d_maxBase = max;
94 
96  }
97 }
double maxSliderValue() const
Definition: scrollbar.cpp:186
bool mLogScale
Definition: scrollbar.h:76
double minSliderValue() const
Definition: scrollbar.cpp:178
virtual void moveSlider(double min, double max)
Definition: scrollbar.cpp:99
double d_minBase
Definition: scrollbar.h:73
double d_maxBase
Definition: scrollbar.h:74
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
void ScrollBar::setInverted ( bool  inverted)

Definition at line 68 of file scrollbar.cpp.

References d_inverted, maxSliderValue(), minSliderValue(), and moveSlider().

Referenced by ScrollZoomer::updateScrollBars().

69 {
70  if (d_inverted != inverted)
71  {
72  d_inverted = inverted;
74  }
75 }
double maxSliderValue() const
Definition: scrollbar.cpp:186
bool d_inverted
Definition: scrollbar.h:72
double minSliderValue() const
Definition: scrollbar.cpp:178
virtual void moveSlider(double min, double max)
Definition: scrollbar.cpp:99
void ScrollBar::setLogScale ( bool  l)

Definition at line 243 of file scrollbar.cpp.

References mLogScale.

Referenced by ScrollZoomer::updateScrollBars().

244 {
245  mLogScale = l;
246 }
bool mLogScale
Definition: scrollbar.h:76
void ScrollBar::sliderMoved ( Qt::Orientation  ,
double  ,
double   
)
signal

Referenced by catchSliderMoved(), and init().

void ScrollBar::sliderRange ( int  value,
double &  min,
double &  max 
) const
protected

Definition at line 161 of file scrollbar.cpp.

References d_baseTicks, isInverted(), mapFromTick(), and mLogScale.

Referenced by catchSliderMoved(), catchValueChanged(), maxSliderValue(), and minSliderValue().

162 {
163  if (isInverted())
164  value = d_baseTicks - value;
165 
166  const int visibleTicks = pageStep();
167 
168  min = mapFromTick(value - visibleTicks / 2);
169  max = mapFromTick(value + visibleTicks / 2);
170 
171  if (mLogScale)
172  {
173  min = exp(min);
174  max = exp(max);
175  }
176 }
double mapFromTick(int) const
Definition: scrollbar.cpp:199
int d_baseTicks
Definition: scrollbar.h:75
bool mLogScale
Definition: scrollbar.h:76
bool isInverted() const
Definition: scrollbar.cpp:77
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
void ScrollBar::valueChanged ( Qt::Orientation  ,
double  ,
double   
)
signal

Referenced by catchValueChanged(), and init().

Member Data Documentation

int ScrollBar::d_baseTicks
private

Definition at line 75 of file scrollbar.h.

Referenced by init(), mapFromTick(), mapToTick(), moveSlider(), and sliderRange().

bool ScrollBar::d_inverted
private

Definition at line 72 of file scrollbar.h.

Referenced by init(), isInverted(), and setInverted().

double ScrollBar::d_maxBase
private

Definition at line 74 of file scrollbar.h.

Referenced by init(), mapFromTick(), mapToTick(), maxBaseValue(), moveSlider(), and setBase().

double ScrollBar::d_minBase
private

Definition at line 73 of file scrollbar.h.

Referenced by init(), mapFromTick(), mapToTick(), minBaseValue(), moveSlider(), and setBase().

bool ScrollBar::mLogScale
private

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