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