Skip to content

Commit

Permalink
Trying to find problem with REFM finding runs and still working on 2d…
Browse files Browse the repository at this point in the history
… view for REFL and REFM. This refs #5801
  • Loading branch information
JeanBilheux committed Sep 10, 2012
1 parent 7c8867d commit 6b60191
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 49 deletions.
22 changes: 13 additions & 9 deletions Code/Mantid/MantidQt/ImageViewer/src/ImageDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void ImageDisplay::SetDataSource( ImageDataSource* data_source )
n_rows, n_cols,
false );

image_plot->setAxisScale( QwtPlot::xBottom, data_array->GetXMin(),
image_plot->setAxisScale( QwtPlot::xBottom, data_array->GetXMin(),
data_array->GetXMax() );
image_plot->setAxisScale( QwtPlot::yLeft, data_array->GetYMin(),
data_array->GetYMax() );
Expand Down Expand Up @@ -147,10 +147,6 @@ void ImageDisplay::UpdateRange()
double max = total_x_max;
double step = (total_x_max - total_x_min)/2000;
range_handler->GetRange( min, max, step );

// std::cout << "In ImageDisplay::UpdateRange() ";
// std::cout


int n_bins = IVUtils::NumSteps( min, max, step );
if ( n_bins == 0 )
Expand Down Expand Up @@ -190,12 +186,19 @@ void ImageDisplay::UpdateImage()
double scale_x_min = total_x_min;
double scale_x_max = total_x_max;
double x_step = (total_x_max - total_x_min)/2000;
range_handler->GetRange( scale_x_min, scale_x_max, x_step );

std::cout << "scale_x_min: " << scale_x_min << std::endl; //changes


range_handler->GetRange( scale_x_min, scale_x_max, x_step );

int n_rows = (int)data_source->GetNRows();
int n_cols = IVUtils::NumSteps( scale_x_min, scale_x_max, x_step );
// This works for linear or log scales

std::cout << "scale_x_min: " << scale_x_min << std::endl; //changes


if ( n_rows == 0 || n_cols == 0 )
{
return; // can't draw empty image
Expand Down Expand Up @@ -226,7 +229,8 @@ void ImageDisplay::UpdateImage()
slider_handler->GetHSliderInterval( x_min, x_max );
// NOTE: The interval [xmin,xmax] is always
// found linearly. For log_x, we need to adjust it
double new_x_min = 0;

double new_x_min = 0;
double new_x_max = 0;

if ( x_step > 0 ) // linear scale, so interpolate linearly
Expand Down Expand Up @@ -266,11 +270,11 @@ void ImageDisplay::UpdateImage()
n_rows, n_cols,
is_log_x );

is_log_x = data_array->IsLogX(); // Data source might not be able to
is_log_x = data_array->IsLogX(); // Data source might not be able to
// provide log binned data, so check
// if log binned data was returned.

image_plot->setAxisScale( QwtPlot::xBottom, data_array->GetXMin(),
image_plot->setAxisScale( QwtPlot::xBottom, data_array->GetXMin(),
data_array->GetXMax() );
if ( is_log_x )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ class EXPORT_OPT_MANTIDQT_IMAGEVIEWER ImageDisplay
static int getTOFmax();

static void setPeakLeft(int value);

static void setPeakRight(int value);
static void setBackLeft(int value);
static void setBackRight(int value);
static void setTOFmin(int value);
static void setTOFmax(int value);

private:
/// Check if the DataSource has been changed under us
bool DataSourceRangeChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_peakRight">
<widget class="QRadioButton" name="radioButton_peakLeft">
<property name="maximumSize">
<size>
<width>150</width>
Expand All @@ -240,7 +240,7 @@
</size>
</property>
<property name="text">
<string>Peak Right</string>
<string>Peak Left</string>
</property>
<property name="checked">
<bool>true</bool>
Expand Down Expand Up @@ -344,25 +344,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_peakLeft">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Peak Left</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_peakRight">
<property name="styleSheet">
Expand Down Expand Up @@ -398,6 +379,25 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_peakRight">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Peak Right</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
75 changes: 65 additions & 10 deletions Code/Mantid/MantidQt/RefDetectorViewer/src/IVConnections.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

#include <iostream>
#include <QLineEdit>
#include <qwt_plot_canvas.h>
#include <QString>

#include "MantidQtRefDetectorViewer/IVConnections.h"
#include "MantidQtRefDetectorViewer/ColorMaps.h"
#include "MantidQtRefDetectorViewer/IVUtils.h"
#include "MantidQtRefDetectorViewer/ErrorHandler.h"

namespace MantidQt
{
Expand Down Expand Up @@ -160,11 +162,17 @@ IVConnections::IVConnections( Ui_MainWindow* ui,
*/
QObject::connect(iv_ui->lineEdit_peakLeft, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );
QObject::connect(iv_ui->lineEdit_peakRight, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );
QObject::connect(iv_ui->lineEdit_backLeft, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );
QObject::connect(iv_ui->lineEdit_backRight, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );
QObject::connect(iv_ui->lineEdit_TOFmin, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );
QObject::connect(iv_ui->lineEdit_TOFmax, SIGNAL(returnPressed()),
this, SLOT(edit_manual_input()) );





QObject::connect(iv_ui->imageSplitter, SIGNAL(splitterMoved(int,int)),
this, SLOT(imageSplitter_moved()) );

Expand Down Expand Up @@ -333,14 +341,61 @@ void IVConnections::graph_range_changed()
}

void IVConnections::edit_manual_input()
{

std::cout << "here" << std::endl;

QLineEdit* peak_left_control = iv_ui->lineEdit_peakLeft;
double peak_left = 100;
if (!IVUtils::StringToDouble(peak_left_control->text().toStdString(), peak_left))
{
// std::cout << "inside edit_manual " << std::endl;
// std::cout << "iv_ui->lineEdit_peakLeft->text(): ";
// std::cout << QString::toStdString(iv_ui->lineEdit_peakLeft->displayText());
//// std::cout << "peak left: " << yValue << std::endl;
// image_display->setPeakLeft(10);
ErrorHandler::Error("Peak Left is not a NUMBER! Value reset to 100.");
}
image_display->setPeakLeft(peak_left);

QLineEdit* peak_right_control = iv_ui->lineEdit_peakRight;
double peak_right = 200;
if (!IVUtils::StringToDouble(peak_right_control->text().toStdString(), peak_right))
{
ErrorHandler::Error("Peak Right is not a NUMBER! Value reset to 200.");
}
image_display->setPeakRight(peak_right);

QLineEdit* back_left_control = iv_ui->lineEdit_backLeft;
double back_left = 50;
if (!IVUtils::StringToDouble(back_left_control->text().toStdString(), back_left))
{
ErrorHandler::Error("Back. Left is not a NUMBER! Value reset to 50.");
}
image_display->setBackLeft(back_left);

QLineEdit* back_right_control = iv_ui->lineEdit_backRight;
double back_right = 250;
if (!IVUtils::StringToDouble(back_right_control->text().toStdString(), back_right))
{
ErrorHandler::Error("Back. Right is not a NUMBER! Value reset to 250.");
}
image_display->setBackRight(back_right);

QLineEdit* tof_min_control = iv_ui->lineEdit_TOFmin;
double tof_min = 50;
if (!IVUtils::StringToDouble(tof_min_control->text().toStdString(), tof_min))
{
ErrorHandler::Error("TOF min is not a NUMBER! Value reset to 50.");
}
image_display->setTOFmin(tof_min);

QLineEdit* tof_max_control = iv_ui->lineEdit_TOFmax;
double tof_max = 250;
if (!IVUtils::StringToDouble(tof_max_control->text().toStdString(), tof_max))
{
ErrorHandler::Error("TOF max is not a NUMBER! Value reset to 250.");
}

image_display->UpdateImage();
std::cout << "peak_left: " << peak_left << std::endl;

}


void IVConnections::v_scroll_bar_moved()
Expand Down
54 changes: 47 additions & 7 deletions Code/Mantid/MantidQt/RefDetectorViewer/src/ImageDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,59 @@ void ImageDisplay::ShowPeakBackSelectionValue(double x, double y )
int ImageDisplay::TOFmax = 0;

/**
* return the value of the peak left
**/
int ImageDisplay::getPeakLeft()
* set the peak left
*/
void ImageDisplay::setPeakLeft(int value)
{
return peakLeft;
peakLeft = value;
}

/**
* set the peak right
*/
void ImageDisplay::setPeakRight(int value)
{
peakRight = value;
}

/**
* set the peak left
* set the back left
*/
void ImageDisplay::setPeakLeft(int value)
void ImageDisplay::setBackLeft(int value)
{
peakLeft = value;
backLeft = value;
}

/**
* set the back right
*/
void ImageDisplay::setBackRight(int value)
{
backRight = value;
}

/**
* set the TOF min
*/
void ImageDisplay::setTOFmin(int value)
{
TOFmin = value;
}

/**
* set the TOF max
*/
void ImageDisplay::setTOFmax(int value)
{
TOFmax = value;
}

/**
* return the value of the peak left
**/
int ImageDisplay::getPeakLeft()
{
return peakLeft;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,12 @@ def call_back(xmin, xmax):
# For REFM it's the other way around
if self.short_name == "REFM":
is_pixel_y = not is_pixel_y

tof_min = int(self._summary.data_from_tof.text())
tof_max = int(self._summary.data_to_tof.text())

print 'file requested is: ' , f[0]

min, max = data_manipulation.counts_vs_pixel_distribution(f[0], is_pixel_y=is_pixel_y,
callback=call_back,
range_min=range_min,
Expand Down

0 comments on commit 6b60191

Please sign in to comment.