casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlotItem.h
Go to the documentation of this file.
00001 //# PlotItem.h: Top of hierarchy for objects that can be drawn on a canvas.
00002 //# Copyright (C) 2008
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 PLOTITEM_H_
00028 #define PLOTITEM_H_
00029 
00030 #include <graphics/GenericPlotter/PlotOptions.h>
00031 
00032 namespace casa {
00033 
00034 //# Forward Declarations
00035 class PlotCanvas;
00036 
00037 // PlotItem is the superclass of any object that is meant to be placed on the
00038 // canvas (plots, annotations, shapes, etc.).  A PlotItem is assumed to have an
00039 // x and y axis for drawing on the canvas.
00040 class PlotItem {
00041 public:
00042     // Constructor.
00043     PlotItem();
00044     
00045     // Destructor.
00046     virtual ~PlotItem();
00047 
00048     
00049     // Returns the canvas this item is currently attached to, or NULL for none.
00050     virtual PlotCanvas* canvas() const = 0;
00051     
00052     // Returns a human-readable title for identification.  Doesn't have to
00053     // be unique. Used for (for example) legends and other user-interactions.
00054     // Note: PlotItems that have no titles should not be shown on the legend.
00055     virtual String title() const = 0;
00056     
00057     // Sets this items's title to the given.
00058     virtual void setTitle(const String& newTitle) = 0;
00059     
00060     // Returns true if this item is valid, false otherwise.  Although validity
00061     // varies between items, canvases should NOT draw items which are invalid.
00062     virtual bool isValid() const = 0;
00063     
00064     // Returns whether this item can be directly casted to a QWidget or not.
00065     virtual bool isQWidget() const = 0;
00066     
00067     // Returns the item's axes.
00068     // <group>
00069     virtual PlotAxis xAxis() const = 0;
00070     virtual PlotAxis yAxis() const = 0;
00071     // </group>
00072 
00073     // Sets the item's axes.
00074     // <group>
00075     virtual void setXAxis(PlotAxis x) = 0;
00076     virtual void setYAxis(PlotAxis y) = 0;
00077     // </group>
00078     
00079     // Sets both the item's axes at once.
00080     // DEFAULT IMPLEMENTATION.
00081     virtual void setAxes(PlotAxis x, PlotAxis y);
00082     
00083     // Returns the "draw count" for this item, which subjectively means how
00084     // many indexed draw operations this item needs to make.  This is used to
00085     // make comparative judgments about how long each item will take to draw,
00086     // and to possibly divide up the work for larger items.  For example, a
00087     // plot with 1000 data points might return 1000, while a square might
00088     // return 1.  Whatever number is returned, the item should expect to be
00089     // able to draw given two indexes; for example, a plot should be able to
00090     // draw from index 0 to index 100.
00091     virtual unsigned int drawCount() const = 0;
00092     
00093     // Returns the number of draw segments for this item, using the given
00094     // segment threshold.  See DrawCount().
00095     // DEFAULT IMPLEMENTATION.
00096     virtual unsigned int drawSegments(unsigned int segmentThreshold) const;
00097 };
00098 typedef CountedPtr<PlotItem> PlotItemPtr;
00099 
00100 }
00101 
00102 #endif /*PLOTITEM_H_*/