diff --git a/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp index 8d192d7bc120f0b35370f2a9d19a22e60dd59700..661d8cc5072e3939ce95df51c7eaa08f144432f6 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp +++ b/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp @@ -170,7 +170,7 @@ InstrumentWindow::InstrumentWindow(const QString& label, ApplicationWindow *app mPlotAction = new QAction(tr("&Plot Spectra"), this); connect(mPlotAction,SIGNAL(triggered()),this,SLOT(plotSelectedSpectra())); - mDetTableAction = new QAction(tr("&Detector Table"), this); + mDetTableAction = new QAction(tr("&Extract Data"), this); connect(mDetTableAction, SIGNAL(triggered()), this, SLOT(showDetectorTable())); mGroupDetsAction = new QAction(tr("&Group"), this); @@ -311,7 +311,7 @@ void InstrumentWindow::plotSelectedSpectra() */ void InstrumentWindow::showDetectorTable() { - emit createDetectorTable(mInstrumentDisplay->getWorkspaceName(), mInstrumentDisplay->getSelectedWorkspaceIndices()); + emit createDetectorTable(mInstrumentDisplay->getWorkspaceName(), mInstrumentDisplay->getSelectedWorkspaceIndices(), true); } QString InstrumentWindow::confirmDetectorOperation(const QString & opName, const QString & inputWS, int ndets) @@ -364,12 +364,10 @@ void InstrumentWindow::maskDetectors() const std::vector<int> & wksp_indices = mInstrumentDisplay->getSelectedWorkspaceIndices(); const std::vector<int> & det_ids = mInstrumentDisplay->getSelectedDetectorIDs(); QString inputWS = mInstrumentDisplay->getWorkspaceName(); - QString outputWS = confirmDetectorOperation("masked", inputWS, static_cast<int>(det_ids.size())); - if( outputWS.isEmpty() ) return; - - QString param_list = "InputWorkspace=%1;OutputWorkspace=%2;WorkspaceIndexList=%3"; + // Masking can only replace the input workspace so no need to ask for confirmation + QString param_list = "Workspace=%1;WorkspaceIndexList=%2"; QString indices = asString(mInstrumentDisplay->getSelectedWorkspaceIndices()); - emit execMantidAlgorithm("MaskDetectors",param_list.arg(inputWS, outputWS, asString(wksp_indices))); + emit execMantidAlgorithm("MaskDetectors",param_list.arg(inputWS, asString(wksp_indices))); } /** diff --git a/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.h b/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.h index 8038d9413b97028d782f4ae943b59c260e7ba339..1ecc0397b3af3cf9ac43422cf69e7df8ffcc54c3 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.h +++ b/Code/qtiplot/qtiplot/src/Mantid/InstrumentWidget/InstrumentWindow.h @@ -107,7 +107,7 @@ public slots: signals: void plotSpectra(const QString&,const std::set<int>&); - void createDetectorTable(const QString&,const std::vector<int>&); + void createDetectorTable(const QString&,const std::vector<int>&,bool); void execMantidAlgorithm(const QString&,const QString&); private slots: diff --git a/Code/qtiplot/qtiplot/src/Mantid/MantidUI.cpp b/Code/qtiplot/qtiplot/src/Mantid/MantidUI.cpp index 2cef60a8bd15fe39a49295e861c591d65b49f33f..095e828c566c9e1f04ce8f60435d978b7cc7557e 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/MantidUI.cpp +++ b/Code/qtiplot/qtiplot/src/Mantid/MantidUI.cpp @@ -660,12 +660,26 @@ Table* MantidUI::createTableDetectors(MantidMatrix *m) return createDetectorTable(m->workspaceName(), indices); } -Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<int>& indices) +Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<int>& indices, bool include_data) { const int nrows = indices.size(); - Table* t = new Table(appWindow()->scriptingEnv(), nrows, 6, "", appWindow(), 0); + int ncols = 6; + QStringList col_names; + col_names << "Index" << "Spectra" << "Detector ID"; + if( include_data ) + { + ncols += 2; + col_names << "Data Value" << "Data Error"; + } + col_names << "R" << "Theta" << "Phi"; + + Table* t = new Table(appWindow()->scriptingEnv(), nrows, ncols, "", appWindow(), 0); appWindow()->initTable(t, appWindow()->generateUniqueName(wsName + "-Detectors-")); - t->showNormal(); + //Set the column names + for( int col = 0; col < ncols; ++col ) + { + t->setColName(col, col_names[col]); + } MatrixWorkspace_sptr ws; if( AnalysisDataService::Instance().doesExist(wsName.toStdString()) ) @@ -673,13 +687,18 @@ Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<i ws = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(wsName.toStdString())); } - if( !ws ) return NULL; + if( !ws ) + { + delete t; + return NULL; + } Mantid::API::Axis *spectraAxis = ws->getAxis(1); Mantid::Geometry::IObjComponent_const_sptr sample = ws->getInstrument()->getSample(); - for( int i = 0; i < nrows; ++i ) + QList<double> col_values; + for( int row = 0; row < nrows; ++row ) { - int ws_index = indices[i]; + int ws_index = indices[row]; int currentSpec = spectraAxis->spectraNo(ws_index); int detID = 0; double R(0.0), Theta(0.0), Phi(0.0); @@ -698,24 +717,19 @@ Table* MantidUI::createDetectorTable(const QString & wsName, const std::vector<i { detID = 0; } - t->setCell(i,0,ws_index); - if (i == 0) t->setColName(0,"Index"); - - t->setCell(i,1,currentSpec); - if (i == 0) t->setColName(1,"Spectra"); - - t->setCell(i,2,detID); - if (i == 0) t->setColName(2,"Detectors"); - - t->setCell(i,3,R); - if (i == 0) t->setColName(3,"R"); - - t->setCell(i,4,Theta); - if (i == 0) t->setColName(4,"Theta"); + col_values << static_cast<double>(ws_index) << static_cast<double>(currentSpec) << static_cast<double>(detID); + if( include_data ) + { + col_values << ws->readY(ws_index)[0] << ws->readE(ws_index)[0]; + } + col_values << R << Theta << Phi; + for(int col = 0; col < ncols; ++col) + { + t->setCell(row, col, col_values[col]); + } - t->setCell(i,5,Phi); - if (i == 0) t->setColName(5,"Phi"); } + t->showNormal(); return t; } @@ -1235,8 +1249,8 @@ InstrumentWindow* MantidUI::getInstrumentView(const QString & wsName) connect (insWin,SIGNAL(showContextMenu()), appWindow(),SLOT(showWindowContextMenu())); connect(insWin,SIGNAL(plotSpectra(const QString&,const std::set<int>&)),this, SLOT(plotSpectraList(const QString&,const std::set<int>&))); - connect(insWin,SIGNAL(createDetectorTable(const QString&,const std::vector<int>&)),this, - SLOT(createDetectorTable(const QString&,const std::vector<int>&))); + connect(insWin,SIGNAL(createDetectorTable(const QString&,const std::vector<int>&,bool)),this, + SLOT(createDetectorTable(const QString&,const std::vector<int>&,bool))); connect(insWin, SIGNAL(execMantidAlgorithm(const QString&,const QString&)), this, SLOT(executeAlgorithm(const QString&, const QString&))); return insWin; diff --git a/Code/qtiplot/qtiplot/src/Mantid/MantidUI.h b/Code/qtiplot/qtiplot/src/Mantid/MantidUI.h index 93f1aa136c18abe1b5d5e561be6cc37371ce70ff..8bec8b38c2c062a245b5ee2eff93ea355597e34a 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/MantidUI.h +++ b/Code/qtiplot/qtiplot/src/Mantid/MantidUI.h @@ -186,7 +186,8 @@ public: // Creates and shows a Table with detector ids for the workspace in the MantidMatrix Table* createTableDetectors(MantidMatrix *m); public slots: - Table* createDetectorTable(const QString & wsName, const std::vector<int>& indices); + /// Create a table showing detector information for the given workspace and indices and optionally the data for that detector + Table* createDetectorTable(const QString & wsName, const std::vector<int>& indices, bool include_data = false); // ***** ***** // public: