Пример #1
0
// back-end
int
GetMoveIndexFromPoint (int x, int y)
{
    int result = -1;
    int start_x = MarginX + MarginW;
    VisualizationData vd;

    if( x >= start_x && InitVisualization( &vd ) ) {
        /* Almost an hack here... we duplicate some of the paint logic */
        if( vd.hist_width < MIN_HIST_WIDTH ) {
            double step;

            vd.hist_count -= vd.hist_count % 8;
            vd.hist_count += 8;
            vd.hist_count /= 2;

            step = (double) vd.paint_width / (vd.hist_count + 1);
            step /= 2;

            result = (int) (0.5 + (double) (x - start_x) / step);
        }
        else {
            result = (x - start_x) / vd.hist_width;
        }
    }

    if( result >= currLast ) {
        result = -1;
    }

    return result;
}
Пример #2
0
// back-end
static void
DrawHistograms ()
{
    VisualizationData vd;
    int i; double step = 1;

    if( InitVisualization( &vd ) ) {
        if( vd.hist_width < MIN_HIST_WIDTH ) {
            DrawHistogramAsDiagram( vd.cy, vd.paint_width, vd.hist_count );
            step = 0.5*vd.paint_width / (((vd.hist_count | 7) + 1)/2 + 1.);
        }
        else {
            DrawHistogramFull( vd.cy, step = vd.hist_width, vd.hist_count );
        }
    }
    if(!differentialView) return;
    differentialView = 0;
    DrawSegment( MarginX + MarginW, vd.cy, NULL, NULL, PEN_NONE );
    for( i=0; i<vd.hist_count; i++ ) {
        int index = currFirst + i;
        int x = MarginX + MarginW + index * step + step/2;
        DrawSegment((int) x, GetValueY( GetPvScore(index) ), NULL, NULL, PEN_ANY );
    }
    differentialView = 1;
}
Пример #3
0
// back-end
static void
DrawHistograms ()
{
    VisualizationData vd;

    if( InitVisualization( &vd ) ) {
        if( vd.hist_width < MIN_HIST_WIDTH ) {
            DrawHistogramAsDiagram( vd.cy, vd.paint_width, vd.hist_count );
        }
        else {
            DrawHistogramFull( vd.cy, vd.hist_width, vd.hist_count );
        }
    }
}
Пример #4
0
 void CSimulator::Init() {
    /* General configuration */
    InitFramework(GetNode(m_tConfigurationRoot, "framework"));
    /* Initialize controllers */
    InitControllers(GetNode(m_tConfigurationRoot, "controllers"));
    /* Create loop functions */
    if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
       /* User specified a loop_functions section in the XML */
       InitLoopFunctions(GetNode(m_tConfigurationRoot, "loop_functions"));
    }
    else {
       /* No loop_functions in the XML */
       m_pcLoopFunctions = new CLoopFunctions;
    }
    /* Physics engines */
    InitPhysics(GetNode(m_tConfigurationRoot, "physics_engines"));
    /* Media */
    InitMedia(GetNode(m_tConfigurationRoot, "media"));
    /* Space */
    InitSpace(GetNode(m_tConfigurationRoot, "arena"));
    /* Call user init function */
    if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
       m_pcLoopFunctions->Init(GetNode(m_tConfigurationRoot, "loop_functions"));
    }
    /* Physics engines */
    InitPhysics2();
    /* Media */
    InitMedia2();
    /* Initialise visualization */
    TConfigurationNodeIterator itVisualization;
    if(NodeExists(m_tConfigurationRoot, "visualization") &&
       ((itVisualization = itVisualization.begin(&GetNode(m_tConfigurationRoot, "visualization"))) != itVisualization.end())) {
       InitVisualization(GetNode(m_tConfigurationRoot, "visualization"));
    }
    else {
       LOG << "[INFO] No visualization selected." << std::endl;
       m_pcVisualization = new CDefaultVisualization();
    }
    /* Start profiling, if needed */
    if(IsProfiling()) {
       m_pcProfiler->Start();
    }
 }