Changeset cd6c317 in tol


Ignore:
Timestamp:
Jun 21, 2009, 5:12:55 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
a75504d
Parents:
e69e5c6
Message:

New arguments in FormatMatrix

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1108 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/text_type/txtgra.cpp

    re69e5c6 rcd6c317  
    16651665//--------------------------------------------------------------------
    16661666DeclareContensClass(BText, BTxtTemporary, BTxtFormatMatrix);
    1667 DefExtOpr(1, BTxtFormatMatrix, "FormatMatrix",    1, 3,
    1668           "Matrix Text Text",
    1669           I2("(Matrix M [, Text colSep=\";\", Text rowSep=NL])",
    1670              "(Matrix M [, Text colSep=\";\", Text rowSep=NL])"),
    1671           I2("Converts a matrix in text with a given format. If no format is"
    1672              " given, default format is used.",
    1673              "Convierte una matriz a texto con un formato dado. Si no se da"
    1674              " se utiliza el formato por defecto."),
     1667DefExtOpr(1, BTxtFormatMatrix, "FormatMatrix", 1, 6,
     1668    "Matrix Text Text Text Text Text", BText("")+
     1669          "(Matrix mat [, Text cellSep=\";\", Text rowSep=\"\\n\", "
     1670    "Text leftBracket=\"(\", Text rightBracket=\")\", "
     1671    "Text realFormat=\""+BDat::RealFormat()+"\"])",
     1672          I2("Converts a matrix in text with a given format. ",
     1673             "Convierte una matriz en texto con un formato dado"),
    16751674          BOperClassify::Conversion_);
     1675//--------------------------------------------------------------------
    16761676void BTxtFormatMatrix::CalcContens()
    16771677//--------------------------------------------------------------------
    16781678{
    1679     BMat        mat = Mat(Arg(1));
    1680     BText format = BDat::RealFormat();
    1681     BText colSep = ";";
    1682     BText rowSep = "\n";
    1683     if(Arg(2)) { colSep = Text(Arg(2)); }
    1684     if(Arg(3)) { rowSep = Text(Arg(3)); }
    1685     contens_ = "";
    1686     for(BInt i=0; i<mat.Rows(); i++)
     1679  BMat& mat = Mat(Arg(1));
     1680  BText cellSep = ",";
     1681  BText rowSep = "\n";
     1682  BText leftBracket = "(";
     1683  BText rightBracket = ")";
     1684  BText format = BDat::RealFormat();
     1685  if(Arg(2)) { cellSep = Text(Arg(2)); }
     1686  if(Arg(3)) { rowSep = Text(Arg(3)); }
     1687  if(Arg(4)) { leftBracket = Text(Arg(4)); }
     1688  if(Arg(5)) { rightBracket = Text(Arg(5)); }
     1689  if(Arg(6)) { format = Text(Arg(6)); }
     1690 
     1691  contens_ = leftBracket;
     1692  int i, j;
     1693  for(i=0; i<mat.Rows(); i++)
     1694  {
     1695    if(i>0) { contens_ += rowSep; }
     1696    contens_ += leftBracket;
     1697    for(j=0; j<mat.Columns(); j++)
    16871698    {
    1688         if(i>0) { contens_ += rowSep; }
    1689         for(BInt j=0; j<mat.Columns(); j++)
    1690         {
    1691             if(j>0) { contens_ += colSep; }
    1692             contens_ += mat(i,j);
    1693         }
     1699      if(j>0) { contens_ += cellSep; }
     1700      contens_ += mat(i,j).Format(format);     
    16941701    }
     1702    contens_ += rightBracket;
     1703  }
     1704  contens_ += rightBracket;
    16951705}
    16961706
Note: See TracChangeset for help on using the changeset viewer.