marker.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:3k
源码类别:

OpenGL

开发平台:

Visual C++

  1. // marker.h
  2. //
  3. // Copyright (C) 2003-2008, Chris Laurel <claurel@shatters.net>
  4. //
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. #ifndef CELENGINE_MARKER_H_
  10. #define CELENGINE_MARKER_H_
  11. #include <vector>
  12. #include <string>
  13. #include <celmath/vecmath.h>
  14. #include <celutil/color.h>
  15. #include <celengine/selection.h>
  16. class MarkerRepresentation
  17. {
  18. public:
  19.     enum Symbol
  20.     {
  21.         Diamond    = 0,
  22.         Triangle     = 1,
  23.         Square     = 2,
  24.         FilledSquare = 3,
  25.         Plus       = 4,
  26.         X          = 5,
  27.         LeftArrow  = 6,
  28.         RightArrow = 7,
  29.         UpArrow    = 8,
  30.         DownArrow  = 9,
  31.         Circle    = 10,
  32.         Disk      = 11,
  33.         Crosshair = 12,
  34.     };    
  35.     
  36.     MarkerRepresentation(Symbol symbol = MarkerRepresentation::Diamond,
  37.                          float size = 10.0f,
  38.                          Color color = Color::White,
  39.                          const std::string& label = "") :
  40.         m_symbol(symbol),
  41.         m_size(size),
  42.         m_color(color),
  43.         m_label(label)
  44.     {
  45.     }
  46.     
  47.     MarkerRepresentation(const MarkerRepresentation& rep);
  48.     
  49.     MarkerRepresentation& operator=(const MarkerRepresentation& rep);
  50.     
  51.     Symbol symbol() const { return m_symbol; }
  52.     Color color() const { return m_color; }
  53.     void setColor(Color);
  54.     float size() const { return m_size; }
  55.     void setSize(float size);
  56.     string label() const { return m_label; }
  57.     void setLabel(const std::string&);
  58.         
  59.     void render(float size) const;
  60.     
  61. private:
  62.     Symbol m_symbol;
  63.     float m_size;
  64.     Color m_color;
  65.     string m_label;
  66. };
  67. /*! Options for marker sizing:
  68.  *    When the sizing is set to ConstantSize, the marker size is interpreted
  69.  *    as a fixed size in pixels.
  70.  *    When the sizing is set to DistancedBasedSize, the marker size is
  71.  *    in kilometers, and the size of the marker on screen is based on
  72.  *    the size divided by the marker's distance from the observer.
  73.  */
  74. enum MarkerSizing
  75. {
  76.     ConstantSize,
  77.     DistanceBasedSize,
  78. };
  79. class Marker
  80. {
  81.  public:
  82.     Marker(const Selection&);
  83.     ~Marker();
  84.     UniversalCoord position(double jd) const;
  85.     Selection object() const;
  86.     int priority() const;
  87.     void setPriority(int);
  88.     bool occludable() const;
  89.     void setOccludable(bool);
  90.     MarkerSizing sizing() const;
  91.     void setSizing(MarkerSizing);
  92.     const MarkerRepresentation& representation() const { return m_representation; }
  93.     MarkerRepresentation& representation() { return m_representation; }
  94.     void setRepresentation(const MarkerRepresentation& rep);
  95.     void render(float size) const;
  96.  private:
  97.     Selection m_object;
  98.     int m_priority;
  99.     MarkerRepresentation m_representation;
  100.     bool m_occludable : 1;
  101.     MarkerSizing m_sizing : 2;
  102. };
  103. typedef std::vector<Marker> MarkerList;
  104. #endif // CELENGINE_MARKER_H_