14 #if QT_VERSION < 0x040000
15 #include <qabstractlayout.h>
18 #include <QtGui/QHBoxLayout>
19 #include <QtGui/QVBoxLayout>
24 #include <qpushbutton.h>
28 #include <qcheckbox.h>
29 #include <qnamespace.h>
30 #include <qscrollbar.h>
31 #include <qlineedit.h>
32 #include <qmessagebox.h>
33 #include <qsizepolicy.h>
39 using namespace hippodraw;
45 :
QWidget ( parent, name, wflags )
58 policy.
setHorData ( QSizePolicy::MinimumExpanding );
60 #if QT_VERSION < 0x040000
62 lowSlider ->setFocusPolicy ( WheelFocus );
65 lowSlider ->setFocusPolicy ( Qt::WheelFocus );
73 #if QT_VERSION < 0x040000
78 highSlider ->setFocusPolicy ( Qt::WheelFocus );
111 checkboxlayout->setAlignment ( Qt::AlignHCenter );
115 connect (
lowTextBox, SIGNAL ( returnPressed() ),
118 connect (
highTextBox, SIGNAL ( returnPressed () ),
121 connect (
lowSlider, SIGNAL ( sliderReleased () ),
124 connect (
highSlider, SIGNAL ( sliderReleased () ),
127 connect (
lowSlider, SIGNAL ( valueChanged (
int ) ),
130 connect (
highSlider, SIGNAL ( valueChanged (
int ) ),
133 connect (
lowSlider, SIGNAL ( sliderPressed () ),
136 connect (
highSlider, SIGNAL ( sliderPressed () ),
158 const Range & fullRange )
175 currentRange.
setRange ( lo, hi, currentRange.
pos() );
195 if ( position - width / 2 < fullRange.
low() ||
196 position + width / 2 > fullRange.
high() ) {
206 currentRange.
setRange ( position - width / 2,
207 position + width / 2,
208 currentRange.
pos() );
224 currentRange.
setRange ( position - width / 2,
225 position + width / 2,
226 currentRange.
pos() );
259 Range & currentRange,
260 const Range & fullRange )
269 if ( new_low < currentRange.
high() ){
270 currentRange.
setLow ( new_low );
275 double low = currentRange.
low();
287 if ( position - width / 2 < fullRange.
low() ||
288 position + width / 2 > fullRange.
high() ) {
295 currentRange.
setRange ( position - width / 2,
296 position + width / 2,
297 currentRange.
pos() );
307 double oldWidth = fullRange.
length();
309 double position = ( fullRange.
high() + fullRange.
low() ) / 2 ;
313 currentRange.
setRange ( position - width / 2,
314 position + width / 2,
315 currentRange.
pos() );
333 Range & currentRange,
334 const Range & fullRange )
342 if ( new_high > currentRange.
low() ) {
343 currentRange.
setHigh ( new_high );
348 double high = currentRange.
high();
360 currentRange.
setRange ( position - 0.5 * width,
361 position + 0.5 * width,
362 currentRange.
pos() );
372 double oldPosition = ( fullRange.
high() + fullRange.
low() ) / 2 ;
373 double position = ( width *
379 currentRange.
setRange ( position - width / 2,
380 position + width / 2,
381 currentRange.
pos() );
393 const Range & fullRange )
408 double currentWidth = currentRange.
high() - currentRange.
low();
409 double currentPosition
410 = 0.5 * ( currentRange.
high() + currentRange.
low() );
437 double currentWidth = currentRange.
high() - currentRange.
low();
438 double currentPosition
439 = 0.5 * ( currentRange.
high() + currentRange.
low() );
465 =
"Attempt to apply invalid range:\n\n"
467 +
"Low end of range must be less than high end.";
536 const Range & fullRange )
626 const Range & fullRange )
629 = static_cast <
int >(
630 ( value - fullRange.
low() ) /
641 const Range & fullRange )
645 ( value ) / fullRange.
length () *
double getLowFromSlider(const Range &fullRange)
Converts the slider position to Low.
double getHighFromSlider(const Range &fullRange)
Converts the slider position to High.
QScrollBar * getHighSlider()
Returns the high slider.
double high() const
Returns the maximum of the range object.
void processZoomPanCheckBoxClicked(const Range ¤tRange, const Range &fullRange)
Called by InspectorBase in response to the zoomPanCheckBoxClicked signal.
void processLowSliderMoved(int value, Range ¤tRange, const Range &fullRange)
Called by InspectorBase in response to the lowSliderMoved signal.
QLineEdit * lowTextBox
The text box that shows the low value.
void highSliderPressed()
Emitted when highSlider is pressed.
void setZoomPan(bool check, bool disables=false)
Checks zoomPanCheckBox if check is true, else un-checks it.
double getPositionFromSlider(const Range &fullRange)
Converts the slider position to Position.
QLineEdit * highTextBox
The text box that shows the high value.
void highSliderValueChanged(int value)
Emitted when highSlider's value has changed.
void setSlider(QScrollBar *s, double value, const Range &fullRange)
Sets the slider s to the value value.
bool m_isCut
A boolean that is true if the AxisWidget controls a cut.
toDouble(bool *ok=0) const
void setCut(bool flag)
Set the isCut flag.
void setLow(double x)
Sets the minimum of the range object.
void updateCutControlValues(const Range ¤tRange, const Range &fullRange)
Set the textboxes and sliders to the values given by the arguments.
hippodraw::AxisWidget class interface
void lowSliderValueChanged(int value)
Emitted when lowSlider's value has changed.
void setHigh(double x)
Sets the maximum of the range object.
QScrollBar * highSlider
The high slider.
bool isZoomPanChecked()
Returns whether zoomPanCheckBox is checked.
void processHighSliderReleased(const Range &fullRange)
Called by InspectorBase in response to the highSliderReleased signal.
void processTextBoxReturnPressed(Range ¤tRange, const Range &fullRange)
Called by InspectorBase in response to the lowTextReturnPressed and highTextReturnPressed signals...
void setSliderZero(QScrollBar *s, double value, const Range &fullRange)
Sets the slider s to the value value, where the slider zero corresponds to data zero.
int getHighSliderValue()
Get the high slider value.
QCheckBox * zoomPanCheckBox
The zoom pan check box.
void zoomPanCheckBoxClicked()
Emitted when zoomPanCheckBox is clicked.
void lowSliderReleased()
Emitted when lowSlider is released.
void setHighText(const QString &s, bool readonly=false)
Set the text in the highTextBox.
double length() const
Returns the length of the range object.
void lowSliderPressed()
Emitted when lowSlider is pressed.
void setRange(double low, double high, double pos)
Changes the current Range.
QScrollBar * lowSlider
The low slider.
QScrollBar * getLowSlider()
Returns the low slider widget.
double getWidthFromSlider(const Range &fullRange)
Converts the slider position to Width.
void invalidRangeError(const std::string &bad)
Throws up a message box when an attempt is made to set an invalid range.
void highSliderReleased()
Emitted when highSlider is released.
void setLowText(const QString &s, bool readonly=false)
Set the text in the lowTextBox.
hippodraw::Range class interface
critical(QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
void setLowSliderValue(int value)
Set the low slider value.
double low() const
Returns the minimum of the range object.
Expresses a range of values.
void processHighSliderMoved(int value, Range ¤tRange, const Range &fullRange)
Called by InspectorBase in response to the highSliderMoved signal.
void highTextReturnPressed()
Emitted when highTextBox gets return pressed.
virtual ~AxisWidget()
The required virtual destructor.
void processLowSliderReleased(const Range &fullRange)
Called by InspectorBase in response to the lowSliderReleased signal.
void setHighSliderValue(int value)
Set the high slider value.
QLabel * highTextLabel
The "High" text label.
int getLowSliderValue()
Get the low slider value.
void setAllDisabled(bool flag)
Enable all controls if flag = false, disable if true.
QLabel * lowTextLabel
The "Low" text label.
AxisWidget(QWidget *parent=0, const char *name=0, Qt::WFlags wflags=0)
The standard QWidget constructor.
double pos() const
Returns the first positive element in range.
void lowTextReturnPressed()
Emitted when lowTextBox gets return pressed.