示例#1
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);
            }
          }
        }
      }
    }
  }