casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtPlotWidget.qo.h
Go to the documentation of this file.
00001 //# QtPlotWidget.qo.h: Classes for GUI editing of plot customization objects.
00002 //# Copyright (C) 2009
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef QTPLOTWIDGET_QO_H_
00028 #define QTPLOTWIDGET_QO_H_
00029 
00030 #include <casaqt/QtUtilities/PlotColorWidget.ui.h>
00031 #include <casaqt/QtUtilities/PlotFillWidget.ui.h>
00032 #include <casaqt/QtUtilities/PlotLineWidget.ui.h>
00033 #include <casaqt/QtUtilities/PlotSymbolWidget.ui.h>
00034 #include <casaqt/QtUtilities/PlotFontWidget.ui.h>
00035 
00036 #include <casaqt/QtUtilities/QtEditingWidget.qo.h>
00037 #include <graphics/GenericPlotter/PlotFactory.h>
00038 
00039 #include <casa/namespace.h>
00040 
00041 namespace casa {
00042 
00043 // Parent for plot widgets.
00044 class QtPlotWidget : public QtEditingWidget {
00045     Q_OBJECT
00046     
00047 public:
00048     // Constructor which takes a PlotFactory and an optional parent widget.
00049     QtPlotWidget(PlotFactoryPtr factory, QWidget* parent = NULL);
00050     
00051     // Destructor.
00052     virtual ~QtPlotWidget();
00053     
00054 protected:
00055     // Factory.
00056     PlotFactoryPtr itsFactory_;
00057 };
00058 
00059 
00060 // Widget for choosing a plot color.
00061 class PlotColorWidget : public QtPlotWidget, Ui::ColorWidget {
00062     Q_OBJECT
00063     
00064 public:
00065     // Constructor which takes a PlotFactory, a flag for whether or not to show
00066     // an alpha spinner, and an optional parent widget.
00067     PlotColorWidget(PlotFactoryPtr factory, bool showAlpha = false,
00068             QWidget* parent = NULL);
00069     
00070     // Destructor.
00071     ~PlotColorWidget();    
00072     
00073     // Gets/Sets the currently set color on the widget.
00074     // <group>
00075     PlotColorPtr getColor() const;
00076     void setColor(PlotColorPtr color);
00077     // </group>
00078     
00079     // Gets/Sets the currently set color on the widget as a String.
00080     // <group>
00081     String getColorString() const;
00082     void setColor(const String& color);
00083     // </group>
00084     
00085 private:
00086     // Last set color.
00087     PlotColorPtr itsColor_;
00088     
00089 private slots:
00090     // Slot to show color chooser.
00091     void colorChoose();
00092     
00093     // Slot for when the set color changes.
00094     void colorChanged();
00095 };
00096 
00097 
00098 // Widget for choosing a plot area fill.  Uses a PlotColorWidget for the color.
00099 class PlotFillWidget : public QtPlotWidget, Ui::FillWidget {
00100     Q_OBJECT
00101     
00102 public:
00103     // Constructor which takes a PlotFactory, a flag for whether or not to show
00104     // an alpha spinner in the color widget, and an optional parent widget.
00105     PlotFillWidget(PlotFactoryPtr factory, bool showAlpha = false,
00106             QWidget* parent = NULL);
00107     
00108     // Destructor.
00109     ~PlotFillWidget();
00110     
00111     // Gets/Sets the currently set area fill on the widget.
00112     // <group>
00113     PlotAreaFillPtr getFill() const;
00114     void setFill(PlotAreaFillPtr fill);
00115     // </group>
00116     
00117 private:
00118     // Color widget.
00119     PlotColorWidget* itsColorWidget_;
00120     
00121     // Last set area fill.
00122     PlotAreaFillPtr itsFill_;
00123     
00124 private slots:
00125     // Slot for when the set area fill changes.
00126     void fillChanged();
00127 };
00128 
00129 
00130 // Widget for choosing a plot line.  Uses a PlotColorWidget for the line
00131 // color.
00132 class PlotLineWidget : public QtPlotWidget, Ui::LineWidget {
00133     Q_OBJECT
00134     
00135 public:
00136     // Constructor which takes a PlotFactory, a flag for whether to use the
00137     // "compact" version of the widget, a flag for whether or not to show an
00138     // alpha spinner in the color widget, and an optional parent widget.
00139     PlotLineWidget(PlotFactoryPtr factory, bool useCompact = true,
00140             bool showAlpha = false, QWidget* parent = NULL);
00141     
00142     // Destructor.
00143     ~PlotLineWidget();    
00144     
00145     // Gets/Sets the currently set line on the widget.
00146     // <group>
00147     PlotLinePtr getLine() const;
00148     void setLine(PlotLinePtr line);
00149     // </group>
00150     
00151 private:
00152     // Color widget.
00153     PlotColorWidget* itsColorWidget_;
00154     
00155     // Last set line.
00156     PlotLinePtr itsLine_;
00157     
00158     
00159     // Gets/Sets the line style from the combo box.
00160     // <group>
00161     PlotLine::Style lineStyle() const;
00162     void setLineStyle(PlotLine::Style style);
00163     // </group>
00164     
00165 private slots:
00166     // Slot for when the set line changes.
00167     void lineChanged();
00168 };
00169 
00170 
00171 // Widget for choosing a plot symbol.  Uses a PlotFillWidget for the area fill
00172 // and a PlotLineWidget for the outline.  Lets the user choose between no
00173 // symbol, a default symbol given at construction, or a custom symbol they can
00174 // set.
00175 class PlotSymbolWidget : public QtPlotWidget, Ui::SymbolWidget {
00176     Q_OBJECT
00177     
00178 public:
00179     // Constructor which takes a PlotFactory, the symbol associated with the
00180     // "default" options, a flag for whether to show an alpha spinner for the
00181     // area fill, a flag for whether to allow the user to set a custom outline,
00182     // a flag for whether to show an alpha spinner for the custom outline, and
00183     // an optional parent widget.
00184     PlotSymbolWidget(PlotFactoryPtr factory, PlotSymbolPtr defaultSymbol,
00185             bool showAlphaFill = false, bool showCustom = true,
00186             bool showAlphaLine = false, bool showCharacter = true,
00187             QWidget* parent = NULL);
00188     
00189     // Destructor.
00190     ~PlotSymbolWidget();
00191     
00192     // Gets/Sets the currently set symbol on the widget.
00193     // <group>
00194     PlotSymbolPtr getSymbol() const;
00195     void setSymbol(PlotSymbolPtr symbol);
00196     // </group>
00197     
00198     // Overrides QtEditingWidget::addRadioButtonsToGroup().
00199     void addRadioButtonsToGroup(QButtonGroup* group) const;
00200     
00201     // Sets the allowable minimum sizes for the given symbol types.
00202     void setMinimumSizes(const map<PlotSymbol::Symbol, int>& minimumSizes);
00203     
00204 private:
00205     // Area fill widget.
00206     PlotFillWidget* itsFillWidget_;
00207     
00208     // Line widget.
00209     PlotLineWidget* itsLineWidget_;
00210     
00211     // Default symbol.
00212     PlotSymbolPtr itsDefault_;
00213     
00214     // Last set symbol.
00215     PlotSymbolPtr itsSymbol_;
00216     
00217     // Minimum allowable sizes.
00218     map<PlotSymbol::Symbol, int> itsMinSizes_;
00219     
00220 private slots:
00221     // Slot for when the set symbol changes.  The "check" flag can be used to
00222     // avoid emitting the changed signals twice (for example, when one radio
00223     // button turns off when another turns on).
00224     void symbolChanged(bool check = true);
00225 };
00226 
00227 
00228 // Widget for choosing a plot font.  Uses a PlotColorWidget for the font color.
00229 class PlotFontWidget : public QtPlotWidget, Ui::FontWidget {
00230     Q_OBJECT
00231     
00232 public:
00233     // Constructor which takes a PlotFactory, a flag for whether to show an
00234     // alpha spinner for the color, and an optional parent widget.
00235     PlotFontWidget(PlotFactoryPtr factory, bool showAlpha = false,
00236             QWidget* parent = NULL);
00237     
00238     // Destructor.
00239     ~PlotFontWidget();
00240     
00241     // Gets/Sets the currently set font on the widget.
00242     // <group>
00243     PlotFontPtr getFont() const;
00244     void setFont(PlotFontPtr font);
00245     // </group>
00246     
00247 private:
00248     // Color widget.
00249     PlotColorWidget* itsColorWidget_;
00250     
00251     // Last set font.
00252     PlotFontPtr itsFont_;
00253     
00254 private slots:
00255     // Slot for when the set font changes.
00256     void fontChanged();
00257 };
00258 
00259 }
00260 
00261 #endif /* QTPLOTWIDGET_QO_H_ */