Skip to content

Commit

Permalink
refs #6271. Enable palette changing in concrete presenter.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 11, 2013
1 parent d4835c4 commit 8e875d2
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace MantidQt
virtual bool changeShownDim();
virtual bool isLabelOfFreeAxis(const std::string& label) const;
SetPeaksWorkspaces presentedWorkspaces() const;
void setForegroundColour(const Colour);
void setBackgroundColour(const Colour);
private:
/// Peak overlay views.
VecPeakOverlayView m_viewPeaks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace SliceViewer
virtual void updateView();
/// Move the position of the peak, by using a different configuration of the existing origin indexes.
void movePosition(PeakTransform_sptr peakTransform);
/// Change foreground colour
virtual void changeForegroundColour(const Colour);
/// Change background colour
virtual void changeBackgroundColour(const Colour);

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace SliceViewer
virtual void updateView();
/// Move the position of the peak, by using a different configuration of the existing origin indexes.
void movePosition(PeakTransform_sptr peakTransform);
/// Change foreground colour
virtual void changeForegroundColour(const Colour);
/// Change background colour
virtual void changeBackgroundColour(const Colour);

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "MantidKernel/System.h"
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include <QPointF>
#include <boost/shared_ptr.hpp>

Expand Down Expand Up @@ -48,6 +49,10 @@ namespace MantidQt
virtual void showView() = 0;
/// Move the peak overlay to a new position.
virtual void movePosition(PeakTransform_sptr peakTransform) = 0;
/// Change foreground colour
virtual void changeForegroundColour(const Colour) = 0;
/// Change background colour
virtual void changeBackgroundColour(const Colour) = 0;
/// Destructor
virtual ~PeakOverlayView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MantidKernel/System.h"
#include <boost/shared_ptr.hpp>
#include "MantidKernel/System.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include <set>

namespace Mantid
Expand Down
26 changes: 26 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/ConcretePeaksPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,31 @@ namespace SliceViewer
return workspaces;
}

void ConcretePeaksPresenter::setForegroundColour(const Colour colour)
{
// Change foreground colours
for(VecPeakOverlayView::iterator it = m_viewPeaks.begin(); it != m_viewPeaks.end(); ++it)
{
if((*it) != NULL)
{
(*it)->changeForegroundColour(colour);
(*it)->updateView();
}
}
}

void ConcretePeaksPresenter::setBackgroundColour(const Colour colour)
{
// Change background colours
for(VecPeakOverlayView::iterator it = m_viewPeaks.begin(); it != m_viewPeaks.end(); ++it)
{
if((*it) != NULL)
{
(*it)->changeBackgroundColour(colour);
(*it)->updateView();
}
}
}

}
}
10 changes: 10 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayCross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,15 @@ namespace SliceViewer
m_physicalPeak.movePosition(transform);
}

void PeakOverlayCross::changeForegroundColour(const Colour colour)
{
this->m_peakColour = QColor(colour);
}

void PeakOverlayCross::changeBackgroundColour(const Colour)
{
// Do nothing with the background colour for a peak widget of this type.
}

} // namespace Mantid
} // namespace SliceViewer
10 changes: 10 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlaySphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,15 @@ namespace SliceViewer
m_physicalPeak.movePosition(transform);
}

void PeakOverlaySphere::changeForegroundColour(const Colour colour)
{
this->m_peakColour = QColor(colour);
}

void PeakOverlaySphere::changeBackgroundColour(const Colour)
{
// Not being drawn at the moment, TODO.
}

} // namespace Mantid
} // namespace SliceViewer
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MantidQtSliceViewer/PeakOverlayViewFactoryBase.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include <boost/make_shared.hpp>

using namespace Mantid::API;
Expand All @@ -8,49 +9,17 @@ namespace MantidQt
namespace SliceViewer
{

PeakOverlayViewFactoryBase::PeakOverlayViewFactoryBase(QwtPlot * plot, QWidget * parent, const size_t colourNumber) : PeakOverlayViewFactory(), m_plot(plot), m_parent(parent)
PeakOverlayViewFactoryBase::PeakOverlayViewFactoryBase(QwtPlot * plot, QWidget * parent, const size_t workspaceNumber) : PeakOverlayViewFactory(), m_plot(plot), m_parent(parent)
{
if(!plot)
throw std::invalid_argument("PeakOverlayViewFactoryBase plot is null");
if(!parent)
throw std::invalid_argument("PeakOverlayViewFactoryBase parent widget is null");

// Create a colour from the input number. We may want to make this more flexible in the future.
Qt::GlobalColor colour = Qt::green;
switch(colourNumber)
{
case 0:
colour = Qt::green;
break;
case 1:
colour = Qt::darkMagenta;
break;
case 2:
colour = Qt::cyan;
break;
case 3:
colour = Qt::darkGreen;
break;
case 4:
colour = Qt::darkCyan;
break;
case 5:
colour = Qt::darkYellow;
break;
case 6:
colour = Qt::darkRed;
break;
case 7:
colour = Qt::black;
break;
case 8:
colour = Qt::white;
break;
default:
colour = Qt::darkGray;
break;
}
m_peakColour = QColor(colour);
PeakPalette defaultPalette;
auto colourEnum = defaultPalette.foregroundIndexToColour(static_cast<int>(workspaceNumber));

m_peakColour = QColor(colourEnum);
}

std::string PeakOverlayViewFactoryBase::getPlotXLabel() const
Expand Down

0 comments on commit 8e875d2

Please sign in to comment.