diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt index 4ca51ad232ad0108e651731970093707faf345b5..2d5cff3b6609f8add295dcd60b00f041fd06cef9 100644 --- a/Code/Mantid/MantidPlot/CMakeLists.txt +++ b/Code/Mantid/MantidPlot/CMakeLists.txt @@ -134,8 +134,6 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/VectorCurve.cpp src/origin/OPJFile.cpp src/plot2D/ImageSymbol.cpp - src/plot2D/ScaleEngine.cpp - src/plot2D/PowerScaleEngine.cpp src/analysis/fft2D.cpp src/lib/src/CollapsiveGroupBox.cpp src/lib/src/ColorBox.cpp @@ -333,7 +331,6 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/PythonScript.h src/PythonScripting.h src/QwtBarCurve.h - src/qwt_compat.h src/QwtErrorPlotCurve.h src/QwtHistogram.h src/QwtPieCurve.h @@ -377,8 +374,6 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/analysis/fft2D.h src/origin/OPJFile.h src/plot2D/ImageSymbol.h - src/plot2D/ScaleEngine.h - src/plot2D/PowerScaleEngine.h src/lib/include/CollapsiveGroupBox.h src/lib/include/ColorBox.h src/lib/include/ColorButton.h diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp index ea3dde957a9768d309ec79f04d8291c639a8b854..2c7c66d743194a903e3a9354bc33325f719f46db 100644 --- a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp +++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp @@ -80,7 +80,7 @@ #include "Folder.h" #include "FindDialog.h" #include "ScaleDraw.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "ScriptingLangDialog.h" #include "ScriptingWindow.h" #include "ScriptFileInterpreter.h" diff --git a/Code/Mantid/MantidPlot/src/AxesDialog.cpp b/Code/Mantid/MantidPlot/src/AxesDialog.cpp index 861a010e16a3d79023cbe3bfecafde66992d8355..15a9218da3e34e1798e42c1e9a20296d21a001fc 100644 --- a/Code/Mantid/MantidPlot/src/AxesDialog.cpp +++ b/Code/Mantid/MantidPlot/src/AxesDialog.cpp @@ -26,7 +26,7 @@ Description : General plot options dialog * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "AxesDialog.h" #include "ApplicationWindow.h" #include "TextDialog.h" @@ -66,7 +66,7 @@ Description : General plot options dialog #include <qwt_plot.h> #include <qwt_scale_widget.h> -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" /* XPM */ static const char* bottom_scl_xpm[] = { "36 38 75 1", " c None", ". c #FFFFFF", diff --git a/Code/Mantid/MantidPlot/src/AxisDetails.cpp b/Code/Mantid/MantidPlot/src/AxisDetails.cpp index badf90ceef098fc9dfedab09401074077cbcfd6a..eeec867d4b3ad6ae074dd082c234c13fe4aa4e8b 100644 --- a/Code/Mantid/MantidPlot/src/AxisDetails.cpp +++ b/Code/Mantid/MantidPlot/src/AxisDetails.cpp @@ -7,10 +7,10 @@ #include "DoubleSpinBox.h" #include <qwt_scale_widget.h> //#include <qwt_plot.h> -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "MyParser.h" #include "Plot.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include <QWidget> #include <QSpinBox> diff --git a/Code/Mantid/MantidPlot/src/Graph.cpp b/Code/Mantid/MantidPlot/src/Graph.cpp index c6fe0465feb4979e2d24006ffffcd0ab2de702cc..4896dda0ac8f5465a4115391ded20133c46cac61 100644 --- a/Code/Mantid/MantidPlot/src/Graph.cpp +++ b/Code/Mantid/MantidPlot/src/Graph.cpp @@ -27,7 +27,7 @@ * * ***************************************************************************/ -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include <QVarLengthArray> #include "pixmaps.h" @@ -56,7 +56,7 @@ #include "RangeSelectorTool.h" #include "PlotCurve.h" #include "ApplicationWindow.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "MantidAPI/AnalysisDataService.h" #include "Mantid/MantidMatrixCurve.h" diff --git a/Code/Mantid/MantidPlot/src/Graph.h b/Code/Mantid/MantidPlot/src/Graph.h index 7f41d4c91326616128de85c2a73522ab19edadb4..9512139404943318a36ffc5dc9fa343d9fc82d7d 100644 --- a/Code/Mantid/MantidPlot/src/Graph.h +++ b/Code/Mantid/MantidPlot/src/Graph.h @@ -53,7 +53,7 @@ #include "MultiLayer.h" #include "ScaleDraw.h" #include "MantidQtAPI/GraphOptions.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include <boost/shared_ptr.hpp> #include <set> diff --git a/Code/Mantid/MantidPlot/src/GridDetails.cpp b/Code/Mantid/MantidPlot/src/GridDetails.cpp index 3bf7273153d9b9c7809e9a8bdd61103562060bf8..c12e316bfc5e042e7f1a6527c7c1b9ac3ca1fc59 100644 --- a/Code/Mantid/MantidPlot/src/GridDetails.cpp +++ b/Code/Mantid/MantidPlot/src/GridDetails.cpp @@ -6,9 +6,9 @@ #include "ApplicationWindow.h" #include <qwt_scale_widget.h> //#include <qwt_plot.h> -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "Plot.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "DoubleSpinBox.h" #include <QWidget> diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp index 3185bc6929f66c64e876e8e77f11360edd1e9d1f..8fff7d099c6d6c20722b66d488dc265bfebe91e3 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp @@ -1,7 +1,7 @@ #include "ColorMapWidget.h" #include "MantidQtAPI/MantidColorMap.h" #include "MantidQtAPI/GraphOptions.h" -#include "plot2D/PowerScaleEngine.h" +#include "MantidQtAPI/PowerScaleEngine.h" #include <QVBoxLayout> #include <QGridLayout> diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/OneCurvePlot.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/OneCurvePlot.cpp index a91d3c8cb4c08e57d1dd2201dfba25028e810563..ea8e944da9099156c470d2fd8454272e96f7891b 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/OneCurvePlot.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/OneCurvePlot.cpp @@ -6,7 +6,7 @@ #include <qwt_scale_engine.h> #include <qwt_scale_draw.h> #include <qwt_plot_canvas.h> -#include <qwt_compat.h> +#include <MantidQtAPI/qwt_compat.h> #include <qwt_plot_zoomer.h> #include <qwt_scale_widget.h> diff --git a/Code/Mantid/MantidPlot/src/Plot.cpp b/Code/Mantid/MantidPlot/src/Plot.cpp index e44b275dd3b8b95d2ff58230fb4b53936aea3d36..1d88cdb895fe5370c7f4c7d435d0f801ea7899b3 100644 --- a/Code/Mantid/MantidPlot/src/Plot.cpp +++ b/Code/Mantid/MantidPlot/src/Plot.cpp @@ -26,7 +26,7 @@ * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "Plot.h" #include "Graph.h" #include "Grid.h" @@ -34,7 +34,7 @@ #include "Spectrogram.h" #include "PlotCurve.h" #include "LegendWidget.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include <qwt_plot.h> #include <qwt_painter.h> diff --git a/Code/Mantid/MantidPlot/src/PlotCurve.cpp b/Code/Mantid/MantidPlot/src/PlotCurve.cpp index 84b4ef9f7335e845b312923fdd94f1a6d0307503..c58c8618fa47c5219a358fce8042418a67a6d48a 100644 --- a/Code/Mantid/MantidPlot/src/PlotCurve.cpp +++ b/Code/Mantid/MantidPlot/src/PlotCurve.cpp @@ -32,7 +32,7 @@ #include "SymbolBox.h" #include "Graph.h" #include "PatternBox.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "Mantid/ErrorBarSettings.h" #include <QDateTime> #include <QMessageBox> diff --git a/Code/Mantid/MantidPlot/src/ScaleDetails.cpp b/Code/Mantid/MantidPlot/src/ScaleDetails.cpp index c31fc4179e748d79c12ae6a6d0c497fd9ffa40df..71190376094ff0093f8972b303d2eba67214edcd 100644 --- a/Code/Mantid/MantidPlot/src/ScaleDetails.cpp +++ b/Code/Mantid/MantidPlot/src/ScaleDetails.cpp @@ -7,9 +7,9 @@ #include "DoubleSpinBox.h" #include <qwt_scale_widget.h> //#include <qwt_plot.h> -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "Plot.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "MantidKernel/Logger.h" diff --git a/Code/Mantid/MantidPlot/src/ScaleDraw.cpp b/Code/Mantid/MantidPlot/src/ScaleDraw.cpp index 85d2926491c8596a4eb55b6872e9d24f5685a119..a003c6c801fc3177f6fb310a091d22b75b2a37d6 100644 --- a/Code/Mantid/MantidPlot/src/ScaleDraw.cpp +++ b/Code/Mantid/MantidPlot/src/ScaleDraw.cpp @@ -28,7 +28,7 @@ ***************************************************************************/ #include "ScaleDraw.h" #include "MyParser.h" -#include "plot2D/ScaleEngine.h" +#include "MantidQtAPI/ScaleEngine.h" #include "Graph.h" #include <QDateTime> diff --git a/Code/Mantid/MantidPlot/src/Spectrogram.cpp b/Code/Mantid/MantidPlot/src/Spectrogram.cpp index 8df0e9d881cc4aff5edb06416d51edce004e2c7c..ece80d7b100332f706b13ad4a60a7d516e7de05b 100644 --- a/Code/Mantid/MantidPlot/src/Spectrogram.cpp +++ b/Code/Mantid/MantidPlot/src/Spectrogram.cpp @@ -25,7 +25,7 @@ * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "qwt_compat.h" +#include "MantidQtAPI/qwt_compat.h" #include "Spectrogram.h" #include <math.h> #include <QPen> diff --git a/Code/Mantid/MantidQt/API/CMakeLists.txt b/Code/Mantid/MantidQt/API/CMakeLists.txt index ee3218ff5273c9585852f33cbfc7f5f4bec30357..42407ba080937ec21c5b828f2704d9cc7d987800 100644 --- a/Code/Mantid/MantidQt/API/CMakeLists.txt +++ b/Code/Mantid/MantidQt/API/CMakeLists.txt @@ -40,6 +40,8 @@ set ( SRC_FILES src/VatesViewerInterface.cpp src/WorkspaceObserver.cpp src/SelectionNotificationService.cpp + src/ScaleEngine.cpp + src/PowerScaleEngine.cpp ) set ( MOC_FILES @@ -97,6 +99,9 @@ set ( INC_FILES inc/MantidQtAPI/ScriptRepositoryView.h inc/MantidQtAPI/SelectionNotificationService.h inc/MantidQtAPI/SignalRange.h + inc/MantidQtAPI/qwt_compat.h + inc/MantidQtAPI/ScaleEngine.h + inc/MantidQtAPI/PowerScaleEngine.h ) set ( UI_FILES diff --git a/Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PowerScaleEngine.h similarity index 94% rename from Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.h rename to Code/Mantid/MantidQt/API/inc/MantidQtAPI/PowerScaleEngine.h index dee1fa24ec32b9ec94aff67839b1f561a04fb82d..b0002cca4370c47a116df82c736f756d23cd4da3 100644 --- a/Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.h +++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/PowerScaleEngine.h @@ -33,8 +33,9 @@ #include <qwt_scale_engine.h> #include <qwt_scale_map.h> #include "ScaleEngine.h" +#include "MantidQtAPI/DllOption.h" -class PowerScaleTransformation: public ScaleTransformation +class EXPORT_OPT_MANTIDQT_API PowerScaleTransformation: public ScaleTransformation { public: PowerScaleTransformation(const ScaleEngine *engine):ScaleTransformation(engine), nth_power(engine->nthPower()){}; @@ -50,7 +51,7 @@ private: \brief A scale engine for power (X^n) scales */ -class PowerScaleEngine: public QwtScaleEngine +class EXPORT_OPT_MANTIDQT_API PowerScaleEngine: public QwtScaleEngine { public: virtual void autoScale(int maxSteps, diff --git a/Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/ScaleEngine.h similarity index 96% rename from Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.h rename to Code/Mantid/MantidQt/API/inc/MantidQtAPI/ScaleEngine.h index 39bd94983a70b330ec8788c5396a64b22380fd18..4f541e0952906ad30972e3b7fc52098699c782ed 100644 --- a/Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.h +++ b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/ScaleEngine.h @@ -29,13 +29,14 @@ #ifndef SCALE_ENGINE_H #define SCALE_ENGINE_H +#include "MantidQtAPI/DllOption.h" #include <qwt_scale_engine.h> #include <qwt_scale_map.h> #include <float.h> class ScaleEngine; -class ScaleTransformation: public QwtScaleTransformation +class EXPORT_OPT_MANTIDQT_API ScaleTransformation: public QwtScaleTransformation { public: enum Type{Linear, Log10, Power}; @@ -52,7 +53,7 @@ protected: const ScaleEngine* d_engine; }; -class ScaleEngine: public QwtScaleEngine +class EXPORT_OPT_MANTIDQT_API ScaleEngine: public QwtScaleEngine { public: ScaleEngine(ScaleTransformation::Type type = ScaleTransformation::Linear, diff --git a/Code/Mantid/MantidPlot/src/qwt_compat.h b/Code/Mantid/MantidQt/API/inc/MantidQtAPI/qwt_compat.h similarity index 100% rename from Code/Mantid/MantidPlot/src/qwt_compat.h rename to Code/Mantid/MantidQt/API/inc/MantidQtAPI/qwt_compat.h diff --git a/Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.cpp b/Code/Mantid/MantidQt/API/src/PowerScaleEngine.cpp similarity index 99% rename from Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.cpp rename to Code/Mantid/MantidQt/API/src/PowerScaleEngine.cpp index 4fdae03130efca60095e7f65a973b0ed53e399f3..bc1c985c4b088e364d562d24d17392d5f848d1f4 100644 --- a/Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.cpp +++ b/Code/Mantid/MantidQt/API/src/PowerScaleEngine.cpp @@ -27,8 +27,8 @@ * * ***************************************************************************/ -#include "PowerScaleEngine.h" -#include "qwt_compat.h" +#include "MantidQtAPI/PowerScaleEngine.h" +#include "MantidQtAPI/qwt_compat.h" /*! Return a dummy transformation diff --git a/Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.cpp b/Code/Mantid/MantidQt/API/src/ScaleEngine.cpp similarity index 99% rename from Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.cpp rename to Code/Mantid/MantidQt/API/src/ScaleEngine.cpp index 75e2e3d9d3b9e0afaacb404c7c685f82372cf4c3..62defc1d9fd830eb0de3a06a26d9ed5709e78e38 100644 --- a/Code/Mantid/MantidPlot/src/plot2D/ScaleEngine.cpp +++ b/Code/Mantid/MantidQt/API/src/ScaleEngine.cpp @@ -26,9 +26,9 @@ * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "ScaleEngine.h" -#include "PowerScaleEngine.h" -#include "qwt_compat.h" +#include "MantidQtAPI/ScaleEngine.h" +#include "MantidQtAPI/PowerScaleEngine.h" +#include "MantidQtAPI/qwt_compat.h" #include <limits.h> QwtScaleTransformation* ScaleEngine::transformation() const diff --git a/Code/Mantid/MantidQt/Python/mantidqt.sip b/Code/Mantid/MantidQt/Python/mantidqt.sip index d3b4d115d6ea77d5710e1f6a5a26eb540be05cd7..47824677bf3e1bcd8e3a02a951fbbfa38afd5ad5 100644 --- a/Code/Mantid/MantidQt/Python/mantidqt.sip +++ b/Code/Mantid/MantidQt/Python/mantidqt.sip @@ -966,16 +966,16 @@ void SliceViewer::loadColorMap(QString filename) %End - void setColorScale(double min, double max, bool log) throw (std::invalid_argument); + void setColorScale(double min, double max, int type) throw (std::invalid_argument); %Docstring -void SliceViewer::setColorScale(double min, double max, bool log) +void SliceViewer::setColorScale(double min, double max, int type) ----------------------------------------------------------------- - Set the color scale limits and log mode via a method call. + Set the color scale limits and type via a method call. Args: min :: minimum value corresponding to the lowest color on the map max :: maximum value corresponding to the highest color on the map - log :: true for a log color scale, false for linear + type :: 0 for linear, 1 for log, 2 for power Raises: std::invalid_argument if max < min or if the values are @@ -1026,6 +1026,19 @@ void SliceViewer::setColorScaleLog(bool log) std::invalid_argument if the min/max values are inconsistent with a log color scale +%End + + int getColorScaleType(); +%Docstring +int SliceViewer::getColorScaleType() +-------------------------------------------- + Get scale type as integer value + + Returns: + 0 for linear scale + 1 for log scale + 2 for power scale + %End double getColorScaleMin() const; diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.h b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.h index 0873d805b8647ed78592a1d021b6b92b2c6d3b7c..a6b08722eeee9f4a95503a74710bb2ba8d442f32 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.h +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.h @@ -51,7 +51,6 @@ signals: class EXPORT_OPT_MANTIDQT_SLICEVIEWER ColorBarWidget : public QWidget { Q_OBJECT - Q_PROPERTY(bool log READ getLog WRITE setLog ) Q_PROPERTY(double minimum READ getMinimum WRITE setMinimum) Q_PROPERTY(double maximum READ getMaximum WRITE setMaximum) @@ -65,20 +64,28 @@ public: void setViewRange(QwtDoubleInterval range); void setMinimum(double min); void setMaximum(double max); - void setLog(bool log); void setRenderMode(bool rendering); double getMinimum() const; double getMaximum() const; - bool getLog() const; QwtDoubleInterval getViewRange() const; MantidColorMap & getColorMap(); + bool getLog(); + + int getScale(); + void setScale(int); + + void setExponent(double); + double getExponent(); + + public slots: - void changedLogState(int); void changedMinimum(); void changedMaximum(); void colorBarMouseMoved(QPoint, double); + void changedScaleType(int); + void changedExponent(double); signals: /// Signal sent when the range or log mode of the color scale changes. diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.ui b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.ui index 71a7c1af89410c55b187675e553e309c11435b9e..0f5d1fac56ab381132c00bd748cb3d466e914a01 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.ui +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/ColorBarWidget.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>64</width> + <width>102</width> <height>286</height> </rect> </property> @@ -26,14 +26,24 @@ <number>3</number> </property> <item> - <widget class="QCheckBox" name="checkLog"> - <property name="toolTip"> - <string>Use a logarithmic color scale (when checked)</string> - </property> - <property name="text"> - <string>Log</string> - </property> - </widget> + <widget class="QComboBox" name="cmbScaleType"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="lblN"> + <property name="text"> + <string>n =</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QDoubleSpinBox" name="dspnN"/> + </item> + </layout> </item> <item> <widget class="QScienceSpinBox" name="valMax"> diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h index d7d634fed501d9861d49eef5e063cf72ec354520..629a8979b22e1c4c4747c278f3e84c354a1e6dd5 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h @@ -96,7 +96,9 @@ public: void setColorScaleMin(double min); void setColorScaleMax(double max); void setColorScaleLog(bool log); + int getColorScaleType(); void setColorScale(double min, double max, bool log); + void setColorScale(double min, double max, int type); void setColorMapBackground(int r, int g, int b); double getColorScaleMin() const; double getColorScaleMax() const; diff --git a/Code/Mantid/MantidQt/SliceViewer/src/ColorBarWidget.cpp b/Code/Mantid/MantidQt/SliceViewer/src/ColorBarWidget.cpp index dd5ed77d3fff8fa791a131127fc751ade53262be..0f3c72044c8c09bbe04904e703fb789d0e477169 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/ColorBarWidget.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/ColorBarWidget.cpp @@ -2,6 +2,7 @@ #include "MantidQtSliceViewer/ColorBarWidget.h" #include "MantidQtSliceViewer/QScienceSpinBox.h" #include "qwt_scale_div.h" +#include "MantidQtAPI/PowerScaleEngine.h" #include <iosfwd> #include <iostream> #include <qwt_scale_map.h> @@ -27,7 +28,14 @@ ColorBarWidget::ColorBarWidget(QWidget *parent) m_max = 1000; m_showTooltip = false; m_log = false; + + // Scales + ui.cmbScaleType->addItem(tr("linear")); + ui.cmbScaleType->addItem(tr("logarithmic")); + ui.cmbScaleType->addItem(tr("power")); m_colorMap.changeScaleType( GraphOptions::Linear ); + ui.dspnN->setMinimum(-100.0); + ui.dspnN->setEnabled(false); // Create and add the color bar m_colorBar = new QwtScaleWidgetExtended(); @@ -40,7 +48,8 @@ ColorBarWidget::ColorBarWidget(QWidget *parent) ui.verticalLayout->insertWidget(2,m_colorBar, 1,0 ); // Hook up signals - QObject::connect(ui.checkLog, SIGNAL(stateChanged(int)), this, SLOT(changedLogState(int))); + QObject::connect(ui.dspnN, SIGNAL(valueChanged(double)), this, SLOT(changedExponent(double))); + QObject::connect(ui.cmbScaleType,SIGNAL(currentIndexChanged(int)), this, SLOT(changedScaleType(int))); QObject::connect(ui.valMin, SIGNAL(editingFinished()), this, SLOT(changedMinimum())); QObject::connect(ui.valMax, SIGNAL(editingFinished()), this, SLOT(changedMaximum())); QObject::connect(ui.valMin, SIGNAL(valueChangedFromArrows()), this, SLOT(changedMinimum())); @@ -61,10 +70,6 @@ double ColorBarWidget::getMinimum() const double ColorBarWidget::getMaximum() const { return m_max; } -/// @return true if the color scale is logarithmic. -bool ColorBarWidget::getLog() const -{ return m_log; } - /// @return then min/max range currently viewed QwtDoubleInterval ColorBarWidget::getViewRange() const { return QwtDoubleInterval(m_min, m_max); } @@ -85,10 +90,60 @@ void ColorBarWidget::setRenderMode(bool rendering) bool visible = !rendering; this->ui.valMin->setVisible(visible); this->ui.valMax->setVisible(visible); - this->ui.checkLog->setVisible(visible); + this->ui.cmbScaleType->setVisible(visible); + this->ui.lblN->setVisible(visible); + this->ui.dspnN->setVisible(visible); +} + +// Get the current colorbar scaling type +int ColorBarWidget::getScale() +{ + // Get value from GUI + return ui.cmbScaleType->currentIndex(); +} + +// Set the current colorbar scaling type +void ColorBarWidget::setScale(int type) +{ + // Set scale in GUI + ui.cmbScaleType->setCurrentIndex(type); + // Update plot + changedScaleType(type); +} +bool ColorBarWidget::getLog() +{ + if (getScale() == 1) + { + return true; + } + else return false; } +// Set exponent value for power scale +void ColorBarWidget::setExponent(double nth_power) +{ + // Set value in GUI + ui.dspnN->setValue(nth_power); + // Update plot + changedExponent(nth_power); +} + +// Get exponent value for power scale +double ColorBarWidget::getExponent() +{ + // Get value from GUI + return ui.dspnN->value(); +} + +// Change the colormap to match new exponent value +void ColorBarWidget::changedExponent(double nth_power) +{ + m_colorMap.setNthPower(nth_power); + updateColorMap(); + + emit changedColorRange(m_min,m_max,m_log); +} //------------------------------------------------------------------------------------------------- /** Send a double-clicked event but only when clicking the color bar */ @@ -200,27 +255,24 @@ void ColorBarWidget::setViewRange(QwtDoubleInterval range) { this->setViewRange(range.minValue(), range.maxValue()); } //------------------------------------------------------------------------------------------------- -/** SLOT called when clicking the log button */ -void ColorBarWidget::changedLogState(int log) -{ - this->setLog(log); - emit changedColorRange(m_min,m_max,m_log); -} - -//------------------------------------------------------------------------------------------------- -/** Set the color bar to use log scale - * - * @param log :: true to use log scale +/* + * Update display if different scale type is selected */ -void ColorBarWidget::setLog(bool log) +void ColorBarWidget::changedScaleType(int type) { - m_log = log; - m_colorMap.changeScaleType( m_log ? GraphOptions::Log10 : GraphOptions::Linear ); - ui.checkLog->setChecked( m_log ); + // If power scale option is selected, enable "n =" widget + ui.dspnN->setEnabled(type == 2); + + // Record if log scale option is selected + m_log = (type == 1); + + m_colorMap.changeScaleType( GraphOptions::ScaleType(type) ); ui.valMin->setLogSteps( m_log ); ui.valMax->setLogSteps( m_log ); setSpinBoxesSteps(); updateColorMap(); + + emit changedColorRange(m_min,m_max,m_log); } //------------------------------------------------------------------------------------------------- @@ -272,7 +324,7 @@ void ColorBarWidget::colorBarMouseMoved(QPoint globalPos, double fraction) /** Update the widget when the color map is changed */ void ColorBarWidget::updateColorMap() { - // The color bar alway shows the same range. Doesn't matter since the ticks don't show up + // The color bar always shows the same range. Doesn't matter since the ticks don't show up QwtDoubleInterval range(1.0, 100.0); m_colorBar->setColorBarEnabled(true); m_colorBar->setColorMap( range, m_colorMap); @@ -294,6 +346,11 @@ void ColorBarWidget::updateColorMap() m_colorBar->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, maxMajorSteps, 5)); m_colorBar->setColorMap(QwtDoubleInterval(minValue, maxValue),m_colorMap); } + else if ( type == GraphOptions::Power ) { + PowerScaleEngine powScaler; + m_colorBar->setScaleDiv(powScaler.transformation(), powScaler.divideScale(minValue, maxValue, maxMajorSteps, 5)); + m_colorBar->setColorMap(QwtDoubleInterval(minValue, maxValue), m_colorMap); + } else { QwtLog10ScaleEngine logScaler; diff --git a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp index c09476644bb058a90d232f1e1daf29007b779db8..e0d61b28c2775a62359978976c7b0404e896646b 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp @@ -96,7 +96,6 @@ SliceViewer::SliceViewer(QWidget *parent) // Set up the ColorBarWidget m_colorBar = ui.colorBarWidget; m_colorBar->setViewRange(0, 10); - m_colorBar->setLog(true); QObject::connect(m_colorBar, SIGNAL(changedColorRange(double, double, bool)), this, SLOT(colorRangeChanged())); @@ -185,7 +184,14 @@ SliceViewer::~SliceViewer() { void SliceViewer::loadSettings() { QSettings settings; settings.beginGroup("Mantid/SliceViewer"); - bool scaleType = (bool)settings.value("LogColorScale", 0).toInt(); + + // Maintain backwards compatibility with use of LogColorScale + int scaleType = settings.value("ColorScale", -1).toInt(); + if (scaleType == -1) { + scaleType = settings.value("LogColorScale", 0).toInt(); + } + + double nth_power = settings.value("PowerScaleExponent", 2.0).toDouble(); // Load Colormap. If the file is invalid the default stored colour map is // used. @@ -200,7 +206,8 @@ void SliceViewer::loadSettings() { // Set values from settings if (!m_currentColorMapFile.isEmpty()) loadColorMap(m_currentColorMapFile); - m_colorBar->setLog(scaleType); + m_colorBar->setScale(scaleType); + m_colorBar->setExponent(nth_power); // Last saved image file m_lastSavedFile = settings.value("LastSavedImagePath", "").toString(); @@ -221,7 +228,8 @@ void SliceViewer::saveSettings() { QSettings settings; settings.beginGroup("Mantid/SliceViewer"); settings.setValue("ColormapFile", m_currentColorMapFile); - settings.setValue("LogColorScale", (int)m_colorBar->getLog()); + settings.setValue("ColorScale", m_colorBar->getScale()); + settings.setValue("PowerScaleExponent", m_colorBar->getExponent()); settings.setValue("LastSavedImagePath", m_lastSavedFile); settings.setValue("TransparentZeros", (m_actionTransparentZeros->isChecked() ? 1 : 0)); @@ -1641,6 +1649,8 @@ double SliceViewer::getSlicePoint(const QString &dim) const { //------------------------------------------------------------------------------ /** Set the color scale limits and log mode via a method call. + * Here for backwards compatibility, setColorScale(double min, double max, int type) + * should be used instead. * * @param min :: minimum value corresponding to the lowest color on the map * @param max :: maximum value corresponding to the highest color on the map @@ -1655,7 +1665,27 @@ void SliceViewer::setColorScale(double min, double max, bool log) { throw std::invalid_argument( "For logarithmic color scales, both minimum and maximum must be > 0."); m_colorBar->setViewRange(min, max); - m_colorBar->setLog(log); + m_colorBar->setScale(log ? 1 : 0); + this->colorRangeChanged(); +} + +//------------------------------------------------------------------------------ +/** Set the color scale limits and type via a method call. + * + * @param min :: minimum value corresponding to the lowest color on the map + * @param max :: maximum value corresponding to the highest color on the map + * @param type :: 0 for linear, 1 for log, 2 for power + * @throw std::invalid_argument if max < min or if the values are + * inconsistent with a log color scale + */ +void SliceViewer::setColorScale(double min, double max, int type) { + if (max <= min) + throw std::invalid_argument("Color scale maximum must be > minimum."); + if (type == 1 && ((min <= 0) || (max <= 0))) + throw std::invalid_argument( + "For logarithmic color scales, both minimum and maximum must be > 0."); + m_colorBar->setViewRange(min, max); + m_colorBar->setScale(type); this->colorRangeChanged(); } @@ -1686,7 +1716,17 @@ void SliceViewer::setColorMapBackground(int r, int g, int b) { * inconsistent with a log color scale */ void SliceViewer::setColorScaleMin(double min) { - this->setColorScale(min, this->getColorScaleMax(), this->getColorScaleLog()); + this->setColorScale(min, this->getColorScaleMax(), this->getColorScaleType()); +} + +//------------------------------------------------------------------------------ +/** Get the colormap scale type + * + * @return int corresponding to the selected scale type + */ +int SliceViewer::getColorScaleType() +{ + return m_colorBar->getScale(); } //------------------------------------------------------------------------------ @@ -1697,7 +1737,7 @@ void SliceViewer::setColorScaleMin(double min) { * inconsistent with a log color scale */ void SliceViewer::setColorScaleMax(double max) { - this->setColorScale(this->getColorScaleMin(), max, this->getColorScaleLog()); + this->setColorScale(this->getColorScaleMin(), max, this->getColorScaleType()); } //------------------------------------------------------------------------------ @@ -1708,7 +1748,7 @@ void SliceViewer::setColorScaleMax(double max) { * with a log color scale */ void SliceViewer::setColorScaleLog(bool log) { - this->setColorScale(this->getColorScaleMin(), this->getColorScaleMax(), log); + this->setColorScale(this->getColorScaleMin(), this->getColorScaleMax(), (int)log); } //------------------------------------------------------------------------------ diff --git a/Code/Mantid/MantidQt/SliceViewer/test/SliceViewerPythonInterfaceTest.py b/Code/Mantid/MantidQt/SliceViewer/test/SliceViewerPythonInterfaceTest.py index 15a86c7f46f0d826638ecd818b797336d4b3123b..f7ac61b15e55516acb33bf420257de185ef081dc 100644 --- a/Code/Mantid/MantidQt/SliceViewer/test/SliceViewerPythonInterfaceTest.py +++ b/Code/Mantid/MantidQt/SliceViewer/test/SliceViewerPythonInterfaceTest.py @@ -279,10 +279,17 @@ class SliceViewerPythonInterfaceTest(unittest.TestCase): self.assertEqual(sv.getColorScaleMin(), 10) self.assertEqual(sv.getColorScaleMax(), 30) self.assertEqual(sv.getColorScaleLog(), False) + self.assertEqual(sv.getColorScaleType(), 0) sv.setColorScale(20, 1000, True) self.assertEqual(sv.getColorScaleMin(), 20) self.assertEqual(sv.getColorScaleMax(), 1000) self.assertEqual(sv.getColorScaleLog(), True) + self.assertEqual(sv.getColorScaleType(), 1) + sv.setColorScale(30, 75, 2) + self.assertEqual(sv.getColorScaleMin(), 30) + self.assertEqual(sv.getColorScaleMax(), 75) + self.assertEqual(sv.getColorScaleLog(), False) + self.assertEqual(sv.getColorScaleType(), 2) def test_setColorScale_throwsOnBadInputs(self): sv = self.sv