Esempio n. 1
0
void PrefAdvanced::getData(Preferences * pref) {
	requires_restart = false;
	clearing_background_changed = false;
	colorkey_changed = false;
	monitor_aspect_changed = false;

	if (pref->monitor_aspect != monitorAspect()) {
		pref->monitor_aspect = monitorAspect();
		monitor_aspect_changed = true;
		requires_restart = true;
	}

	if (pref->always_clear_video_background != clearBackground()) {
		pref->always_clear_video_background = clearBackground();
		clearing_background_changed = true;
    }

	TEST_AND_SET(pref->use_mplayer_window, useMplayerWindow());
	TEST_AND_SET(pref->mplayer_additional_options, mplayerAdditionalArguments());
	TEST_AND_SET(pref->mplayer_additional_video_filters, mplayerAdditionalVideoFilters());
	TEST_AND_SET(pref->mplayer_additional_audio_filters, mplayerAdditionalAudioFilters());
	if (pref->color_key != colorKey()) {
		pref->color_key = colorKey();
		colorkey_changed = true;
		requires_restart = true;
	}

	pref->log_mplayer = logMplayer();
	pref->log_smplayer = logSmplayer();
	pref->log_filter = logFilter();

	TEST_AND_SET(pref->rx_endoffile, endOfFileText());
	TEST_AND_SET(pref->rx_novideo, noVideoText());
}
Esempio n. 2
0
void initVGA()
{

	// Use the name of your pixel buffer DMA core
	pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma");

	unsigned int pixel_buffer_addr1 = PIXEL_BUFFER_BASE;
	unsigned int pixel_buffer_addr2 = PIXEL_BUFFER_BASE + (320*240*2);

	/* Set the background buffer address – Although we don’t use the
	background, they only provide a function to change the background
	buffer address, so we must set that, and then swap it to the foreground */
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr1);

	// Swap background and foreground buffers
	// Wait for the swap to complete
	updateVGA();

	//set the 2nd buffer address
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr2);

	// Clear both buffers (this makes all pixels black)
	clearForeground();
	clearBackground();

}
Esempio n. 3
0
void Main::cmdReceivedCB(const std_msgs::CharConstPtr & cmd)
{
  switch (cmd->data)
    {
    case 'b':
      clearBackground();
      break;
    case 'c':
      stopTracking();
      break;
    case 'l':
      toggleLearning();
      break;
    case 'a':
      alternatingMode();
      break;
    case 'e':
      exportModel();
      break;
    case 'i':
      importModel();
      break;
    case 'r':
      reset();
      break;
    case 'v':
      sendCenterView();
      break;
    default:
      break;
    }
}
Esempio n. 4
0
    //void Main::cmdReceivedCB(const std_msgs::CharConstPtr & cmd)
    void Main::cmdReceivedCB(const std_msgs::StringConstPtr & cmd)
    {
	  char cd=cmd->data.c_str()[0];
      //switch (cmd->data)
      switch (cd)
      {
        case 'b':
          clearBackground();
          break;
        case 'c':
          stopTracking();
          break;
        case 'l':
          toggleLearning();
          break;
        case 'a':
          alternatingMode();
          break;
        case 'e':
          exportModel();
          break;
        case 'i':
          importModel();
          break;
        case 'r':
          reset();
          break;
        default:
          break;
      }
    }
