Skip to content

Commit

Permalink
refs #6271. Develop mini peaks table.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 8, 2013
1 parent 8d0e40f commit f4d4b02
Show file tree
Hide file tree
Showing 6 changed files with 439 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set ( SRC_FILES
src/PhysicalCrossPeak.cpp
src/PhysicalSphericalPeak.cpp
src/ProxyCompositePeaksPresenter.cpp
src/QPeaksTableModel.cpp
src/QScienceSpinBox.cpp
src/QwtRasterDataMD.cpp
src/SliceViewer.cpp
Expand Down Expand Up @@ -64,6 +65,7 @@ set ( INC_FILES
inc/MantidQtSliceViewer/PhysicalCrossPeak.h
inc/MantidQtSliceViewer/PhysicalSphericalPeak.h
inc/MantidQtSliceViewer/ProxyCompositePeaksPresenter.h
inc/MantidQtSliceViewer/QPeaksTableModel.h
inc/MantidQtSliceViewer/QScienceSpinBox.h
inc/MantidQtSliceViewer/QwtRasterDataMD.h
inc/MantidQtSliceViewer/SliceViewer.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "DllOption.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "ui_PeaksWorkspaceWidget.h"

namespace MantidQt
{
namespace SliceViewer
Expand Down Expand Up @@ -37,13 +36,17 @@ namespace SliceViewer
/// Background colour
QColor m_backgroundColour;

int m_originalTableWidth;

virtual void resizeEvent(QResizeEvent*);

private slots:
void onExpandChanged(bool);
void onBackgroundColourClicked();
void onForegroundColourClicked();
void onShowBackgroundChanged(bool);
void onRemoveWorkspaceClicked();
void onToggleHideInPlot(bool);
void onTableClicked(const QModelIndex&);
};

} //namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,28 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,1">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
<item>
<layout class="QHBoxLayout" name="infoLayout">
<item>
<widget class="QLabel" name="lblWSName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Workspace:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceName">
<property name="text">
Expand All @@ -48,6 +61,19 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblPeaksIntegrated">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Peaks Integrated:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceState">
<property name="text">
Expand All @@ -68,6 +94,19 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblCoordinates">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Coordinates:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceCoordinates">
<property name="text">
Expand All @@ -88,16 +127,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="ckExpand">
<property name="text">
<string>Expand</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand All @@ -107,6 +136,21 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
Expand All @@ -115,13 +159,43 @@
<layout class="QHBoxLayout" name="controlsLayout">
<item>
<widget class="QPushButton" name="btnRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHide">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Hide in Plot</string>
</property>
Expand Down Expand Up @@ -152,6 +226,24 @@
</item>
<item>
<widget class="QPushButton" name="btnPeakColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand Down Expand Up @@ -188,6 +280,18 @@
</item>
<item>
<widget class="QPushButton" name="btnBackgroundColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include <QAbstractTableModel>
#include <boost/shared_ptr.hpp>
#include "boost/bind.hpp"
#include "boost/function.hpp"
#include "boost/tuple/tuple.hpp"
#include <map>

// Forward declarations
namespace Mantid
{
namespace API
{
class IPeaksWorkspace;
class IPeak;
}
}

namespace MantidQt
{
namespace SliceViewer
{
/** @class QtWorkspaceMementoModel
QAbstractTableModel for serving up PeaksWorkspaces.
@author Owen Arnold
@date 07/01/2013
Copyright &copy; 2011-12 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class QPeaksTableModel : public QAbstractTableModel
{
public:
QPeaksTableModel(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS);
void update();
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
~QPeaksTableModel();
typedef std::map<int, QString> ColumnIndexNameMap;
typedef std::map<QString, QString> ColumnNameRowValueMap;

private:

static const QString RUNNUMBER;
static const QString DETID;
static const QString HKL;
static const QString DSPACING;
static const QString INT;
static const QString SIGINT;
static const QString QLAB;
static const QString QSAMPLE;

QString findColumnName(const int colIndex) const;
ColumnNameRowValueMap createMap(const Mantid::API::IPeak& peak) const;

/// Collection of data for viewing.
boost::shared_ptr<const Mantid::API::IPeaksWorkspace> m_peaksWS;

ColumnIndexNameMap m_columnNameMap;

};
}
}

0 comments on commit f4d4b02

Please sign in to comment.