Ejemplo n.º 1
0
/**
 * Clone the curve for the use by a particular Graph
 */
MantidMatrixCurve *MantidMatrixCurve::clone(const Graph *g) const {
  MantidMatrixCurve *mc = new MantidMatrixCurve(*this);
  if (g) {
    mc->setDrawAsDistribution(g->isDistribution());
  }
  return mc;
}
Ejemplo n.º 2
0
MantidMatrixCurve::MantidMatrixCurve(const MantidMatrixCurve &c)
    : MantidCurve(createCopyName(c.title().text()), c.m_drawErrorBars,
                  c.m_drawAllErrorBars),
      m_wsName(c.m_wsName), m_index(c.m_index), m_indexType(c.m_indexType),
      m_xUnits(c.m_xUnits), m_yUnits(c.m_yUnits) {
  setData(c.data());
  observePostDelete();
  connect(this, SIGNAL(resetData(const QString &)), this,
          SLOT(dataReset(const QString &)));
  observeAfterReplace();
  observeADSClear();
}
Ejemplo n.º 3
0
/**
 * Called from constructor.
 * Sets up tool based on the given curve.
 * @param curve :: [input] Curve to use for initialization
 * @returns :: success or failure
 */
bool PeakPickerTool::initializeFromCurve(PlotCurve *curve) {
  if (!curve) {
    return false;
  }
  DataCurve *dcurve = dynamic_cast<DataCurve *>(curve);
  if (dcurve) {
    m_wsName = dcurve->table()->name().section('-', 0, 0);
    m_spec = dcurve->table()->colName(0).section('_', 1, 1).mid(2).toInt();
  } else {
    MantidMatrixCurve *mcurve = dynamic_cast<MantidMatrixCurve *>(curve);
    if (mcurve) {
      const QString title = mcurve->title().text();
      if (title.contains("Workspace-Calc")) {
        // Don't set up from a fit curve
        return false;
      } else {
        // Set up the tool from this curve
        m_wsName = mcurve->workspaceName();
        m_spec = mcurve->workspaceIndex();
        m_shouldBeNormalised =
            mcurve->isDistribution() && mcurve->isNormalizable();
      }
    } else {
      return false;
    }
  }
  return true;
}
Ejemplo n.º 4
0
void CurvesDialog::init()
{
  if (d_app){
    bool currentFolderOnly = d_app->d_show_current_folder;
    boxShowCurrentFolder->setChecked(currentFolderOnly);
    showCurrentFolder(currentFolderOnly);

    QStringList matrices = d_app->matrixNames();
    if (!matrices.isEmpty ()){
      boxMatrixStyle->show();
      available->addItems(matrices);
    }

    int style = d_app->defaultCurveStyle;
    if (style == Graph::Line)
      boxStyle->setCurrentItem(0);
    else if (style == Graph::Scatter)
      boxStyle->setCurrentItem(1);
    else if (style == Graph::LineSymbols)
      boxStyle->setCurrentItem(2);
    else if (style == Graph::VerticalDropLines)
      boxStyle->setCurrentItem(3);
    else if (style == Graph::Spline)
      boxStyle->setCurrentItem(4);
    else if (style == Graph::VerticalSteps)
      boxStyle->setCurrentItem(5);
    else if (style == Graph::HorizontalSteps)
      boxStyle->setCurrentItem(6);
    else if (style == Graph::Area)
      boxStyle->setCurrentItem(7);
    else if (style == Graph::VerticalBars)
      boxStyle->setCurrentItem(8);
    else if (style == Graph::HorizontalBars)
      boxStyle->setCurrentItem(9);
  }

  QList<MdiSubWindow *> wList = d_app->windowsList();
  foreach(MdiSubWindow* w, wList)
  {
    MultiLayer* ml = dynamic_cast<MultiLayer*>(w);
    if (ml)// layers are numbered starting from 1
    {
      for(int i=1;i<=ml->layers();i++)
      {
        Graph* g = ml->layer(i);
        if (g)
        {
          for(int j=0;j<g->curves();j++)
          {
            MantidMatrixCurve* c = dynamic_cast<MantidMatrixCurve*>(g->curve(j));
            if (c)
            {
              available->addItem(c->title().text());
              // Store copies of the curves
              // Necessary because a curve is deleted when it's removed from a plot
              d_plotCurves[c->title().text()] = c->clone(g);
              ml->setCloseOnEmpty(false);
            }
          }
        }
      }
    }
  }