casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PanelDisplay.h
Go to the documentation of this file.
00001 //# PanelDisplay.h: Provision of panelled displays for data
00002 //# Copyright (C) 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_PANELDISPLAY_H
00029 #define TRIALDISPLAY_PANELDISPLAY_H
00030 
00031 #include <casa/aips.h>
00032 #include <tr1/memory>
00033 #include <casa/Containers/List.h>
00034 #include <casa/Containers/RecordInterface.h>
00035 #include <casa/Containers/SimOrdMap.h>
00036 #include <display/Utilities/DisplayOptions.h>
00037 #include <display/Display/MultiWCHolder.h>
00038 #include <display/Display/DisplayEnums.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 class PixelCanvas;
00043 class WorldCanvas;
00044 class WorldCanvasHolder;
00045 class Attribute;
00046 class AttributeBuffer;
00047 class MultiWCTool;
00048 
00049 // <summary>
00050 // A class which creates and manages "panelled" displays.
00051 // </summary>
00052 //
00053 // <use visibility=export>
00054 //
00055 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00056 // </reviewed>
00057 // 
00058 // <prerequisite>
00059 //   <li><linkto class="PixelCanvas">PixelCanvas</linkto>
00060 //   <li><linkto class="MultiWCHolder">MultiWCHolder</linkto>
00061 //   <li><linkto class="DisplayData">DisplayData</linkto>
00062 // </prerequisite>
00063 //
00064 // <etymology>
00065 // The PanelDisplay class provides a display consisting of a 
00066 // number of panels.
00067 // </etymology>
00068 //
00069 // <synopsis>
00070 // This class uses the <linkto
00071 // class="MultiWCHolder">MultiWCHolder</linkto> class to provide a
00072 // regular set of panels for display multi-view DisplayDatas.
00073 // </synopsis>
00074 //
00075 // <example> 
00076 // </example>
00077 //
00078 // <motivation> 
00079 // </motivation>
00080 
00081 class PanelDisplay : public MultiWCHolder, public DisplayOptions {
00082 
00083  public:
00084 
00085   enum FillOrder {
00086     // left to right, then top to bottom
00087     LEFT_TOP
00088     // others are imaginable
00089   };
00090 
00091 
00092   // Constructor taking: a pointer to the PixelCanvas on which to lay
00093   // the panels, the number of panels in the x and y directions, the
00094   // extent of the PixelCanvas to cover with panels, and the
00095   // fractional spacing between the panels.
00096   PanelDisplay(PixelCanvas* pixelcanvas, 
00097                const Int nx = 3, const Int ny = 2,
00098                const Float xOrigin = 0.0, const Float yOrigin = 0.0, 
00099                const Float xSize = 1.0, const Float ySize = 1.0,
00100                const Float dx = 0.0, const Float dy = 0.0,
00101                const PanelDisplay::FillOrder order = LEFT_TOP);
00102 
00103   // Destructor.
00104   virtual ~PanelDisplay();
00105 
00106   // Install the default options for this PanelDisplay
00107   virtual void setDefaultOptions();
00108 
00109   // Apply options stored in rec to the PanelDisplay; these get
00110   // forwarded to all underlying WorldCanvases
00111   virtual Bool setOptions(const Record& rec, Record& updatedOptions);
00112   virtual Record getOptions() const;
00113   // Set attributes on all WolrdCanvases
00114   virtual void setAttributes(AttributeBuffer& at);
00115   virtual void getAttributeValue(const String& name, Int& newValue) const;
00116   
00117   // Describe or set the geometry of the panels, either explicitly
00118   // or in RecordInterface form.
00119   // (Note: setGeometry() does not automatically refresh;
00120   //  when called within setOptions it does, though.)
00121   // <group>
00122   virtual void getGeometry(Int& nx, Int& ny, Float& xOrigin, 
00123                            Float& yOrigin, Float& xSize, Float& ySize,
00124                            Float& dx, Float& dy, 
00125                            PanelDisplay::FillOrder& order) const;
00126   virtual void getGeometry(RecordInterface& rec) const;
00127   virtual void setGeometry(const Int nx, const Int ny, const Float xOrigin, 
00128                            const Float yOrigin, const Float xSize, 
00129                            const Float ySize, const Float dx, const Float dy,
00130                            const PanelDisplay::FillOrder order);
00131   virtual void setGeometry(const RecordInterface& rec);
00132   // </group>
00133 
00134   // Clear our part of the PC.  (Clears both front and back buffers.)
00135   virtual void clear();
00136 
00137   
00138   virtual WorldCanvasHolder* wcHolder(WorldCanvas* wc) const;
00139 
00140   virtual PixelCanvas* pixelCanvas() {
00141     return itsPixelCanvas;
00142   }
00143 
00144   ConstListIter<WorldCanvas* >* myWCLI;
00145 
00146   virtual void addTool(const String& key, const std::tr1::shared_ptr<MultiWCTool> & );
00147   /* virtual void addTool(const String& key, MultiWCTool* value); */
00148   virtual void removeTool(const String& key);
00149   virtual void setToolKey(const String& toolname,
00150                           const Display::KeySym& keysym);
00151   virtual Bool hasTools();
00152   virtual void updateTools(Bool remove = True, Bool add = True);
00153   virtual void disableTools();
00154   virtual void enableTools();
00155   virtual void enableTool(const String& toolname);
00156   virtual void disableTool(const String& toolname);
00157   virtual const std::tr1::shared_ptr<MultiWCTool> getTool(const String& key);
00158 
00159   virtual ListIter<WorldCanvas* > wcs() {
00160     //return itsWCLI;
00161         return ListIter<WorldCanvas* >(itsWCList);
00162   }
00163 
00164   // Is the specified DisplayData the one in charge of coordinate
00165   // state of the Panel's WCs?
00166   virtual Bool isCSmaster(const DisplayData *dd) const;
00167   void setCSmaster( DisplayData* dd );
00168 
00173    float getDrawUnit(  ) const;
00174 
00179    int getColumnCount( ) const;
00180 
00185    int getRowCount() const;
00186 
00187 
00188    static const String X_ORIGIN;
00189    static const String Y_ORIGIN;
00190    static const String X_SIZE;
00191    static const String Y_SIZE;
00192 
00193 
00194 
00195 
00196 private:
00197 
00198   // The PixelCanvas on which the panels are laid.
00199   PixelCanvas* itsPixelCanvas;
00200 
00201   // The number of panels in x and y.
00202   Int itsNX, itsNY;
00203 
00204   // The origin and size of the used area of the PixelCanvas.
00205   Float itsXOrigin, itsYOrigin, itsXSize, itsYSize;
00206 
00207   // The offset between each panel.
00208   Float itsDX, itsDY;
00209   
00210   //The pgmargins
00211   Int itslpgm, itsrpgm, itstpgm, itsbpgm;
00212 
00213   // What order do we fill the canvases in?
00214   FillOrder itsOrder;
00215 
00216   // Whether the geometry is currently setup?
00217   Bool itsGeometrySet;
00218 
00219   // The WorldCanvases which we made, and a convenient iterator.
00220   List<WorldCanvas* > itsWCList;
00221   //ListIter<WorldCanvas* >* itsWCLI;
00222 
00223 
00224   // The WorldCanvasHolders which we made, and a convenient iterator.
00225 
00226   // (dk note: you should create a local iterator instead of using member
00227   // iterators.  Otherwise, a call chain may include two methods in the
00228   // class stepping on each other's iterator use.  Even if you think that
00229   // won't happen currently, it creates a maintenance minefield).
00230   //
00231   // Also note: _exactly the same list_ (with the same _name_, even)
00232   // is maintained on MWCH level (to be fixed).
00233 
00234   List<WorldCanvasHolder* > itsWCHList;
00235 
00236   //ListIter<WorldCanvasHolder* >* itsWCHLI;
00237 
00238   SimpleOrderedMap<String, std::tr1::shared_ptr<MultiWCTool> > itsMWCTools;
00239 
00240   // unSetup the Geometry.
00241   void unSetupGeometry();
00242 
00243 
00244 
00245 
00246 };
00247 
00248 
00249 } //# NAMESPACE CASA - END
00250 
00251 #endif