casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TBSlicer.qo.h
Go to the documentation of this file.
00001 //# TBSlicer.qo.h: Widget to display and change the current array slice.
00002 //# Copyright (C) 2005
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 TBSLICER_H_
00028 #define TBSLICER_H_
00029 
00030 #include <casaqt/QtBrowser/TBSlicer.ui.h>
00031 
00032 #include <vector>
00033 
00034 #include <QtGui>
00035 
00036 #include <casa/BasicSL/String.h>
00037 
00038 #include <casa/namespace.h>
00039 using namespace std;
00040 
00041 namespace casa {
00042 
00043 // <summary>
00044 // Widget to display and change the current array slice.
00045 // </summary>
00046 //
00047 // <synopsis>
00048 // A TBSlicer has two parts: the bottom part allows the user to chooser which
00049 // dimension is viewed along the two axes, and the top part chooses which
00050 // "slice" along those two axes to view.  When the user changes the slice,
00051 // a signal is emitted; the parent/caller is responsible for connecting and
00052 // processing the signal.
00053 // </synopsis>
00054 
00055 class TBSlicer : public QWidget, Ui_Slicer {
00056     Q_OBJECT
00057 
00058 public:
00059     // Constructor that takes the shape of the array.
00060     TBSlicer(vector<int> d);
00061 
00062     ~TBSlicer();
00063 
00064 signals:
00065     // This signal is emitted when the user changes the slice.  The slice
00066     // parameter contains non-negative values along all dimensions EXCEPT
00067     // for the two dimensions that are mapped to the X- and Y-axes.  The
00068     // dimension mapped to the X-axis has the value
00069         // TBConstants::SLICER_ROW_AXIS in the vector while the dimension mapped
00070         // to the Y-axis has the value TBConstants::SLICER_COL_AXIS in the vector.
00071         // For example, if the array was 4x4x4, a slice of [SLICER_ROW_AXIS 1
00072         // SLICER_COL_AXIS] would mean to display the first dimension along the
00073         // X-axis and the third dimension along the Y-axis and to use 1 as the
00074         // index for the second dimension.
00075     void sliceChanged(vector<int> slice);
00076     
00077 private:
00078     // Current spinners.
00079     vector<QSpinBox*> spinners;
00080 
00081     // Current slice values.
00082     vector<int> values;
00083 
00084     // Holds the old row index.
00085     int oldR;
00086 
00087     // Holds the old column index.
00088     int oldC;
00089 
00090     // Flag to indicate whether GUI-generated events are "genuine."
00091     bool shouldEmit;
00092 
00093     
00094     // Collects the slice and emits the sliceChanged() signal.
00095     void emitSliceChanged();
00096 
00097 private slots:
00098     // Slot for when one of the spinners changes values.  Updates the current
00099         // slice and calls emitSliceChanged() if the slice has changed.
00100     void valueChanged();
00101 
00102     // Slot for when the row axis dimension is changed.  Updates the slicer
00103     // accordingly.
00104     void rowAxisChanged(int newRow);
00105 
00106     // Slot for when the column axis dimension is changed.  Updates the slicer
00107     // accordingly.
00108     void colAxisChanged(int newCol);
00109 };
00110 
00111 }
00112 
00113 #endif /* TBSLICER_H_ */