Skip to content

Commit

Permalink
Update scroll bars on resize
Browse files Browse the repository at this point in the history
Refs #10324
  • Loading branch information
DanNixon committed Oct 28, 2014
1 parent b4d795f commit 5f23e4b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
Expand Up @@ -58,6 +58,7 @@ class RangeHandler;
class SliderHandler;
class SpectrumDisplay;
class SVConnections;
class MatrixWSDataSource;

class EXPORT_OPT_MANTIDQT_SPECTRUMVIEWER SpectrumView : public QMainWindow, public MantidQt::API::WorkspaceObserver
{
Expand All @@ -75,6 +76,7 @@ protected slots:
void updateWorkspace();

protected:
virtual void resizeEvent(QResizeEvent * event);
void preDeleteHandle(const std::string& wsName,const boost::shared_ptr<Mantid::API::Workspace> ws);
void afterReplaceHandle(const std::string& wsName,const boost::shared_ptr<Mantid::API::Workspace> ws);

Expand All @@ -84,6 +86,8 @@ protected slots:
GraphDisplay* h_graph;
GraphDisplay* v_graph;

MatrixWSDataSource *m_data_source;

// keep void pointers to the following objects, to avoid having to
// include ui_SpectrumView.h, which disappears by the time MantidPlot is
// being built. We need the pointers so we can delete them in the
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/MantidQt/SpectrumViewer/src/SVConnections.cpp
Expand Up @@ -337,7 +337,7 @@ bool SVConnections::eventFilter(QObject *object, QEvent *event)
QPoint newPoint = spectrum_display->GetPlotTransform(newPositionData);
int newY = newPoint.y();

// see if we should react
// Ignore the event if the position is outside of the plot area
if (newX < 0) return false;
if (newY < 0) return false;
const QSize canvasSize = sv_ui->spectrumPlot->canvas()->size();
Expand All @@ -354,6 +354,7 @@ bool SVConnections::eventFilter(QObject *object, QEvent *event)
sv_ui->spectrumPlot->canvas()->cursor().setPos(QPoint(canvasPos.x()+m_picker_x, canvasPos.y()+m_picker_y));
// update the pointed at position
spectrum_display->SetPointedAtPoint( QPoint(m_picker_x, m_picker_y) );

// consume the event
return true;
}
Expand Down
33 changes: 21 additions & 12 deletions Code/Mantid/MantidQt/SpectrumViewer/src/SpectrumView.cpp
Expand Up @@ -3,7 +3,6 @@
#include "MantidQtSpectrumViewer/SpectrumView.h"
#include "MantidQtSpectrumViewer/ColorMaps.h"

#include "ui_SpectrumView.h"
#include "MantidQtSpectrumViewer/SVConnections.h"
#include "MantidQtSpectrumViewer/SpectrumDisplay.h"
#include "MantidQtSpectrumViewer/SliderHandler.h"
Expand All @@ -30,6 +29,7 @@ namespace SpectrumView
SpectrumView::SpectrumView(QWidget *parent) :
QMainWindow(parent, 0),
WorkspaceObserver(),
m_data_source(NULL),
m_ui(new Ui::SpectrumViewer())
{
m_ui->setupUi(this);
Expand All @@ -39,23 +39,33 @@ SpectrumView::~SpectrumView()
{
// std::cout << "SpectrumView destructor called" << std::endl;

delete h_graph;
delete v_graph;
delete h_graph;
delete v_graph;

delete m_ui;
delete m_slider_handler;
delete m_range_handler;
delete m_spectrum_display;
delete m_sv_connections;
delete m_ui;
delete m_slider_handler;
delete m_range_handler;
delete m_spectrum_display;
delete m_sv_connections;
delete m_data_source;
if ( m_emode_handler)
{
delete m_emode_handler;
}
}

void SpectrumView::resizeEvent(QResizeEvent * event)
{
QMainWindow::resizeEvent(event);

if(m_data_source)
m_spectrum_display->UpdateImage();
}

void SpectrumView::renderWorkspace(Mantid::API::MatrixWorkspace_const_sptr wksp)
{
MatrixWSDataSource* data_source = new MatrixWSDataSource(wksp);
this->updateHandlers(data_source);
m_data_source = new MatrixWSDataSource(wksp);
this->updateHandlers(m_data_source);

// Watch for the deletion of the associated workspace
observeAfterReplace();
Expand Down Expand Up @@ -84,7 +94,7 @@ void SpectrumView::renderWorkspace(Mantid::API::MatrixWorkspace_const_sptr wksp)
m_sv_connections = new SVConnections( m_ui, this, m_spectrum_display,
h_graph, v_graph );

m_spectrum_display->SetDataSource( data_source );
m_spectrum_display->SetDataSource( m_data_source );
}

/// Setup the various handlers (energy-mode, slider, range)
Expand All @@ -109,7 +119,6 @@ void SpectrumView::updateHandlers(SpectrumDataSource* data_source)

m_slider_handler = new SliderHandler( m_ui );
m_range_handler = new RangeHandler( m_ui );

}

/** Slot to close the window */
Expand Down

0 comments on commit 5f23e4b

Please sign in to comment.