Skip to content

Commit

Permalink
Re #6451. Redrawing picking image every time made it slow.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jan 29, 2013
1 parent 50bf49b commit 424fbec
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1333,15 +1333,17 @@ int InstrumentWindow::getInstrumentDisplayHeight() const
}

/// Redraw the instrument view
void InstrumentWindow::updateInstrumentView()
/// @param picking :: Set to true to update the picking image regardless the interaction
/// mode of the surface.
void InstrumentWindow::updateInstrumentView(bool picking)
{
if ( m_InstrumentDisplay && m_instrumentDisplayLayout->currentWidget() == dynamic_cast<QWidget*>(m_InstrumentDisplay) )
{
m_InstrumentDisplay->updateView();
m_InstrumentDisplay->updateView(picking);
}
else
{
m_simpleDisplay->updateView();
m_simpleDisplay->updateView(picking);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class InstrumentWindow : public MdiSubWindow, public MantidQt::API::WorkspaceObs
/// Toggle between the GL and simple instrument display widgets
void enableOpenGL( bool on );
/// Redraw the instrument view
void updateInstrumentView();
void updateInstrumentView(bool picking = false);
/// Recalculate the detector data and redraw the instrument view
void updateInstrumentDetectors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void InstrumentWindowMaskTab::showEvent (QShowEvent *)
bool hasMasks = m_instrWindow->getSurface()->hasMasks();
enableApply( hasMasks );
enableClear( hasMasks || m_instrWindow->getInstrumentActor()->hasMaskWorkspace() );
m_instrWindow->updateInstrumentView(true);
}

void InstrumentWindowMaskTab::clearProperties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,10 @@ void InstrumentWindowPickTab::addPeak(double x,double y)
*/
void InstrumentWindowPickTab::showEvent (QShowEvent *)
{
auto surface = getSurface();
// Make the state of the display view consistent with the current selection type
setSelectionType();
// make sure picking updated
m_instrWindow->updateInstrumentView(true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,14 @@ void MantidGLWidget::componentSelected(Mantid::Geometry::ComponentID id)
}
}

void MantidGLWidget::updateView()
/// Redraw the view
/// @param picking :: Set to true to update the picking image regardless the interaction
/// mode of the surface.
void MantidGLWidget::updateView(bool picking)
{
if ( m_surface )
{
m_surface->updateView();
m_surface->updateView(picking);
update();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MantidGLWidget : public QGLWidget

public slots:
void enableLighting(bool);
void updateView();
void updateView(bool picking = false);
void updateDetectors();
void componentSelected(Mantid::Geometry::ComponentID id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ ProjectionSurface::ProjectionSurface(const InstrumentActor* rootActor,const Mant
m_interactionMode(MoveMode),
m_peakLabelPrecision(6),
m_peakShapesStyle(0),
m_viewChanged(true)
m_viewChanged(true),
m_redrawPicking(true)
{
connect(rootActor,SIGNAL(colorMapChanged()),this,SLOT(colorMapChanged()));
connect(&m_maskShapes,SIGNAL(shapeCreated()),this,SLOT(catchShapeCreated()));
Expand Down Expand Up @@ -128,9 +129,10 @@ void ProjectionSurface::clear()
*/
void ProjectionSurface::draw(MantidGLWidget *widget)const
{
if ( m_viewChanged )
if ( m_viewChanged && ( m_redrawPicking || m_interactionMode == PickSingleMode || m_interactionMode == PickTubeMode ) )
{
draw(widget,true);
m_redrawPicking = false;
}
draw(widget,false);
if ( m_viewChanged )
Expand Down Expand Up @@ -224,7 +226,11 @@ void ProjectionSurface::drawSimple(QWidget* widget)const
m_pickImage = new QImage(widget->width(), widget->height(),QImage::Format_RGB32);
}

drawSimpleToImage(m_pickImage,true);
if ( m_redrawPicking || m_interactionMode == PickSingleMode || m_interactionMode == PickTubeMode )
{
drawSimpleToImage(m_pickImage,true);
m_redrawPicking = false;
}
drawSimpleToImage(m_viewImage,false);
m_viewChanged = false;
}
Expand Down Expand Up @@ -302,9 +308,15 @@ void ProjectionSurface::leaveEvent(QEvent *e)
getController()->leaveEvent( e );
}

void ProjectionSurface::updateView()
/**
* Update the view of the surface at the next redraw.
* @param picking :: Set to true to update the picking image regardless the interaction
* mode of the surface.
*/
void ProjectionSurface::updateView(bool picking)
{
m_viewChanged = true;
m_redrawPicking = picking;
}

void ProjectionSurface::updateDetectors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ProjectionSurface: public QObject
/// called when the gl widget gets resized
virtual void resize(int, int);
/// redraw surface without recalulationg of colours, etc
virtual void updateView();
virtual void updateView(bool picking = false);
/// full update and redraw of the surface
virtual void updateDetectors();
/// returns the bounding rectangle in the real coordinates
Expand Down Expand Up @@ -263,6 +263,8 @@ protected slots:
QMap<int,InputController*> m_inputControllers; ///< controllers for mouse and keyboard input
/// Set when the image must be redrawn
mutable bool m_viewChanged;
/// Set when the picking image must be redrawn regardless of the interaction mode
mutable bool m_redrawPicking;
};

typedef boost::shared_ptr<ProjectionSurface> ProjectionSurface_sptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ void SimpleWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface)
}

/// Redraw the view
void SimpleWidget::updateView()
/// @param picking :: Set to true to update the picking image regardless the interaction
/// mode of the surface.
void SimpleWidget::updateView(bool picking)
{
if(m_surface)
{
m_surface->updateView();
m_surface->updateView(picking);
update();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SimpleWidget : public QWidget
/// Return the surface
boost::shared_ptr<ProjectionSurface> getSurface(){return m_surface;}
/// Redraw the view
void updateView();
void updateView(bool picking = false);
/// Update the detector information (count values) and redraw
void updateDetectors();
protected:
Expand Down

0 comments on commit 424fbec

Please sign in to comment.