1 /* 2 * Gnome Chemisty Utils 3 * spectrumview.h 4 * 5 * Copyright (C) 2007-2012 Jean Bréfort <jean.brefort@normalesup.org> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 20 * USA 21 */ 22 23 #ifndef GCU_SPECTRUM_VIEW_H 24 #define GCU_SPECTRUM_VIEW_H 25 26 #include <gcu/macros.h> 27 28 /*!\file*/ 29 namespace gcugtk 30 { 31 32 class SpectrumDocument; 33 34 /*!\class SpectrumView gcugtk/spectrumview.h 35 The view class used for spectra. This API is still quite unstable and 36 might change in the future. 37 */ 38 class SpectrumView 39 { 40 friend class SpectrumViewPrivate; 41 public: 42 //!Constructor. 43 /*! 44 @param pDoc: a pointer to the SpectrumDocument instance. 45 46 Creates a view for the document. 47 */ 48 SpectrumView (SpectrumDocument *pDoc); 49 50 //!Destructor. 51 /*! 52 The destructor of SpectrumView. 53 */ 54 virtual ~SpectrumView (); 55 56 /*! 57 @param target an axis type. 58 @param min the mimimum value to show. 59 @param max the maximum value to show. 60 @param inverted whether to invert the axis. 61 62 Sets the scale of the first axis of the selected type. 63 */ 64 void SetAxisBounds (GogAxisType target, double min, double max, bool inverted); 65 66 /*! 67 @param target an axis type. 68 @param unit a text (might be a unit). 69 70 Sets the text for the label of the first axis of the selected type. 71 */ 72 void SetAxisLabel (GogAxisType target, char const *unit); 73 74 /*! 75 @param target an axis type. 76 @param show whether to show the axis or not 77 78 Used to show or hide the first axis of either GOG_AXIS_X or GOG_AXIS_Y types. 79 */ 80 void ShowAxis (GogAxisType target, bool show); 81 82 /*! 83 @param target an axis type. 84 @param inverted whether to invert the axis scale or not 85 86 Used to invert the first axis of either GOG_AXIS_X or GOG_AXIS_Y types. 87 */ 88 void InvertAxis (GogAxisType target, bool inverted); 89 90 /*! 91 @param cr the cairo_t* to which render. 92 @param width the width of the rendering area. 93 @param height the height of the rendering area. 94 95 Renders the chart to \a cr. 96 */ 97 void Render (cairo_t *cr, double width, double height); 98 99 /*! 100 Called by the framework if the minimum has changed for the x-axis. 101 */ 102 void OnMinChanged (); 103 104 /*! 105 Called by the framework if the minimum has changed for the y-axis. 106 */ 107 void OnYMinChanged (); 108 109 /*! 110 Called by the framework if the maximum has changed for the x-axis. 111 */ 112 void OnMaxChanged (); 113 114 /*! 115 Called by the framework if the maximum has changed for the y-axis. 116 */ 117 void OnYMaxChanged (); 118 119 /*! 120 Called by the framework if the range has changed for the x-axis. 121 */ 122 void OnXRangeChanged (); 123 124 /*! 125 Called by the framework if the range has changed for the y-axis. 126 */ 127 void OnYRangeChanged (); 128 129 /*! 130 @param new_plot if true, a new plot is created (this is not yet implemented). 131 Creates a new GogSeries for the chart. 132 */ 133 GogSeries *NewSeries (bool new_plot); 134 135 /*! 136 @param filename the name of the file. 137 @param mime_type the requested mime type. 138 @param width the width of the generated image. 139 @param height the height of the generated image. 140 141 Export the view contents as an image. The size of the new image is defined by the width 142 and height parameters. Supported ilage file format include svg, png, jpeg, ps, eps, 143 and pdf, and possibly a few other bitmap formats. 144 */ 145 void SaveAsImage (std::string const &filename, char const *mime_type, unsigned width, unsigned height) const; 146 147 /*! 148 @param w the widget to add to the view. 149 150 Adds a widget to display more options to the view. 151 */ 152 void AddToOptionBox (GtkWidget *w); 153 154 /*! 155 Destroys any widget that might have been added to the view using 156 AddToOptionBox(). 157 */ 158 void DestroyExtraWidget (); 159 160 private: 161 GtkSpinButton *xminbtn, *xmaxbtn, *yminbtn, *ymaxbtn; 162 GtkRange *xrange, *yrange; 163 gulong minsgn, maxsgn, yminsgn, ymaxsgn, xrangesgn, yrangesgn; 164 double xmin, xmax, xstep, ymin, ymax, ystep; 165 GtkWidget *m_ExtraWidget; 166 167 /*!\fn GetDoc() 168 @return the associated document. 169 */ 170 GCU_RO_PROP (SpectrumDocument *, Doc) 171 /*!\fn GetWidget() 172 @return the widget used to display the spectrum. 173 */ 174 GCU_RO_PROP (GtkWidget *, Widget) 175 /*!\fn GetOptionBox() 176 @return a GtkBox to which an optional user interface might be added. 177 */ 178 GCU_RO_PROP (GtkWidget *, OptionBox) 179 /*!\fn GetSeries() 180 @return the first GogSeries* created for the view. 181 */ 182 GCU_RO_PROP (GogSeries *, Series) 183 /*!\fn GetWidth() 184 @return the view width. 185 */ 186 GCU_RO_PROP (int, Width) 187 /*!\fn GetHeight() 188 @return the view height. 189 */ 190 GCU_RO_PROP (int, Height) 191 }; 192 193 } 194 195 #endif // GCU_SPECTRUM_VIEW_H 196