casa
$Rev:20696$
|
00001 //# PrincipalAxesDM.h: Base class for drawing axis-bound datasets 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 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 00028 #ifndef TRIALDISPLAY_PRINCIPALAXESDM_H 00029 #define TRIALDISPLAY_PRINCIPALAXESDM_H 00030 00031 #include <casa/aips.h> 00032 #include <display/Display/DisplayEnums.h> 00033 #include <display/DisplayDatas/DisplayMethod.h> 00034 #include <display/DisplayDatas/PrincipalAxesDD.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 class WorldCanvasHolder; 00039 class IPosition; 00040 class WorldCanvas; 00041 template <class T> class Vector; 00042 00043 // <summary> 00044 // Interface for DisplayMethods which have data arranged in "axes." 00045 // </summary> 00046 // 00047 // <synopsis> 00048 // This class adds to the interface defined by DisplayMethod to 00049 // provide further infrastructure relevant to data which is 00050 // arranged by axis (eg. lattice or column-based data). 00051 // </synopsis> 00052 00053 class PrincipalAxesDM : public DisplayMethod { 00054 00055 public: 00056 00057 // User constructor. 00058 PrincipalAxesDM(uInt xAxis, uInt yAxis, uInt mAxis, 00059 PrincipalAxesDD *padd); 00060 00061 // Destructor. 00062 virtual ~PrincipalAxesDM(); 00063 00064 // Draw on the provided WorldCanvasHolder. This method provides 00065 // generic preparation that is common to all objects which are 00066 // being sliced along principal axes. It calls the pure virtual 00067 // functions (below) which must be defined in fully typed derived 00068 // classes. 00069 virtual void draw(Display::RefreshReason reason, 00070 WorldCanvasHolder &wcHolder); 00071 00072 // clear drawlist state. 00073 virtual void cleanup(); 00074 00075 protected: 00076 00077 // This method does setup stuff that is common to all elements 00078 // of an axis-bound display data element. 00079 virtual void setup(IPosition fixedPos); 00080 00081 virtual void setup2d(); 00082 00083 // This method should be defined in derived classes to simply 00084 // return the shape of the data object, eg. Array.shape() or 00085 // Image.shape(), etc. 00086 virtual IPosition dataShape() = 0; 00087 00088 // This method should be defined in derived classes to actually 00089 // draw the data contained in datMatrix, however it likes, starting 00090 // at the point blc, on *wCanvas. It *must* return a uInt which 00091 // indicates the drawListNumber it allocated for this drawing. 00092 // If <src>usePixelEdges</src> is True, then the given blc and 00093 // trc correspond to the world blc and trc of the first and last 00094 // pixels in the given data, otherwise they correspond to the world 00095 // centres of the blc and trc pixels. 00096 virtual uInt dataDrawSelf(WorldCanvas *wCanvas, 00097 const Vector<Double> &blc, 00098 const Vector<Double> &trc, 00099 const IPosition &start, 00100 const IPosition &sliceShape, 00101 const IPosition &stride, 00102 const Bool usePixelEdges = False) = 0; 00103 00104 // Called by draw(): an optimization for ColormapChange in 24bit mode. 00105 // Redraws the last image using only mapToColor on the WorldCanvas, 00106 // if possible. If it returns True, the new method 00107 // WC::redrawIndexedImage() was used successfully (otherwise, draw() 00108 // continues in the normal way). Override to enable, if necessary 00109 // (see LatticePADMRaster for an example). 00110 virtual Bool dataRedrawSelf(WorldCanvas*, Display::RefreshReason) { 00111 return False; 00112 }; 00113 00114 // Some data members which all display elements along principal 00115 // axes will play around with: 00116 IPosition start; 00117 IPosition sliceShape; 00118 IPosition stride; 00119 00120 // Is a transpose necessary? 00121 virtual Bool needToTranspose() { 00122 return sliceShape(itsYAxisNum) >1 && 00123 (sliceShape(itsXAxisNum)==1 || itsXAxisNum>itsYAxisNum); } 00124 // The logic behind this cryptic code (see LatticePADM::dataGetSlice): 00125 // If a either a 1xN or Nx1 slice (including 1x1) is requested, 00126 // LatticePADM's latt.getSlice() Array will be 1-dimensional, which 00127 // the Matrix = Array operator will turn into an Nx1 matrix. 00128 // If, on the other hand, there is no degeneracy in the desired 00129 // slice Matrix, it is returned in lattice (not X,Y) order. (dk) 00130 00131 // (Required) default constructor. 00132 PrincipalAxesDM(); 00133 00134 // (Required) copy constructor. 00135 PrincipalAxesDM(const PrincipalAxesDM &other); 00136 00137 // (Required) copy assignment. 00138 void operator=(const PrincipalAxesDM &other); 00139 00140 private: 00141 00142 // Axis numbers for internal book-keeping. 00143 uInt itsXAxisNum, itsYAxisNum, itsZAxisNum; 00144 00145 // Drawlist state. Moved here, where it's used, from DisplayMethod, 00146 // and made private. 11/03 dk. The Caching side uses different 00147 // state (and purgeCache(), rather than cleanup()). 00148 00149 Bool notUsed; 00150 WorldCanvasHolder *holder; 00151 AttributeBuffer drawState; 00152 uInt drawListNumber; 00153 00154 }; 00155 00156 00157 } //# NAMESPACE CASA - END 00158 00159 #endif