Skip to content

Commit

Permalink
refs #6271. PeaksWorkspaceWidgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 11, 2013
1 parent ea2c4e7 commit db92f2c
Show file tree
Hide file tree
Showing 11 changed files with 400 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ set ( SRC_FILES
src/PeakTransformQSample.cpp
src/PeakTransformQLab.cpp
src/PeakTransformSelector.cpp
src/PeaksViewer.cpp
src/PeaksWorkspaceWidget.cpp
src/PhysicalCrossPeak.cpp
src/PhysicalSphericalPeak.cpp
src/QScienceSpinBox.cpp
Expand Down Expand Up @@ -54,6 +56,8 @@ set ( INC_FILES
inc/MantidQtSliceViewer/PeakTransform.h
inc/MantidQtSliceViewer/PeakTransformFactory.h
inc/MantidQtSliceViewer/PeakTransformSelector.h
inc/MantidQtSliceViewer/PeaksViewer.h
inc/MantidQtSliceViewer/PeaksWorkspaceWidget.h
inc/MantidQtSliceViewer/PhysicalCrossPeak.h
inc/MantidQtSliceViewer/PhysicalSphericalPeak.h
inc/MantidQtSliceViewer/QScienceSpinBox.h
Expand All @@ -77,6 +81,8 @@ set ( MOC_FILES
inc/MantidQtSliceViewer/ColorBarWidget.h
inc/MantidQtSliceViewer/QScienceSpinBox.h
inc/MantidQtSliceViewer/SnapToGridDialog.h
inc/MantidQtSliceViewer/PeaksViewer.h
inc/MantidQtSliceViewer/PeaksWorkspaceWidget.h
inc/MantidQtSliceViewer/XYLimitsDialog.h
)

Expand All @@ -87,6 +93,8 @@ set ( UI_FILES
inc/MantidQtSliceViewer/LinePlotOptions.ui
inc/MantidQtSliceViewer/ColorBarWidget.ui
inc/MantidQtSliceViewer/SnapToGridDialog.ui
inc/MantidQtSliceViewer/PeaksWorkspaceWidget.ui
inc/MantidQtSliceViewer/PeaksViewer.ui
inc/MantidQtSliceViewer/XYLimitsDialog.ui
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef PEAKSVIEWER_H
#define PEAKSVIEWER_H

#include <QtGui/QWidget>
#include "DllOption.h"
#include "MantidQtSliceViewer/PeaksPresenter.h"

namespace MantidQt
{
namespace SliceViewer
{

class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeaksViewer : public QWidget
{
Q_OBJECT
public:
PeaksViewer(QWidget *parent = 0);
void setPeaksWorkspaces(const SetPeaksWorkspaces& workspaces);
~PeaksViewer();
};

} //namespace
}
#endif // PEAKSVIEWER_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef PEAKSWORKSPACEWIDGET_H
#define PEAKSWORKSPACEWIDGET_H

#include <QtGui/QWidget>
#include "DllOption.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "ui_PeaksWorkspaceWidget.h"

namespace MantidQt
{
namespace SliceViewer
{

class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeaksWorkspaceWidget : public QWidget
{
Q_OBJECT
public:
PeaksWorkspaceWidget(Mantid::API::IPeaksWorkspace_const_sptr ws, QWidget *parent = 0);
~PeaksWorkspaceWidget();
private:
/// Populate the widget with model data.
void populate();
/// Auto-generated UI controls.
Ui::PeaksWorkspaceWidget ui;
/// Peaks workspace to view.
Mantid::API::IPeaksWorkspace_const_sptr m_ws;
private slots:
void expandChanged(bool);
};

} //namespace
}
#endif // PEAKSWORKSPACEWIDGET_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PeaksWorkspaceWidget</class>
<widget class="QWidget" name="PeaksWorkspaceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>140</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,1">
<item>
<layout class="QHBoxLayout" name="infoLayout">
<item>
<widget class="QLabel" name="lblWorkspaceName">
<property name="text">
<string>[Workspace]</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceState">
<property name="text">
<string>[Integrated/UnIntegrated]</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceCoordinates">
<property name="text">
<string>[Viewing Coordinate System]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</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>
<layout class="QHBoxLayout" name="tableLayout">
<item>
<widget class="QTableView" name="tblPeaks">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="controlsLayout">
<item>
<widget class="QPushButton" name="btnHide">
<property name="text">
<string>Hide</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Peak Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPeakColor">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Peak Background Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBackgroundColor">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ckShowBackground">
<property name="text">
<string>Show Background</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "MantidQtAPI/SyncedCheckboxes.h"
#include "MantidQtSliceViewer/LineOverlay.h"
#include "MantidQtSliceViewer/PeakTransformSelector.h"
#include "MantidQtSliceViewer/PeaksPresenter.h"
#include "QwtRasterDataMD.h"
#include "ui_SliceViewer.h"
#include <QtCore/QtCore>
Expand Down Expand Up @@ -94,13 +95,18 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget
void setRebinMode(bool mode, bool locked);
void refreshRebin();

/// Methods relating to peaks overlays.
SetPeaksWorkspaces getPeaksWorkspaces() const;

signals:
/// Signal emitted when the X/Y index of the shown dimensions is changed
void changedShownDim(size_t dimX, size_t dimY);
/// Signal emitted when the slice point moves
void changedSlicePoint(Mantid::Kernel::VMD slicePoint);
/// Signal emitted when the LineViewer should be shown/hidden.
void showLineViewer(bool);
/// Signal emitted when the PeaksViewer should be shown/hidden.
void showPeaksViewer(bool);
/// Signal emitted when someone uses setWorkspace() on SliceViewer
void workspaceChanged();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "MantidQtAPI/WorkspaceObserver.h"
#include "MantidQtSliceViewer/LineViewer.h"
#include "MantidQtSliceViewer/SliceViewer.h"
#include "MantidQtSliceViewer/PeaksViewer.h"
#include <QtGui/QMainWindow>
#include <QtGui/QSplitter>
#include <QtGui/qdialog.h>
Expand Down Expand Up @@ -57,6 +58,7 @@ protected slots:
void resizeWindow();
void lineViewer_changedFixedBinWidth(bool fixed, double binWidth);
void showLineViewer(bool);
void showPeaksViewer(bool);

protected:
void preDeleteHandle(const std::string& wsName,const boost::shared_ptr<Mantid::API::Workspace> ws);
Expand All @@ -68,6 +70,9 @@ protected slots:

/// The LineViewer
MantidQt::SliceViewer::LineViewer * m_liner;

/// The PeaksViewer
MantidQt::SliceViewer::PeaksViewer * m_peaksViewer;

/// Horizontal splitter between slice viewer and LineViewer
QSplitter * m_splitter;
Expand All @@ -83,6 +88,9 @@ protected slots:
/// Width of the LineViewer last time it was open
int m_lastLinerWidth;

/// Width of the PeaksViewer last tiem it was open
int m_lastPeaksViewerWidth;

/// Window width
int m_desiredWidth;
};
Expand Down
36 changes: 36 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeaksViewer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "MantidQtSliceViewer/PeaksViewer.h"
#include "MantidQtSliceViewer/PeaksWorkspaceWidget.h"
#include <QBoxLayout>

namespace MantidQt
{
namespace SliceViewer
{
PeaksViewer::PeaksViewer(QWidget *parent)
: QWidget(parent)
{
this->setMinimumWidth(500);
}

void PeaksViewer::setPeaksWorkspaces(const SetPeaksWorkspaces& workspaces)
{
auto _layout = layout();
if(_layout)
{
delete _layout;
}
this->setLayout(new QVBoxLayout);
auto it = workspaces.begin();
while(it != workspaces.end())
{
layout()->addWidget(new PeaksWorkspaceWidget(*it, this));
++it;
}
}

PeaksViewer::~PeaksViewer()
{
}

} // namespace
}
45 changes: 45 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeaksWorkspaceWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "MantidQtSliceViewer/PeaksWorkspaceWidget.h"

namespace MantidQt
{
namespace SliceViewer
{
PeaksWorkspaceWidget::PeaksWorkspaceWidget(Mantid::API::IPeaksWorkspace_const_sptr ws, QWidget *parent)
: QWidget(parent), m_ws(ws)
{
ui.setupUi(this);

ui.tblPeaks->setHidden(true);
ui.tblPeaks->setFixedHeight(0);
connect(ui.ckExpand, SIGNAL(clicked(bool)), this, SLOT(expandChanged(bool)));


populate();
}

void PeaksWorkspaceWidget::populate()
{
ui.lblWorkspaceName->setText(m_ws->name().c_str());

const QString unintegratedMsg = "un-integrated";
const QString integratedMsg = "integrated";

ui.lblWorkspaceName->setText(m_ws->hasIntegratedPeaks() ? integratedMsg : unintegratedMsg );

// Viewing coordinate system.... ? SliceViewer::peakCoordinateSystem() -> PeakTransformSelector -> PeakTransformFactory::productName(instancemethod) -> PeakTransform::name(static)
// Default Background colour .... ? -- PeakPallette ?
// Default Foreground colour .... ? -- PeakPallette ?
}

PeaksWorkspaceWidget::~PeaksWorkspaceWidget()
{
}

void PeaksWorkspaceWidget::expandChanged(bool open)
{
ui.tblPeaks->setHidden(!open);
ui.tblPeaks->setFixedHeight(QWIDGETSIZE_MAX);
}

} // namespace
}

0 comments on commit db92f2c

Please sign in to comment.