Esempio n. 5
0
void DrawWidget::beginDrawing(bool clearBackground_)
{
  checkSize();
  //p.begin(buffer, this);
  p.begin(paintDevice);
  //p.setRenderHint(QPainter::Antialiasing, false);
  //p.setRenderHint(QPainter::TextAntialiasing, false);
  //p.setRenderHint(QPainter::SmoothPixmapTransform, false);
#ifndef SINGLE_DRAWING_BUFFER
  p.initFrom(this);
#endif
  if(clearBackground_) clearBackground();
}
Esempio n. 6
0
void GLXGraphicsystem::renderSWLayers(LayerList layers, bool clear)
{
    // This is a stub.
    //
    // TODO: render in a more optimal way
    //   1. Turn off blending for first surface rendered
    //   2. Don't clear when it's legal to avoid it
    //         eg. a fullscreen opaque surface exists
    //   3. Render multiple surfaces at time via multi-texturing
    //   4. Remove fully obscured layers/surfaces
    if (clear)
    {
        clearBackground();
    }

    for (LayerListConstIterator layer = layers.begin(); layer != layers.end(); layer++)
    {
        renderSWLayer(*layer, false); // Don't clear
    }
}
Esempio n. 7
0
void GLXGraphicsystem::renderSWLayer(Layer *layer, bool clear)
{
    if (clear)
    {
        clearBackground();
    }

    if ( layer->visibility && layer->opacity > 0.0 )
    {
        SurfaceList surfaces = layer->getAllSurfaces();
        beginLayer(layer);
        for(SurfaceListConstIterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++)
        {
            if ((*currentS)->hasNativeContent() && (*currentS)->visibility && (*currentS)->opacity>0.0f)
            {
                renderSurface(*currentS);
            }
        }
        endLayer();
    }
}
Esempio n. 8
0
int main(int argc, char** argv)
{
    srand((unsigned int)time(NULL));

    gBallLock = SDL_CreateMutex();
    gRenderLock = SDL_CreateMutex();

    SDL_Init(SDL_INIT_VIDEO);
    gWnd = SDL_CreateWindow("Cannonball Marksman", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCR_W, SCR_H, SDL_WINDOW_SHOWN);
    gSurf = SDL_GetWindowSurface(gWnd);
    gRend = SDL_CreateRenderer(gWnd, -1, SDL_RENDERER_ACCELERATED);
    SimpleTimerClass timer;
    initBGTex();

    clearBackground();

    CannonBall ball = CannonBall(263860.0f, 2.0f, vec3f(10, 0, 1.0f), vec3f(100.0f, 0.0f, 66.0f), vec3f(0.0f, 0.0f, 0.0f));
    RopeBall rball = RopeBall(850000.0f, 8.0f, 80.0f, vec3f(600.0f, 0.0f, 300.0f));
    cannon = new Cannon(std::string("cannon.bmp"), vec3f(100, 0, 66));

    SDL_Thread* commandThreadID = SDL_CreateThread(commandHandler, "commandThread", (void*)&ball);


    while (!exitCond)
    {
        timer.update();
        rball.update((float)timer.deltaTime, wind);

        SDL_LockMutex(gBallLock);
        if (ball.launch == true)
        {
            Kollision(&ball, &rball); //Check if cannonball collides with pendulum(ropeBall)
            ball.update((float)timer.deltaTime, wind);
            if (length(ball.linVel) < 0.001f && ball.pos.z  - ball.radius < 0.01f && length(ball.fricForce) < 0.01f)
            {
                printf("The ball has stopped.\n");
                ball.launch = false;
            }
        }
        SDL_UnlockMutex(gBallLock);

        SDL_LockMutex(gRenderLock);

        clearBackground();
        rball.render();
        ball.render();
        cannon->render();
        SDL_RenderPresent(gRend);

        SDL_UnlockMutex(gRenderLock);

    }
    delete cannon;
    SDL_WaitThread(commandThreadID, NULL);
    SDL_DestroyMutex(gBallLock);
    SDL_DestroyMutex(gRenderLock);
    SDL_DestroyTexture(gBGTex);
    SDL_DestroyWindow(gWnd);
    SDL_DestroyRenderer(gRend);
    SDL_Quit();
    return 0;
}
Esempio n. 9
0
void cmdHelp(std::string* args, CannonBall* ball)
{
    if (args[0].compare("help") == 0)
    {
        printf("exit                Exits the program\n");
        printf("help                Lists available commands.\n");
        printf("printinfo           Prints velocity and force acting on the cannonball\n");
        printf("setlinvel x y z     Sets velocity of cannonball\n");
        printf("setangvel x y z     Sets angular velocity of ball\n");
        printf("setwind x y z       Sets wind velocity\n");
        printf("setmass m           Sets mass of cannonball\n");
        printf("setradius r         Sets radius of cannonball\n");
        printf("setpos x y z        Sets the position of the cannonball\n");
        printf("reset               Sets position, lin. velocity, ang. velocity and wind to 0.\n");
        printf("launch              Launches the ball\n");

    }
    else if (args[0].compare("printinfo") == 0)
    {
        ball->printInfo();
    }
    else if (args[0].compare("launch") == 0)
    {
        ball->launch = true;
    }
    else if (args[0].compare("setpos") == 0)
    {
        float x, y, z;
        set3f(x, y, z, args);
        ball->pos.x = x;
        ball->pos.y = y;
        ball->pos.z = z;
    }
    else if (args[0].compare("reset") == 0)
    {
        ball->pos = vec3f(10, 0, ball->radius);
        ball->linVel = vec3f(0, 0, 0);
        ball->launch = false;
        wind = vec3f(0, 0, 0);
        ball->angVel = vec3f(0, 0, 0);
    }
    else if (args[0].compare("setlinvel") == 0)
    {
        float x, y, z;
        set3f(x, y, z, args);
        ball->linVel.x = x;
        ball->linVel.y = y;
        ball->linVel.z = z;
        cannon->setDirection(ball->linVel);
    }
    else if (args[0].compare("setangvel") == 0)
    {
        float x, y, z;
        set3f(x, y, z, args);
        ball->angVel.x = x;
        ball->angVel.y = y;
        ball->angVel.z = z;
    }
    else if (args[0].compare("setwind") == 0)
    {
        float x, y, z;
        set3f(x, y, z, args);
        wind.x = x;
        wind.y = y;
        wind.z = z;
    }
    else if (args[0].compare("setmass") == 0)
    {
        float x = 0;
        x = stof(args[1]);
        if (x > EPSILON)
        {
            ball->mass = x;
            ball->gravForce = vec3f(0.0f, 0.0f, ball->mass * -1.0f * GRAVACC);
        }
        else
            printf("Mass too low\n");
    }
    else if (args[0].compare("setradius") == 0)
    {
        float x = 0;
        x = stof(args[1]);
        if (x > EPSILON)
        {
            ball->radius = x;
            ball->area = ball->radius * ball->radius * PI;
        }
        else
            printf("Radius too low\n");
    }
    else if (args[0].compare("clear") == 0)
    {
        SDL_LockMutex(gRenderLock);
        clearBackground();
        SDL_UnlockMutex(gRenderLock);
    }
    else
    {
        printf("Unrecognized command\n");
    }
}
Esempio n. 10
0
void CorrelationWidget::paintEvent( QPaintEvent * )
{
  Channel *active = gdata->getActiveChannel();

  AnalysisData *data = NULL;
  int chunk=0;
  double dh2 = double(height()-1) / 2.0;
  int j, x, y;
    
  beginDrawing(false);
    
  if(active) {
    
    active->lock();
    chunk = active->currentChunk();
    data = active->dataAtChunk(chunk);

    //int centerX = width() / 2;
    if(data) {
      double freq = data->getFundamentalFreq();
      double period = double(active->rate()) / freq;
      //double numPeriods = double(active->size()) / period;
      double scaleX = period * double(width()) / double(active->nsdfData.size()); //pixels per period
      
      //draw alternating background color indicating period
      if(gdata->view->backgroundShading() && period > 4.0 && period < double(active->nsdfData.size())) {
        int n = int(ceil(double(width()) / scaleX)); //number of colored patches
        p.setPen(Qt::NoPen);
        QColor color1 = colorBetween(gdata->backgroundColor(), gdata->shading1Color(), data->getCorrelation());
        QColor color2 = colorBetween(gdata->backgroundColor(), gdata->shading2Color(), data->getCorrelation());
        for(j = 0; j<n; j++) {
          x = toInt(scaleX*double(j));
          p.setBrush((j%2) ? color1 : color2);
          p.drawRect(x, 0, toInt(scaleX*double(j+1)) - toInt(scaleX*double(j)), height());
        }
        p.setPen(colorBetween(gdata->backgroundColor(), Qt::black, 0.3 * data->getCorrelation()));
        for(j = 0; j<n; j++) {
          x = toInt(scaleX*double(j));
          p.drawLine(x, 0, x, height());
        }
      } else {
        clearBackground();
      }
      QString numPeriodsText;
      numPeriodsText.sprintf("Period = %lf", period);
      p.setPen(Qt::black);
      p.drawText(5, height() - 8, numPeriodsText);
    } else {
      clearBackground();
    }
  } else {
    clearBackground();
  }

  //draw the horizontal center line
  p.setPen(QPen(colorBetween(colorGroup().background(), Qt::black, 0.3), 0));
  p.drawLine(0, toInt(dh2), width(), toInt(dh2));

  if(active) { 
    if(gdata->doingFreqAnalysis()) {
      int w = width() / 2; //only do every second pixel (for speed)
      //draw the waveform
      if(int(pointArray.size()) != w) pointArray.resize(w);
      if(lookup.size() != w) lookup.resize(w);

      NoteData *currentNote = active->getCurrentNote();
      Array1d<float> *input = &(active->nsdfData);
      if(currentNote) {
        if(aggregateMode == 1) input = &currentNote->nsdfAggregateData;
        else if(aggregateMode == 2) input = &currentNote->nsdfAggregateDataScaled;
      }
      //bresenham1d(*input, lookup);
      maxAbsDecimate1d(*input, lookup);
      for(int j=0; j<w; j++) {
        pointArray.setPoint(j, j*2, toInt(dh2 - lookup[j]*dh2));
      }

      p.setPen(QPen(active->color, 0));
      p.drawPolyline(pointArray);
    }
    if(data && (aggregateMode == 0)) {
      double ratio = double(width()) / double(active->nsdfData.size()); //pixels per index
      //float highest = active->nsdfData.at(data->highestCorrelationIndex);
      //float chosen = active->nsdfData.at(data->chosenCorrelationIndex);
      
      //draw a dot at all the period estimates
      p.setPen(Qt::blue);
      p.setBrush(Qt::blue);
      for(j=0; j<int(data->getPeriodEstimatesSize()); j++) {
        x = toInt(double(data->getPeriodEstimatesAt(j)) * ratio);
        y = toInt(dh2 - data->getPeriodEstimatesAmpAt(j) * dh2);
        p.drawEllipse(x-2, y-2, 5, 5);
      }
      
      if(data->getHighestCorrelationIndex() >= 0) {
        float highest = data->getPeriodEstimatesAmpAt(data->getHighestCorrelationIndex());
        //draw threshold line
        p.setPen(QPen(colorBetween(colorGroup().background(), Qt::black, 0.3), 0));
        y = toInt(dh2 - (highest * active->threshold()) * dh2);
        p.drawLine(0, y, width(), y);
      
        //draw a dot at the highest correlation period
        p.setPen(Qt::black);
        p.setBrush(Qt::black);
        //x = toInt(double(data->highestCorrelationIndex) * ratio);
        x = toInt(double(data->getPeriodEstimatesAt(data->getHighestCorrelationIndex())) * ratio);
        y = toInt(dh2 - highest * dh2);
        p.drawEllipse(x-2, y-2, 5, 5);
      }
      
      //draw a dot at the chosen correlation period
      if(data->getChosenCorrelationIndex() >= 0) {
        p.setPen(Qt::red);
        p.setBrush(Qt::red);
        //x = toInt(double(data->chosenCorrelationIndex) * ratio);
        //y = toInt(dh2 - chosen * dh2);
        x = toInt(double(data->getPeriodEstimatesAt(data->getChosenCorrelationIndex())) * ratio);
        y = toInt(dh2 - data->getPeriodEstimatesAmpAt(data->getChosenCorrelationIndex()) * dh2);
        p.drawEllipse(x-2, y-2, 5, 5);
      }

      //draw a line at the chosen correlation period
      if(data->getChosenCorrelationIndex() >= 0) {
        p.setPen(Qt::green);
        p.setBrush(Qt::green);
        //x = toInt(double(data->periodOctaveEstimate) * ratio);
        x = toInt(double(active->periodOctaveEstimate(chunk)) * ratio);
        p.drawLine(x, 0, x, height());
      }
    }
    
    active->unlock();
    
  }
  endDrawing();
}