示例#1
0
/*!
    Returns an iterator pointing to the last document element inside the frame.

    \sa begin()
*/
QTextFrame::iterator QTextFrame::end() const
{
    const QTextDocumentPrivate *priv = docHandle();
    int b = priv->blockMap().findNode(firstPosition());
    int e = priv->blockMap().findNode(lastPosition()+1);
    return iterator(const_cast<QTextFrame *>(this), e, b, e);
}
/*!
    Returns a frame iterator pointing to the end of the table's cell.

    \sa begin()
*/
QTextFrame::iterator QTextTableCell::end() const
{
    QTextDocumentPrivate *p = table->docHandle();
    int b = p->blockMap().findNode(firstPosition());
    int e = p->blockMap().findNode(lastPosition()+1);
    return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
}
SimpleGridReader::SimpleGridReader(std::string filename, CartesianGrid3DIntegrator* m) 
    : filename(filename), model(m) 
{

    typedef CartesianGrid3D::Point Point;
    typedef CartesianGrid3D::Scalar Scalar;
    typedef CartesianGrid3D::Vector Vector;

    FILE* file=fopen(filename.c_str(), "rt");

    // initialize memory
    Point gridSpacing(1,1,1);
    Point firstPosition(0,0,0);
    std::vector<int> gridShape(3,1); // fill with ones

    // shape is first line, all integers
    fscanf(file, "%d %d %d", &gridShape[0], &gridShape[1], &gridShape[2]);
    std::cout << gridShape[0] << " " << gridShape[1] << " " << gridShape[2] << std::endl;

    boost::array<CartesianGrid3D::index, 3> shape = {{ 200, 200, 200 }};
    model->grid = new CartesianGrid3D::grid_type(shape);


//      Point gridSpacing(1,1,1);
//      Point firstPosition(-50,-50,-50);

      /** lorentz **/

      typedef CartesianGrid3D::index index;
      Scalar x,y,z;
      Scalar sigma = 10;
      Scalar r = 21;
      Scalar b = 2.6;
      for(index i = 0; i != shape[0]; ++i) 
      {
        x = firstPosition[0] + gridSpacing[0] * i;
        for(index j = 0; j != shape[1]; ++j)
        {
          y = firstPosition[1] + gridSpacing[1] * j;
          for(index k = 0; k != shape[2]; ++k)
          {
            z = firstPosition[2] + gridSpacing[2] * k;
            (*model->grid)[i][j][k] = Vector(sigma*(y-x), r*x-y-x*z, x*y-b*z);
          }
        }
      }  

    fclose(file);

      model->dynamics = new CartesianGrid3D(*model->grid, gridSpacing, firstPosition);
      double stepSize = 0.01;
      model->integrator = new RungeKutta4<CartesianGrid3D>(*(model->dynamics), stepSize);
}
示例#4
0
/*!
    Returns the first cursor position inside the frame.

    \sa lastCursorPosition() firstPosition() lastPosition()
*/
QTextCursor QTextFrame::firstCursorPosition() const
{
    Q_D(const QTextFrame);
    return QTextCursor(d->pieceTable, firstPosition());
}
/*!
    Returns the first valid cursor position in this cell.

    \sa lastCursorPosition()
*/
QTextCursor QTextTableCell::firstCursorPosition() const
{
    return QTextCursor(table->d_func()->pieceTable, firstPosition());
}