Mantid
Loading...
Searching...
No Matches
WorkspaceIcons.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//-----------------------------------------------------------------------------
8// Includes
9//-----------------------------------------------------------------------------
12
13namespace MantidQt::API {
14//-----------------------------------------------------------------------------
15// Public member functions
16//-----------------------------------------------------------------------------
21
26QPixmap WorkspaceIcons::getIcon(const std::string &workspaceID) const {
27 // All mappings are simple bar the MDEventWorkspace as each of its templates
28 // has different ID.
29 if (workspaceID.compare(0, 16, "MDEventWorkspace") == 0)
30 return getQPixmap(m_idToPixmapName.value("MDEventWorkspace"));
31 else
32 return getQPixmap(m_idToPixmapName.value(workspaceID));
33}
34
40std::string WorkspaceIcons::getIconID(const std::string &workspaceID) const {
41 if (workspaceID.compare(0, 16, "MDEventWorkspace") == 0)
42 return m_idToPixmapName.value("MDEventWorkspace");
43 else
44 return m_idToPixmapName.value(workspaceID);
45}
46
47//-----------------------------------------------------------------------------
48// Private member functions
49//-----------------------------------------------------------------------------
50
52 m_idToPixmapName.clear();
53 // MatrixWorkspace types
54 m_idToPixmapName["EventWorkspace"] = "mantid_matrix_xpm";
55 m_idToPixmapName["GroupingWorkspace"] = "mantid_matrix_xpm";
56 m_idToPixmapName["MaskWorkspace"] = "mantid_matrix_xpm";
57 m_idToPixmapName["OffsetsWorkspace"] = "mantid_matrix_xpm";
58 m_idToPixmapName["RebinnedOutput"] = "mantid_matrix_xpm";
59 m_idToPixmapName["SpecialWorkspace2D"] = "mantid_matrix_xpm";
60 m_idToPixmapName["Workspace2D"] = "mantid_matrix_xpm";
61 m_idToPixmapName["WorkspaceSingleValue"] = "mantid_matrix_xpm";
62
63 // Table workspace types
64 m_idToPixmapName["TableWorkspace"] = "worksheet_xpm";
65 m_idToPixmapName["PeaksWorkspace"] = "worksheet_xpm";
66 m_idToPixmapName["LeanElasticPeaksWorkspace"] = "worksheet_xpm";
67
68 // Group
69 m_idToPixmapName["WorkspaceGroup"] = "mantid_wsgroup_xpm";
70
71 // MD
72 m_idToPixmapName["MDHistoWorkspace"] = "mantid_mdws_xpm";
73 m_idToPixmapName["MDEventWorkspace"] = "mantid_mdws_xpm";
74}
75} // namespace MantidQt::API
WorkspaceIcons()
Default constructor.
QMap< std::string, std::string > m_idToPixmapName
Internal map instance.
std::string getIconID(const std::string &workspaceID) const
Returns an icon ID for the given workspace ID.
QPixmap getIcon(const std::string &workspaceID) const
Returns an icon for the given ID.
void initInternalLookup()
Defines the mapping between ID & pixmap name.
EXPORT_OPT_MANTIDQT_COMMON QPixmap getQPixmap(const std::string &name)
Function that returns a QPixmap given a string name.
Definition: pixmaps.cpp:12823