Example #1
0
/**
 *  @param g :: The Graph widget which will display the curve
 *  @param distr :: True if this is a distribution,
 *  not applicable here.
 *  @param style :: The graph style to use
 *  @param multipleSpectra :: True if there are multiple spectra,
 *  not applicable here.
 */
void MantidMDCurve::init(Graph *g, bool distr, GraphOptions::CurveType style,
                         bool multipleSpectra) {
  UNUSED_ARG(distr);
  UNUSED_ARG(multipleSpectra);
  IMDWorkspace_const_sptr ws = boost::dynamic_pointer_cast<IMDWorkspace>(
      AnalysisDataService::Instance().retrieve(m_wsName.toStdString()));
  if (!ws) {
    std::string message =
        "Could not extract IMDWorkspace of name: " + m_wsName.toStdString();
    throw std::runtime_error(message);
  }
  if (ws->getNonIntegratedDimensions().size() != 1) {
    std::string message = "This plot only applies to MD Workspaces with a "
                          "single expanded dimension";
    throw std::invalid_argument(message);
  }

  this->setTitle(m_wsName + "-signal");

  const bool log = g->isLog(QwtPlot::yLeft);
  MantidQwtIMDWorkspaceData data(ws, log);
  setData(data);

  int lineWidth = 1;
  MultiLayer *ml = dynamic_cast<MultiLayer *>(g->parent()->parent()->parent());
  if (ml && (style == GraphOptions::Unspecified ||
             ml->applicationWindow()->applyCurveStyleToMantid)) {
    // FIXME: Style HorizontalSteps does NOT seem to be applied
    applyStyleChoice(style, ml, lineWidth);
  } 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();
}