Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
5bdc20b7
Commit
5bdc20b7
authored
10 years ago
by
Roman Tolchenov
Browse files
Options
Downloads
Patches
Plain Diff
Re #5983. Check if sample is null.
parent
06e1a705
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
+31
-5
31 additions, 5 deletions
...ntidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
+2
-1
2 additions, 1 deletion
Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
with
33 additions
and
6 deletions
Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp
+
31
−
5
View file @
5bdc20b7
...
@@ -58,6 +58,18 @@ using namespace MantidQt::API;
...
@@ -58,6 +58,18 @@ using namespace MantidQt::API;
// Name of the QSettings group to store the InstrumentWindw settings
// Name of the QSettings group to store the InstrumentWindw settings
const
char
*
InstrumentWindowSettingsGroup
=
"Mantid/InstrumentWindow"
;
const
char
*
InstrumentWindowSettingsGroup
=
"Mantid/InstrumentWindow"
;
namespace
{
/**
* Exception type thrown when an istrument has no sample and cannot be displayed in the instrument view.
*/
class
InstrumentHasNoSampleError
:
public
std
::
runtime_error
{
public:
InstrumentHasNoSampleError
()
:
std
::
runtime_error
(
"Istrument has no sample.
\n
Source and sample need to be set in the IDF."
){}
};
}
/**
/**
* Constructor.
* Constructor.
*/
*/
...
@@ -331,6 +343,10 @@ void InstrumentWindow::setSurfaceType(int type)
...
@@ -331,6 +343,10 @@ void InstrumentWindow::setSurfaceType(int type)
{
{
Mantid
::
Geometry
::
Instrument_const_sptr
instr
=
m_instrumentActor
->
getInstrument
();
Mantid
::
Geometry
::
Instrument_const_sptr
instr
=
m_instrumentActor
->
getInstrument
();
Mantid
::
Geometry
::
IComponent_const_sptr
sample
=
instr
->
getSample
();
Mantid
::
Geometry
::
IComponent_const_sptr
sample
=
instr
->
getSample
();
if
(
!
sample
)
{
throw
InstrumentHasNoSampleError
();
}
Mantid
::
Kernel
::
V3D
sample_pos
=
sample
->
getPos
();
Mantid
::
Kernel
::
V3D
sample_pos
=
sample
->
getPos
();
Mantid
::
Kernel
::
V3D
axis
;
Mantid
::
Kernel
::
V3D
axis
;
// define the axis
// define the axis
...
@@ -369,6 +385,11 @@ void InstrumentWindow::setSurfaceType(int type)
...
@@ -369,6 +385,11 @@ void InstrumentWindow::setSurfaceType(int type)
surface
=
new
PanelsSurface
(
m_instrumentActor
,
sample_pos
,
axis
);
surface
=
new
PanelsSurface
(
m_instrumentActor
,
sample_pos
,
axis
);
}
}
}
}
catch
(
InstrumentHasNoSampleError
&
)
{
QApplication
::
restoreOverrideCursor
();
throw
;
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
{
errorMessage
=
e
.
what
();
errorMessage
=
e
.
what
();
...
@@ -703,12 +724,17 @@ void InstrumentWindow::saveSettings()
...
@@ -703,12 +724,17 @@ void InstrumentWindow::saveSettings()
settings
.
beginGroup
(
"Mantid/InstrumentWindow"
);
settings
.
beginGroup
(
"Mantid/InstrumentWindow"
);
if
(
m_InstrumentDisplay
)
if
(
m_InstrumentDisplay
)
settings
.
setValue
(
"BackgroundColor"
,
m_InstrumentDisplay
->
currentBackgroundColor
());
settings
.
setValue
(
"BackgroundColor"
,
m_InstrumentDisplay
->
currentBackgroundColor
());
settings
.
setValue
(
"PeakLabelPrecision"
,
getSurface
()
->
getPeakLabelPrecision
());
auto
surface
=
getSurface
();
settings
.
setValue
(
"ShowPeakRows"
,
getSurface
()
->
getShowPeakRowsFlag
());
if
(
surface
)
settings
.
setValue
(
"ShowPeakLabels"
,
getSurface
()
->
getShowPeakLabelsFlag
());
foreach
(
InstrumentWindowTab
*
tab
,
m_tabs
)
{
{
tab
->
saveSettings
(
settings
);
// if surface is null istrument view wasn't created and there is nothing to save
settings
.
setValue
(
"PeakLabelPrecision"
,
getSurface
()
->
getPeakLabelPrecision
());
settings
.
setValue
(
"ShowPeakRows"
,
getSurface
()
->
getShowPeakRowsFlag
());
settings
.
setValue
(
"ShowPeakLabels"
,
getSurface
()
->
getShowPeakLabelsFlag
());
foreach
(
InstrumentWindowTab
*
tab
,
m_tabs
)
{
tab
->
saveSettings
(
settings
);
}
}
}
settings
.
endGroup
();
settings
.
endGroup
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
+
2
−
1
View file @
5bdc20b7
...
@@ -1886,7 +1886,8 @@ InstrumentWindow* MantidUI::getInstrumentView(const QString & wsName, int tab)
...
@@ -1886,7 +1886,8 @@ InstrumentWindow* MantidUI::getInstrumentView(const QString & wsName, int tab)
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
{
{
QApplication
::
restoreOverrideCursor
();
QApplication
::
restoreOverrideCursor
();
QMessageBox
::
critical
(
appWindow
(),
"MantidPlot - Error"
,
e
.
what
());
QString
errorMessage
=
"Instrument view canot be created:
\n\n
"
+
QString
(
e
.
what
());
QMessageBox
::
critical
(
appWindow
(),
"MantidPlot - Error"
,
errorMessage
);
if
(
insWin
)
if
(
insWin
)
{
{
appWindow
()
->
closeWindow
(
insWin
);
appWindow
()
->
closeWindow
(
insWin
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment