Skip to content

Commit

Permalink
Re #5462. Some const-correctness changes ahead of the real work.
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellTaylor committed Jun 12, 2012
1 parent 69452b7 commit 4dbb08a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
15 changes: 7 additions & 8 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ using namespace Mantid::Kernel;
using namespace MantidQt::API;

//Mantid::Kernel::Logger & MantidMatrix::g_log=Mantid::Kernel::Logger::get("MantidMatrix");
MantidMatrix::MantidMatrix(Mantid::API::MatrixWorkspace_sptr ws, ApplicationWindow* parent, const QString& label, const QString& name, int start, int end)
MantidMatrix::MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, ApplicationWindow* parent, const QString& label, const QString& name, int start, int end)
: MdiSubWindow(parent, label, name, 0),
WorkspaceObserver(),
m_appWindow(parent),
m_workspace(ws),
y_start(0.0),y_end(0.0),
m_histogram(false),
m_min(0),m_max(0),
m_are_min_max_set(false),
m_boundingRect(),
m_funct(this),
m_strName(name.toStdString()),
m_selectedRows(),
m_selectedCols()
{
m_appWindow = parent;
m_strName = name.toStdString();
m_workspace = ws;
setup(ws,start,end);
setWindowTitle(name);
setName(name);
Expand Down Expand Up @@ -177,7 +177,7 @@ bool isANumber(volatile const double& d)
return d != std::numeric_limits<double>::infinity() && !boost::math::isnan(d);
}

