casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotCanvas.h
Go to the documentation of this file.
1 //# PlotCanvas.h: Main drawing area for different plot items to be attached.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTCANVAS_H_
28 #define PLOTCANVAS_H_
29 
39 
40 #include <casa/BasicSL/String.h>
41 
42 namespace casa {
43 
44 //# Forward Declarations
45 class PlotFactory;
46 
47 
48 // Abstract parent for any class that wants to be notified when the canvas
49 // is about to start drawing. This class is needed because a canvas could
50 // start redrawing for a number of reasons (user-requested, items changing the
51 // scale, resizing, ...) and instead of forcing applications to catch all cases
52 // this class can be used to notify when a drawing has begun for any reason.
54 public:
55  // Constructor.
57 
58  // Destructor.
59  virtual ~PlotDrawWatcher() { }
60 
61 
62  // This method should be called by the canvas whenever drawing is about to
63  // begin. The watcher is given:
64  // * A pointer to the PlotOperation object which is updated with progress
65  // information,
66  // * A flag indicating whether the drawing will happen in its own thread or
67  // not,
68  // * A flag indicating which layers are going to be drawn (bitwise-or of
69  // PlotCanvasLayer values).
70  // The method should return true UNLESS the watcher wants to stop the
71  // canvas from drawing. For example, if a canvas does not have threaded
72  // drawing, the watcher may want to stop drawing initially in order to
73  // spawn a new thread and then redraw.
74  virtual bool canvasDrawBeginning(PlotOperationPtr drawOperation,
75  bool drawingIsThreaded, int drawnLayersFlag) = 0;
76 };
78 
79 
80 // PlotCanvas is an area for different PlotItems to be attached and drawn. It
81 // also has axes and other properties. It's one of the more important plotting
82 // classes.
83 class PlotCanvas {
84 public:
85  // Static //
86 
87  // Position that the legend can be in, relative to the canvas.
89  INT_URIGHT, // inside the canvas, on the upper right
90  INT_LRIGHT, // inside the canvas, on the lower right
91  INT_ULEFT, // inside the canvas, on the upper left
92  INT_LLEFT, // inside the canvas, on the lower left
93  EXT_RIGHT, // outside the canvas, on the right
94  EXT_TOP, // outside the canvas, on the top
95  EXT_LEFT, // outside the canvas, on the left
96  EXT_BOTTOM // outside the canvas, on the bottom
97  };
98 
99  // Returns all legend positions.
100  // <group>
101  static std::vector<LegendPosition> allLegendPositions();
102  static std::vector<casacore::String> allLegendPositionStrings();
103  // </group>
104 
105  // Converts between legend positions and their casacore::String representations.
106  // <group>
108  static LegendPosition legendPosition(casacore::String p, bool* ok = NULL);
109  // </group>
110 
111  // Indicates whether the given legend position is internal to the canvas or
112  // not.
114 
115  // Returns a std::vector containing all values in the PlotAxis enum, ordered
116  // from lowest value to highest value.
117  static std::vector<PlotAxis> allAxes();
118 
119  // Returns the or'ed value of all PlotAxis enum values.
120  static int allAxesFlag();
121 
122  // Returns a vector containing all values in the PlotCanvasLayer enum,
123  // ordered from lowest value to highest value.
124  static std::vector<PlotCanvasLayer> allLayers();
125 
126  // Returns the or'ed value of all PlotCanvasLayer enum values.
127  static int allLayersFlag();
128 
129  // Convenient access to operation names.
130  // <group>
133  // </group>
134 
135 
136  // Non-Static //
137 
138  // Constructor.
139  PlotCanvas();
140 
141  // Destructor.
142  virtual ~PlotCanvas();
143 
144 
145  // Support Methods //
146 
147  // See PlotFactory::canvasHasThreadedDrawing().
148  // DEFAULT IMPLEMENTATION.
149  virtual bool hasThreadedDrawing() const;
150 
151  // See PlotFactory::canvasHasCachedLayerDrawing().
152  // DEFAULT IMPLEMENTATION.
153  virtual bool hasCachedLayerDrawing() const;
154 
155  // See PlotFactory::hasCachedAxesStack().
156  // DEFAULT IMPLEMENTATION.
157  virtual bool hasCachedAxesStack() const;
158 
159 
160  // GUI Methods //
161 
162  // Returns the canvas size in pixels (width x height).
163  virtual std::pair<int, int> size() const = 0;
164  virtual void setMinimumSize( int width, int height ) = 0;
165  virtual void setMinimumSizeHint( int width, int height ) = 0;
166  virtual void show() = 0;
167  virtual void hide() = 0;
168  virtual bool isDrawing( )= 0;
169  // Returns the text of the canvas title, or an empty casacore::String if none is
170  // shown. The title is shown above the plotting area.
171  virtual casacore::String title() const = 0;
172 
173  // Sets the text of the canvas title to the given. Setting the title to an
174  // empty string should remove the title from the canvas.
175  virtual void setTitle(const casacore::String& title) = 0;
176 
177  // Returns a copy of the font used for the canvas title. If no title is
178  // shown this behavior is undefined.
179  virtual PlotFontPtr titleFont() const = 0;
180 
181  // Set the font of the canvas title to the given.
182  virtual void setTitleFont(const PlotFont& font) = 0;
183 
184  // Convenience method for setting title font.
185  // DEFAULT IMPLEMENTATION.
186  virtual void setTitleFont(const PlotFontPtr font);
187 
188  // Returns a copy of the canvas background.
189  virtual PlotAreaFillPtr background() const = 0;
190  virtual PlotAreaFillPtr defaultBackground() const;
191 
192  // Sets the background of the canvas to the given.
193  virtual void setBackground(const PlotAreaFill& areaFill) = 0;
194 
195  // Convenience methods for setting background.
196  // DEFAULT IMPLEMENTATION.
197  // <group>
198  virtual void setBackground(const PlotAreaFillPtr areaFill);
199  virtual void setBackground(const casacore::String& color,
201  // </group>
202 
203  // Gets/sets the cursor for this canvas.
204  // <group>
205  virtual PlotCursor cursor() const = 0;
206  virtual void setCursor(PlotCursor cursor) = 0;
207  // </group>
208 
209  // Refreshes the GUI, which includes redrawing plot items as needed even if
210  // drawing is currently being held.
211  virtual void refresh() = 0;
212 
213  // Refreshes the GUI, ONLY for the layers as indicated by the flag. The
214  // flag should be a bitwise-or of PlotCanvasLayer values.
215  virtual void refresh(int drawLayersFlag) = 0;
216 
217  // Indicates whether a cast to QWidget would succeed for this object.
218  virtual bool isQWidget() const = 0;
219 
220 
221  // Axes Methods //
222 
223  // Returns a bitwise-or of PlotAxis values corresponding to which sides are shown
224  virtual PlotAxisBitset shownAxes() const = 0;
225 
226  // Shows/Hides axes based on the given bitset, which should be a bitwise-or
227  // of PlotAxis values.
228  virtual void showAxes(PlotAxisBitset axes) = 0;
229 
230 
231  // Returns true if the given axis is shown, false otherwise.
232  // DEFAULT IMPLEMENTATION.
233  virtual bool isAxisShown(PlotAxis axis) const;
234 
235 
236  // Shows/hides the given axis.
237  // DEFAULT IMPLEMENTATION.
238  virtual void showAxis(PlotAxis axis, bool show = true);
239  virtual void setCommonAxes( bool commonX, bool commonY ) = 0;
240 
241  // Convenience method for showing/hiding two axes at once.
242  // DEFAULT IMPLEMENTATION.
243  virtual void showAxes(PlotAxis xAxis, PlotAxis yAxis, bool show = true);
244 
245  // Convenience method for showing/hiding all four axes at once.
246  // DEFAULT IMPLEMENTATION.
247  virtual void showAllAxes(bool show);
248 
249  // Returns the scale for the given axis.
250  virtual PlotAxisScale axisScale(PlotAxis axis) const = 0;
251 
252  // Sets the scale for the given axis and rescales accordingly. May reset
253  // tool stacks.
254  virtual void setAxisScale(PlotAxis axis, PlotAxisScale scale, casacore::uInt base=10) = 0;
255 
256  // Sets/gets the sort direction of the scale for the given axis
257  virtual bool setAxisScaleSortDirection(PlotAxis axis, SortDirection direction) = 0;
258  virtual std::pair<bool,SortDirection> axisScaleSortDirection(PlotAxis axis) const = 0;
259 
260  // Sets/gets the angle format of the scale for the given axis
261  virtual void setAxisScaleAngleFormat(PlotAxis axis, AngleFormat format) = 0;
262  virtual AngleFormat axisScaleAngleFormat(PlotAxis axis) const = 0;
263 
264  // Convenience method for setting the axis scale for two axes at once. May
265  // reset tool stacks.
266  // DEFAULT IMPLEMENTATION.
267  virtual void setAxesScales(PlotAxis xAxis, PlotAxisScale xScale,
268  PlotAxis yAxis, PlotAxisScale yScale);
269 
270  // Gets/Sets the reference values for the given axis. If a reference value
271  // is set for an axis, its tick labels use an offset from that value
272  // instead of the actual tick value. For example, if a reference value is
273  // set to 15, instead of ticks reading "14 15 16" they would read "-1 0 1".
274  // <group>
275  virtual bool axisReferenceValueSet(PlotAxis axis) const = 0;
276  virtual double axisReferenceValue(PlotAxis axis) const = 0;
277  virtual void setAxisReferenceValue(PlotAxis axis, bool on,
278  double value = 0) = 0;
279  // </group>
280 
281  // Returns whether the given Cartesian axis is shown or not. (See
282  // showCartesianAxis().)
283  virtual bool cartesianAxisShown(PlotAxis axis) const = 0;
284 
285  // Show or hide the given Cartesian axis. A Cartesian axis is different
286  // from a normal axis in that it is inside the graph, corresponding to the
287  // (0,0) location of the plot(s), rather than outside the graph. The
288  // secondary axis is the axis at which the mirrored axis will be placed at
289  // the 0 value of. For example, to show the Cartesian X_BOTTOM axis you'd
290  // likely want to mirror the axis at Y_LEFT = 0, so that would be the
291  // secondary axis. If hideNormalAxis is true, it is equivalent to
292  // showAxis(mirrorAxis, !hideNormalAxis).
293  virtual void showCartesianAxis(PlotAxis mirrorAxis, PlotAxis secondaryAxis,
294  bool show = true, bool hideNormalAxis = true) = 0;
295 
296  // Convenience methods for most common Cartesian axes cases.
297  // DEFAULT IMPLEMENTATION.
298  // <group>
299  virtual void showCartesianAxis(PlotAxis mirrorAxis, bool show = true,
300  bool hideNormalAxis = true);
301  virtual void showCartesianAxes(bool show = true, bool hideNormal = true);
302  // </group>
303 
304  // Returns the label for the given axis, or an empty casacore::String if none is
305  // shown.
306  virtual casacore::String axisLabel(PlotAxis axis) const = 0;
307 
308  // Sets the label of an axis title to the given. Setting the title to an
309  // empty string should remove the title from the axis.
310  virtual void setAxisLabel(PlotAxis axis, const casacore::String& title) = 0;
311 
312  // Convenience method for clearing labels from all axes.
313  // DEFAULT IMPLEMENTATION.
314  virtual void clearAxesLabels();
315 
316  // Returns a copy of the font used for the given axis label. If no title
317  // is shown this behavior is undefined.
318  virtual PlotFontPtr axisFont(PlotAxis axis) const = 0;
319 
320  // Set the font of the axis title to the given.
321  virtual void setAxisFont(PlotAxis axis, const PlotFont& font) = 0;
322 
323  // Convenience method for setting axis font.
324  // DEFAULT IMPLEMENTATION.
325  virtual void setAxisFont(PlotAxis axis, const PlotFontPtr font);
326 
327  // Returns true if a color bar is shown on the given axis, false otherwise.
328  // A color bar should only be shown when one of more of the items on the
329  // canvas is a RasterPlot or a SpectrogramPlot. If there are multiple
330  // raster or spectrograms, behavior is undefined.
331  virtual bool colorBarShown(PlotAxis axis = Y_RIGHT) const = 0;
332 
333  // Shows/hides a color bar is shown on the given axis. (See
334  // colorBarShown().)
335  virtual void showColorBar(bool show = true, PlotAxis axis = Y_RIGHT) = 0;
336 
337 
338  // Axes Range Methods //
339 
340  // Returns the displayed range of the given axis, in world coordinates.
341  virtual prange_t axisRange(PlotAxis axis) const = 0;
342 
343  // Returns the displayed ranges of the given axes, in world coordinates.
344  // DEFAULT IMPLEMENTATION.
345  virtual PlotRegion axesRanges(PlotAxis xAxis, PlotAxis yAxis) const;
346 
347  // Sets the displayed range of the given axis, in world coordinates.
348  // Implies setAxesAutoRescale(false), and does NOT reset tool stacks since
349  // the tools may be using this method.
350  virtual void setAxisRange(PlotAxis axis, double from, double to) = 0;
351 
352  // Swap scale's boundaries of the given axis
353  virtual void invertAxis(PlotAxis axis) = 0;
354 
355  // See setAxisRange(PlotAxis, double, double).
356  // DEFAULT IMPLEMTNATION.
357  virtual void setAxisRange(PlotAxis axis, const prange_t& range);
358 
359  // Sets the displayed ranges of the given axes, in world coordinates.
360  // Implies setAxesAutoRescale(false), and does NOT reset tool stacks since
361  // the tools may be using this method. It is recommended that subclasses
362  // reimplement this to be more efficient.
363  // DEFAULT IMPLEMENTATION.
364  // <group>
365  virtual void setAxesRanges(PlotAxis xAxis, double xFrom, double xTo,
366  PlotAxis yAxis, double yFrom, double yTo);
367  virtual void setAxesRanges(PlotAxis xAxis, const prange_t& xRange,
368  PlotAxis yAxis, const prange_t& yRange);
369  // </group>
370 
371  // Sets the displayed range of the given axes. Implies
372  // setAxesAutoRescale(false), and does NOT reset tool stacks since the
373  // tools may be using this method.
374  // DEFAULT IMPLEMENTATION.
375  virtual void setAxesRegion(PlotAxis xAxis, PlotAxis yAxis,
376  const PlotRegion& region);
377 
378  // Moves (pans) the axes range by the given delta, in world coordinates.
379  // Implies setAxesAutoRescale(false), and does NOT reset tool stacks since
380  // the tools may be using these methods.
381  // DEFAULT IMPLEMENTATION.
382  // <group>
383  virtual void moveAxisRange(PlotAxis axis, double delta);
384  virtual void moveAxesRanges(PlotAxis xAxis, double xDelta,
385  PlotAxis yAxis, double yDelta);
386  // </group>
387 
388  // Returns true if the axes are set to autorescale when a new plot item is
389  // added, false otherwise.
390  virtual bool axesAutoRescale() const = 0;
391 
392  // Sets auto-rescaling for future plot items. If autoRescale is true,
393  // implies setAxesRatioLocked(false).
394  virtual void setAxesAutoRescale(bool autoRescale = true) = 0;
395 
396  // Rescales the axis to show all plot items on the canvas. Implies
397  // setAxesAutoRescale(false), and may reset PlotTools.
398  virtual void rescaleAxes() = 0;
399 
400  // Returns true if the axes ratio is locked, false otherwise. If the
401  // ratio is locked, resizing one axis will resize the others
402  // proportionally.
403  virtual bool axesRatioLocked() const = 0;
404 
405  // Sets whether the axes ratio is locked or not.
406  virtual void setAxesRatioLocked(bool locked = true) = 0;
407 
408 
409  // casacore::Stack Methods //
410 
411  // Returns a single PlotAxesStack associated with this canvas. Note that
412  // the canvas itself doesn't modify/use this stack AT ALL; it is expressly
413  // for outside tools/classes/etc to have a single stack per canvas.
414  // DEFAULT IMPLEMENTATION.
415  // <group>
416  virtual PlotAxesStack& axesStack();
417  virtual const PlotAxesStack& axesStack() const;
418  // </group>
419 
420  // Convenience method to move along the PlotAxesStack associated with this
421  // canvas (see axesStack()). Calls the stack's moveAndReturn method, and
422  // then sets the axes ranges to the returned PlotRegion. If delta is 0,
423  // the stack is moved to its base; otherwise it moves forward or backward
424  // from the current stack index (see PlotAxesStack::moveAndReturn()).
425  // Returns true if the operation succeeded, false otherwise (for invalid
426  // delta).
427  // DEFAULT IMPLEMENTATION.
428  virtual bool axesStackMove(int delta);
429 
430  // Gets/Sets the length limit on the PlotAxesStack associated with this
431  // canvas. See PlotAxesStack::lengthLimit() and
432  // PlotAxesStack::setLengthLimit().
433  // DEFAULT IMPLEMENTATION.
434  // <group>
435  virtual int axesStackLengthLimit() const;
436  virtual void setAxesStackLengthLimit(int lengthLimit);
437  // </group>
438 
439  // Gets/Sets the size limit, in kilobytes, on the draw cache for the axes
440  // stack associated with this canvas (see
441  // PlotFactory::canvasHasCachedAxesStack()). A zero or negative value
442  // means no limit. NOTE: Only valid for implementations that supports a
443  // cached axes stack.
444  // <group>
445  virtual int cachedAxesStackSizeLimit() const = 0;
446  virtual void setCachedAxesStackSizeLimit(int sizeInKilobytes) = 0;
447  // </group>
448 
449  // Gets/Sets the size of the image used for the cached axes stack, in
450  // pixels. The default implementation is set to (-1, -1) which means that
451  // the images are set to the current size of the canvas. It could be
452  // useful to set this value to a large size so that, for example, resizing
453  // wouldn't require a redraw of the whole canvas but rather just resizing
454  // the larger image to a smaller one.
455  // DEFAULT IMPLEMENTATION.
456  // <group>
457  virtual std::pair<int, int> cachedAxesStackImageSize() const;
458  virtual void setCachedAxesStackImageSize(int width, int height);
459  // </group>
460 
461 
462  // Plot Methods //
463 
464  // Adds the given plot item to this canvas, if not null or otherwise
465  // invalid. Returns whether the adding succeeded or not. May reset
466  // registered PlotTools.
467  virtual bool plotItem(PlotItemPtr item, PlotCanvasLayer layer = MAIN) = 0;
468 
469  // Item-specific add methods.
470  // DEFAULT IMPLEMENTATION.
471  // <group>
472  virtual bool plot(PlotPtr plot, bool overplot = true);
473  virtual bool plotPoint(PlotPointPtr point);
474  virtual bool drawShape(PlotShapePtr shape);
475  virtual bool drawAnnotation(PlotAnnotationPtr annotation);
476  // </group>
477 
478  // Returns all plot items currently on the canvas.
479  virtual std::vector<PlotItemPtr> allPlotItems() const = 0;
480 
481  // Item-specific all methods.
482  // DEFAULT IMPLEMENTATION.
483  // <group>
484  virtual std::vector<PlotPtr> allPlots() const;
485  virtual std::vector<PlotPointPtr> allPoints() const;
486  virtual std::vector<PlotShapePtr> allShapes() const;
487  virtual std::vector<PlotAnnotationPtr> allAnnotations() const;
488  // </group>
489 
490  // Returns the number of plot items currently on the canvas.
491  // DEFAULT IMPLEMENTATION.
492  virtual unsigned int numPlotItems() const;
493 
494  // Item-specific num methods.
495  // DEFAULT IMPLEMENTATION.
496  // <group>
497  virtual unsigned int numPlots() const;
498  virtual unsigned int numPoints() const;
499  virtual unsigned int numShapes() const;
500  virtual unsigned int numAnnotations() const;
501  // </group>
502 
503  // Returns all plot items currently on the given layer of the canvas.
504  virtual std::vector<PlotItemPtr> layerPlotItems(PlotCanvasLayer layer) const= 0;
505 
506  // Item-specific layer methods.
507  // DEFAULT IMPLEMENTATION.
508  // <group>
509  virtual std::vector<PlotPtr> layerPlots(PlotCanvasLayer layer) const;
510  virtual std::vector<PlotPointPtr> layerPoints(PlotCanvasLayer layer) const;
511  virtual std::vector<PlotShapePtr> layerShapes(PlotCanvasLayer layer) const;
512  virtual std::vector<PlotAnnotationPtr> layerAnnotations(PlotCanvasLayer l)const;
513  // </group>
514 
515  // Returns the number of plot items currently on the given layer of the
516  // canvas.
517  // DEFAULT IMPLEMENTATION.
518  virtual unsigned int numLayerPlotItems(PlotCanvasLayer layer) const;
519 
520  // Item-specific layer num methods.
521  // DEFAULT IMPLEMENTATION.
522  // <group>
523  virtual unsigned int numLayerPlots(PlotCanvasLayer layer) const;
524  virtual unsigned int numLayerPoints(PlotCanvasLayer layer) const;
525  virtual unsigned int numLayerShapes(PlotCanvasLayer layer) const;
526  virtual unsigned int numLayerAnnotations(PlotCanvasLayer layer) const;
527  // </group>
528 
529  // Removes the given item from this canvas (if valid) and updates the GUI.
530  // May reset registered PlotTools.
531  // DEFAULT IMPLEMENTATION.
532  virtual void removePlotItem(PlotItemPtr item);
533 
534  // Item-specific remove methods.
535  // DEFAULT IMPLEMENTATION.
536  // <group>
537  virtual void removePlot(PlotPtr plot);
538  virtual void removePoint(PlotPointPtr point);
539  virtual void removeShape(PlotShapePtr shape);
540  virtual void removeAnnotation(PlotAnnotationPtr annotation);
541  // </group>
542 
543  // Removes the given items from this canvas (if valid) and updates the GUI.
544  // May reset registered PlotTools.
545  virtual void removePlotItems(const std::vector<PlotItemPtr>& items) = 0;
546 
547  // Removes the last plot item added to the canvas and updates the GUI. May
548  // reset registered PlotTools.
549  // DEFAULT IMPLEMENTATION.
550  virtual void removeLastPlotItem();
551 
552  // Item-specific remove last methods.
553  // DEFAULT IMPLEMENTATION.
554  // <group>
555  virtual void removeLastPlot();
556  virtual void removeLastPoint();
557  virtual void removeLastShape();
558  virtual void removeLastAnnotation();
559  // </group>
560 
561  // Clears all plot items from this canvas and updates the GUI. May reset
562  // registered PlotTools.
563  // DEFAULT IMPLEMENTATION.
564  virtual void clearItems();
565 
566  // Item-specific clear methods.
567  // DEFAULT IMPLEMENTATION.
568  // <group>
569  virtual void clearPlots();
570  virtual void clearPoints();
571  virtual void clearShapes();
572  virtual void clearAnnotations();
573  // </group>
574 
575  // Clears all plot items from the given layer on this canvas and updates
576  // the GUI. May reset registered PlotTools.
577  // DEFAULT IMPLEMENTATION.
578  virtual void clearLayer(PlotCanvasLayer layer);
579 
580 
581  // Draw Methods //
582 
583  // Hold or release drawing of plot items on the canvas. This can be used,
584  // for example, when adding many items to a canvas to avoid redrawing the
585  // canvas until all items are on. Hold/release are NOT recursive.
586  // <group>
587  virtual void holdDrawing() = 0;
588  virtual void releaseDrawing() = 0;
589  virtual bool drawingIsHeld() const = 0;
590  // </group>
591 
592  // Registers/Unregisters the given draw watcher for this canvas. See
593  // documentation for PlotDrawWatcher.
594  // DEFAULT IMPLEMENTATION.
595  // <group>
596  virtual void registerDrawWatcher(PlotDrawWatcherPtr watcher);
597  virtual void unregisterDrawWatcher(PlotDrawWatcherPtr watcher);
598  // </group>
599 
600  // Returns a PlotOperation object that can be used to track drawing
601  // progress across threads. There must be one PlotOperation for drawing
602  // per canvas.
603  // DEFAULT IMPLEMENTATION.
604  // <group>
607  // </group>
608 
609 
610  // Selection Methods //
611 
612  // Returns true if a line is shown for the selection tool, false otherwise.
613  // DEFAULT IMPLEMENTATION.
614  virtual bool selectLineShown() const;
615 
616  // Sets whether a line is shown for the selection tool.
617  virtual void setSelectLineShown(bool shown = true) = 0;
618 
619  // returns a copy of the line for the selection tool
620  virtual PlotLinePtr selectLine() const = 0;
621 
622  // set the line for the selection tool
623  virtual void setSelectLine(const PlotLine& line) = 0;
624 
625  // Convenience methods for setting selection line.
626  // DEFAULT IMPLEMENTATION.
627  // <group>
628  virtual void setSelectLine(const PlotLinePtr line);
629  virtual void setSelectLine(const casacore::String& color,
631  double width = 1.0);
632  // </group>
633 
634 
635  // Grid Methods //
636 
637  // Returns true if any grid lines are shown, false otherwise. If bool
638  // parameters are given, they will be set for if each line group is shown
639  // or not.
640  virtual bool gridShown(bool* xMajor = NULL, bool* xMinor = NULL,
641  bool* yMajor = NULL, bool* yMinor = NULL) const = 0;
642 
643  // Sets whether the grid is shown, for each of the given line groups.
644  virtual void showGrid(bool xMajor, bool xMinor, bool yMajor,bool yMinor)=0;
645 
646  // Convenience methods for showing/hiding the grid.
647  // DEFAULT IMPLEMENTATION.
648  // <group>
649  virtual void showGrid(bool showAll = true);
650  virtual void showGridMajor(bool show = true);
651  virtual void showGridMinor(bool show = true);
652  // </group>
653 
654  // Gets/Sets whether major grid lines are shown for the x-axis.
655  // DEFAULT IMPLEMENTATION.
656  // <group>
657  virtual bool gridXMajorShown() const;
658  virtual void showGridXMajor(bool s = true);
659  // </group>
660 
661  // Gets/Sets whether minor grid lines are shown for the x-axis.
662  // DEFAULT IMPLEMENTATION.
663  // <group>
664  virtual bool gridXMinorShown() const;
665  virtual void showGridXMinor(bool s = true);
666  // </group>
667 
668  // Gets/Sets whether major grid lines are shown for the y-axis.
669  // DEFAULT IMPLEMENTATION.
670  // <group>
671  virtual bool gridYMajorShown() const;
672  virtual void showGridYMajor(bool s = true);
673  // </group>
674 
675  // Gets/Sets whether minor grid lines are shown for the y-axis.
676  // DEFAULT IMPLEMENTATION.
677  // <group>
678  virtual bool gridYMinorShown() const;
679  virtual void showGridYMinor(bool s = true);
680  // </group>
681 
682  // Returns a copy of the line used to draw the major grid lines.
683  virtual PlotLinePtr gridMajorLine() const = 0;
684 
685  // Sets the line used to draw the major grid lines.
686  virtual void setGridMajorLine(const PlotLine& line) = 0;
687 
688  // Returns a copy of the line used to draw the minor grid lines.
689  virtual PlotLinePtr gridMinorLine() const = 0;
690 
691  // Sets the line used to draw the minor grid lines.
692  virtual void setGridMinorLine(const PlotLine& line) = 0;
693 
694  // Convenience methods for setting major/minor grid lines.
695  // DEFAULT IMPLEMENTATION.
696  // <group>
697  virtual void setGridMajorLine(const PlotLinePtr line);
698  virtual void setGridMajorLine(const casacore::String& color,
699  PlotLine::Style style = PlotLine::SOLID, double width = 1.0);
700  virtual void setGridMinorLine(const PlotLinePtr line);
701  virtual void setGridMinorLine(const casacore::String& color,
702  PlotLine::Style style = PlotLine::SOLID, double width = 1.0);
703  // </group>
704 
705 
706  // Legend Methods //
707 
708  // Returns whether the legend is shown or not
709  virtual bool legendShown() const = 0;
710 
711  // Show/hide the legend. If on is true, show the legend in the given
712  // position.
713  virtual void showLegend(bool on = true,
714  LegendPosition position = EXT_BOTTOM) = 0;
715 
716  // Returns the position of the legend. Note: if the legend is hidden,
717  // this behavior is undefined.
718  virtual LegendPosition legendPosition() const = 0;
719 
720  // Sets the position of the legend, if it is shown.
721  virtual void setLegendPosition(LegendPosition position) = 0;
722 
723  // Returns a copy of the line used to outline the legend.
724  virtual PlotLinePtr legendLine() const = 0;
725 
726  // Sets the line used to outline the legend.
727  virtual void setLegendLine(const PlotLine& line) = 0;
728 
729  // Convenience methods for setting legend line.
730  // DEFAULT IMPLEMENTATION.
731  // <group>
732  virtual void setLegendLine(const PlotLinePtr line);
733  virtual void setLegendLine(const casacore::String& color,
734  PlotLine::Style style = PlotLine::SOLID, double width = 1.0);
735  // </group>
736 
737  // Returns a copy of the area fill used for the legend background
738  virtual PlotAreaFillPtr legendFill() const = 0;
739 
740  // Sets the area fill used for the legend background
741  virtual void setLegendFill(const PlotAreaFill& area) = 0;
742 
743  // Convenience methods for setting legend background.
744  // DEFAULT IMPLEMENTATION.
745  // <group>
746  virtual void setLegendFill(const PlotAreaFillPtr area);
747  virtual void setLegendFill(const casacore::String& color,
749  // </group>
750 
751  // Returns a copy of the font used for the legend text.
752  virtual PlotFontPtr legendFont() const = 0;
753 
754  // Sets the font used for the legend text.
755  virtual void setLegendFont(const PlotFont& font) = 0;
756 
757  // Convenience method for setting legend font.
758  // DEFAULT IMPLEMENTATION.
759  virtual void setLegendFont(const PlotFontPtr font);
760 
761 
762  // Miscellaneous Plotting Functionality //
763 
764  // Returns true if autoincrementcolors is on, false otherwise. (See
765  // setAutoIncrementColors().)
766  virtual bool autoIncrementColors() const = 0;
767 
768  // Sets whether adding new overplotted plots should automatically
769  // "increment" colors or not. If this property is true, each new
770  // overplotted plot should have a different color. The specific handling
771  // of this behavior is left up to the implementation.
772  virtual void setAutoIncrementColors(bool autoInc = true) = 0;
773 
774  // Exports this canvas to the given format and returns true on success.
775  virtual bool exportToFile(const PlotExportFormat& format) = 0;
776 
777  // Returns a PlotOperation object that can be used to track export
778  // progress across threads. There must be one PlotOperation for export
779  // per canvas.
780  // DEFAULT IMPLEMENTATION.
781  // <group>
784  // </group>
785 
786  // Shows a file chooser dialog and return the absolute filename that the
787  // user chooses. If a directory is given, start the dialog there. If the
788  // user cancels the dialog, an empty casacore::String should be returned.
789  virtual casacore::String fileChooserDialog(const casacore::String& title = "File Chooser",
790  const casacore::String& directory = "") = 0;
791 
792  // Gets/Sets the date format for this canvas. See Plotter::dateFormat().
793  // <group>
794  virtual const casacore::String& dateFormat() const = 0;
795  virtual void setDateFormat(const casacore::String& dateFormat) = 0;
796  // </group>
797 
798  // Gets/Sets the date format for values relative to a reference value for
799  // this canvas. See Plotter::relativeDateFormat().
800  // <group>
801  virtual const casacore::String& relativeDateFormat() const = 0;
802  virtual void setRelativeDateFormat(const casacore::String& dateFormat) = 0;
803  // </group>
804 
805  // Converts the given coordinate into a coordinate with the given system.
806  virtual PlotCoordinate convertCoordinate(const PlotCoordinate& coord,
807  PlotCoordinate::System newSystem = PlotCoordinate::WORLD) const = 0;
808 
809  bool hasSelectedRectangles();
810  std::vector<PlotRegion> getSelectedRects();
811  void clearSelectedRects();
812 
813  // methods related to per-panel flag mode
814  void clearMark();
815  bool isMarkedForFlag();
816  bool isMarkedForUnflag();
818  void setAllFlagged();
819 
820  // Converts the given region into a region with the given system.
821  // DEFAULT IMPLEMENTATION.
822  virtual PlotRegion convertRegion(const PlotRegion& region,
823  PlotCoordinate::System newSystem) const;
824 
825  // Returns the width, height, and descent for the given text in the given
826  // font. Note: this was put into place for use in a matplotlib backend,
827  // but probably doesn't have much use outside that.
828  virtual std::vector<double> textWidthHeightDescent(const casacore::String& text,
829  PlotFontPtr font) const = 0;
830 
831  // Returns the width, height, and descent for the given annotation. Note:
832  // this was put into place for use in a matplotlib backend, but probably
833  // doesn't have much use outside that.
834  // DEFAULT IMPLEMENTATION.
835  virtual std::vector<double> annotationWidthHeightDescent(
836  const PlotAnnotationPtr annot) const;
837 
838  // Returns the implementation of this canvas as a Plotter::Implementation
839  // value.
840  virtual int implementation() const = 0;
841 
842  // Returns a new instance of a PlotFactory that can create plot items for
843  // this implementation. It is the caller's responsibility to delete the
844  // PlotFactory when finished.
845  virtual PlotFactory* implementationFactory() const = 0;
846 
847  // Returns a mutex appropriate for this implementation.
848  // DEFAULT IMPLEMENTATION.
849  virtual PlotMutexPtr mutex() const;
850 
851  // Locate data indices that have values within the given region such that:
852  // x >= region.upperLeft().x() && x <= region.lowerRight().x() &&
853  // y <= region.upperLeft().y() && y >= region.lowerRight().y().
854  // The returned vector has length equal to allPlots().size() (in other
855  // words, each plot on the canvas has an index in the returned vector).
856  // Each element of the returned vector is a list of all the data indices
857  // that are in the region. Each element in this list is a range of indices.
858  // For plots that have no data in the region, the list is empty.
859  //
860  // For example, say there are two plots on the canvas. In the first plot,
861  // indices 1, 2, 3, 7, and 10 are in the region; in the second plot,
862  // indices 6 and 7 are in the region. The returned value would be a vector
863  // of size 2. The first element would be the list [(1, 3), (7, 7),
864  // (10, 10)] while the second element would be the list [(6, 7)].
865  // DEFAULT IMPLEMENTATION.
866  virtual std::vector<std::vector<std::pair<unsigned int, unsigned int> > >* locate(
867  const PlotRegion& region) const;
868 
869  // Calls locate() and posts the result to the given log.
870  // DEFAULT IMPLEMENTATION.
871  virtual void locateAndLog(const PlotRegion& region,
872  PlotLoggerPtr logger) const;
873 
874 
875  // Tool Methods //
876 
877  // Manage mouse tools.
878  // DEFAULT IMPLEMENTATION.
879  // <group>
880  virtual void registerMouseTool(PlotMouseToolPtr tool, bool activate = true,
881  bool blocking = false);
882  virtual std::vector<PlotMouseToolPtr> allMouseTools() const;
883  virtual std::vector<PlotMouseToolPtr> activeMouseTools() const;
884  virtual void unregisterMouseTool(PlotMouseToolPtr tool);
885  // </group>
886 
887  // Returns the standard mouse tools associated with this canvas. If none
888  // is associated, creates and associates one that is non-active.
889  // DEFAULT IMPLEMENTATION.
890  virtual PlotStandardMouseToolGroupPtr standardMouseTools();
891 
892 
893  // Event Handler Methods //
894 
895  // Manage select handlers.
896  // DEFAULT IMPLEMENTATION.
897  // <group>
899  PlotCoordinate::System system = PlotCoordinate::WORLD);
900  virtual std::vector<PlotSelectEventHandlerPtr> allSelectHandlers() const;
902  // </group>
903 
904  // Manage click handlers.
905  // DEFAULT IMPLEMENTATION.
906  // <group>
907  virtual void registerClickHandler(PlotClickEventHandlerPtr handler,
908  PlotCoordinate::System system = PlotCoordinate::WORLD);
909  virtual std::vector<PlotClickEventHandlerPtr> allClickHandlers() const;
910  virtual void unregisterClickHandler(PlotClickEventHandlerPtr handler);
911  // </group>
912 
913  // Manage mouse press handlers.
914  // DEFAULT IMPLEMENTATION.
915  // <group>
917  PlotCoordinate::System system = PlotCoordinate::WORLD);
918  virtual std::vector<PlotMousePressEventHandlerPtr>
919  allMousePressHandlers() const;
920  virtual void unregisterMousePressHandler(
922  // </group>
923 
924  // Manage mouse release handlers.
925  // DEFAULT IMPLEMENTATION.
926  // <group>
927  virtual void registerMouseReleaseHandler(
929  PlotCoordinate::System system = PlotCoordinate::WORLD);
930  virtual std::vector<PlotMouseReleaseEventHandlerPtr>
931  allMouseReleaseHandlers() const;
932  virtual void unregisterMouseReleaseHandler(
934  // </group>
935 
936  // Manage mouse drag handlers.
937  // DEFAULT IMPLEMENTATION.
938  // <group>
940  PlotCoordinate::System system = PlotCoordinate::WORLD);
941  virtual std::vector<PlotMouseDragEventHandlerPtr> allMouseDragHandlers() const;
943  // </group>
944 
945  // Manage mouse move handlers. NOTE: since this can be costly, it should
946  // be avoided if possible. Implementation canvases are expected to
947  // conserve resources if no move handlers are registered.
948  // DEFAULT IMPLEMENTATION.
949  // <group>
951  PlotCoordinate::System system = PlotCoordinate::WORLD);
952  virtual std::vector<PlotMouseMoveEventHandlerPtr> allMouseMoveHandlers() const;
954  // </group>
955 
956  // Manage wheel handlers.
957  // DEFAULT IMPLEMENTATION.
958  // <group>
959  virtual void registerWheelHandler(PlotWheelEventHandlerPtr handler,
960  PlotCoordinate::System system = PlotCoordinate::WORLD);
961  virtual std::vector<PlotWheelEventHandlerPtr> allWheelHandlers() const;
962  virtual void unregisterWheelHandler(PlotWheelEventHandlerPtr handler);
963  // </group>
964 
965  // Manage key handlers.
966  // DEFAULT IMPLEMENTATION.
967  // <group>
968  virtual void registerKeyHandler(PlotKeyEventHandlerPtr handler);
969  virtual std::vector<PlotKeyEventHandlerPtr> allKeyHandlers() const;
970  virtual void unregisterKeyHandler(PlotKeyEventHandlerPtr handler);
971  // </group>
972 
973  // Manage resize handlers.
974  // DEFAULT IMPLEMENTATION.
975  // <group>
976  virtual void registerResizeHandler(PlotResizeEventHandlerPtr handler);
977  virtual std::vector<PlotResizeEventHandlerPtr> allResizeHandlers() const;
979  // </group>
980 
981 protected:
982  // One-per-canvas axes stack.
984 
985  // One-per-canvas operations.
986  // <group>
989  // </group>
990 
991  // Draw watchers.
992  std::vector<PlotDrawWatcherPtr> m_drawWatchers;
993 
994  // One-per-canvas standard mouse tools.
995  PlotStandardMouseToolGroupPtr m_standardTools;
996 
997  // Registered mouse tools.
998  std::vector<PlotMouseToolPtr> m_mouseTools;
999 
1000  // Event handlers.
1001  // <group>
1002  std::vector<std::pair<PlotSelectEventHandlerPtr, PlotCoordinate::System> >
1004  std::vector<std::pair<PlotClickEventHandlerPtr, PlotCoordinate::System> >
1006  std::vector<std::pair<PlotMousePressEventHandlerPtr, PlotCoordinate::System> >
1008  std::vector<std::pair<PlotMouseReleaseEventHandlerPtr, PlotCoordinate::System> >
1010  std::vector<std::pair<PlotMouseDragEventHandlerPtr, PlotCoordinate::System> >
1012  std::vector<std::pair<PlotMouseMoveEventHandlerPtr, PlotCoordinate::System> >
1014  std::vector<std::pair<PlotWheelEventHandlerPtr, PlotCoordinate::System> >
1016  std::vector<PlotKeyEventHandlerPtr> m_keyHandlers;
1017  std::vector<PlotResizeEventHandlerPtr> m_resizeHandlers;
1018  // </group>
1019 
1020 
1021  // Resets mouse tools.
1022  void resetMouseTools();
1023 
1024  // Notifies any registered draw watchers that a draw is about to begin, and
1025  // returns the AND of the PlotDrawWatcher::canvasDrawBeginning() results.
1026  // See PlotDrawWatcher::canvasDrawBeginning() for parameters.
1027  bool notifyDrawWatchers(PlotOperationPtr drawOperation,
1028  bool drawingIsThreaded, int drawnLayersFlag);
1029 
1030  // Notification methods for event handlers. Returns true if one mouse tool
1031  // or event handler was available to handle the event, false otherwise.
1032  // <group>
1033  bool notifySelectHandlers(const PlotRegion& selectedRegion);
1035  PlotMouseEvent::Button button, const PlotCoordinate& coord);
1037  const PlotCoordinate& coord);
1039  const PlotCoordinate& coord);
1041  const PlotCoordinate& coord);
1043  const PlotCoordinate& coord);
1045  const PlotCoordinate& coord);
1046  bool notifyWheelHandlers(int delta, const PlotCoordinate& coord);
1047  bool notifyKeyHandlers(char key,
1048  const std::vector<PlotKeyEvent::Modifier>& modifiers);
1049  bool notifyResizeHandlers(int oldWidth, int oldHeight,
1050  int newWidth, int newHeight);
1051  // </group>
1052 };
1054 
1055 }
1056 
1057 #endif /*PLOTCANVAS_H_*/
bool notifyDragHandlers(PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual void clearShapes()
LegendPosition
Static //.
Definition: PlotCanvas.h:88
virtual std::vector< PlotPointPtr > layerPoints(PlotCanvasLayer layer) const
virtual void moveAxesRanges(PlotAxis xAxis, double xDelta, PlotAxis yAxis, double yDelta)
virtual PlotRegion axesRanges(PlotAxis xAxis, PlotAxis yAxis) const
Returns the displayed ranges of the given axes, in world coordinates.
std::vector< PlotResizeEventHandlerPtr > m_resizeHandlers
Definition: PlotCanvas.h:1017
virtual PlotAreaFillPtr legendFill() const =0
Returns a copy of the area fill used for the legend background.
virtual bool gridYMajorShown() const
Gets/Sets whether major grid lines are shown for the y-axis.
virtual bool setAxisScaleSortDirection(PlotAxis axis, SortDirection direction)=0
Sets/gets the sort direction of the scale for the given axis.
virtual void removePlotItems(const std::vector< PlotItemPtr > &items)=0
Removes the given items from this canvas (if valid) and updates the GUI.
virtual AngleFormat axisScaleAngleFormat(PlotAxis axis) const =0
virtual void holdDrawing()=0
Draw Methods //.
virtual void removeLastShape()
bool hasSelectedRectangles()
std::vector< std::pair< PlotMouseMoveEventHandlerPtr, PlotCoordinate::System > > m_moveHandlers
Definition: PlotCanvas.h:1013
static std::vector< LegendPosition > allLegendPositions()
Returns all legend positions.
virtual unsigned int numPlotItems() const
Returns the number of plot items currently on the canvas.
virtual std::vector< PlotItemPtr > allPlotItems() const =0
Returns all plot items currently on the canvas.
virtual void removeLastPlotItem()
Removes the last plot item added to the canvas and updates the GUI.
virtual unsigned int numLayerPoints(PlotCanvasLayer layer) const
virtual PlotAxisBitset shownAxes() const =0
Axes Methods //.
virtual void showGridXMajor(bool s=true)
static int allLayersFlag()
Returns the or&#39;ed value of all PlotCanvasLayer enum values.
bool notifyResizeHandlers(int oldWidth, int oldHeight, int newWidth, int newHeight)
virtual prange_t xRange() const =0
Returns the range of x.
virtual bool gridShown(bool *xMajor=NULL, bool *xMinor=NULL, bool *yMajor=NULL, bool *yMinor=NULL) const =0
Grid Methods //.
virtual void clearAxesLabels()
Convenience method for clearing labels from all axes.
virtual PlotLinePtr legendLine() const =0
Returns a copy of the line used to outline the legend.
PlotOperationPtr m_exportOperation
Definition: PlotCanvas.h:988
virtual PlotFontPtr legendFont() const =0
Returns a copy of the font used for the legend text.
virtual void showGrid(bool xMajor, bool xMinor, bool yMajor, bool yMinor)=0
Sets whether the grid is shown, for each of the given line groups.
virtual bool hasThreadedDrawing() const
Support Methods //.
virtual void unregisterMouseTool(PlotMouseToolPtr tool)
virtual std::vector< PlotClickEventHandlerPtr > allClickHandlers() const
virtual void showGridMajor(bool show=true)
virtual std::pair< int, int > cachedAxesStackImageSize() const
Gets/Sets the size of the image used for the cached axes stack, in pixels.
virtual std::vector< PlotResizeEventHandlerPtr > allResizeHandlers() const
virtual PlotOperationPtr operationExport()
Returns a PlotOperation object that can be used to track export progress across threads.
virtual bool canvasDrawBeginning(PlotOperationPtr drawOperation, bool drawingIsThreaded, int drawnLayersFlag)=0
This method should be called by the canvas whenever drawing is about to begin.
virtual prange_t axisRange(PlotAxis axis) const =0
Axes Range Methods //.
virtual int implementation() const =0
Returns the implementation of this canvas as a Plotter::Implementation value.
virtual void unregisterKeyHandler(PlotKeyEventHandlerPtr handler)
virtual void setTitleFont(const PlotFont &font)=0
Set the font of the canvas title to the given.
virtual bool selectLineShown() const
Selection Methods //.
virtual std::vector< PlotItemPtr > layerPlotItems(PlotCanvasLayer layer) const =0
Returns all plot items currently on the given layer of the canvas.
static std::vector< PlotCanvasLayer > allLayers()
Returns a vector containing all values in the PlotCanvasLayer enum, ordered from lowest value to high...
virtual bool plotItem(PlotItemPtr item, PlotCanvasLayer layer=MAIN)=0
Plot Methods //.
PlotStandardMouseToolGroupPtr m_standardTools
One-per-canvas standard mouse tools.
Definition: PlotCanvas.h:995
unsigned int PlotAxisBitset
Set of bit flags to indicate combinations of sides, used (as of this writing) for indicating which ax...
Definition: PlotOptions.h:70
virtual Type type()
Return the type enum.
std::vector< std::pair< PlotWheelEventHandlerPtr, PlotCoordinate::System > > m_wheelHandlers
Definition: PlotCanvas.h:1015
virtual std::vector< PlotAnnotationPtr > allAnnotations() const
virtual unsigned int numAnnotations() const
virtual void removePoint(PlotPointPtr point)
virtual std::vector< PlotMouseDragEventHandlerPtr > allMouseDragHandlers() const
virtual std::vector< PlotAnnotationPtr > layerAnnotations(PlotCanvasLayer l) const
virtual void setCursor(PlotCursor cursor)=0
virtual void showAxis(PlotAxis axis, bool show=true)
Shows/hides the given axis.
virtual bool axisReferenceValueSet(PlotAxis axis) const =0
Gets/Sets the reference values for the given axis.
virtual void registerResizeHandler(PlotResizeEventHandlerPtr handler)
Manage resize handlers.
PlotDrawWatcher()
Constructor.
Definition: PlotCanvas.h:56
virtual void showLegend(bool on=true, LegendPosition position=EXT_BOTTOM)=0
Show/hide the legend.
virtual PlotLinePtr selectLine() const =0
returns a copy of the line for the selection tool
std::vector< PlotRegion > getSelectedRects()
virtual PlotOperationPtr operationDraw()
Returns a PlotOperation object that can be used to track drawing progress across threads.
virtual void setAxisRange(PlotAxis axis, double from, double to)=0
Sets the displayed range of the given axis, in world coordinates.
Abstract class for area fill.
Definition: PlotOptions.h:296
virtual void unregisterDrawWatcher(PlotDrawWatcherPtr watcher)
virtual void setAxesRatioLocked(bool locked=true)=0
Sets whether the axes ratio is locked or not.
Button
Mouse button types that we care about.
Definition: PlotEvent.h:90
virtual const casacore::String & dateFormat() const =0
Gets/Sets the date format for this canvas.
bool isMarkedForFlag()
virtual std::vector< PlotMouseToolPtr > activeMouseTools() const
virtual bool hasCachedLayerDrawing() const
See PlotFactory::canvasHasCachedLayerDrawing().
virtual void setGridMinorLine(const PlotLine &line)=0
Sets the line used to draw the minor grid lines.
virtual bool plotPoint(PlotPointPtr point)
virtual void removeLastPlot()
Item-specific remove last methods.
virtual PlotFontPtr axisFont(PlotAxis axis) const =0
Returns a copy of the font used for the given axis label.
virtual bool axesRatioLocked() const =0
Returns true if the axes ratio is locked, false otherwise.
virtual void unregisterSelectHandler(PlotSelectEventHandlerPtr handler)
PlotCanvas()
Non-Static //.
The idea behind a plot factory is to produce classes that are useful to the underlying implementation...
Definition: PlotFactory.h:52
virtual void removeAnnotation(PlotAnnotationPtr annotation)
Pattern
Pattern enum, similar in spirit to http://doc.trolltech.com/4.3/qt.html#BrushStyle-enum.
Definition: PlotOptions.h:300
virtual unsigned int numLayerPlots(PlotCanvasLayer layer) const
Item-specific layer num methods.
virtual void clearItems()
Clears all plot items from this canvas and updates the GUI.
std::vector< std::pair< PlotClickEventHandlerPtr, PlotCoordinate::System > > m_clickHandlers
Definition: PlotCanvas.h:1005
virtual unsigned int numPoints() const
virtual void registerKeyHandler(PlotKeyEventHandlerPtr handler)
Manage key handlers.
virtual bool axesStackMove(int delta)
Convenience method to move along the PlotAxesStack associated with this canvas (see axesStack())...
virtual void clearPlots()
Item-specific clear methods.
virtual unsigned int numLayerPlotItems(PlotCanvasLayer layer) const
Returns the number of plot items currently on the given layer of the canvas.
virtual bool gridXMajorShown() const
Gets/Sets whether major grid lines are shown for the x-axis.
virtual std::vector< double > annotationWidthHeightDescent(const PlotAnnotationPtr annot) const
Returns the width, height, and descent for the given annotation.
virtual std::vector< PlotShapePtr > layerShapes(PlotCanvasLayer layer) const
virtual void setCachedAxesStackImageSize(int width, int height)
virtual unsigned int numLayerShapes(PlotCanvasLayer layer) const
virtual void show()=0
virtual bool gridYMinorShown() const
Gets/Sets whether minor grid lines are shown for the y-axis.
virtual std::vector< PlotSelectEventHandlerPtr > allSelectHandlers() const
static bool legendPositionIsInternal(LegendPosition p)
Indicates whether the given legend position is internal to the canvas or not.
TableExprNode pattern(const TableExprNode &node)
Definition: ExprNode.h:1444
virtual PlotMutexPtr mutex() const
Returns a mutex appropriate for this implementation.
virtual PlotAreaFillPtr background() const =0
Returns a copy of the canvas background.
static const casacore::String OPERATION_EXPORT
Definition: PlotCanvas.h:132
virtual void setSelectLine(const PlotLine &line)=0
set the line for the selection tool
virtual void unregisterWheelHandler(PlotWheelEventHandlerPtr handler)
virtual PlotLinePtr gridMinorLine() const =0
Returns a copy of the line used to draw the minor grid lines.
virtual void locateAndLog(const PlotRegion &region, PlotLoggerPtr logger) const
Calls locate() and posts the result to the given log.
virtual void invertAxis(PlotAxis axis)=0
Swap scale&#39;s boundaries of the given axis.
virtual bool plot(PlotPtr plot, bool overplot=true)
Item-specific add methods.
virtual PlotCursor cursor() const =0
Gets/sets the cursor for this canvas.
void resetMouseTools()
Resets mouse tools.
virtual void setAxisFont(PlotAxis axis, const PlotFont &font)=0
Set the font of the axis title to the given.
virtual bool colorBarShown(PlotAxis axis=Y_RIGHT) const =0
Returns true if a color bar is shown on the given axis, false otherwise.
static std::vector< casacore::String > allLegendPositionStrings()
virtual void rescaleAxes()=0
Rescales the axis to show all plot items on the canvas.
virtual void showGridYMinor(bool s=true)
casacore::CountedPtr< PlotCanvas > PlotCanvasPtr
Definition: PlotCanvas.h:1053
virtual void removeLastPoint()
virtual std::vector< PlotWheelEventHandlerPtr > allWheelHandlers() const
virtual std::vector< PlotKeyEventHandlerPtr > allKeyHandlers() const
virtual bool isDrawing()=0
virtual PlotAxesStack & axesStack()
casacore::Stack Methods //
virtual bool exportToFile(const PlotExportFormat &format)=0
Exports this canvas to the given format and returns true on success.
bool notifyMoveHandlers(PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual void clearLayer(PlotCanvasLayer layer)
Clears all plot items from the given layer on this canvas and updates the GUI.
void clearSelectedRects()
bool notifyPressHandlers(PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual void setAxisReferenceValue(PlotAxis axis, bool on, double value=0)=0
virtual void setDateFormat(const casacore::String &dateFormat)=0
virtual void releaseDrawing()=0
virtual prange_t yRange() const =0
Returns the range of y.
virtual PlotAreaFillPtr defaultBackground() const
virtual void setAxisScale(PlotAxis axis, PlotAxisScale scale, casacore::uInt base=10)=0
Sets the scale for the given axis and rescales accordingly.
virtual void setLegendFill(const PlotAreaFill &area)=0
Sets the area fill used for the legend background.
virtual PlotLinePtr gridMajorLine() const =0
Returns a copy of the line used to draw the major grid lines.
A PlotAxesStack is basically a list of PlotRegions as well as axis information that provides stack fu...
Definition: PlotOptions.h:735
virtual void unregisterMousePressHandler(PlotMousePressEventHandlerPtr handler)
virtual void showGridYMajor(bool s=true)
Abstract class for a line.
Definition: PlotOptions.h:368
virtual void unregisterMouseDragHandler(PlotMouseDragEventHandlerPtr h)
virtual void registerMousePressHandler(PlotMousePressEventHandlerPtr hndlr, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage mouse press handlers.
std::vector< std::pair< PlotSelectEventHandlerPtr, PlotCoordinate::System > > m_selectHandlers
Event handlers.
Definition: PlotCanvas.h:1003
static int allAxesFlag()
Returns the or&#39;ed value of all PlotAxis enum values.
PlotOperationPtr m_drawOperation
One-per-canvas operations.
Definition: PlotCanvas.h:987
virtual void showGridXMinor(bool s=true)
virtual void showAllAxes(bool show)
Convenience method for showing/hiding all four axes at once.
virtual void removePlotItem(PlotItemPtr item)
Removes the given item from this canvas (if valid) and updates the GUI.
virtual ~PlotCanvas()
Destructor.
virtual void setAxesAutoRescale(bool autoRescale=true)=0
Sets auto-rescaling for future plot items.
virtual bool autoIncrementColors() const =0
Miscellaneous Plotting Functionality //.
SMART POINTER DEFINITIONS PlotShapePtr
Definition: PlotShape.h:374
virtual casacore::String title() const =0
Returns the text of the canvas title, or an empty casacore::String if none is shown.
virtual std::vector< PlotShapePtr > allShapes() const
virtual void showCartesianAxes(bool show=true, bool hideNormal=true)
virtual bool drawAnnotation(PlotAnnotationPtr annotation)
Style
Static //.
Definition: PlotOptions.h:373
static std::vector< PlotAxis > allAxes()
Returns a std::vector containing all values in the PlotAxis enum, ordered from lowest value to highes...
PlotCursor
Enum for cursors.
Definition: PlotOptions.h:94
virtual void setAxesRegion(PlotAxis xAxis, PlotAxis yAxis, const PlotRegion &region)
Sets the displayed range of the given axes.
PlotAxis
Enum for the four plot axes.
Definition: PlotOptions.h:62
virtual void setAxesStackLengthLimit(int lengthLimit)
virtual std::vector< double > textWidthHeightDescent(const casacore::String &text, PlotFontPtr font) const =0
Returns the width, height, and descent for the given text in the given font.
virtual void registerMouseTool(PlotMouseToolPtr tool, bool activate=true, bool blocking=false)
Tool Methods //.
virtual bool isQWidget() const =0
Indicates whether a cast to QWidget would succeed for this object.
PlotExportFormat contains parameters for exporting a canvas to a file.
Definition: PlotOptions.h:817
virtual double axisReferenceValue(PlotAxis axis) const =0
bool notifyKeyHandlers(char key, const std::vector< PlotKeyEvent::Modifier > &modifiers)
virtual void unregisterClickHandler(PlotClickEventHandlerPtr handler)
virtual void registerWheelHandler(PlotWheelEventHandlerPtr handler, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage wheel handlers.
void clearMark()
methods related to per-panel flag mode
virtual void setSelectLineShown(bool shown=true)=0
Sets whether a line is shown for the selection tool.
virtual void setAxesRanges(PlotAxis xAxis, double xFrom, double xTo, PlotAxis yAxis, double yFrom, double yTo)
Sets the displayed ranges of the given axes, in world coordinates.
virtual void removeShape(PlotShapePtr shape)
std::vector< PlotMouseToolPtr > m_mouseTools
Registered mouse tools.
Definition: PlotCanvas.h:998
bool notifyDrawWatchers(PlotOperationPtr drawOperation, bool drawingIsThreaded, int drawnLayersFlag)
Notifies any registered draw watchers that a draw is about to begin, and returns the AND of the PlotD...
virtual void setLegendFont(const PlotFont &font)=0
Sets the font used for the legend text.
std::vector< std::pair< PlotMousePressEventHandlerPtr, PlotCoordinate::System > > m_pressHandlers
Definition: PlotCanvas.h:1007
virtual void unregisterMouseMoveHandler(PlotMouseMoveEventHandlerPtr h)
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
virtual void moveAxisRange(PlotAxis axis, double delta)
Moves (pans) the axes range by the given delta, in world coordinates.
virtual LegendPosition legendPosition() const =0
Returns the position of the legend.
virtual std::vector< std::vector< std::pair< unsigned int, unsigned int > > > * locate(const PlotRegion &region) const
Locate data indices that have values within the given region such that: x &gt;= region.upperLeft().x() &amp;&amp; x &lt;= region.lowerRight().x() &amp;&amp; y &lt;= region.upperLeft().y() &amp;&amp; y &gt;= region.lowerRight().y().
virtual unsigned int numShapes() const
virtual void hide()=0
virtual bool drawingIsHeld() const =0
virtual bool hasCachedAxesStack() const
See PlotFactory::hasCachedAxesStack().
virtual std::vector< PlotPtr > layerPlots(PlotCanvasLayer layer) const
Item-specific layer methods.
std::pair< double, double > prange_t
Typedef for range, which is two doubles (min and max).
Definition: PlotOptions.h:41
PlotCanvas is an area for different PlotItems to be attached and drawn.
Definition: PlotCanvas.h:83
virtual PlotCoordinate convertCoordinate(const PlotCoordinate &coord, PlotCoordinate::System newSystem=PlotCoordinate::WORLD) const =0
Converts the given coordinate into a coordinate with the given system.
virtual void setTitle(const casacore::String &title)=0
Sets the text of the canvas title to the given.
Type
Mouse event types.
Definition: PlotEvent.h:81
virtual void setAxisLabel(PlotAxis axis, const casacore::String &title)=0
Sets the label of an axis title to the given.
virtual void setGridMajorLine(const PlotLine &line)=0
Sets the line used to draw the major grid lines.
virtual void setBackground(const PlotAreaFill &areaFill)=0
Sets the background of the canvas to the given.
virtual void setAxesScales(PlotAxis xAxis, PlotAxisScale xScale, PlotAxis yAxis, PlotAxisScale yScale)
Convenience method for setting the axis scale for two axes at once.
SortDirection
Definition: PlotOptions.h:52
virtual void removePlot(PlotPtr plot)
Item-specific remove methods.
AngleFormat
Enum for angle formats.
Definition: PlotOptions.h:87
virtual std::pair< int, int > size() const =0
GUI Methods //.
std::vector< std::pair< PlotMouseDragEventHandlerPtr, PlotCoordinate::System > > m_dragHandlers
Definition: PlotCanvas.h:1011
Abstract parent for any class that wants to be notified when the canvas is about to start drawing...
Definition: PlotCanvas.h:53
virtual void clearAnnotations()
casacore::CountedPtr< PlotDrawWatcher > PlotDrawWatcherPtr
Definition: PlotCanvas.h:77
virtual PlotFactory * implementationFactory() const =0
Returns a new instance of a PlotFactory that can create plot items for this implementation.
virtual bool legendShown() const =0
Legend Methods //.
virtual void showCartesianAxis(PlotAxis mirrorAxis, PlotAxis secondaryAxis, bool show=true, bool hideNormalAxis=true)=0
Show or hide the given Cartesian axis.
virtual unsigned int numPlots() const
Item-specific num methods.
virtual void showColorBar(bool show=true, PlotAxis axis=Y_RIGHT)=0
Shows/hides a color bar is shown on the given axis.
virtual PlotAxisScale axisScale(PlotAxis axis) const =0
Returns the scale for the given axis.
virtual std::vector< PlotPointPtr > allPoints() const
virtual bool axesAutoRescale() const =0
Returns true if the axes are set to autorescale when a new plot item is added, false otherwise...
virtual bool isAxisShown(PlotAxis axis) const
Returns true if the given axis is shown, false otherwise.
virtual PlotFontPtr titleFont() const =0
Returns a copy of the font used for the canvas title.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
bool isMarkedForUnflag()
virtual std::pair< bool, SortDirection > axisScaleSortDirection(PlotAxis axis) const =0
virtual casacore::String axisLabel(PlotAxis axis) const =0
Returns the label for the given axis, or an empty casacore::String if none is shown.
virtual PlotStandardMouseToolGroupPtr standardMouseTools()
Returns the standard mouse tools associated with this canvas.
virtual int axesStackLengthLimit() const
Gets/Sets the length limit on the PlotAxesStack associated with this canvas.
virtual void setCachedAxesStackSizeLimit(int sizeInKilobytes)=0
virtual void setMinimumSize(int width, int height)=0
virtual casacore::String fileChooserDialog(const casacore::String &title="File Chooser", const casacore::String &directory="")=0
Shows a file chooser dialog and return the absolute filename that the user chooses.
virtual void removeLastAnnotation()
virtual void setAutoIncrementColors(bool autoInc=true)=0
Sets whether adding new overplotted plots should automatically &quot;increment&quot; colors or not...
virtual void refresh()=0
Refreshes the GUI, which includes redrawing plot items as needed even if drawing is currently bei...
bool isBackgroundColorChanged()
virtual void setLegendPosition(LegendPosition position)=0
Sets the position of the legend, if it is shown.
virtual std::vector< PlotMousePressEventHandlerPtr > allMousePressHandlers() const
std::vector< PlotKeyEventHandlerPtr > m_keyHandlers
Definition: PlotCanvas.h:1016
virtual void registerSelectHandler(PlotSelectEventHandlerPtr handler, PlotCoordinate::System system=PlotCoordinate::WORLD)
Event Handler Methods //.
bool notifyReleaseHandlers(PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual bool cartesianAxisShown(PlotAxis axis) const =0
Returns whether the given Cartesian axis is shown or not.
virtual void clearPoints()
virtual const casacore::String & relativeDateFormat() const =0
Gets/Sets the date format for values relative to a reference value for this canvas.
std::vector< PlotDrawWatcherPtr > m_drawWatchers
Draw watchers.
Definition: PlotCanvas.h:992
virtual void setRelativeDateFormat(const casacore::String &dateFormat)=0
Abstract class for fonts.
Definition: PlotOptions.h:200
virtual void setLegendLine(const PlotLine &line)=0
Sets the line used to outline the legend.
virtual std::vector< PlotMouseMoveEventHandlerPtr > allMouseMoveHandlers() const
std::vector< std::pair< PlotMouseReleaseEventHandlerPtr, PlotCoordinate::System > > m_releaseHandlers
Definition: PlotCanvas.h:1009
PlotAxisScale
Enum for possible axis scales.
Definition: PlotOptions.h:78
virtual void registerClickHandler(PlotClickEventHandlerPtr handler, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage click handlers.
virtual int cachedAxesStackSizeLimit() const =0
Gets/Sets the size limit, in kilobytes, on the draw cache for the axes stack associated with this can...
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
A PlotRegion is basically just a wrapper for two PlotCoordinates: an upper left coordinate and a lowe...
Definition: PlotOptions.h:682
bool notifyClickHandlers(PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual void unregisterResizeHandler(PlotResizeEventHandlerPtr handler)
virtual void registerMouseMoveHandler(PlotMouseMoveEventHandlerPtr h, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage mouse move handlers.
virtual void showAxes(PlotAxisBitset axes)=0
Shows/Hides axes based on the given bitset, which should be a bitwise-or of PlotAxis values...
virtual void setAxisScaleAngleFormat(PlotAxis axis, AngleFormat format)=0
Sets/gets the angle format of the scale for the given axis.
PlotCanvasLayer
The canvas is composed of multiple layers, where changing/adding items from one layer will not affect...
Definition: PlotOptions.h:109
virtual ~PlotDrawWatcher()
Destructor.
Definition: PlotCanvas.h:59
virtual void registerMouseDragHandler(PlotMouseDragEventHandlerPtr h, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage mouse drag handlers.
virtual void setCommonAxes(bool commonX, bool commonY)=0
virtual PlotRegion convertRegion(const PlotRegion &region, PlotCoordinate::System newSystem) const
Converts the given region into a region with the given system.
bool notifyWheelHandlers(int delta, const PlotCoordinate &coord)
virtual std::vector< PlotPtr > allPlots() const
Item-specific all methods.
virtual void setMinimumSizeHint(int width, int height)=0
virtual void registerMouseReleaseHandler(PlotMouseReleaseEventHandlerPtr handler, PlotCoordinate::System system=PlotCoordinate::WORLD)
Manage mouse release handlers.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual void registerDrawWatcher(PlotDrawWatcherPtr watcher)
Registers/Unregisters the given draw watcher for this canvas.
static const casacore::String OPERATION_DRAW
Convenient access to operation names.
Definition: PlotCanvas.h:131
unsigned int uInt
Definition: aipstype.h:51
PlotAxesStack m_stack
One-per-canvas axes stack.
Definition: PlotCanvas.h:983
bool notifyMouseHandlers(PlotMouseEvent::Type type, PlotMouseEvent::Button button, const PlotCoordinate &coord)
virtual void unregisterMouseReleaseHandler(PlotMouseReleaseEventHandlerPtr handler)
virtual unsigned int numLayerAnnotations(PlotCanvasLayer layer) const
bool notifySelectHandlers(const PlotRegion &selectedRegion)
Notification methods for event handlers.
virtual bool gridXMinorShown() const
Gets/Sets whether minor grid lines are shown for the x-axis.
virtual std::vector< PlotMouseReleaseEventHandlerPtr > allMouseReleaseHandlers() const
virtual std::vector< PlotMouseToolPtr > allMouseTools() const
virtual bool drawShape(PlotShapePtr shape)
virtual void showGridMinor(bool show=true)