Skip to content

Commit

Permalink
refs #5167. Open peakws into the sliceviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Aug 23, 2012
1 parent 9a3d55b commit bb1c92d
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <QDialog>
#include <QListWidget>
#include <QStringList>

#include "WidgetDllOption.h"
#include <string>

namespace MantidQt
{
Expand Down Expand Up @@ -41,14 +42,14 @@ namespace MantidWidgets
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class SelectWorkspacesDialog : public QDialog
class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS SelectWorkspacesDialog : public QDialog
{
Q_OBJECT

public:

/// Constructor
SelectWorkspacesDialog (QDialog* parent);
SelectWorkspacesDialog (QWidget* parent = NULL, const std::string& typeFilter = "");

/// Return the selected names
QStringList getSelectedNames()const;
Expand Down
38 changes: 33 additions & 5 deletions Code/Mantid/MantidQt/MantidWidgets/src/SelectWorkspacesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,49 @@ namespace MantidQt
namespace MantidWidgets
{

/**
Helper comparitor class used to determine if a workspace is of a given type.
*/
class WorkspaceIsOfType
{
private:
const std::string m_type;
public:
WorkspaceIsOfType(const std::string type) : m_type(type)
{
}
bool operator()(Mantid::API::Workspace_sptr ws) const
{
return ws->id() != m_type;
}
};

//---------------------------------------
// Public member functions
//---------------------------------------

/// Constructor
SelectWorkspacesDialog::SelectWorkspacesDialog(QDialog* parent) :
/** Constructor
@param parent : Parent widget
@param typeFilter : optional filter for filtering workspaces by type.
*/
SelectWorkspacesDialog::SelectWorkspacesDialog(QWidget* parent, const std::string& typeFilter) :
QDialog(parent)
{
setWindowTitle("MantidPlot - Select workspace");
m_wsList = new QListWidget(parent);


Mantid::API::AnalysisDataServiceImpl& ADS = Mantid::API::AnalysisDataService::Instance();
typedef std::vector<Mantid::API::Workspace_sptr> VecWorkspaces;
VecWorkspaces workspaces = ADS.getObjects();
WorkspaceIsOfType comparitor(typeFilter);
workspaces.erase(std::remove_if(workspaces.begin(), workspaces.end(), comparitor), workspaces.end() );
QStringList tmp;
std::set<std::string> sv = Mantid::API::AnalysisDataService::Instance().getObjectNames();
for (std::set<std::string>::const_iterator it = sv.begin(); it != sv.end(); ++it)
tmp<<QString::fromStdString(*it);
for (VecWorkspaces::const_iterator it = workspaces.begin(); it != workspaces.end(); ++it)
{
//if(useFilter && ADS::
tmp<<QString::fromStdString((*it)->name());
}

m_wsList->addItems(tmp);
m_wsList->setSelectionMode(QAbstractItemView::MultiSelection);
Expand Down
30 changes: 16 additions & 14 deletions Code/Mantid/MantidQt/SliceViewer/icons/SliceViewerIcons.qrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<RCC>
<qresource prefix="/SliceViewer/icons">
<file>view-fullscreen.png</file>
<file>color-pallette.png</file>
<file>color-pallette-part.png</file>
<file>stock-tool-pencil-16.png</file>
<file>stock-lock.png</file>
<file>cross.png</file>
<file>refresh.png</file>
<file>document-new.png</file>
<file>grid.png</file>
<file>letter_x.png</file>
<file>letter_y.png</file>
<file>SliceViewerWindow_icon.png</file>
</qresource>
<qresource prefix="/SliceViewer/icons">
<file>peak_disabled.png</file>
<file>peak.png</file>
<file>view-fullscreen.png</file>
<file>color-pallette.png</file>
<file>color-pallette-part.png</file>
<file>stock-tool-pencil-16.png</file>
<file>stock-lock.png</file>
<file>cross.png</file>
<file>refresh.png</file>
<file>document-new.png</file>
<file>grid.png</file>
<file>letter_x.png</file>
<file>letter_y.png</file>
<file>SliceViewerWindow_icon.png</file>
</qresource>
</RCC>
Binary file added Code/Mantid/MantidQt/SliceViewer/icons/peak.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public slots:
void rebinParamsChanged();
void dynamicRebinComplete(bool error);

// Peaks overlay
void peakOverlay_toggled(bool);

private:
void loadSettings();
Expand Down Expand Up @@ -243,7 +245,7 @@ public slots:

/// Synced menu/buttons
MantidQt::API::SyncedCheckboxes *m_syncLineMode, *m_syncSnapToGrid,
*m_syncRebinMode, *m_syncRebinLock;
*m_syncRebinMode, *m_syncRebinLock, *m_syncPeakOverlay;

/// Cached double for infinity
double m_inf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,49 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnPeakOverlay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Overlay a peaks workspace</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../icons/SliceViewerIcons.qrc">
<normaloff>:/SliceViewer/icons/peak.png</normaloff>
<disabledoff>:/SliceViewer/icons/peak_disabled.png</disabledoff>:/SliceViewer/icons/peak.png</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -567,7 +610,7 @@
<widget class="MantidQt::MantidWidgets::SafeQwtPlot" name="safeQwtPlot"/>
</item>
<item>
<widget class="MantidQt::SliceViewer::ColorBarWidget" name="colorBarWidget"/>
<widget class="MantidQt::SliceViewer::ColorBarWidget" name="colorBarWidget" native="true"/>
</item>
</layout>
</widget>
Expand All @@ -585,15 +628,17 @@
<extends>QWidget</extends>
<header>MantidQtSliceViewer/ColorBarWidget.h</header>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::SafeQwtPlot</class>
<extends>QwtPlot</extends>
<header>MantidQtMantidWidgets/SafeQwtPlot.h</header>
</customwidget>
<customwidget>
<class>QwtPlot</class>
<extends>QFrame</extends>
<header>qwt_plot.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::SafeQwtPlot</class>
<extends>QwtPlot</extends>
<header>MantidQtMantidWidgets/SafeQwtPlot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
Expand Down
37 changes: 35 additions & 2 deletions Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "MantidQtSliceViewer/SliceViewer.h"
#include "MantidQtSliceViewer/SnapToGridDialog.h"
#include "MantidQtSliceViewer/XYLimitsDialog.h"
#include "MantidQtMantidWidgets/SelectWorkspacesDialog.h"
#include "qmainwindow.h"
#include "qmenubar.h"
#include <iomanip>
Expand Down Expand Up @@ -116,12 +117,14 @@ SliceViewer::SliceViewer(QWidget *parent)
initZoomer();
ui.btnZoom->hide();


// ----------- Toolbar button signals ----------------
QObject::connect(ui.btnResetZoom, SIGNAL(clicked()), this, SLOT(resetZoom()));
QObject::connect(ui.btnClearLine, SIGNAL(clicked()), this, SLOT(clearLine()));
QObject::connect(ui.btnRangeFull, SIGNAL(clicked()), this, SLOT(setColorScaleAutoFull()));
QObject::connect(ui.btnRangeSlice, SIGNAL(clicked()), this, SLOT(setColorScaleAutoSlice()));
QObject::connect(ui.btnRebinRefresh, SIGNAL(clicked()), this, SLOT(rebinParamsChanged()));
QObject::connect(ui.btnPeakOverlay, SIGNAL(toggled(bool)), this, SLOT(peakOverlay_toggled(bool)));

// ----------- Other signals ----------------
QObject::connect(m_colorBar, SIGNAL(colorBarDoubleClicked()), this, SLOT(loadColorMapSlot()));
Expand All @@ -139,13 +142,14 @@ SliceViewer::SliceViewer(QWidget *parent)
m_lineOverlay = new LineOverlay(m_plot, m_plot->canvas());
m_lineOverlay->setShown(false);

m_peakOverlay = new PeakOverlay(m_plot, m_plot->canvas());

m_overlayWSOutline = new LineOverlay(m_plot, m_lineOverlay);
m_overlayWSOutline->setShowHandles(false);
m_overlayWSOutline->setShowLine(false);
m_overlayWSOutline->setShown(false);

// -------- Peak Overlay ----------------
//m_peakOverlay = new PeakOverlay(m_plot, m_plot->canvas()); //TODO use the peak overlay
ui.btnPeakOverlay->setEnabled(true);
}

//------------------------------------------------------------------------------------
Expand Down Expand Up @@ -291,6 +295,13 @@ void SliceViewer::initMenus()

m_menuView->addSeparator();

action = new QAction(QPixmap(), "Peak Overlay", this);
m_syncPeakOverlay = new SyncedCheckboxes(action, ui.btnPeakOverlay, false);
connect(action, SIGNAL(toggled(bool)), this, SLOT(peakOverlay_toggled(bool)));
m_menuView->addAction(action);

m_menuView->addSeparator();

QActionGroup* group = new QActionGroup( this );

action = new QAction(QPixmap(), "No Normalization", this);
Expand Down Expand Up @@ -2041,6 +2052,28 @@ void SliceViewer::dynamicRebinComplete(bool error)
this->updateDisplay();
}

/**
Event handler for selection/de-selection of peak overlays.
@param checked : True if peak overlay option is checked.
*/
void SliceViewer::peakOverlay_toggled(bool checked)
{
if(checked)
{
MantidQt::MantidWidgets::SelectWorkspacesDialog dlg(this, "PeaksWorkspace");
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
QStringList list = dlg.getSelectedNames();
UNUSED_ARG(list); // TODO, display these peak workspaces.
}
else
{
return;
}
}
}

} //namespace
}

0 comments on commit bb1c92d

Please sign in to comment.