Skip to content

Commit

Permalink
Re #5732. MultiLayer containing the plot wasn't properly connected.
Browse files Browse the repository at this point in the history
Should work now.
  • Loading branch information
mantid-roman committed Aug 10, 2012
1 parent b014ecf commit 65920e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12352,6 +12352,14 @@ Spectrogram* ApplicationWindow::openSpectrogram(Graph*ag,const std::string &spe
}
if(!m) return 0 ;
Spectrogram* sp=m->plotSpectrogram(ag,this,Graph::ColorMap,true,prjData);
if ( ag->multiLayer() != NULL )
{
m->attachMultilayer( ag->multiLayer() );
}
else
{
throw std::runtime_error("Open project: spectrogram cannot be initialized properly.");
}
return sp;
}

Expand Down
10 changes: 8 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,13 @@ Graph3D * MantidMatrix::plotGraph3D(int style)
return plot;
}

void MantidMatrix::attachMultilayer(MultiLayer* ml)
{
m_plots2D << ml;
connect(ml, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(dependantClosed(MdiSubWindow*)));
}


/** Creates a MultiLayer graph and plots this MantidMatrix as a Spectrogram.
@param type :: The "curve" type.
Expand All @@ -945,8 +952,7 @@ MultiLayer* MantidMatrix::plotGraph2D(Graph::CurveType type)

ApplicationWindow *a = applicationWindow();
MultiLayer* g = a->multilayerPlot(a->generateUniqueName(tr("Graph")));
m_plots2D<<g;
connect(g, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(dependantClosed(MdiSubWindow*)));
attachMultilayer( g );
//#799 fix for multiple dialog creation on double clicking/ on right click menu scale on 2d plot
// a->connectMultilayerPlot(g);
Graph* plot = g->activeGraph();
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class MantidMatrix : public MdiSubWindow, MantidQt::API::WorkspaceObserver
const std::string & getWorkspaceName();

Spectrogram* plotSpectrogram(Graph* plot ,ApplicationWindow* app,Graph::CurveType type,bool project,ProjectData*prjdata);
/// Add a multilayer as a dependent mdi sub-window. This method is addeed to fix a crash (ticket #5732).
/// A better solution is needed
void attachMultilayer(MultiLayer*);

void afterReplaceHandle(const std::string& wsName,const boost::shared_ptr<Mantid::API::Workspace> ws);
void preDeleteHandle(const std::string& wsName,const boost::shared_ptr<Mantid::API::Workspace> ws);
Expand Down

0 comments on commit 65920e7

Please sign in to comment.