Logo Search packages:      
Sourcecode: gaia version File versions  Download package

void GPSLayer::Overdraw ( Region rgn  )  [virtual]

Render layer data as region

Parameters:
rgn region to render
This function is similar to MasterLayer::RenderRegion, and is called when slave layer has OVERDRAW capability set.

Reimplemented from SlaveLayer.

Definition at line 126 of file GPSLayer.cc.

References Hud::AddObject(), Timer::GetTime(), Timer::Instance(), m_Entities, Region::v, Region::w, Vector3< T >::x, Vector2< T >::x, Vector3< T >::y, Vector2< T >::y, and Vector3< T >::z.

                                   {
      double model[16];
      double proj[16];
      int view[4];

      glGetDoublev(GL_PROJECTION_MATRIX, proj);
      glGetDoublev(GL_MODELVIEW_MATRIX, model);
      glGetIntegerv(GL_VIEWPORT, view);

      /* draw all entities */
      for (std::vector<GPSEntity*>::iterator i = m_Entities.begin(); i < m_Entities.end(); i++) {
            pthread_mutex_lock(&(*i)->datamutex);
            int valid = Timer::Instance()->GetTime() - (*i)->lastupdate < DATA_ROT_TIME;
            for (std::vector<GPSData>::iterator d = (*i)->data.begin(); d < (*i)->data.end(); d++) {
                  double x = (*d).longitude;
                  double y = (*d).latitude;

                  if (x >= rgn->w[0].x && x < rgn->w[1].x && y >= rgn->w[0].y && y < rgn->w[1].y) {
                        double xk = (x - rgn->w[0].x)/(rgn->w[1].x - rgn->w[0].x);
                        double yk = (y - rgn->w[0].y)/(rgn->w[1].y - rgn->w[0].y);

                        Vector3d v = rgn->v[0]*(1.0-xk)*(1.0-yk) + rgn->v[1]*xk*(1.0-yk) + rgn->v[2]*xk*yk + rgn->v[3]*(1.0-xk)*yk;
                        Vector3d p; // projected

                        gluProject(v.x, v.y, v.z, model, proj, view, &p.x, &p.y, &p.z);

                        p.x += 0.5;
                        p.y += 0.5;

                        if (d + 1 == (*i)->data.end()) {
                              if (valid)  Hud::Instance()->AddObject(ICON_GPS_POSITION((int)p.x, (int)p.y, 100));
                              else        Hud::Instance()->AddObject(ICON_GPS_POSITION_INVALID((int)p.x, (int)p.y, 100));
                        } else
                              Hud::Instance()->AddObject(ICON_GPS_POINT((int)p.x, (int)p.y, 99));
                  }
            }
            pthread_mutex_unlock(&(*i)->datamutex);
      }
}


Generated by  Doxygen 1.6.0   Back to index