Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_sclif.cpp

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #include "qwt_sclif.h"
    00011
    00013 QwtScaleIf::QwtScaleIf()
    00014 {
    00015     d_userScale = FALSE;
    00016     d_maxMajor = 5;
    00017     d_maxMinor = 3;
    00018
    00019     d_scaleDraw = new QwtScaleDraw();
    00020     d_scaleDraw->setScale(0.0,100.0,d_maxMajor, d_maxMinor);
    00021 }
    00022
    00024 QwtScaleIf::~QwtScaleIf()
    00025 {
    00026     delete d_scaleDraw;
    00027 }
    00028
    00044 void QwtScaleIf::setScale(double vmin, double vmax, int logarithmic)
    00045 {
    00046     setScale(vmin,vmax,0.0,logarithmic);
    00047 }
    00048
    00049
    00066 void QwtScaleIf::setScale(double vmin, double vmax,
    00067     double step, int logarithmic)
    00068 {
    00069     QwtScaleDiv oldscl(d_scaleDraw->scaleDiv());
    00070
    00071     d_scaleDraw->setScale(vmin, vmax, d_maxMajor, d_maxMinor, step, logarithmic);
    00072     d_userScale = TRUE;
    00073     if (oldscl != d_scaleDraw->scaleDiv())
    00074        scaleChange();
    00075 }
    00076
    00081 void QwtScaleIf::setScale(const QwtScaleDiv &s)
    00082 {
    00083     if (s != d_scaleDraw->scaleDiv())
    00084     {
    00085         d_scaleDraw->setScale(s);
    00086         d_maxMajor = s.majCnt();
    00087         d_maxMinor = s.minCnt();
    00088         d_userScale = TRUE;
    00089         scaleChange();
    00090     }
    00091 }
    00092
    00099 void QwtScaleIf::autoScale()
    00100 {
    00101     if (!d_userScale)
    00102     {
    00103         d_userScale = FALSE;
    00104         scaleChange();
    00105     }
    00106 }
    00107
    00117 void QwtScaleIf::setScaleMaxMajor(int ticks)
    00118 {
    00119     if (ticks != d_maxMajor)
    00120     {
    00121         d_maxMajor = ticks;
    00122         d_scaleDraw->setScale(d_scaleDraw->scaleDiv().lBound(),
    00123         d_scaleDraw->scaleDiv().hBound(),
    00124         d_maxMajor, d_maxMinor, 0.0,d_scaleDraw->scaleDiv().logScale());
    00125         scaleChange();
    00126     }
    00127 }
    00128
    00138 void QwtScaleIf::setScaleMaxMinor(int ticks)
    00139 {
    00140     if ( ticks != d_maxMinor)
    00141     {
    00142         d_maxMinor = ticks;
    00143         d_scaleDraw->setScale(d_scaleDraw->scaleDiv().lBound(),
    00144             d_scaleDraw->scaleDiv().hBound(),
    00145             d_maxMajor, d_maxMinor, 0.0, d_scaleDraw->scaleDiv().logScale());
    00146         scaleChange();
    00147     }
    00148 }
    00149
    00155 void QwtScaleIf::setScaleDraw(QwtScaleDraw *sd)
    00156 {
    00157     if ( sd == NULL || sd == d_scaleDraw )
    00158         return;
    00159
    00160     delete d_scaleDraw;
    00161     d_scaleDraw = sd;
    00162 }
    00163
    00168 QwtScaleDraw *QwtScaleIf::scaleDraw()
    00169 {
    00170     return d_scaleDraw;
    00171 }
    00172
    00177 const QwtScaleDraw *QwtScaleIf::scaleDraw() const
    00178 {
    00179     return d_scaleDraw;
    00180 }
    00181