From 12981a9cb20922e15b1d4adc24967f39bd69bc6c Mon Sep 17 00:00:00 2001 From: Jean Bilheux <bilheuxjm@ornl.gov> Date: Tue, 9 Oct 2012 14:27:43 -0400 Subject: [PATCH] Program does not complain anymore when one of the input field is missing and using ENTER. This refs #5801 --- .../src/RefIVConnections.cpp | 70 ++++++++++++------- .../src/RefMatrixWSImageView.cpp | 11 +-- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Code/Mantid/MantidQt/RefDetectorViewer/src/RefIVConnections.cpp b/Code/Mantid/MantidQt/RefDetectorViewer/src/RefIVConnections.cpp index 752a53111ed..34450234280 100644 --- a/Code/Mantid/MantidQt/RefDetectorViewer/src/RefIVConnections.cpp +++ b/Code/Mantid/MantidQt/RefDetectorViewer/src/RefIVConnections.cpp @@ -343,53 +343,71 @@ void RefIVConnections::graph_range_changed() void RefIVConnections::edit_manual_input() { - QLineEdit* peak_left_control = iv_ui->lineEdit_peakLeft; - double peak_left = 100; - if (!IVUtils::StringToDouble(peak_left_control->text().toStdString(), peak_left)) + QLineEdit* peak_left_control = iv_ui->lineEdit_peakLeft; + if (peak_left_control->text().toStdString() != "") { - ErrorHandler::Error("Peak Left is not a NUMBER! Value reset to 100."); + double peak_left = 100; + if (!IVUtils::StringToDouble(peak_left_control->text().toStdString(), peak_left)) + { + ErrorHandler::Error("Peak Left is not a NUMBER! Value reset to 100."); + } + image_display->setPeakLeft(static_cast<int>(peak_left)); } - image_display->setPeakLeft(static_cast<int>(peak_left)); QLineEdit* peak_right_control = iv_ui->lineEdit_peakRight; - double peak_right = 200; - if (!IVUtils::StringToDouble(peak_right_control->text().toStdString(), peak_right)) + if (peak_right_control->text().toStdString() != "") { - ErrorHandler::Error("Peak Right is not a NUMBER! Value reset to 200."); + 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(static_cast<int>(peak_right)); } - image_display->setPeakRight(static_cast<int>(peak_right)); - + QLineEdit* back_left_control = iv_ui->lineEdit_backLeft; - double back_left = 50; - if (!IVUtils::StringToDouble(back_left_control->text().toStdString(), back_left)) + if (back_left_control->text().toStdString() != "") { - ErrorHandler::Error("Back. Left is not a NUMBER! Value reset to 50."); + 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(static_cast<int>(back_left)); } - image_display->setBackLeft(static_cast<int>(back_left)); QLineEdit* back_right_control = iv_ui->lineEdit_backRight; - double back_right = 250; - if (!IVUtils::StringToDouble(back_right_control->text().toStdString(), back_right)) + if (back_right_control->text().toStdString() != "") { - ErrorHandler::Error("Back. Right is not a NUMBER! Value reset to 250."); + 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(static_cast<int>(back_right)); } - image_display->setBackRight(static_cast<int>(back_right)); QLineEdit* tof_min_control = iv_ui->lineEdit_TOFmin; - double tof_min = 50; - if (!IVUtils::StringToDouble(tof_min_control->text().toStdString(), tof_min)) + if (tof_min_control->text().toStdString() != "") { - ErrorHandler::Error("TOF min is not a NUMBER! Value reset to 50."); + 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(static_cast<int>(tof_min)); } - image_display->setTOFmin(static_cast<int>(tof_min)); QLineEdit* tof_max_control = iv_ui->lineEdit_TOFmax; - double tof_max = 250; - if (!IVUtils::StringToDouble(tof_max_control->text().toStdString(), tof_max)) + if (tof_max_control->text().toStdString() != "") { - ErrorHandler::Error("TOF max is not a NUMBER! Value reset to 250."); + 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->setTOFmax(static_cast<int>(tof_max)); } - image_display->setTOFmax(static_cast<int>(tof_max)); image_display->UpdateImage(); diff --git a/Code/Mantid/MantidQt/RefDetectorViewer/src/RefMatrixWSImageView.cpp b/Code/Mantid/MantidQt/RefDetectorViewer/src/RefMatrixWSImageView.cpp index 0bc8afd9d3e..29820a133e5 100644 --- a/Code/Mantid/MantidQt/RefDetectorViewer/src/RefMatrixWSImageView.cpp +++ b/Code/Mantid/MantidQt/RefDetectorViewer/src/RefMatrixWSImageView.cpp @@ -46,9 +46,9 @@ RefMatrixWSImageView::RefMatrixWSImageView( QString wps_name) float *data = new float[size_t(total_ymax * sz)]; - std::cout << "Starting the for loop " << std::endl; - std::cout << "total_xmax: " << total_xmax << std::endl; - std::cout << "sz is : " << sz << std::endl; +// std::cout << "Starting the for loop " << std::endl; +// std::cout << "total_xmax: " << total_xmax << std::endl; +// std::cout << "sz is : " << sz << std::endl; std::vector<double> yaxis; for (int px=0; px<total_ymax; px++) @@ -61,17 +61,12 @@ RefMatrixWSImageView::RefMatrixWSImageView( QString wps_name) } } - std::cout << "about to create RefArrayDataSource" << std::endl; RefArrayDataSource* source = new RefArrayDataSource(total_xmin, total_xmax, total_ymin, total_ymax, total_rows, total_cols, data); - std::cout << "done with RefArrayDataSource" << std::endl; //std::cout << "ws->readX(0).size(): " << ws->readX(0).size() << std::endl; - - -// RefArrayDataSource* source = new RefArrayDataSource(wps_name); image_view = new RefImageView( source ); } -- GitLab