Example #1
0
  Cities ()  :  DataSet ()
    { Load ("data/cities/geonames_cities5000.txt");

      city_name = StrColumn   (0);
      latitude  = FloatColumn (1);
      longitude = FloatColumn (2);

      LoadShaders ("shaders/foggy.vert", "shaders/null.frag");

      for (int64 i = 0  ;  i < Count ()  ;  i++)
        { Vect globe_position = LatLongToSphereSurface (GLOBE_RADIUS,
                                                        latitude[i],
                                                        longitude[i]);
          SetPointLocation (i, globe_position.x,
                               globe_position.y,
                               globe_position.z);

          // INFORM ( city_name[i] + ", "
          //        + ToStr (longitude[i]) + ", "
          //        + ToStr (latitude[i]) );

          SetPointColor (i, HSB (0.12, 0.2, 1.0, 1.0));
          SetPointSize (i, 2.0);
        }
      DataReady ();
    }
// ------------------------------------------------------------------------
void PointPicker::OnMouseMove()
{
    // if not moving we can do default behavoiur
    if(!isMoving)
    {
        return;
    }

    SetPointLocation();



}
// ------------------------------------------------------------------------
void PointPicker::OnLeftButtonDown()
{
    int * clickPos = this->GetInteractor()->GetEventPosition();

    // get the xyz at this location
    pointPicker->Pick(clickPos[0], clickPos[1], 0, this->currentRenderer);
    double * pos = pointPicker->GetPickPosition();

    if(PointAtPickLocation())
    {
        this->isMoving = true;
        this->pickedPoint = pointPicker->GetPointId();
        std::cout << "Moving point: " << this->pickedPoint << std::endl;
        this->pickedData = dynamic_cast<vtkPolyData*>(pointPicker->GetDataSet());

        SetPointLocation();
    }



    // trigger the parent event
    //vtkInteractorStyleImage::OnLeftButtonDown();
}
Example #4
0
  CountryBorders ()  :  DataSet ()
    { Load ("data/Tissot_indicatrix_world_map_equirectangular_proj_360x180_coords_cleaner2.txt");

      //  Interpret the 0th and 1th column in the data as floats,
      //  and the 2th column as ints
      longitude = FloatColumn (0);
      latitude  = FloatColumn (1);
      drawitude = IntColumn   (2);

      LoadShaders ("shaders/foggy.vert", "shaders/null.frag");

      for (int64 i = 4  ;  i < Count ()  ;  i++)
        { float64 mapped_longitude
            = Range (longitude[i], 0.0, 360.0, -180.0, 180.0) - 0.2;

          //  todo: - .2 because the borders data is a tad off
          float64 mapped_latitude
            = Range (latitude[i], 0.0, 180.0, 90.0, -90.0) + 0.25;

          //  todo: + .25 because the borders data is a tad off

          Vect globe_position = LatLongToSphereSurface (GLOBE_RADIUS - 0.5,
                                                        mapped_latitude,
                                                        mapped_longitude);
          SetPointLocation (i, globe_position.x,
                            globe_position.y,
                            globe_position.z);

          SetPointColor (i, HSB (0.5, 0.0, 0.2, 1.0 * drawitude[i]));
        }

      DataReady ();
      SetDrawMode (GL_LINE_STRIP);

      RotationAnimateChase (0.75);
      TranslationAnimateChase (0.25);
    }