Beispiel #1
0
void GLFont::drawText(int x, int y, const char *pszText)
{
    char prevCh = 0;
    char ch = 0;
    int dx = x;
    int dy = y;
    int charHeight = getCellHeight();
    int whitespaceWidth = getChar(' ').width;

    while (*pszText != '\0')
    {
        prevCh = ch;
        ch = *pszText++;

        if (ch == ' ')
        {
            if (prevCh != '\r')
                dx += whitespaceWidth;
        }
        else if (ch == '\n' || ch == '\r')
        {
            dx = x;
            dy += charHeight;
        }
        else if (ch == '\t')
        {
            dx += whitespaceWidth * TAB_SPACES;
        }
        else if (ch >= CHAR_FIRST && ch <= CHAR_LAST)
        {
            drawChar(ch, dx, dy);
            dx += getChar(ch).width;
        }
    }
}
Beispiel #2
0
void Mesh::computeTotCurrents(){

    MeshCell* meshCell;
    MeshSurface* surfaceSide;
    double sum_cur;

    int cell_width = getCellWidth();
    int cell_height = getCellHeight();

    /* loop over cells */
    for (int i = 0; i < cell_width*cell_height; i++){

        /* get mesh cell */
        meshCell = &_cells[i];

        /* loop over surfaces*/
        for (int i = 0; i < 4; i++){

            /* get mesh surface */
            surfaceSide = meshCell->getMeshSurfaces(i);

            /* set current tally to 0 */
            sum_cur = 0.0;

            /* loop over energy groups */
            for (int e = 0; e < NUM_ENERGY_GROUPS; e++){
                sum_cur += surfaceSide->getCurrent(e);
            }

            /* set current at group 0 to total current */
            surfaceSide->setCurrent(sum_cur,0);

        }
    }
}
Beispiel #3
0
void uiTextNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
	const int lineHeight = getCellHeight(node);
	const int deltaY = (mouseScrollY - y) / lineHeight;
	/* We're doing only vertical scroll, that's enough for the most instances */
	if (abs(mouseScrollY - y) >= lineHeight) {
		scrollY(node, deltaY);
		/* @todo not accurate */
		mouseScrollX = x;
		mouseScrollY = y;
	}
	onMouseMove(node, x, y);
}
void uiOptionListNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
	const int lineHeight = getCellHeight(node);
	const int deltaY = (mouseScrollY - y) / lineHeight;
	/* We're doing only vertical scroll, that's enough for the most instances */
	if (deltaY != 0) {
		bool updated;
		updated = EXTRADATA(node).scrollY.moveDelta(deltaY);
		if (EXTRADATA(node).onViewChange && updated)
			UI_ExecuteEventActions(node, EXTRADATA(node).onViewChange);
		/* @todo not accurate */
		mouseScrollX = x;
		mouseScrollY = y;
	}
	onMouseMove(node, x, y);
}
Beispiel #5
0
void Mesh::splitCornerQuadCurrents()
{
    MeshSurface* surfaceCorner;
    MeshSurface *surface1, *surface2, *surface_next1, *surface_next2;

    int cw = getCellWidth();
    int ch = getCellHeight();
    MeshCell *meshCell, *meshCellNext, *meshCellNext2; 
    double current;
    double f = 0.50; 

    int nq = 4; // number of quadrature currents. 
    int counter_j[] = {1, 0, 3, 2};

    for (int y = 0; y < ch; y++)
    {
        for (int x = 0; x < cw; x++)
        {
            int ii = y * cw + x;
            meshCell = &_cells[ii];

            for (int i = 0; i < 4; i++)
            {
                surfaceCorner = meshCell->getMeshSurfaces(i + 4);

                /* perform splitting inside of this cell: distribute
                 * evenly to the two surfaces surrounding the
                 * corner */
                surface1 = meshCell->getMeshSurfaces(_s1[i]);
                surface2 = meshCell->getMeshSurfaces(_s2[i]);

                for (int j = 0; j < nq; j++)
                {
                    for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                    {
                        current = f * surfaceCorner->getQuadCurrent(g, j);
                        surface1->incrementQuadCurrent(current, g, j);
                        surface2->incrementQuadCurrent(current, g, j);
                    }
                }

                /* effects on the neighboring cells */
                /* if left or right cell exists */
                if ((x > _min_x[i]) && (x < _max_x[i]))
                {
                    meshCellNext = &_cells[ii + _delta_x[i]];
                    surface_next1 = meshCellNext->getMeshSurfaces(_s_x[i]);
                   
                    for (int j = 0; j < nq; j++)
                    {
                        for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                        {
                            current = f * surfaceCorner->getQuadCurrent(g, j);
                            surface_next1->incrementQuadCurrent(current, g, j);
                        }
                    }
                } 
                /* only need to worry about this when reflective */
                else if (((x == _min_x[i]) && (_boundary[0] == REFLECTIVE)) 
                         || ((x == _max_x[i]) && (_boundary[2] == REFLECTIVE)))
                {
                    surface_next1 = meshCell->getMeshSurfaces(_s_x[i]);
                   
                    for (int j = 0; j < nq; j++)
                    {
                        for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                        {
                            current = f * surfaceCorner->getQuadCurrent(g, j);
                            surface_next1->incrementQuadCurrent
                                (current, g, counter_j[j]);
                        }
                    }
                }

                if ((y > _min_y[i]) && (y < _max_y[i])) 
                {
                    meshCellNext2 = &_cells[ii + _delta_y[i] * cw];
                    surface_next2 = meshCellNext2->getMeshSurfaces(_s_y[i]);

                    for (int j = 0; j < nq; j++)
                    {
                        for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                        {
                            current = f * surfaceCorner->getQuadCurrent(g, j);
                            surface_next2->incrementQuadCurrent(current, g, j);
                        }
                    }
                } 
                else if (((y == _min_y[i]) && (_boundary[3] == REFLECTIVE)) 
                         || ((y == _max_y[i]) && (_boundary[1] == REFLECTIVE)))
                {
                    surface_next2 = meshCell->getMeshSurfaces(_s_y[i]);
                    
                    for (int j = 0; j < nq; j++)
                    {
                        for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                        {
                            current = f * surfaceCorner->getQuadCurrent(g, j);
                            surface_next2->incrementQuadCurrent
                                (current, g, counter_j[j]);
                        }
                    }
                } 
            }
        }
    }
    return;
}
Beispiel #6
0
void Mesh::splitCornerCurrents()
{
    MeshSurface* surfaceCorner;
    MeshSurface *surface1, *surface2, *surface_x, *surface_y;

    int cw = getCellWidth();
    int ch = getCellHeight();
    MeshCell *meshCell, *meshCellNext, *meshCellNext2; 
    double currents[NUM_ENERGY_GROUPS];
    double f = 0.50;


    for (int y = 0; y < ch; y++)
    {
        for (int x = 0; x < cw; x++)
        {
            int ii = y * cw + x;
            meshCell = &_cells[ii];

            for (int i = 0; i < 4; i++)
            {
                surfaceCorner = meshCell->getMeshSurfaces(i + 4);
                for (int g = 0; g < NUM_ENERGY_GROUPS; g++)
                    currents[g] = f * surfaceCorner->getCurrent(g);

                /* perform splitting inside of this cell: distribute
                 * evenly to the two surfaces surrounding the corner */
                surface1 = meshCell->getMeshSurfaces(_s1[i]);
                surface2 = meshCell->getMeshSurfaces(_s2[i]);

                surface1->incrementCurrents(currents);
                surface2->incrementCurrents(currents);

                /* distributes on the neighboring cells, three
                 * posibilities: inner cells: distribute on
                 * neighboring cells; reflective boundaries: reflect
                 * in the current cell; vacuum boundaries: do nothing
                 * as the current just leaves the surface. */
                if ((x > _min_x[i]) && (x < _max_x[i]))
                {
                    meshCellNext = &_cells[ii + _delta_x[i]];
                    surface_x = meshCellNext->getMeshSurfaces(_s_x[i]);
                    surface_x->incrementCurrents(currents);
                }
                else if (((x == _min_x[i]) && (_boundary[0] == REFLECTIVE)) 
                         || ((x == _max_x[i]) && (_boundary[2] == REFLECTIVE)))
                {
                    meshCellNext = meshCell;
                    surface_x = meshCellNext->getMeshSurfaces(_s_x[i]);
                    surface_x->incrementCurrents(currents);
                }

                if ((y > _min_y[i]) && (y < _max_y[i])) 
                {
                    meshCellNext2 = &_cells[ii + _delta_y[i] * cw];
                    surface_y = meshCellNext2->getMeshSurfaces(_s_y[i]);
                    surface_y->incrementCurrents(currents);
                }
                else if (((y == _min_y[i]) && (_boundary[3] == REFLECTIVE)) 
                         || ((y == _max_y[i]) && (_boundary[1] == REFLECTIVE)))
                {
                    meshCellNext2 = meshCell;                    
                    surface_y = meshCellNext2->getMeshSurfaces(_s_y[i]);
                    surface_y->incrementCurrents(currents);
                }
            } 
        }
    }
    return;
}