1 // -*- C++ -*- 2 3 /* 4 * Gnome Chemistry Utils 5 * gccv/line.h 6 * 7 * Copyright (C) 2008-2010 Jean Bréfort <jean.brefort@normalesup.org> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 3 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 22 * USA 23 */ 24 25 #ifndef GCCV_LINE_H 26 #define GCCV_LINE_H 27 28 /*!\file*/ 29 30 #include "line-item.h" 31 32 namespace gccv { 33 34 /*! 35 @brief Straight lines. 36 37 Implements one segment straight lines. 38 */ 39 class Line: public LineItem 40 { 41 public: 42 /*! 43 @param canvas a Canvas. 44 @param xstart the horizontal start position. 45 @param ystart the vertical start position. 46 @param xend the horizontal end position. 47 @param yend the vertical end position. 48 49 Creates a new Line sets it as a child of the root Group of \a canvas. 50 */ 51 Line (Canvas *canvas, double xstart, double ystart, double xend, double yend); 52 /*! 53 @param parent the Group to which the new Line will be added. 54 @param xstart the horizontal start position. 55 @param ystart the vertical start position. 56 @param xend the horizontal end position. 57 @param yend the vertical end position. 58 @param client the ItemClient for the new Line if any. 59 60 Creates a new Line inside \a parent and sets \a client as its associated 61 ItemClient. 62 */ 63 Line (Group *parent, double xstart, double ystart, double xend, double yend, ItemClient *client = NULL); 64 /*! 65 The destructor. 66 */ 67 virtual ~Line (); 68 /*! 69 @param xstart the new horizontal start position. 70 @param ystart the new vertical start position. 71 @param xend the new horizontal end position. 72 @param yend the new vertical end position. 73 74 Sets the Line position. 75 */ 76 void SetPosition (double xstart, double ystart, double xend, double yend); 77 78 // virtual methods 79 /*! 80 @param x horizontal position 81 @param y vertical position 82 @param item where to store the Item. 83 84 Implementation of Item::Distance() for the Line class. Sets \a item to \a this. 85 */ 86 double Distance (double x, double y, Item **item) const; 87 /*! 88 @param cr a cairo_t. 89 @param is_vector whether the cairo_t is a vectorial context. 90 91 Draws the Line to \a cr. 92 */ 93 void Draw (cairo_t *cr, bool is_vector) const; 94 /*! 95 @param x the horizontal deplacement 96 @param y the vertical deplacement 97 98 Moves the Line. 99 */ 100 void Move (double x, double y); 101 102 protected: 103 /*! 104 Evaluates the Line bounds. 105 */ 106 void UpdateBounds (); 107 108 protected: 109 /*! 110 The horizontal start position. 111 */ 112 double m_xstart; 113 /*! 114 The vertical start position. 115 */ 116 double m_ystart; 117 /*! 118 The horizontal end position. 119 */ 120 double m_xend; 121 /*! 122 The vertical end position. 123 */ 124 double m_yend; 125 }; 126 127 } 128 129 #endif // GCCV_LINE_H 130