casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DrawingDisplayData.h
Go to the documentation of this file.
00001 //# DrawingDisplayData.h: interactive drawing DisplayData
00002 //# Copyright (C) 1999,2000,2002
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_DRAWINGDISPLAYDATA_H
00029 #define TRIALDISPLAY_DRAWINGDISPLAYDATA_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Containers/List.h>
00033 #include <display/Display/DisplayEnums.h>
00034 #include <display/DisplayDatas/PassiveCachingDD.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 class WorldCanvas;
00039 class WorldCanvasHolder;
00040 class AttributeBuffer;
00041 class DrawingDisplayMethod;
00042 class DDDObject;
00043 
00044 // <summary>
00045 // DisplayData which provides interactive drawing capabilities.
00046 // </summary>
00047 
00048 // <synopsis>
00049 // This class provides an implementation of a PassiveCachingDD which
00050 // provides the ability for the programmer to add various objects
00051 // to the display (eg. rectangles), and then modify them, or allow
00052 // the user to interactively modify the objects.
00053 // </synopsis>
00054 
00055 class DrawingDisplayData : public PassiveCachingDD {
00056 
00057  public:
00058 
00059   // Constructor.
00060   DrawingDisplayData(const Display::KeySym keysym = 
00061                      Display::K_Pointer_Button1);
00062 
00063   // Destructor.
00064   virtual ~DrawingDisplayData();
00065 
00066   // Install the default options for this DisplayData.
00067   virtual void setDefaultOptions();
00068 
00069   // Apply options stored in <src>rec</src> to the DisplayData.  A
00070   // return value of <src>True</src> means a refresh is needed.
00071   // <src>recOut</src> contains any fields which were implicitly 
00072   // changed as a result of the call to this function.
00073   virtual Bool setOptions(Record &rec, Record &recOut);
00074 
00075   // Retrieve the current and default options and parameter types.
00076   virtual Record getOptions();
00077 
00078   // Return the type of this DisplayData.
00079   virtual Display::DisplayDataType classType()
00080     { return Display::CanvasAnnotation; }
00081 
00082   // Create a new AxesDisplayMethod for drawing on the given
00083   // WorldCanvas when the AttributeBuffers are suitably matched to the
00084   // current state of this DisplayData and of the WorldCanvas/Holder.
00085   // The tag is a unique number used to identify the age of the newly
00086   // constructed CachingDisplayMethod.
00087   virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas,
00088                                  AttributeBuffer *wchAttributes,
00089                                  AttributeBuffer *ddAttributes,
00090                                                  CachingDisplayData *dd);
00091  
00092   // Return the current options of this DisplayData as an
00093   // AttributeBuffer.
00094   virtual AttributeBuffer optionsAsAttributes();
00095 
00096   virtual void refreshEH(const WCRefreshEvent &ev);
00097 
00098   // Add an object to the drawing as described in the given Record.
00099   virtual void addObject(const Record &description);
00100 
00101   // Get the description of the object with the given id.
00102   virtual Record description(const Int objectID);
00103 
00104   // Set the description of the object with the given id.
00105   virtual void setDescription(const Int objectID, const Record &rec);
00106 
00107   // Remove the object with the given id.
00108   virtual void removeObject(const Int objectID);
00109 
00110   // Set the handle state of the particular item.
00111   virtual void setHandleState(DDDObject *item, const Bool state);
00112 
00113   // Return the current setting of the labelposition option.
00114   virtual String labelPosition()
00115     { return itsOptionsLabelPosition; }
00116   
00117   // Set/get which key to catch.
00118   // <group>
00119   virtual void setKey(const Display::KeySym &keysym);
00120   virtual Display::KeySym key() const
00121     { return itsKeySym; }
00122   virtual Display::KeyModifier keyModifier() const
00123     { return itsKeyModifier; }
00124   // </group>
00125 
00126   // Double click interval.
00127   virtual Double doubleClickInterval() const
00128     { return itsDoubleClickInterval; }
00129 
00130   // Called when a double click occurred for the identified object.
00131   // Null implementation in this class, derived classes can over-ride.
00132   virtual void doubleClick(const Int objectID);
00133 
00134  protected:
00135 
00136   // (Required) copy constructor.
00137   DrawingDisplayData(const DrawingDisplayData &other);
00138 
00139   // (Required) copy assignment.
00140   void operator=(const DrawingDisplayData &other);
00141 
00142  private:
00143 
00144   friend class DrawingDisplayMethod;
00145 
00146   // The key to handle.
00147   Display::KeySym itsKeySym;
00148 
00149   // The modifier mask for the key.
00150   Display::KeyModifier itsKeyModifier;
00151 
00152   // Double click interval (seconds)
00153   Double itsDoubleClickInterval;
00154 
00155   // List containing the DDDObjects for this DrawingDisplayData.
00156   List<void *> itsDDDOList;
00157 
00158   // Iterator for itsDDDOList
00159   ListIter<void *> *itsDDDOListIter;
00160 
00161   // Obvious!
00162   DDDObject *itsObjectWhichIsShowingHandles;
00163 
00164   // Install the default options for this DisplayData.
00165   void installDefaultOptions();
00166 
00167   // Option: position for labels
00168   String itsOptionsLabelPosition;
00169 
00170 };
00171 
00172 
00173 } //# NAMESPACE CASA - END
00174 
00175 #endif