// curve.hpp -- base class for polyline data // // Written by Frederic Bouvier, started October 2001. // // Copyright (C) 2001 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: curve.hpp,v 1.17 2005/05/09 07:01:50 fredb Exp $ #ifndef _curve_hpp_ #define _curve_hpp_ #include #include #include #include "triobject.hpp" class SGPropertyNode; class FGSD_Tile; class FGSD_MainWindow; class FGSD_Curve : public FGSD_BaseObject { public: typedef FGSD_TriangleObject::CDTplus::Vertex_handle Vertex_handle; struct Node { Point3D p; Vertex_handle v; FGSD_Tile *t; Node( const Point3D &__p ) : p( __p ), t( 0 ) {} double x() const { return p.x(); } double y() const { return p.y(); } }; typedef std::vector PointList; enum CurveType { UnSet, Curve2D, Curve2D5, Curve3D }; FGSD_Curve(); FGSD_Curve( FGSD_BaseObject::ObjectType __type ); virtual void save( SGPropertyNode *__node ); virtual bool load( SGPropertyNode *__node ); // virtual size_t weight( SGPropertyNode *__node ); void draw( double alpha, bool lines, DrawType drawType, double minx, double maxx, double miny, double maxy, double zLevel ); bool propertiesUnderMouse( double lon, double lat, double &height, std::string &material, std::string &airportID ) const; bool objectUnderMouse( double lon, double lat, double zLevel ); bool visible( double minx, double maxx, double miny, double maxy ) const; bool visible( double lon, double lat ) const; std::string getName() const; void *convertTo( FGSD_BaseObject::ObjectType __type ); bool insertPoint( double __lon, double __lat ); bool moveCurrentPoint( double __lon, double __lat ); bool removeMousePoint( bool selected ); void removePoint( size_t __index ); bool tryToClose( double zLevel ); void open(); void changeCurrentPoint(); void changeCurrentPoint( size_t __index ); void changeMousePoint( size_t __index ); bool checkForCrossingSegments( const Point3D &A, const Point3D &B, size_t moving = (size_t)-1 ) const; void embedInTiles( FGSD_MainWindow *mw ); bool selected() const; void selected( bool __sel ); bool pointSelected() const; bool mouseOnPoint() const; bool hasPoints() const; void setOpened( bool __opened ); Point3D firstPoint() const; Point3D secondPoint() const; Point3D mousePoint() const; Point3D currentPoint() const; Point3D pointAt( size_t index ) const; size_t size() const; size_t mouseIndex() const; bool mouseOnEdge() const; PointList points() const; bool opened() const; size_t current() const; CurveType curveType() const; void curveType(CurveType t); double height() const; void height( double h ); std::string material() const; void material( const char *m ); bool water() const; void water( bool w ); bool embedded() const; bool newCurve() const; void setNewCurve( bool n ); private: CurveType _type; bool _opened; bool _selected; PointList _pointList; size_t _curPoint; size_t _mousePoint; size_t _mouseEdge; double _minx; double _miny; double _maxx; double _maxy; double _height; std::string _material; bool _water; bool _embedded; bool _new; }; inline bool FGSD_Curve::selected() const { return _selected; } inline void FGSD_Curve::selected( bool __sel ) { _selected = __sel; } inline bool FGSD_Curve::hasPoints() const { return _pointList.size() != 0; } inline void FGSD_Curve::setOpened( bool __opened ) { _opened = __opened; } inline Point3D FGSD_Curve::firstPoint() const { return _pointList[ 0 ].p; } inline Point3D FGSD_Curve::secondPoint() const { return _pointList[ 1 ].p; } inline FGSD_Curve::PointList FGSD_Curve::points() const { return _pointList; } inline bool FGSD_Curve::opened() const { return _opened; } inline size_t FGSD_Curve::current() const { return _curPoint; } inline void FGSD_Curve::changeCurrentPoint( size_t __index ) { _curPoint = __index; } inline void FGSD_Curve::changeMousePoint( size_t __index ) { _mousePoint = __index; } inline Point3D FGSD_Curve::mousePoint() const { return _mousePoint != size_t(-1) ? _pointList[ _mousePoint ].p : Point3D(); } inline Point3D FGSD_Curve::currentPoint() const { return _curPoint != size_t(-1) ? _pointList[ _curPoint ].p : Point3D(); } inline size_t FGSD_Curve::mouseIndex() const { return _mousePoint; } inline bool FGSD_Curve::mouseOnEdge() const { return _mouseEdge != (size_t)-1; } inline Point3D FGSD_Curve::pointAt( size_t index ) const { return _pointList[ index ].p; } inline size_t FGSD_Curve::size() const { return _pointList.size(); } inline FGSD_Curve::CurveType FGSD_Curve::curveType() const { return _type; } inline void FGSD_Curve::curveType(CurveType t) { _type = t; } inline double FGSD_Curve::height() const { return _height; } inline void FGSD_Curve::height( double h ) { _height = h; } inline std::string FGSD_Curve::material() const { return _material; } inline void FGSD_Curve::material( const char *m ) { _material = m; } inline bool FGSD_Curve::water() const { return _water; } inline void FGSD_Curve::water( bool w ) { _water = w; } inline bool FGSD_Curve::embedded() const { return _embedded; } inline bool FGSD_Curve::newCurve() const { return _new; } inline void FGSD_Curve::setNewCurve( bool n ) { _new = n; } #endif