Пример #1
0
/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void canimxy3d(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, block->inptr[0], block->inptr[1], block->inptr[2]);
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
Пример #2
0
int Chessboard::checkChessboardField(int x, int y)
{
    if (getFigure(x, y)->getID() == 0)
        return 0;
    else if (getFigure(x, y)->getColor() == 0)
        return RED;
    else
        return BLACK;
}
Пример #3
0
/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cscopxy3d(scicos_block * block, scicos_flag flag)
{
    int iFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
            }
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
            }
            break;

        case StateUpdate:
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, GetRealInPortPtrs(block, 1), GetRealInPortPtrs(block, 2), GetRealInPortPtrs(block, 3));
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
Пример #4
0
/** \fn void cmatview(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cmatview(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    double *u;
    sco_data *sco;

    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            u = GetRealInPortPtrs(block, 1);

            result = pushData(block, u);
            if (result == FALSE)
            {
                Coserror("%s: unable to push some data.", "cmatview");
                break;
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
Пример #5
0
shared_ptr< IInplaceEditor > TextEditPart::queryInplaceEditor(const Point& point)
{
	if (selected_ && getFigure()->getOutlineRect().contains (point))
	{
		shared_ptr< LabelFigure > label_figure = dynamic_pointer_cast< LabelFigure >(getFigure());
		
		return shared_ptr< IInplaceEditor >( 
			new TextInplaceEditor( label_figure ) );
	}
	
	return shared_ptr< IInplaceEditor >();
}
Пример #6
0
void TextEditPart::onModelTextChanged()
{
	shared_ptr< LabelFigure > label_figure = dynamic_pointer_cast< LabelFigure >(getFigure());
	shared_ptr< TextShape > text_shape = dynamic_pointer_cast< TextShape >(getModel());

	label_figure->setText (text_shape->getText());
}
Пример #7
0
static BOOL setPolylinesBounds(scicos_block * block, int input, int periodCounter)
{
    char const* pFigureUID;
    char *pAxeUID;

    double dataBounds[6];
    int nin = block->nin;
    double period = block->rpar[block->nrpar - 3 * nin + input];

    dataBounds[0] = periodCounter * period; // xMin
    dataBounds[1] = (periodCounter + 1) * period;   // xMax
    dataBounds[2] = block->rpar[block->nrpar - 2 * nin + 2 * input];    // yMin
    dataBounds[3] = block->rpar[block->nrpar - 2 * nin + 2 * input + 1];    // yMax
    dataBounds[4] = -1.0;       // zMin
    dataBounds[5] = 1.0;        // zMax

#ifndef S_SPLINT_S
    LOG("%s: %s at %d to %f\n", "cmscope", "setPolylinesBounds", input, dataBounds[1]);
#endif /* !S_SPLINT_S */

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block, input);

    return setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
}
Пример #8
0
static BOOL setSegsBuffers(scicos_block * block, int maxNumberOfPoints)
{
    int iFigureUID;
    int iAxeUID;
    int iSegsUID;

    int i;
    int nclk = block->nipar - 6;
    BOOL result = TRUE;

    int color;

    iFigureUID = getFigure(block);
    iAxeUID = getAxe(iFigureUID, block);
    for (i = 0; i < nclk; i++)
    {
        iSegsUID = getSegs(iAxeUID, block, i);
        result = setGraphicObjectProperty(iSegsUID, __GO_NUMBER_ARROWS__, &maxNumberOfPoints, jni_int, 1);

        /*
         * Update color due to bug #9902
         * http://bugzilla.scilab.org/show_bug.cgi?id=9902
         */
        color = block->ipar[2 + i];
        if (color > 0)
        {
            setGraphicObjectProperty(iSegsUID, __GO_SEGS_COLORS__, &color, jni_int_vector, 1);
        }
    }

    return result;
}
Пример #9
0
static BOOL setPolylinesBounds(scicos_block * block)
{
    char const* pFigureUID;
    char *pAxeUID;

    BOOL result;
    double dataBounds[6];
    double rotationAngle[2];

    dataBounds[0] = block->rpar[0]; // xMin
    dataBounds[1] = block->rpar[1]; // xMax
    dataBounds[2] = block->rpar[2]; // yMin
    dataBounds[3] = block->rpar[3]; // yMax
    dataBounds[4] = block->rpar[4]; // zMin
    dataBounds[5] = block->rpar[5]; // zMax

    rotationAngle[0] = block->rpar[6];  // alpha
    rotationAngle[1] = block->rpar[7];  // theta

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);

    result = setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
    result &= setGraphicObjectProperty(pAxeUID, __GO_ROTATION_ANGLES__, rotationAngle, jni_double_vector, 2);

    return result;
}
Пример #10
0
bool Board::move(const char* from,const char* to )
{

	unsigned int fromX = from[1] - '1';
	unsigned int fromY = from[0] - 'a';
	unsigned int toX = to[1] - '1';
	unsigned int toY = to[0] - 'a';
	
	Figure* figure = getFigure(Position(fromX, fromY));
	if (figure == NULL) {
		return false;
	}

	if (figure->figureColor != moveTurn) {
		return false;
	}

	if (figure->move(Position(toX, toY))) {

		//change turn
		moveTurn = !moveTurn;

		return true;
	} else {
		return false;
	}
}
Пример #11
0
static BOOL setPolylinesBuffers(scicos_block * block, int input, int maxNumberOfPoints)
{
    int i;

    char const* pFigureUID;
    char *pAxeUID;
    char *pPolylineUID;

    BOOL result = TRUE;
    int polylineSize[2] = { 1, maxNumberOfPoints };

#ifndef S_SPLINT_S
    LOG("%s: %s at %d to %d\n", "cmscope", "setPolylinesBuffers", input, maxNumberOfPoints);
#endif /* !S_SPLINT_S */

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block, input);

    for (i = 0; i < block->insz[input]; i++)
    {
        pPolylineUID = getPolyline(pAxeUID, block, input, i);
        result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, polylineSize, jni_int_vector, 2);
    }

    return result;
}
Пример #12
0
static BOOL pushData(scicos_block * block, int input, int row)
{
    char const* pFigureUID;
    char *pAxeUID;
    char *pPolylineUID;

    double *data;
    sco_data *sco;

    BOOL result = TRUE;

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block, input);
    pPolylineUID = getPolyline(pAxeUID, block, input, row);

    sco = getScoData(block);
    if (sco == NULL)
        return FALSE;


    // select the right input and row
    data = sco->internal.data[input][row];

    result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_X__, sco->internal.time[input], jni_double_vector, sco->internal.maxNumberOfPoints[input]);
    result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_Y__, data, jni_double_vector, sco->internal.maxNumberOfPoints[input]);

    return result;
}
Пример #13
0
int main(int argc, char const *argv[])
{
	unsigned int number, base;
	int i, k;

	printf("please input your original number:");
	scanf("%u", &number);
	//printf("%u\n", number);
	printf("please input your base:");
	scanf("%u", &base);
	k = getNumber(number, base);
	while (k >= 0)
		printf("%c", getFigure(output[k--]));
	putchar('\n');
	return 0;
}
Пример #14
0
static BOOL pushData(scicos_block * block, double *data)
{
    char const* pFigureUID;
    char *pAxeUID;
    char *pGrayplotUID;

    BOOL result;
    int i;

    int m, n;
    double alpha, beta;
    double *scaledData;

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);
    pGrayplotUID = getGrayplot(pAxeUID, block);

    m = GetInPortSize(block, 1, 1);
    n = GetInPortSize(block, 1, 2);
    if (m * n <= 0)
    {
        set_block_error(-5);
        return FALSE;
    }

    /*
     * Scale the data
     */
    alpha = block->rpar[0];
    beta = block->rpar[1];

    scaledData = (double *)MALLOC(m * n * sizeof(double));
    if (scaledData == NULL)
    {
        return FALSE;
    }

    for (i = 0; i < m * n; i++)
    {
        scaledData[i] = floor(alpha * data[i] + beta);
    }

    result = setGraphicObjectProperty(pGrayplotUID, __GO_DATA_MODEL_Z__, scaledData, jni_double_vector, m * n);
    FREE(scaledData);

    return result;
}
Пример #15
0
void TextEditPart::onLabelTextApplied()
{
	shared_ptr< LabelFigure > label_figure = dynamic_pointer_cast< LabelFigure >(getFigure());
	shared_ptr< TextShape > text_shape = dynamic_pointer_cast< TextShape >(getModel());
	
	shared_ptr< DiagramEditPart > diagram_edit_part = DiagramEditPart::queryDiagramFromChild (shared_from_this());
	
	if (diagram_edit_part)
	{
		shared_ptr< EditTextCommand > cmd( new EditTextCommand(
			dynamic_pointer_cast< Diagram >(diagram_edit_part->getModel()),
			text_shape,
			label_figure->getText()) );
		
		CommandManager::getInstance()->execute (cmd);
	}
}
Пример #16
0
static BOOL setPolylinesBounds(scicos_block * block)
{
    char const* pFigureUID;
    char *pAxeUID;

    double dataBounds[6];

    dataBounds[0] = block->rpar[0]; // xMin
    dataBounds[1] = block->rpar[1]; // xMax
    dataBounds[2] = block->rpar[2]; // yMin
    dataBounds[3] = block->rpar[3]; // yMax
    dataBounds[4] = -1.0;       // zMin
    dataBounds[5] = 1.0;        // zMax

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);

    return setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
}
Пример #17
0
void wxhdCompositeFigureTool::mouseDown(wxhdMouseEvent& event)
{
	int x=event.GetPosition().x, y=event.GetPosition().y;
	wxhdCompositeFigure *cfigure = (wxhdCompositeFigure*) getFigure();
	wxhdIFigure *figure = cfigure->findFigure(x,y);
	
	if(figure)
	{
		setDelegateTool(figure->CreateFigureTool(getDrawingEditor(),getDefaultTool()));
	}
	else
	{
		setDelegateTool(getDefaultTool());
	}

	if(delegateTool)
	{
		delegateTool->mouseDown(event);
	}
}
Пример #18
0
static BOOL pushData(scicos_block * block, double *data)
{
    int iFigureUID;
    int iAxeUID;
    int iPlot3dUID;

    BOOL result;

    int m, n;

    iFigureUID = getFigure(block);
    iAxeUID = getAxe(iFigureUID, block);
    iPlot3dUID = getPlot3d(iAxeUID, block);

    m = GetInPortSize(block, 1, 1);
    n = GetInPortSize(block, 1, 2);

    result = setGraphicObjectProperty(iPlot3dUID, __GO_DATA_MODEL_Z__, data, jni_double_vector, m * n);

    return result;
}
Пример #19
0
static BOOL pushData(scicos_block * block, double *data)
{
    char const* pFigureUID;
    char *pAxeUID;
    char *pPlot3dUID;

    BOOL result;

    int m, n;

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);
    pPlot3dUID = getPlot3d(pAxeUID, block);

    m = GetInPortSize(block, 1, 1);
    n = GetInPortSize(block, 1, 2);

    result = setGraphicObjectProperty(pPlot3dUID, __GO_DATA_MODEL_Z__, data, jni_double_vector, m * n);

    return result;
}
Пример #20
0
static BOOL pushData(scicos_block * block, int input)
{
    int iFigureUID;
    int iAxeUID;
    int iSegsUID;

    int dataLen;
    double *base;
    double *direction;
    sco_data *sco;

    BOOL result;

    iFigureUID = getFigure(block);
    iAxeUID = getAxe(iFigureUID, block);
    iSegsUID = getSegs(iAxeUID, block, input);

    sco = getScoData(block);
    if (sco == NULL)
    {
        return FALSE;
    }

    // select the right input and row
    base = sco->internal.data[2 * input];
    direction = sco->internal.data[2 * input + 1];

    dataLen = 3 * sco->internal.maxNumberOfPoints[input];

    result = setGraphicObjectProperty(iSegsUID, __GO_BASE__, base, jni_double_vector, dataLen);
    if (result == FALSE)
    {
        return result;
    }
    result = setGraphicObjectProperty(iSegsUID, __GO_DIRECTION__, direction, jni_double_vector, dataLen);

    return result;
}
Пример #21
0
static BOOL pushData(scicos_block * block, int row)
{
    char const* pFigureUID;
    char *pAxeUID;
    char *pPolylineUID;

    double *coordinates;
    sco_data *sco;

    pFigureUID = getFigure(block);
    pAxeUID = getAxe(pFigureUID, block);
    pPolylineUID = getPolyline(pAxeUID, block, row);

    sco = getScoData(block);
    if (sco == NULL)
    {
        return FALSE;
    }

    // select the right input and row
    coordinates = sco->internal.coordinates[row];

    return setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_COORDINATES__, coordinates, jni_double_vector, sco->internal.maxNumberOfPoints);
}
Пример #22
0
static void appendData(scicos_block * block, int input, double t)
{
    sco_data *sco = getScoData(block);
    int maxNumberOfPoints = sco->internal.maxNumberOfPoints[input];
    int numberOfPoints = sco->internal.numberOfPoints[input];

    int i;
    int nclk = block->nipar - 6;

    /*
     * Handle the case where the t is greater than the data_bounds
     */
    if (t > ((sco->scope.periodCounter + 1) * block->rpar[0]))
    {
        sco->scope.periodCounter++;

        // reset the number of points for all the segs
        numberOfPoints = 0;
        for (i = 0; i < nclk; i++)
        {
            sco->internal.numberOfPoints[i] = 0;
        }
        if (setBounds(block, getAxe(getFigure(block), block), sco->scope.periodCounter) == FALSE)
        {
            set_block_error(-5);
            freeScoData(block);
            sco = NULL;
        }
    }

    /*
     * Handle the case where the scope has more points than maxNumberOfPoints
     */
    if (sco != NULL && numberOfPoints >= maxNumberOfPoints)
    {
        // on a full scope, re-alloc
        maxNumberOfPoints = maxNumberOfPoints + DEFAULT_MAX_NUMBER_OF_POINTS;
        sco = reallocScoData(block, input, maxNumberOfPoints);

        // reconfigure related graphic objects
        if (setSegsBuffers(block, maxNumberOfPoints) == FALSE)
        {
            set_block_error(-5);
            freeScoData(block);
            sco = NULL;
        }
    }

    /*
     * Update data
     */
    if (sco != NULL)
    {
        int setLen;

        /*
         * Base pointer
         */
        for (setLen = maxNumberOfPoints - numberOfPoints - 1; setLen >= 0; setLen--)
        {
            sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 0] = t;   // x
            sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 1] = 0;   // y
            sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 2] = (double) input;   // z
        }

        /*
         * Direction pointer
         */
        for (setLen = maxNumberOfPoints - numberOfPoints - 1; setLen >= 0; setLen--)
        {
            sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 0] = t;   // x
            sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 1] = 0.8; // y
            sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 2] = (double) input;   // z
        }

        sco->internal.numberOfPoints[input]++;
    }
}
Пример #23
0
/** \fn void cscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cevscpe(scicos_block * block, scicos_flag flag)
{
    int iFigureUID;

    double t;
    int i;
    int mask;
    int nclk = block->nipar - 6;
    sco_data *sco;

    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
            }
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            setSegsBuffers(block, DEFAULT_MAX_NUMBER_OF_POINTS);
            break;

        case StateUpdate:
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            t = get_scicos_time();

            // select only the masked indexes
            for (i = 0; i < nclk; i++)
            {
                mask = 1 << i;
                if ((block->nevprt & mask) == mask)
                {
                    appendData(block, i, t);

                    result = pushData(block, i);
                    if (result == FALSE)
                    {
                        Coserror("%s: unable to push some data.", "cevscpe");
                        break;
                    }
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
Пример #24
0
/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    double t;
    double *u;
    sco_data *sco;

    int i, j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            t = get_scicos_time();
            for (i = 0; i < block->nin; i++)
            {
                u = (double *)block->inptr[i];

                appendData(block, i, t, u);
                for (j = 0; j < block->insz[i]; j++)
                {
                    result = pushData(block, i, j);
                    if (result == FALSE)
                    {
                        Coserror("%s: unable to push some data.", "cmscope");
                        break;
                    }
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}