segment.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // This file is part of libgvectors.
00004 // libgvectors is a C++ library intended for visualizing mathematical vectors.
00005 // Copyright (C) 2007  Rafael Ostertag
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00020 // USA.
00021 //
00022 // $Id: segment_8h-source.html,v 1.1 2007-09-08 19:02:37 rafi Exp $
00023 //
00024 // File:   segment.h
00025 // Author: Rafael Ostertag
00026 //
00027 // Created on March 12, 2007, 8:36 PM
00028 //
00029 
00030 
00042 #ifndef _SEGMENT_H
00043 #define _SEGMENT_H
00044 
00045 #include <gvenums.h>
00046 #include <color.h>
00047 #include <coordinates.h>
00048 
00049 namespace GVectors {
00050     
00051 
00052     // Forward declaration for Drawer.
00053     class Drawer;
00054     
00080     class Segment  {
00081     private:
00087         Color s_color;
00093         Coordinates from;
00099         Coordinates to;
00105         double initial_length;
00111         double initial_angle;
00112         
00113     public:
00115         Segment();
00117         Segment(const Coordinates &f, const Coordinates &t);
00119         Segment(const Coordinates &f, const Coordinates &t, const Color& c);
00121         virtual ~Segment();
00123         Segment(const Segment &s);
00124         
00126         void set_from(const Coordinates &c);
00128         void set_to(const Coordinates &c);
00130         void set(const Coordinates &f, const Coordinates &t);
00132         void set_pol(const Coordinates &f, double length, double angle, Angle_Type at=ANG_RAD);
00140         inline void set_color(const Color& c) { s_color = c; }
00148         inline void color(const Color& c) { s_color = c; }
00149         
00151         void get_from(Coordinates &f) const;
00153         Coordinates get_from() const;
00155         void get_to(Coordinates &t) const;
00157         Coordinates get_to() const;
00159         void get(Coordinates &f, Coordinates &t) const;
00167         inline Color get_color() const { return s_color; }
00175         inline Color color() const { return s_color; }
00176         
00178         double length() const;
00180         double angle(Angle_Type at=ANG_RAD) const;
00181         
00183         void move_to(const Coordinates &c);
00185         void move_by(const Coordinates &c);
00187         void draw(Drawer &d) const;
00188         
00190         const Segment& operator=(const Segment &s);
00191     };
00197     typedef Segment* se_ptr_t;
00203     typedef Segment& se_ref_t;
00209     typedef const Segment* const_se_ptr_t;
00215     typedef const Segment& const_se_ref_t;
00216 }
00217 #endif  /* _SEGMENT_H */

Generated on Sat Sep 8 19:37:29 2007 for libgvectors by  doxygen 1.4.7