diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp index 34b454283632d49edce5c2f168da79d769c84dc2..c4fbcea30e6e11d79125256b31e21ceb063ef4fe 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.cpp @@ -69,7 +69,8 @@ void ColorMapWidget::scaleOptionsChanged(int i) } /** - * + * Set up a new colour map. + * @param colorMap :: Reference to the new colour map. */ void ColorMapWidget::setupColorBarScaling(const MantidColorMap& colorMap) { @@ -102,22 +103,54 @@ void ColorMapWidget::setupColorBarScaling(const MantidColorMap& colorMap) m_scaleOptions->blockSignals(false); } +/// Send the minValueChanged signal void ColorMapWidget::minValueChanged() { emit minValueChanged(m_minValueBox->text().toDouble()); } +/// Send the maxValueChanged signal void ColorMapWidget::maxValueChanged() { emit maxValueChanged(m_maxValueBox->text().toDouble()); } +/** + * Set a new min value and update the widget. + * @param value :: The new value + */ void ColorMapWidget::setMinValue(double value) { - m_minValueBox->setText(QString::number(value)); + setMinValueText(value); + updateScale(); + minValueChanged(); } +/** + * Set a new max value and update the widget. + * @param value :: The new value + */ void ColorMapWidget::setMaxValue(double value) +{ + setMaxValueText(value); + updateScale(); + maxValueChanged(); +} + +/** + * Update the min value text box. + * @param value :: Value to be displayed in the text box. + */ +void ColorMapWidget::setMinValueText(double value) +{ + m_minValueBox->setText(QString::number(value)); +} + +/** + * Update the max value text box. + * @param value :: Value to be displayed in the text box. + */ +void ColorMapWidget::setMaxValueText(double value) { m_maxValueBox->setText(QString::number(value)); } @@ -131,16 +164,50 @@ void ColorMapWidget::setMinPositiveValue(double value) m_minPositiveValue = value; } +/** + * Return the scale type: Log10 or Linear. + */ int ColorMapWidget::getScaleType()const { return m_scaleOptions->itemData(m_scaleOptions->currentIndex()).toUInt(); } +/** + * Set the scale type: Log10 or Linear. + */ void ColorMapWidget::setScaleType(int type) { m_scaleOptions->setCurrentIndex(m_scaleOptions->findData(type)); } +/** + * Update the colour scale after the range changes. + */ +void ColorMapWidget::updateScale() +{ + double minValue = m_minValueBox->displayText().toDouble(); + double maxValue = m_maxValueBox->displayText().toDouble(); + GraphOptions::ScaleType type = (GraphOptions::ScaleType)m_scaleOptions->itemData(m_scaleOptions->currentIndex()).toUInt(); + if( type == GraphOptions::Linear ) + { + QwtLinearScaleEngine linScaler; + m_scaleWidget->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, 20, 5)); + } + else + { + QwtLog10ScaleEngine logScaler; + double logmin(minValue); + if( logmin <= 0.0 ) + { + logmin = m_minPositiveValue; + } + m_scaleWidget->setScaleDiv(logScaler.transformation(), logScaler.divideScale(logmin, maxValue, 20, 5)); + } +} + +/** + * Respond to a mouse press event. Start dragging to modify the range (min or max value). + */ void ColorMapWidget::mousePressEvent(QMouseEvent* e) { QRect rect = m_scaleWidget->rect(); @@ -153,6 +220,9 @@ void ColorMapWidget::mousePressEvent(QMouseEvent* e) } } +/** + * Respond to mouse move event. If the left button is down change the min or max. + */ void ColorMapWidget::mouseMoveEvent(QMouseEvent* e) { if (!m_dragging) return; @@ -163,33 +233,20 @@ void ColorMapWidget::mouseMoveEvent(QMouseEvent* e) if (m_dtype == Bottom) { minValue += double(e->y() - m_y)/height()*(maxValue - minValue); - setMinValue(minValue); + setMinValueText(minValue); } else { maxValue += double(e->y() - m_y)/height()*(maxValue - minValue); - setMaxValue(maxValue); + setMaxValueText(maxValue); } m_y = e->y(); - - GraphOptions::ScaleType type = (GraphOptions::ScaleType)m_scaleOptions->itemData(m_scaleOptions->currentIndex()).toUInt(); - if( type == GraphOptions::Linear ) - { - QwtLinearScaleEngine linScaler; - m_scaleWidget->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, 20, 5)); - } - else - { - QwtLog10ScaleEngine logScaler; - double logmin(minValue); - if( logmin <= 0.0 ) - { - logmin = m_minPositiveValue; - } - m_scaleWidget->setScaleDiv(logScaler.transformation(), logScaler.divideScale(logmin, maxValue, 20, 5)); - } + updateScale(); } +/** + * Respond to a mouse release event. Finish all dragging. + */ void ColorMapWidget::mouseReleaseEvent(QMouseEvent* /*e*/) { if (!m_dragging) return; diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.h index 81aa4a641d3c0fdd1695f4014de3f846e77b8893..e3506d5c1dd63f33b25270e6fcdaca1b1d5ff92b 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/ColorMapWidget.h @@ -33,6 +33,9 @@ protected: void mousePressEvent(QMouseEvent*); void mouseMoveEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); + void updateScale(); + void setMinValueText(double); + void setMaxValueText(double); private slots: void scaleOptionsChanged(int); void minValueChanged(); diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp index ba161a3a3b8de267b0b2194cbc79660509c6c447..40ac86d2356f6229eb0a5cdab934aa2a3547bbe9 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp @@ -481,20 +481,23 @@ QString InstrumentWindow::asString(const std::vector<int>& numbers) const /// Set a maximum and minimum for the colour map range void InstrumentWindow::setColorMapRange(double minValue, double maxValue) { - setColorMapMinValue(minValue); - setColorMapMaxValue(maxValue); + m_renderTab->setMinValue(minValue); + m_renderTab->setMaxValue(maxValue); + update(); } /// Set the minimum value of the colour map void InstrumentWindow::setColorMapMinValue(double minValue) { m_renderTab->setMinValue(minValue); + update(); } /// Set the maximumu value of the colour map void InstrumentWindow::setColorMapMaxValue(double maxValue) { m_renderTab->setMaxValue(maxValue); + update(); } /** @@ -945,3 +948,44 @@ void InstrumentWindow::executeAlgorithm(const QString& alg_name, const QString& { emit execMantidAlgorithm(alg_name,param_list,this); } + +/** + * Set the type of the view (SurfaceType). + * @param type :: String code for the type. One of: + * FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y, CYLINDRICAL_Z, SPHERICAL_X, SPHERICAL_Y, SPHERICAL_Z + */ +void InstrumentWindow::setViewType(const QString& type) +{ + QString type_upper = type.toUpper(); + SurfaceType itype = FULL3D; + if (type_upper == "FULL3D") + { + itype = FULL3D; + } + else if (type_upper == "CYLINDRICAL_X") + { + itype = CYLINDRICAL_X; + } + else if (type_upper == "CYLINDRICAL_Y") + { + itype = CYLINDRICAL_Y; + } + else if (type_upper == "CYLINDRICAL_Z") + { + itype = CYLINDRICAL_Z; + } + else if (type_upper == "SPHERICAL_X") + { + itype = SPHERICAL_X; + } + else if (type_upper == "SPHERICAL_Y") + { + itype = SPHERICAL_Y; + } + else if (type_upper == "SPHERICAL_Z") + { + itype = SPHERICAL_Z; + } + setSurfaceType(itype); + m_renderTab->updateSurfaceTypeControl(itype); +} diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h index 6b352b3b03419662f33414407f2e2ca0e16a7fd5..01c63c88d2739123bebf76afb6eaf1ab35496cf0 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.h @@ -98,6 +98,7 @@ public: void setColorMapRange(double minValue, double maxValue); void selectComponent(const QString & name); void setScaleType(GraphOptions::ScaleType type); + void setViewType(const QString& type); /// for saving the instrument window to mantid project QString saveToString(const QString& geometry, bool saveAsTemplate= false); MantidGLWidget* getInstrumentDisplay(){return m_InstrumentDisplay;} diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.cpp index 7bdbf202b0f77d4f4d7fc301c2714e8777aea477..d59e2d457eb008a5ee55d908990bcc5c9c7cff09 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.cpp @@ -28,13 +28,13 @@ QFrame(instrWindow),m_instrWindow(instrWindow) QVBoxLayout* renderControlsLayout=new QVBoxLayout(this); // Render Mode control - QComboBox* renderMode = new QComboBox(this); - renderMode->setToolTip("Set render mode"); + m_renderMode = new QComboBox(this); + m_renderMode->setToolTip("Set render mode"); QStringList modeList; modeList << "Full 3D" << "Cylindrical X" << "Cylindrical Y" << "Cylindrical Z" << "Spherical X" << "Spherical Y" << "Spherical Z"; - renderMode->insertItems(0,modeList); - connect(renderMode,SIGNAL(currentIndexChanged(int)),m_instrWindow,SLOT(setSurfaceType(int))); - connect(renderMode, SIGNAL(currentIndexChanged(int)), this, SLOT(showResetView(int))); + m_renderMode->insertItems(0,modeList); + connect(m_renderMode,SIGNAL(currentIndexChanged(int)),m_instrWindow,SLOT(setSurfaceType(int))); + connect(m_renderMode, SIGNAL(currentIndexChanged(int)), this, SLOT(showResetView(int))); // Save image control mSaveImage = new QPushButton(tr("Save image")); @@ -76,7 +76,7 @@ QFrame(instrWindow),m_instrWindow(instrWindow) connect(m_colorMapWidget,SIGNAL(maxValueChanged(double)),m_instrWindow, SLOT(changeColorMapMaxValue(double))); // layout - renderControlsLayout->addWidget(renderMode); + renderControlsLayout->addWidget(m_renderMode); renderControlsLayout->addWidget(axisViewFrame); renderControlsLayout->addWidget(displaySettings); renderControlsLayout->addWidget(mSaveImage); @@ -221,3 +221,14 @@ void InstrumentWindowRenderTab::showEvent (QShowEvent *) surface->setInteractionModeMove(); } } + +/** + * Update the surface type control to show type without emiting the signal. + * @param type :: InstrumentWindow::SurfaceType. + */ +void InstrumentWindowRenderTab::updateSurfaceTypeControl(int type) +{ + m_renderMode->blockSignals(true); + m_renderMode->setCurrentIndex(type); + m_renderMode->blockSignals(false); +} diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h index 03aac5d224e78e268e87bcae57d8dea18a51d9d4..c8f069437e053815ed6d9f2d211a71e6494ca176 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h @@ -36,6 +36,7 @@ public: void setAxis(const QString& axisName); bool areAxesOn()const; void init(); + void updateSurfaceTypeControl(int); public slots: void showAxes(bool on); private slots: @@ -48,6 +49,7 @@ private: InstrumentWindow* m_instrWindow; MantidGLWidget *m_InstrumentDisplay; + QComboBox* m_renderMode; QPushButton *mSaveImage; ColorMapWidget* m_colorMapWidget; QFrame* m_resetViewFrame; diff --git a/Code/Mantid/MantidPlot/src/qti.sip b/Code/Mantid/MantidPlot/src/qti.sip index 93893e39f2ca82544499922f393e8d35e4a03949..35979b3bcd9fa6f8ac33eef46f6bc8d387f1e5c2 100644 --- a/Code/Mantid/MantidPlot/src/qti.sip +++ b/Code/Mantid/MantidPlot/src/qti.sip @@ -1712,6 +1712,7 @@ public: void setIntegrationRange(double, double) /PyName = setBinRange/; void selectComponent(const QString &); void setScaleType(GraphOptions::ScaleType); + void setViewType(const QString &); private: InstrumentWindow(const InstrumentWindow &); };