QtPlotSvrPanel.qo.h

Go to the documentation of this file.
00001 //# QtPlotSvrPanel.qo.h: Qt implementation of main 2D plot server display window.
00002 //# with surrounding Gui functionality
00003 //# Copyright (C) 2005
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id: QtDisplayPanelGui.qo.h,v 1.7 2006/10/10 21:42:05 dking Exp $
00028 
00029 #ifndef CASAQT_QTPLOTSRVPANEL_H
00030 #define CASAQT_QTPLOTSRVPANEL_H
00031 
00032 #include <QMainWindow>
00033 #include <QStringList>
00034 #include <QColor>
00035 #include <qwt_global.h>
00036 #include <qwt_plot_curve.h>
00037 #include <qwt_color_map.h>
00038 #include <casaqt/QwtConfig.h>
00039 #include <casaqt/QtUtilities/QtId.h>
00040 #include <casaqt/QtUtilities/QtPanelBase.qo.h>
00041 #include <casaqt/QtPlotServer/QtPlotHistogram.h>
00042 #include <casadbus/types/ptr.h>
00043 #include <map>
00044 #include <vector>
00045 
00046 class QwtPlotCurve;
00047 class QwtPlotSpectrogram;
00048 class QVBoxLayout;
00049 class QHBoxLayout;
00050 class QSlider;
00051 class QwtPlotZoomer;
00052 
00053 namespace casa {
00054 
00055     class QtPlotFrame;
00056 
00057     class QtPlotSvrMain : public QtPanelBase {
00058     Q_OBJECT
00059         public:
00060             QtPlotSvrMain( QWidget */*parent*/=0 ) : QtPanelBase( ) { }
00061 
00062         signals:
00063             void closing( bool );
00064 
00065         protected: 
00066             // scripted (via dbus) panels should override the closeEvent( ) and hide the gui
00067             // instead of deleting it when it was created via a dbus script...
00068             void closeEvent(QCloseEvent *event);
00069     };
00070 
00071     class QtPlotSvrPanel : public QObject {
00072     Q_OBJECT
00073         public:
00074 
00075             void hide( );
00076             void show( );
00077             void closeMainPanel( );
00078             bool isVisible( );
00079             void releaseMainPanel( );
00080 
00081             QtPlotSvrPanel( QWidget *parent=0 );
00082             QtPlotSvrPanel( const QString &title,  const QString &xlabel="", const QString &ylabel="", const QString &window_title="",
00083                             const QList<int> &size=QList<int>( ), const QString &legend="bottom", const QString &zoom="bottom",
00084                             QtPlotSvrPanel *with_panel=0, bool new_row=false, QWidget *parent=0 );
00085 
00086             static QStringList colors( );
00087             static QStringList colormaps( );
00088             static QStringList symbols( );
00089 
00090             QwtPlotCurve *line( const QList<double> &x, const QList<double> &y, const QString &color="black", const QString &label="" );
00091             QwtPlotCurve *scatter( const QList<double> &x, const QList<double> &y, const QString &color="black", const QString &label="",
00092                                    const QString &symbol="", int symbol_size=-1, int dot_size=-1 );
00093             QtPlotHistogram *histogram( const QList<double> &y, int bins=0, const QString &color="blue", const QString &label="" );
00094             QwtPlotSpectrogram *raster( const QList<double> &matrix, int sizex, int sizey, const QString &colormap="Rainbow 2" );
00095 
00096             void replot( );
00097 
00098             void setxlabel( const QString &xlabel );
00099             void setylabel( const QString &ylabel );
00100             void settitle( const QString &title );
00101             QwtLinearColorMap * getnewcolormap(const QString & colormap);
00102             
00103             std::pair<QDockWidget*,QString> loaddock( const QString &file_or_xml, const QString &loc, const QStringList &dockable );
00104 
00105             virtual ~QtPlotSvrPanel( ) { }
00106 
00107         signals:
00108 
00109             void button( QtPlotSvrPanel *, QString );
00110             void check( QtPlotSvrPanel *, QString, int );
00111             void radio( QtPlotSvrPanel *, QString, bool );
00112             void linetext( QtPlotSvrPanel *, QString, const QString &text );
00113             void slidevalue( QtPlotSvrPanel *, QString, int );
00114 
00115             void closing( QtPlotSvrPanel *, bool );
00116 
00117         protected slots:
00118 
00119             void emit_button( );
00120             void emit_check( int );
00121             void emit_radio( bool );
00122             void emit_linetext( const QString &text );
00123             void emit_slidevalue( int );
00124 
00125             void emit_closing( bool );
00126 
00127             void zoom( int x=-1 );
00128 #ifdef QWT6
00129             void zoomed( const QRectF & );
00130 #else
00131             void zoomed( const QwtDoubleRect & );
00132 #endif
00133 
00134         protected: 
00135 
00136             QWidget *loaddock( QString file );
00137             QFont defaultfont;
00138 
00139             typedef std::map<QString,std::vector<QColor> > colormap_map;
00140             static void load_colormaps( );
00141             static colormap_map *colormaps_;
00142 
00143         private:
00144 
00145             class row_desc {
00146             public:
00147 
00148                 class plot_desc {
00149                 public:
00150                     plot_desc( QWidget *c, QLayout *l, QtPlotFrame *p, QSlider *s ) :
00151                         container_(c), layout_(l), plot_(p), slider_(s) { }
00152                     QWidget *&container( ) { return container_; }
00153                     QLayout *&layout( ) { return layout_; }
00154                     QtPlotFrame *&plot( ) { return plot_; }
00155                     QSlider *&slider( ) { return slider_; }
00156 
00157                 private:
00158                     QWidget *container_;
00159                     QLayout *layout_;
00160                     QtPlotFrame *plot_;
00161                     QSlider *slider_;
00162                 };
00163 
00164                 row_desc( QWidget *c, QHBoxLayout *l ) : container_(c), layout_(l), id_(QtId::get_id( )) { }
00165                 QWidget *container( ) { return container_; }
00166                 QHBoxLayout *layout( ) { return layout_; }
00167                 void addplot( QWidget *container, QLayout *layout, QtPlotFrame *plot, QSlider *slider )
00168                                 { plots.push_back( new plot_desc(container, layout, plot, slider ) ); }
00169                 int id( ) { return id_; }
00170             private:
00171                 typedef std::list<plot_desc*> plotlist;
00172                 plotlist plots;
00173                 QWidget *container_;
00174                 QHBoxLayout *layout_;
00175                 int id_;
00176             };
00177 
00178             class win_desc {
00179             public:
00180                 win_desc( QtPlotSvrMain *b, QWidget *c, QVBoxLayout *l ) : base_(b), container_(c), layout_(l) { }
00181                 QtPlotSvrMain *& base( ) { return base_; }
00182                 QWidget *&container( ) { return container_; }
00183                 QVBoxLayout *&layout( ) { return layout_; }
00184             private:
00185                 QtPlotSvrMain *base_;
00186                 QWidget *container_;
00187                 QVBoxLayout *layout_;
00188             };
00189 
00190             typedef std::map<QtPlotSvrPanel*,memory::cptr<row_desc> > rowmap;
00191             memory::cptr<rowmap> rows_;
00192 
00193             memory::cptr<win_desc> window_;
00194 
00195             QSlider *slider;
00196             QtPlotFrame *plot;
00197             QwtPlotZoomer *zoomer;
00198             double current_zoom_level;
00199             int slider_last_value;
00200     };
00201 }
00202 
00203 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1