本文整理汇总了C++中mantid::api::MatrixWorkspace_const_sptr::YUnitLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::YUnitLabel方法的具体用法?C++ MatrixWorkspace_const_sptr::YUnitLabel怎么用?C++ MatrixWorkspace_const_sptr::YUnitLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::YUnitLabel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/**
* @param g :: The Graph widget which will display the curve
* @param distr :: True for a distribution
* @param style :: The curve type to use
*/
void MantidMatrixCurve::init(Graph *g, bool distr,
GraphOptions::CurveType style) {
// Will throw if name not found but return NULL ptr if the type is incorrect
MatrixWorkspace_const_sptr workspace =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
m_wsName.toStdString());
if (!workspace) // The respective *Data classes will check for index validity
{
std::stringstream ss;
ss << "Workspace named '" << m_wsName.toStdString()
<< "' found but it is not a MatrixWorkspace. ID='"
<< AnalysisDataService::Instance().retrieve(m_wsName.toStdString())->id()
<< "'";
throw std::invalid_argument(ss.str());
}
// Set the curve name if it the non-naming constructor was called
if (this->title().isEmpty()) {
// If there's only one spectrum in the workspace, title is simply workspace
// name
if (workspace->getNumberHistograms() == 1)
this->setTitle(m_wsName);
else
this->setTitle(createCurveName(workspace));
}
Mantid::API::MatrixWorkspace_const_sptr matrixWS =
boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>(
workspace);
// we need to censor the data if there is a log scale because it can't deal
// with negative values, only the y-axis has been found to be problem so far
const bool log = g->isLog(QwtPlot::yLeft);
// Y units are the same for both spectrum and bin plots, e.g. counts
m_yUnits.reset(new Mantid::Kernel::Units::Label(matrixWS->YUnit(),
matrixWS->YUnitLabel()));
if (m_indexType == Spectrum) // Spectrum plot
{
QwtWorkspaceSpectrumData data(*matrixWS, m_index, log, distr);
setData(data);
// For spectrum plots, X axis are actual X axis, e.g. TOF
m_xUnits = matrixWS->getAxis(0)->unit();
} else // Bin plot
{
QwtWorkspaceBinData data(*matrixWS, m_index, log);
setData(data);
// For bin plots, X axis are "spectra axis", e.g. spectra numbers
m_xUnits = matrixWS->getAxis(1)->unit();
}
if (!m_xUnits) {
m_xUnits.reset(new Mantid::Kernel::Units::Empty());
}
int lineWidth = 1;
MultiLayer *ml = dynamic_cast<MultiLayer *>(g->parent()->parent()->parent());
if (ml && (style == GraphOptions::Unspecified ||
ml->applicationWindow()->applyCurveStyleToMantid)) {
applyStyleChoice(style, ml, lineWidth);
} else if (matrixWS->isHistogramData() && !matrixWS->isDistribution()) {
setStyle(QwtPlotCurve::Steps);
setCurveAttribute(
Inverted,
true); // this is the Steps style modifier that makes horizontal steps
} else {
setStyle(QwtPlotCurve::Lines);
}
g->insertCurve(this, lineWidth);
// set the option to draw all error bars from the global settings
if (hasErrorBars()) {
setErrorBars(true, g->multiLayer()->applicationWindow()->drawAllErrors);
}
// Initialise error bar colour to match curve colour
m_errorSettings->m_color = pen().color();
m_errorSettings->setWidth(pen().widthF());
connect(g, SIGNAL(axisScaleChanged(int, bool)), this,
SLOT(axisScaleChanged(int, bool)));
observePostDelete();
connect(this, SIGNAL(resetData(const QString &)), this,
SLOT(dataReset(const QString &)));
observeAfterReplace();
observeADSClear();
}