diff --git a/Code/qtiplot/qtiplot/src/Graph.cpp b/Code/qtiplot/qtiplot/src/Graph.cpp index a8e3f8e05416226001b392841d22100b17677c3f..eebde6ebeeeff572597dc8bf885b73abe4831fb1 100644 --- a/Code/qtiplot/qtiplot/src/Graph.cpp +++ b/Code/qtiplot/qtiplot/src/Graph.cpp @@ -1247,6 +1247,60 @@ void Graph::setScale(int axis, double start, double end, double step, // d_plot->replot(); // d_plot->axisWidget(axis)->repaint(); } +/** Overloads function setScale() with one with a much easier +* argument list +* @param axis the scale to change either QwtPlot::xBottom or QwtPlot::yLeft +* @param scaleType either QwtScaleTransformation::Log10 or ::Linear +*/ +void Graph::setScale(QwtPlot::Axis axis, QwtScaleTransformation::Type scaleType) +{ + const QwtScaleDiv *scDiv = d_plot->axisScaleDiv(axis); + double start = QMIN(scDiv->lBound(), scDiv->hBound()); + double end = QMAX(scDiv->lBound(), scDiv->hBound()); + + ScaleEngine *scaleEng = (ScaleEngine *)d_plot->axisScaleEngine(axis); + + // call the QTiPlot function set scale which takes many arguments, fill the arguments with the same settings the plot already has + setScale(axis, start, end, axisStep(axis), + scDiv->ticks(QwtScaleDiv::MajorTick).count(), + d_plot->axisMaxMinor(axis), scaleType, + scaleEng->testAttribute(QwtScaleEngine::Inverted), + scaleEng->axisBreakLeft(), + scaleEng->axisBreakRight(), + scaleEng->minTicksBeforeBreak(), + scaleEng->minTicksAfterBreak(), + scaleEng->log10ScaleAfterBreak(), + scaleEng->breakWidth(), + scaleEng->hasBreakDecoration()); +} + +void Graph::logLogAxes() +{ + setScale(QwtPlot::xBottom, QwtScaleTransformation::Log10); + setScale(QwtPlot::yLeft, QwtScaleTransformation::Log10); + notifyChanges(); +} + +void Graph::logXLinY() +{ + setScale(QwtPlot::xBottom, QwtScaleTransformation::Log10); + setScale(QwtPlot::yLeft, QwtScaleTransformation::Linear); + notifyChanges(); +} + +void Graph::logYlinX() +{ + setScale(QwtPlot::xBottom, QwtScaleTransformation::Linear); + setScale(QwtPlot::yLeft, QwtScaleTransformation::Log10); + notifyChanges(); +} + +void Graph::linearAxes() +{ + setScale(QwtPlot::xBottom, QwtScaleTransformation::Linear); + setScale(QwtPlot::yLeft, QwtScaleTransformation::Linear); + notifyChanges(); +} void Graph::setAxisScale(int axis, double start, double end, int type, double step, int majorTicks, int minorTicks) diff --git a/Code/qtiplot/qtiplot/src/Graph.h b/Code/qtiplot/qtiplot/src/Graph.h index 64e768c0ba17b5e3f7703feb80e89c676ad10612..6e29d57715c5c5e06ed89a7da6c8eb74a8a20e53 100644 --- a/Code/qtiplot/qtiplot/src/Graph.h +++ b/Code/qtiplot/qtiplot/src/Graph.h @@ -321,11 +321,20 @@ public slots: double left_break = -DBL_MAX, double right_break = DBL_MAX, int pos = 50, double stepBeforeBreak = 0.0, double stepAfterBreak = 0.0, int minTicksBeforeBreak = 4, int minTicksAfterBreak = 4, bool log10AfterBreak = false, int breakWidth = 4, bool breakDecoration = true); + void setScale(QwtPlot::Axis axis, QwtScaleTransformation::Type scaleType); double axisStep(int axis){return d_user_step[axis];}; //! Set the axis scale void setAxisScale(int axis, double start, double end, int type = -1, double step = 0.0, int majorTicks = 5, int minorTicks = 5); - + + /// in plot windows change both axis to log-log + void logLogAxes(); + /// the plot's x-axis will be log and y-axis linear + void logXLinY(); + /// the plot's y-axis will be log and x-axis linear + void logYlinX(); + /// set both the x and y axes to linear + void linearAxes(); //! \name Curves Layout //@{