void MantidMatrix::setup(Mantid::API::MatrixWorkspace_sptr ws, int start, int end)
void MantidMatrix::setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start, int end)
{
if (!ws.get())
{
Expand All @@ -189,7 +189,6 @@ void MantidMatrix::setup(Mantid::API::MatrixWorkspace_sptr ws, int start, int en
return;
}

m_workspace = ws;
m_workspaceTotalHist = static_cast<int>(ws->getNumberHistograms());
m_startRow = (start<0 || start>=m_workspaceTotalHist)?0:start;
m_endRow = (end<0 || end>=m_workspaceTotalHist || end < start)? m_workspaceTotalHist - 1 : end;
Expand Down Expand Up @@ -1427,7 +1426,7 @@ const std::string & MantidMatrix::getWorkspaceName()
@param type :: Type of the data to display: Y, X, or E
*/
MantidMatrixModel::MantidMatrixModel(QObject *parent,
Mantid::API::MatrixWorkspace* ws,
const Mantid::API::MatrixWorkspace* ws,
int rows,
int cols,
int start,
Expand All @@ -1439,7 +1438,7 @@ m_format('e'),m_prec(6)
}

/// Call this function if the workspace has changed
void MantidMatrixModel::setup(Mantid::API::MatrixWorkspace* ws,
void MantidMatrixModel::setup(const Mantid::API::MatrixWorkspace* ws,
int rows,
int cols,
int start)
Expand Down
14 changes: 7 additions & 7 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MantidMatrix : public MdiSubWindow, MantidQt::API::WorkspaceObserver

public:

MantidMatrix(Mantid::API::MatrixWorkspace_sptr ws, ApplicationWindow* parent, const QString& label, const QString& name = QString(), int start=-1, int end=-1);
MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, ApplicationWindow* parent, const QString& label, const QString& name = QString(), int start=-1, int end=-1);
~MantidMatrix();

void connectTableView(QTableView*,MantidMatrixModel*);
Expand All @@ -119,7 +119,7 @@ class MantidMatrix : public MdiSubWindow, MantidQt::API::WorkspaceObserver
int indexX(int row,double s)const;
int indexY(double s)const;

Mantid::API::MatrixWorkspace_sptr workspace(){return m_workspace;}
Mantid::API::MatrixWorkspace_const_sptr workspace(){return m_workspace;}
QString workspaceName() const;

QPixmap matrixIcon(){return m_matrix_icon;}
Expand Down Expand Up @@ -246,10 +246,10 @@ public slots:

protected:

void setup(Mantid::API::MatrixWorkspace_sptr ws, int start=-1, int end=-1);
void setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start=-1, int end=-1);

ApplicationWindow *m_appWindow;
Mantid::API::MatrixWorkspace_sptr m_workspace;
const Mantid::API::MatrixWorkspace_const_sptr m_workspace;
QTabWidget *m_tabs;
QTableView *m_table_viewY;
QTableView *m_table_viewX;
Expand Down Expand Up @@ -354,14 +354,14 @@ class MantidMatrixModel:public QAbstractTableModel
public:
typedef enum {Y,X,E} Type;
MantidMatrixModel(QObject *parent,
Mantid::API::MatrixWorkspace* ws,
const Mantid::API::MatrixWorkspace* ws,
int rows,
int cols,
int start,
Type type);

/// Call this function if the workspace has changed
void setup(Mantid::API::MatrixWorkspace* ws,
void setup(const Mantid::API::MatrixWorkspace* ws,
int rows,
int cols,
int start);
Expand Down Expand Up @@ -398,7 +398,7 @@ public slots:
/// Signals QTableView that the data have changed.
void resetData(){reset();}
private:
Mantid::API::MatrixWorkspace* m_workspace;
const Mantid::API::MatrixWorkspace* m_workspace;
int m_startRow; ///< starting workspace index to display
int m_endRow; ///< ending workspace index to display
int m_rows,m_cols; ///< numbers of rows and columns
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2838,7 +2838,7 @@ void MantidUI::setUpSpectrumGraph(MultiLayer* ml, const QString& wsName)
@param Name :: Name of the graph
@param workspace :: The workspace
*/
void MantidUI::setUpBinGraph(MultiLayer* ml, const QString& Name, Mantid::API::MatrixWorkspace_sptr workspace)
void MantidUI::setUpBinGraph(MultiLayer* ml, const QString& Name, Mantid::API::MatrixWorkspace_const_sptr workspace)
{
Graph* g = ml->activeGraph();
g->setTitle(tr("Workspace ")+Name);
Expand Down Expand Up @@ -3142,7 +3142,7 @@ MultiLayer* MantidUI::plotSelectedRows(const MantidMatrix * const m, bool errs,
return plotSpectraList(m->workspaceName(),rowSet,errs,distr);
}

Table* MantidUI::createTableFromBins(const QString& wsName, Mantid::API::MatrixWorkspace_sptr workspace, const QList<int>& bins, bool errs, int fromRow, int toRow)
Table* MantidUI::createTableFromBins(const QString& wsName, Mantid::API::MatrixWorkspace_const_sptr workspace, const QList<int>& bins, bool errs, int fromRow, int toRow)
{
if (bins.empty()) return NULL;

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ public slots:
static void setUpSpectrumGraph(MultiLayer* ml, const QString& wsName);

// Set properties of a 1d graph which plots data from a workspace
static void setUpBinGraph(MultiLayer* ml, const QString& wsName, Mantid::API::MatrixWorkspace_sptr workspace);
static void setUpBinGraph(MultiLayer* ml, const QString& wsName, Mantid::API::MatrixWorkspace_const_sptr workspace);

// Copy to a Table Y-values (and Err-values if errs==true) of bins with indeces from i0 to i1 (inclusive) from a workspace
Table* createTableFromBins(const QString& wsName, Mantid::API::MatrixWorkspace_sptr workspace, const QList<int>& bins, bool errs=true,int fromRow = -1, int toRow = -1);
Table* createTableFromBins(const QString& wsName, Mantid::API::MatrixWorkspace_const_sptr workspace, const QList<int>& bins, bool errs=true,int fromRow = -1, int toRow = -1);

// Copies selected columns (time bins) in a MantidMatrix to a Table
Table* createTableFromSelectedColumns(MantidMatrix *m, bool errs);
Expand Down

0 comments on commit 4dbb08a

Please sign in to comment.