예제 #1
0
파일: OsiNames.cpp 프로젝트: e2bsq/Symphony
/*
  Set a run of column names. Quietly fail if the specified indices are
  invalid.

  On the target side, [tgtStart, tgtStart+len-1] must be in the range
  [0,n-1], where n is the number of columns.  On the source side, srcStart
  must be zero or greater. If we run off the end of srcNames, we just
  generate default names.
*/
void OsiSolverInterface::setColNames (OsiNameVec &srcNames,
				      int srcStart, int len, int tgtStart)

{ int nameDiscipline ;
/*
  Determine how we're handling names. It's possible that the underlying solver
  has overridden getIntParam, but doesn't recognise OsiNameDiscipline. In that
  case, we want to default to auto names
*/
  bool recognisesOsiNames = getIntParam(OsiNameDiscipline,nameDiscipline) ;
  if (recognisesOsiNames == false)
  { nameDiscipline = 0 ; }
/*
  If the name discipline is auto, we're already done.
*/
  if (nameDiscipline == 0)
  { return ; }
/*
  A little self-protection. Check that we're within [0,m-1] on the target side,
  and that srcStart is zero or greater. Quietly fail if the indices don't fit.
*/
  int n = getNumCols() ;
  if (tgtStart < 0 || tgtStart+len > n)
  { return ; }
  if (srcStart < 0)
  { return ; }
  int srcLen = static_cast<int>(srcNames.size()) ;
/*
  Load 'em up.
*/
  int srcNdx = srcStart ;
  int tgtNdx = tgtStart ;
  for ( ; tgtNdx < tgtStart+len ; srcNdx++,tgtNdx++)
  { if (srcNdx < srcLen)
    { setColName(tgtNdx,srcNames[srcNdx]) ; }
    else
    { setColName(tgtNdx,dfltRowColName('c',tgtNdx)) ; } }

  return ; }
TableStatistics::TableStatistics(ScriptingEnv *env, QWidget *parent, Table *base, Type t, QValueList<int> targets)
  : Table(env, 0, 0, "", parent, ""),
  d_base(base), d_type(t), d_targets(targets)
{
  worksheet->setReadOnly(true);
  setCaptionPolicy(myWidget::Both);
  if (d_type == row)
  {
    setName(QString(d_base->name())+"-"+tr("RowStats"));
    setWindowLabel(tr("Row Statistics of %1").arg(base->name()));
    resizeRows(d_targets.size());
    resizeCols(9);
    setColName(0, tr("Row"));
    setColName(1, tr("Cols"));
    setColName(2, tr("Mean"));
    setColName(3, tr("StandardDev"));
    setColName(4, tr("Variance"));
    setColName(5, tr("Sum"));
    setColName(6, tr("Max"));
    setColName(7, tr("Min"));
    setColName(8, "N");

    for (unsigned i=0; i < d_targets.size(); i++)
      setText(i, 0, QString::number(d_targets[i]+1));
    update(d_base, QString::null);
  }
  else if (d_type == column)
  {
    setName(QString(d_base->name())+"-"+tr("ColStats"));
    setWindowLabel(tr("Column Statistics of %1").arg(base->name()));
    resizeRows(d_targets.size());
    resizeCols(11);
    setColName(0, tr("Col"));
    setColName(1, tr("Rows"));
    setColName(2, tr("Mean"));
    setColName(3, tr("StandardDev"));
    setColName(4, tr("Variance"));
    setColName(5, tr("Sum"));
    setColName(6, tr("iMax"));
    setColName(7, tr("Max"));
    setColName(8, tr("iMin"));
    setColName(9, tr("Min"));
    setColName(10, "N");

    for (unsigned i=0; i < d_targets.size(); i++)
    {
      setText(i, 0, d_base->colLabel(d_targets[i]));
      update(d_base, d_base->colName(d_targets[i]));
    }
  }
  int w=9*(worksheet->horizontalHeader())->sectionSize(0);
  int h;
  if (tableRows()>11)
    h=11*(worksheet->verticalHeader())->sectionSize(0);
  else
    h=(tableRows()+1)*(worksheet->verticalHeader())->sectionSize(0);
  setGeometry(50,50,w + 45, h + 45);

  setColPlotDesignation(0, Table::X);
  setHeaderColType();
}