Exemplo n.º 1
0
int main()
{

    fprintf(stderr, "Running smug VBO test. Switch rendering mode with F1 and F2\n");
    
    Graphics_init();
   
    generateLayers();

    double time = glfwGetTime();
    double lastfps = time;
    int fps = 0;
    int rendermode = 0;

    while(!done)
    {
        time = glfwGetTime();
    
        if (glfwGetKey(GLFW_KEY_ESC))
        {
            done = 1;
        }
        if (glfwGetKey(GLFW_KEY_F1))
        {
            fprintf(stderr, "Rendermode: immediate\n");
            rendermode = 0;
        }
        if (glfwGetKey(GLFW_KEY_F2))
        {
            fprintf(stderr, "Rendermode: retained\n");
            rendermode = 1;
        }    
        
        
        if (rendermode)
            renderRetained();
        else
            renderImmediate();
    
        fps++;
        if (time - lastfps >= 1.0)
        {
            fprintf(stderr, "FPS: %i, objects: %i\n", (int)((double)fps /(time-lastfps)), LAYERS*BOXES);
            fps = 0;
            lastfps += 1.0;
        }
        glfwSwapBuffers();
    }

    glfwTerminate();
    
    fprintf(stderr, "Done.\n");
    
    return 0;
}
Exemplo n.º 2
0
void terrama2::services::view::core::Service::viewJob(const terrama2::core::ExecutionPackage& executionPackage,
                                                      std::shared_ptr<ViewLogger> logger,
                                                      std::weak_ptr<DataManager> weakDataManager)
{
  auto dataManager = weakDataManager.lock();

  if(!dataManager.get())
  {
    TERRAMA2_LOG_ERROR() << QObject::tr("Unable to access DataManager");
    notifyWaitQueue(executionPackage.processId);
    sendProcessFinishedSignal(executionPackage.processId, executionPackage.executionDate, false);
    return;
  }

  RegisterId logId = executionPackage.registerId;
  ViewId viewId = executionPackage.processId;
  std::string viewName = "";

  QJsonObject jsonAnswer;

  try
  {
    TERRAMA2_LOG_DEBUG() << QObject::tr("Starting view %1 generation.").arg(viewId);

    auto mapsServer = MapsServerFactory::getInstance().make(mapsServerUri_, "GEOSERVER");

    /////////////////////////////////////////////////////////////////////////
    //  aquiring metadata

    auto lock = dataManager->getLock();

    auto viewPtr = dataManager->findView(viewId);

    viewName = viewPtr->viewName;

    terrama2::core::DataSeriesPtr inputDataSeries = dataManager->findDataSeries(viewPtr->dataSeriesID);
    terrama2::core::DataProviderPtr inputDataProvider = dataManager->findDataProvider(inputDataSeries->dataProviderId);

    lock.unlock();

    /////////////////////////////////////////////////////////////////////////

    auto processingStartTime = terrama2::core::TimeUtils::nowUTC();

    QJsonObject mapsServerAnswer = mapsServer->generateLayers(viewPtr,
                                                              inputDataSeries,
                                                              inputDataProvider,
                                                              dataManager,
                                                              logger,
                                                              logId);

    TERRAMA2_LOG_INFO() << tr("View %1(%2) generated successfully.").arg(QString::fromStdString(viewName)).arg(viewId);

    auto processingEndTime = terrama2::core::TimeUtils::nowUTC();

    logger->setStartProcessingTime(processingStartTime, executionPackage.registerId);
    logger->setEndProcessingTime(processingEndTime, executionPackage.registerId);

    logger->result(ViewLogger::Status::DONE, terrama2::core::TimeUtils::nowUTC(), logId);

    jsonAnswer = mapsServerAnswer;
    jsonAnswer.insert("class", QString("RegisteredViews"));
    jsonAnswer.insert("process_id",static_cast<int32_t>(viewPtr->id));
    jsonAnswer.insert("maps_server", QString::fromStdString(mapsServerUri_.uri()));

    sendProcessFinishedSignal(viewId, executionPackage.executionDate, true, jsonAnswer);
    notifyWaitQueue(viewId);

    return;
  }
  catch(const terrama2::core::LogException& e)
  {
    auto error = boost::get_error_info<terrama2::ErrorDescription>(e);
    std::string errMsg;
    if(error)
    {
      errMsg = error->toStdString();
      TERRAMA2_LOG_ERROR() << errMsg;
    }
    else
    {
      TERRAMA2_LOG_ERROR() << QObject::tr("Error logging view build error.");
    }
    TERRAMA2_LOG_INFO() << QObject::tr("Build of view %1(%2) finished with error(s).").arg(QString::fromStdString(viewName)).arg(viewId);
  }
  catch(const terrama2::Exception& e)
  {
    auto error = boost::get_error_info<terrama2::ErrorDescription>(e);
    std::string errMsg;
    if(error)
    {
      errMsg = error->toStdString();
      TERRAMA2_LOG_ERROR() << errMsg;
    }
    else
    {
      TERRAMA2_LOG_ERROR() << QObject::tr("Error logging view build error.");
    }
    TERRAMA2_LOG_INFO() << QObject::tr("Build of view %1(%2) finished with error(s).").arg(QString::fromStdString(viewName)).arg(viewId);

    if(logId != 0)
      logger->log(ViewLogger::MessageType::ERROR_MESSAGE, errMsg, logId);
  }
  catch(const boost::exception& e)
  {
    auto error = boost::get_error_info<terrama2::ErrorDescription>(e);
    std::string errMsg;
    if(error)
    {
      errMsg = error->toStdString();
      TERRAMA2_LOG_ERROR() << errMsg;
    }
    else
    {
      TERRAMA2_LOG_ERROR() << QObject::tr("Error logging view build error.");
    }
    TERRAMA2_LOG_INFO() << QObject::tr("Build of view %1(%2) finished with error(s).").arg(QString::fromStdString(viewName)).arg(viewId);

    if(logId != 0)
      logger->log(ViewLogger::MessageType::ERROR_MESSAGE, errMsg, logId);
  }
  catch(const std::exception& e)
  {
    std::string errMsg = e.what();
    TERRAMA2_LOG_ERROR() << errMsg;
    TERRAMA2_LOG_INFO() << QObject::tr("Build of view %1(%2) finished with error(s).").arg(QString::fromStdString(viewName)).arg(viewId);

    if(logId != 0)
      logger->log(ViewLogger::MessageType::ERROR_MESSAGE, errMsg, logId);
  }
  catch(...)
  {
    std::string errMsg = "Unknown error.";
    TERRAMA2_LOG_ERROR() << QObject::tr("Unknown error.");
    TERRAMA2_LOG_INFO() << QObject::tr("Build of view %1(%2) finished with error(s).").arg(QString::fromStdString(viewName)).arg(viewId);

    if(logId != 0)
      logger->log(ViewLogger::MessageType::ERROR_MESSAGE, errMsg, logId);
  }

  if(logId != 0)
    logger->result(ViewLogger::Status::ERROR, terrama2::core::TimeUtils::nowUTC(), logId);

  sendProcessFinishedSignal(viewId, executionPackage.executionDate, false);
  notifyWaitQueue(viewId);
}